OSDN Git Service

BugTrack/328のつづき:
authorarino <arino>
Wed, 14 May 2003 10:13:31 +0000 (19:13 +0900)
committerarino <arino>
Wed, 14 May 2003 10:13:31 +0000 (19:13 +0900)
-PHP4.1.2で注釈の変換に失敗する問題を修理
-make_str_rules()の呼び出しをinline2()からmake_link()に移動
--inline2()の呼び出しをmake_link()の呼び出しに変更

convert_html.php
html.php
make_link.php
plugin/bugtrack.inc.php
plugin/calendar2.inc.php
plugin/comment.inc.php
plugin/vote.inc.php

index f710334..e5d52da 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: convert_html.php,v 1.36 2003/05/12 10:28:48 arino Exp $
+// $Id: convert_html.php,v 1.37 2003/05/14 10:13:29 arino Exp $
 //
 function convert_html($lines)
 {
@@ -49,7 +49,7 @@ class Inline extends Element
                        $this->setParent($parent);
                }
                else {
-                       $this->text = trim((substr($text,0,1) == "\n") ? $text : inline2($text));
+                       $this->text = trim((substr($text,0,1) == "\n") ? $text : make_link($text));
                }
        }
        function &add(&$obj)
@@ -318,7 +318,7 @@ class DList extends ListContainer
                }
                parent::ListContainer('dl','dd',$level,$out[1]);
                if ($out[0] != '') {
-                       array_unshift($this->elements,new Inline("\n<dt>".inline2($out[0])."</dt>\n"));
+                       array_unshift($this->elements,new Inline("\n<dt>".make_link($out[0])."</dt>\n"));
                }
        }
 }
@@ -583,7 +583,7 @@ class YTable extends Block
                                        $colspan[$i]++;
                                }
                                $colspan[$i] = ($colspan[$i] > 1) ? " colspan=\"{$colspan[$i]}\"" : '';
-                               $str .= "<td class=\"style_td\"{$align[$i]}{$colspan[$i]}>".inline2($value[$i]).'</td>';
+                               $str .= "<td class=\"style_td\"{$align[$i]}{$colspan[$i]}>".make_link($value[$i]).'</td>';
                        }
                }
                $this->elements[] = $str;
index 78588a7..be352a6 100644 (file)
--- a/html.php
+++ b/html.php
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: html.php,v 1.73 2003/05/12 10:29:48 arino Exp $
+// $Id: html.php,v 1.74 2003/05/14 10:13:29 arino Exp $
 //
 
 // ËÜʸ¤ò½ÐÎÏ
@@ -113,10 +113,10 @@ function inline($line,$remove=FALSE)
        return $line;
 }
 
-// ¥¤¥ó¥é¥¤¥óÍ×ÁǤΥѡ¼¥¹ (¥ê¥ó¥¯¡¢¸«½Ð¤·°ìÍ÷)
+// ¥¤¥ó¥é¥¤¥óÍ×ÁǤΥѡ¼¥¹ (¥ê¥ó¥¯¡¢¸«½Ð¤·°ìÍ÷) (obsolete)
 function inline2($str)
 {
-       return make_line_rules(make_link($str));
+       return make_link($str);
 }
 
 // ÊÔ½¸¥Õ¥©¡¼¥à¤Îɽ¼¨
@@ -290,6 +290,9 @@ function make_heading($str)
 {
        global $NotePattern;
        
-       return strip_htmltag(inline2(preg_replace($NotePattern,'',$str)));
+       // ¸«½Ð¤·¤Î¸ÇÍ­IDÉô¤òºï½ü
+       $str = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/m','$1$2',$str);
+       
+       return strip_htmltag(make_link(preg_replace($NotePattern,'',$str)));
 }
 ?>
index 5ab954c..85c0bcf 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: make_link.php,v 1.37 2003/05/13 07:56:12 arino Exp $
+// $Id: make_link.php,v 1.38 2003/05/14 10:13:30 arino Exp $
 //
 
 // ¥ê¥ó¥¯¤òÉղ乤ë
