]> git.mjollnir.org Git - s9y.git/commitdiff
fix wrong variable name, thanks to stm!
authorgarvinhicking <garvinhicking>
Sat, 5 Aug 2006 20:47:49 +0000 (20:47 +0000)
committergarvinhicking <garvinhicking>
Sat, 5 Aug 2006 20:47:49 +0000 (20:47 +0000)
plugins/serendipity_plugin_comments/serendipity_plugin_comments.php

index 03c6808e1dd1421e838ef3429558a94969614641..59fb696d0154e2ffd7c9f7e83c67a6ba0f8a92d8 100644 (file)
@@ -22,7 +22,7 @@ class serendipity_plugin_comments extends serendipity_plugin
         $propbag->add('description',   PLUGIN_COMMENTS_BLAHBLAH);
         $propbag->add('stackable',     true);
         $propbag->add('author',        'Garvin Hicking/Tadashi Jokagi/Judebert');
-        $propbag->add('version',       '1.8');
+        $propbag->add('version',       '1.10');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -121,9 +121,9 @@ class serendipity_plugin_comments extends serendipity_plugin
         }
 
         $viewtype = '';
-        if ($this->get_config('viewtype') == 'comments') {
+        if ($this->get_config('viewmode') == 'comments') {
             $viewtype .= ' AND c.type = \'NORMAL\'';
-        } elseif ($this->get_config('viewtype') == 'trackbacks') {
+        } elseif ($this->get_config('viewmode') == 'trackbacks') {
             $viewtype .= ' AND c.type = \'TRACKBACK\'';
         }
 
@@ -150,8 +150,8 @@ class serendipity_plugin_comments extends serendipity_plugin
 
         if ($sql && is_array($sql)) {
             foreach($sql AS $key => $row) {
-                if ( $serendipity['lang'] == "ja" && function_exists( 'mb_strimwidth')) {
-                    $comment = mb_strimwidth( strip_tags($row['comment']), 0, $max_chars, " [...]");
+                if (function_exists('mb_strimwidth')) {
+                    $comment = mb_strimwidth(strip_tags($row['comment']), 0, $max_chars, " [...]", LANG_CHARSET);
                 } else {
                     $comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1);
                     $aComment = explode('@@@', $comments);
@@ -173,22 +173,30 @@ class serendipity_plugin_comments extends serendipity_plugin
                     $user = PLUGIN_COMMENTS_ANONYMOUS;
                 }
 
-                if ( $serendipity['lang'] == "ja" && function_exists( 'mb_strimwidth')) {
+                if (function_exists('mb_strimwidth')) {
                     $pos = 0;
                     $parts = array();
-                    $comment_len = mb_strlen( $comment);
-                    while ( $pos < $comment_len) {
-                        $part = mb_strimwidth( $comment, $pos, $wordwrap);
-                        $pos += mb_strlen( $part);
+                    $enc = LANG_CHARSET;
+                    $comment_len = mb_strlen($comment, $enc);
+                    while ($pos < $comment_len) {
+                        $part = mb_strimwidth($comment, $pos, $wordwrap, '', $enc);
+                        $pos += mb_strlen($part, $enc);
                         $parts[] = $part;
                     }
-                    $comment = implode( "\n", $parts);
+                    $comment = implode("\n", $parts);
                 } else {
                     $comment = wordwrap($comment, $wordwrap, "\n", 1);
                 }
                 $entry = array('comment' => $comment,
                                'email'   => $row['comment_email']);
+                               
+                // Let's help the BBCOde plugin a bit:
+                if (class_exists('serendipity_event_bbcode')) {
+                    $entry['comment'] = preg_replace('@((\[.*)[\n\r]+(.*\]))+@imsU', '\2\3', $entry['comment']);
+                    $entry['comment'] = preg_replace('@((\[.+\].*)[\r\n]+(.*\[/.+\]))+@imsU', '\2\3', $entry['comment']);
+                }
                 serendipity_plugin_api::hook_event('frontend_display', $entry);
+
                 printf(
                   '<div class="plugin_comment_wrap">' . PLUGIN_COMMENTS_ABOUT . '</div>',
 
@@ -197,7 +205,7 @@ class serendipity_plugin_comments extends serendipity_plugin
                       . htmlspecialchars($row['subject'])
                       . '</a><br />' . "\n"
                       . '<span class="plugin_comment_date">' . htmlspecialchars(serendipity_strftime($dateformat, $row['stamp'])) . '</span><br />' . "\n"
-                      . '<span class="plugin_comment_body">' . strip_tags($entry['comment'], '<br /><img>') . '</span>'
+                      . '<span class="plugin_comment_body">' . strip_tags($entry['comment'], '<br /><img><a>') . '</span>'
                       . '<br /><br /><br />' . "\n\n"
                 );
             }