OSDN Git Service

BugTrack/791: Fix typo 0,91 => 0.91
[pukiwiki/pukiwiki.git] / plugin / pcomment.inc.php
index 34e3bdf..869b224 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone
-// $Id: pcomment.inc.php,v 1.36 2005/01/23 07:01:56 henoheno Exp $
+// $Id: pcomment.inc.php,v 1.38 2005/01/30 01:13:11 henoheno Exp $
 //
 // pcomment plugin - Insetring comment into specified (another) page
 
@@ -117,7 +117,7 @@ function plugin_pcomment_convert()
        list($comments, $digest) = pcmt_get_comments($_page, $count, $dir, $params['reply']);
 
        if (PKWK_READONLY) {
-               $form = '';
+               $form_start = $form = $form_end = '';
        } else {
                // ¥Õ¥©¡¼¥à¤òɽ¼¨
                if ($params['noname']) {
@@ -138,8 +138,8 @@ function plugin_pcomment_convert()
                $s_nodate = htmlspecialchars($params['nodate']);
                $s_count  = htmlspecialchars($count);
 
+               $form_start = '<form action="' . $script . '" method="post">' . "\n";
                $form = <<<EOD
-<form action="$script" method="post">
   <div>
   <input type="hidden" name="digest" value="$digest" />
   <input type="hidden" name="plugin" value="pcomment" />
@@ -151,8 +151,8 @@ function plugin_pcomment_convert()
   $radio $title $name $comment
   <input type="submit" value="{$_pcmt_messages['btn_comment']}" />
   </div>
-</form>
 EOD;
+               $form_end = '</form>' . "\n";
        }
 
        if (! is_page($_page)) {
@@ -164,9 +164,23 @@ EOD;
                $recent = ! empty($count) ? sprintf($_pcmt_messages['msg_recent'], $count) : '';
        }
 
-       return $dir ?
-               '<div><p>' . $recent . ' ' . $link . '</p>' . "\n" .  $comments . "\n" .  $form . '</div>' . "\n" :
-               '<div>' . $form . $comments. "\n" . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . '</div>' . "\n";
+       if ($dir) {
+               return '<div>' .
+                       '<p>' . $recent . ' ' . $link . '</p>' . "\n" .
+                       $form_start .
+                               $comments . "\n" .
+                               $form .
+                       $form_end .
+                       '</div>' . "\n";
+       } else {
+               return '<div>' .
+                       $form_start .
+                               $form .
+                               $comments. "\n" .
+                       $form_end .
+                       '<p>' . $recent . ' ' . $link . '</p>' . "\n" .
+                       '</div>' . "\n";
+       }
 }
 
 function pcmt_insert()
@@ -333,6 +347,8 @@ function pcmt_get_comments($page, $count, $dir, $reply)
        if (! check_readable($page, false, false))
                return array(str_replace('$1', $page, $_msg_pcomment_restrict));
 
+       $reply = (! PKWK_READONLY && $reply); // Suprress radio-buttons
+
        $data = get_source($page);
        $data = preg_replace('/^#pcomment\(?.*/i', '', $data);  // Avoid eternal recurse
 
@@ -349,6 +365,8 @@ function pcmt_get_comments($page, $count, $dir, $reply)
 
                if (preg_match('/^(\-{1,2})(?!\-)(.+)$/', $line, $matches)) {
                        if ($count > 0 && strlen($matches[1]) == 1 && ++$cnt > $count) break;
+
+                       // Ready for radio-buttons
                        if ($reply) {
                                ++$num;
                                $cmts[] = "$matches[1]\x01$num\x02" . md5($matches[2]) . "\x03$matches[2]\n";
@@ -369,12 +387,11 @@ function pcmt_get_comments($page, $count, $dir, $reply)
        $comments = convert_html($data);
        unset($data);
 
-       //¥³¥á¥ó¥È¤Ë¥é¥¸¥ª¥Ü¥¿¥ó¤Î°õ¤ò¤Ä¤±¤ë
-       if ($reply) {
+       // Add radio-buttons
+       if ($reply)
                $comments = preg_replace("/<li>\x01(\d+)\x02(.*)\x03/",
                        '<li class="pcmt"><input class="pcmt" type="radio" name="reply" value="$2" tabindex="$1" />',
                        $comments);
-       }
 
        return array($comments, $digest);
 }