@@ -40,6 +40,7 @@ class InlineConverter
                                'autolink',      // AutoLink
                                'bracketname',   // BracketName
                                'wikiname',      // WikiName
+//                             'rules',         // ¥æ¡¼¥¶ÄêµÁ¥ë¡¼¥ë
                        );
                }
                if ($excludes !== NULL)
@@ -48,7 +49,7 @@ class InlineConverter
                }
                $this->converters = array();
                $patterns = array();
-               $start = 3; // $this->pattern¤Î¥µ¥Ö¥Ñ¥¿¡¼¥ó2¸Ä¤ò´Þ¤à
+               $start = 1;
                
                foreach ($converters as $name)
                {
@@ -64,25 +65,31 @@ class InlineConverter
                        $start += $converter->get_count();
                        $start++;
                }
-               $this->pattern = '(.*?)('.join('|',$patterns).')'; // $start += 2
+               $this->pattern = join('|',$patterns);
        }
        function convert($string,$page)
        {
                $this->page = $page;
-               $this->result = '';
+               $this->result = array();
                
                $string = preg_replace_callback("/{$this->pattern}/x",array(&$this,'replace'),$string);
                
-               return $this->result.htmlspecialchars($string);
+               $arr = explode("\x08",make_line_rules(htmlspecialchars($string)));
+               $retval = '';
+               while (count($arr))
+               {
+                       $retval .= array_shift($arr).array_shift($this->result);
+               }
+               return $retval;
        }
        function replace($arr)
        {
                $obj = $this->get_converter($arr);
                
-               $this->result .= ($obj !== NULL and $obj->set($arr,$this->page) !== FALSE) ?
-                       htmlspecialchars($arr[1]).$obj->toString() : htmlspecialchars($arr[0]);
+               $this->result[] = ($obj !== NULL and $obj->set($arr,$this->page) !== FALSE) ?
+                       $obj->toString() : make_line_rules(htmlspecialchars($arr[0]));
                
-               return ''; //½èÍýºÑ¤ß¤ÎÉôʬ¤òʸ»úÎ󤫤éºï½ü¤¹¤ë
+               return "\x08"; //½èÍýºÑ¤ß¤ÎÉôʬ¤Ë¥Þ¡¼¥¯¤òÆþ¤ì¤ë
        }
        function get_objects($string,$page)
        {
@@ -292,7 +299,7 @@ EOD;
                $arr = $this->splice($arr);
                
                $id = ++$note_id;
-               $note = make_line_rules(make_link($arr[1]));
+               $note = make_link($arr[1]);
                
                $foot_explain[$id] = <<<EOD
 <a id="notefoot_$id" href="#notetext_$id" class="note_super">*$id</a>
@@ -664,6 +671,76 @@ class Link_autolink extends Link
                );
        }
 }
