]> git.mjollnir.org Git - s9y.git/commitdiff
Allow to (only) show trackbbacks, comments or both
authorgarvinhicking <garvinhicking>
Tue, 4 Oct 2005 12:50:29 +0000 (12:50 +0000)
committergarvinhicking <garvinhicking>
Tue, 4 Oct 2005 12:50:29 +0000 (12:50 +0000)
plugins/serendipity_plugin_comments/serendipity_plugin_comments.php

index 234934488c2b27d74005952345c68f388c490906..c3b20ad9931b85df9ce182d729016321a5fdff4e 100644 (file)
@@ -29,7 +29,7 @@ class serendipity_plugin_comments extends serendipity_plugin
         $propbag->add('description',   PLUGIN_COMMENTS_BLAHBLAH);
         $propbag->add('stackable',     true);
         $propbag->add('author',        'Garvin Hicking');
-        $propbag->add('version',       '1.2');
+        $propbag->add('version',       '1.3');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -41,12 +41,31 @@ class serendipity_plugin_comments extends serendipity_plugin
                                              'wordwrap',
                                              'max_chars',
                                              'max_entries',
-                                             'dateformat'));
+                                             'dateformat',
+                                             'viewmode'));
     }
 
     function introspect_config_item($name, &$propbag)
     {
         switch($name) {
+            case 'viewmode':
+                $types = array(
+                    'comments'   => COMMENTS,
+                    'trackbacks' => TRACKBACKS,
+                    'all'        => COMMENTS . ' + ' . TRACKBACKS
+                );
+                $propbag->add('type',        'select');
+                $propbag->add('name',        TYPE);
+                $propbag->add('description', '');
+                $propbag->add('select_values', $types);
+                $propbag->add('default',     'all');
+
+                $propbag->add('type',        'string');
+                $propbag->add('name',        TITLE);
+                $propbag->add('description', '');
+                $propbag->add('default',     COMMENTS);
+                break;
+
             case 'title':
                 $propbag->add('type',        'string');
                 $propbag->add('name',        TITLE);
@@ -113,6 +132,13 @@ class serendipity_plugin_comments extends serendipity_plugin
             $dateformat = '%a, %d.%m.%Y %H:%M';
         }
 
+        $viewtype = '';
+        if ($this->get_config('viewtype') == 'comments') {
+            $viewtype .= ' AND c.type = \'NORMAL\'';
+        } elseif ($this->get_config('viewtype') == 'trackbacks') {
+            $viewtype .= ' AND c.type = \'TRACKBACK\'';
+        }
+
         $q = 'SELECT    c.body              AS comment,
                         c.timestamp         AS stamp,
                         c.author            AS user,
@@ -129,6 +155,7 @@ class serendipity_plugin_comments extends serendipity_plugin
                WHERE    e.id = c.entry_id
                  AND    NOT (c.type = \'TRACKBACK\' AND c.author = \'' . serendipity_db_escape_string($serendipity['blogTitle']) . '\' AND c.title != \'\')
                  AND    c.status = \'approved\'
+                        ' . $viewtype . '
             ORDER BY    c.timestamp DESC
             LIMIT ' . $max_entries;
 ?>