+// ¥æ¡¼¥¶ÄêµÁ¥ë¡¼¥ë
+/*
+class Link_rules extends Link
+{
+       var $replaces;
+       var $count;
+       
+       function Link_rules($start)
+       {
+               parent::Link($start);
+       }
+       function get_pattern()
+       {
+               global $line_rules;
+               
+               $rules = array();
+               $this->replaces = array();
+               $this->count = 0;
+               
+               foreach ($line_rules as $pattern=>$replace)
+               {
+                       $rules[] = "($pattern)";
+                       $this->replaces[++$this->count] = $replace;
+                       if (preg_match_all('/\$\d/',$replace,$matches,PREG_SET_ORDER))
+                       {
+                               $this->count += count($matches);
+                       }
+               }
+               $this->replaces[++$this->count] = ''; // sentinel
+               return join("|",$rules);
+       }
+       function get_count()
+       {
+               return $this->count;
+       }
+       function set($arr,$page)
+       {
+               $arr = $this->splice($arr);
+               
+               $name = $arr[0];
+               reset($this->replaces);
+               while (list($start,$replace) = each($this->replaces))
+               {
+                       if ($replace == '')
+                       {
+                               $name = htmlspecialchars($name);
+                               break;
+                       }
+                       if (!array_key_exists($start,$arr) or $arr[$start] == '')
+                       {
+                               continue;
+                       }
+                       list($end,$dummy) = each($this->replaces);
+                       $count = $end - $start;
+                       $_arr = array_splice($arr,$start,$count);
+                       $name = $replace;
+                       for ($n = 1; $n < $count; $n++)
+                       {
+                               $name = str_replace('$'.$n,make_link($_arr[$n]),$name);
+                       }
+                       break;
+               }
+               return parent::setParam($page,$name,'rule','');
+       }
+       function toString()
+       {
+               return $this->name;
+       }
+}
+*/
 // ¥Ú¡¼¥¸Ì¾¤Î¥ê¥ó¥¯¤òºîÀ®
 function make_pagelink($page,$alias='',$anchor='',$refer='')
 {
index 638108f..3001f13 100644 (file)
@@ -8,7 +8,7 @@
  * Êѹ¹ÍúÎò:
  *  2002.06.17: ºî¤ê»Ï¤á
  *
- * $Id: bugtrack.inc.php,v 1.12 2003/03/28 15:34:29 panda Exp $
+ * $Id: bugtrack.inc.php,v 1.13 2003/05/14 10:13:31 arino Exp $
  */
 
 function plugin_bugtrack_init()
@@ -262,9 +262,8 @@ function plugin_bugtrack_pageinfo($page,$no = NULL)
                }
        }
        
-       global $_bugtrack_plugin_summary;
        if (preg_match("/\*([^\n]+)/",$body,$matches)) {
-               $summary = htmlspecialchars($matches[1]);
+               $summary = make_heading($matches[1]);
        }
        
        return array($page, $no, $summary, $name, $priority, $state, $category);
@@ -304,7 +303,7 @@ function plugin_bugtrack_list_convert()
        
        foreach ($data as $line) {
                list($page, $no, $summary, $name, $priority, $state, $category) = $line;
-               $page_link = make_link("[[$page]]");
+               $page_link = make_pagelink($page);
                $state_no = array_search($state,$_bugtrack_plugin_state_sort);
                if ($state_no === NULL or $state_no === FALSE) {
                        $state_no = count($_bugtrack_plugin_state_list);
index d61c3c0..7a2ff54 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: calendar2.inc.php,v 1.17 2003/03/03 07:30:42 panda Exp $
+// $Id: calendar2.inc.php,v 1.18 2003/05/14 10:13:30 arino Exp $
 // *°ú¿ô¤Ëoff¤È½ñ¤¯¤³¤È¤Çº£Æü¤ÎÆüµ­¤òɽ¼¨¤·¤Ê¤¤¤è¤¦¤Ë¤·¤¿¡£
 function plugin_calendar2_convert()
 {
@@ -154,7 +154,7 @@ EOD;
                        $get['page'] = $post['page'] = $vars['page'] = $_page;
                }
                else {
-                       $str = sprintf($_calendar2_plugin_empty,make_link(sprintf('[[%s%4d-%02d-%02d]]',$prefix, $today['year'], $today['mon'], $today['mday'])));
+                       $str = sprintf($_calendar2_plugin_empty,make_pagelink(sprintf('%s%4d-%02d-%02d',$prefix, $today['year'], $today['mon'], $today['mday'])));
                }
                $ret .= "  </td>\n  <td valign=\"top\">$str</td>\n </tr>\n</table>\n";
        }
index 627676a..d750df9 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: comment.inc.php,v 1.16 2003/04/13 06:28:52 arino Exp $
+// $Id: comment.inc.php,v 1.17 2003/05/14 10:13:30 arino Exp $
 
 /////////////////////////////////////////////////
 // ¥³¥á¥ó¥È¤Î̾Á°¥Æ¥­¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
@@ -81,7 +81,7 @@ function plugin_comment_action()
        $body = '';
        if (md5(@join('',get_source($post['refer']))) != $post['digest']) {
                $title = $_title_comment_collided;
-               $body = $_msg_comment_collided . make_link($post['refer']);
+               $body = $_msg_comment_collided . make_pagelink($post['refer']);
        }
        
        page_write($post['refer'],$postdata);
index 89bd69c..809a64c 100644 (file)
@@ -1,18 +1,26 @@
 <?php
-// $Id: vote.inc.php,v 1.12 2003/04/13 06:28:52 arino Exp $
+/////////////////////////////////////////////////
+// PukiWiki - Yet another WikiWikiWeb clone.
+//
+// $Id: vote.inc.php,v 1.13 2003/05/14 10:13:31 arino Exp $
+//
 
 function plugin_vote_init()
 {
        if (LANG == 'ja')
+       {
                $messages = array(
                        '_vote_plugin_choice' => 'ÁªÂò»è',
                        '_vote_plugin_votes' => 'Åêɼ',
                );
+       }
        else
+       {
                $messages = array(
                        '_vote_plugin_choice' => 'Selection',
                        '_vote_plugin_votes' => 'Vote',
                );
+       }
        set_plugin_messages($messages);
 }
 
@@ -26,26 +34,32 @@ function plugin_vote_action()
        $vote_no = 0;
        $title = $body = $postdata = '';
 
-       foreach($postdata_old as $line) {
-               if (!preg_match("/^#vote\((.*)\)\s*$/",$line,$arg)) {
+       foreach($postdata_old as $line)
+       {
+               if (!preg_match("/^#vote\((.*)\)\s*$/",$line,$arg))
+               {
                        $postdata .= $line;
                        continue;
                }
                
-               if ($vote_no++ != $post['vote_no']) {
+               if ($vote_no++ != $post['vote_no'])
+               {
                        $postdata .= $line;
                        continue;
                }
                $args = explode(',',$arg[1]);
                
-               foreach($args as $arg) {
+               foreach($args as $arg)
+               {
                        $cnt = 0;
-                       if (preg_match("/^(.+)\[(\d+)\]$/",$arg,$match)) {
+                       if (preg_match("/^(.+)\[(\d+)\]$/",$arg,$match))
+                       {
                                $arg = $match[1];
                                $cnt = $match[2];
                        }
                        $e_arg = encode($arg);
-                       if (!empty($post["vote_$e_arg"]) and $post["vote_$e_arg"] == $_vote_plugin_votes) {
+                       if (!empty($post["vote_$e_arg"]) and $post["vote_$e_arg"] == $_vote_plugin_votes)
+                       {
                                $cnt++;
                        }
                        
@@ -58,7 +72,8 @@ function plugin_vote_action()
                $postdata .= $vote_str;
        }
 
-       if (md5(@join('',get_source($post['refer']))) != $post['digest']) {
+       if (md5(@join('',get_source($post['refer']))) != $post['digest'])
+       {
                $title = $_title_collided;
                
                $s_refer = htmlspecialchars($post['refer']);
@@ -103,7 +118,8 @@ function plugin_vote_convert()
        }
        $vote_no = $numbers[$vars['page']]++;
        
-       if (!func_num_args()) {
+       if (!func_num_args())
+       {
                return '';
        }
 
@@ -127,10 +143,12 @@ function plugin_vote_convert()
 EOD;
        
        $tdcnt = 0;
-       foreach($args as $arg) {
+       foreach($args as $arg)
+       {
                $cnt = 0;
                
-               if (preg_match("/^(.+)\[(\d+)\]$/",$arg,$match)) {
+               if (preg_match("/^(.+)\[(\d+)\]$/",$arg,$match))
+               {
                        $arg = $match[1];
                        $cnt = $match[2];
                }