From: arino Date: Tue, 29 Jul 2003 09:57:14 +0000 (+0900) Subject: BugTrack/425: #contentsや#relatedを「本当のブロックプラグイン」に近い動作に X-Git-Tag: r1_5_0_rc1~1461 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=352e5150eb234057850606f25bef9a29204719ff;p=pukiwiki%2Fpukiwiki.git BugTrack/425: #contentsや#relatedを「本当のブロックプラグイン」に近い動作に --- diff --git a/convert_html.php b/convert_html.php index 51e16e9..e66ecc9 100644 --- a/convert_html.php +++ b/convert_html.php @@ -2,7 +2,7 @@ ///////////////////////////////////////////////// // PukiWiki - Yet another WikiWikiWeb clone. // -// $Id: convert_html.php,v 1.50 2003/07/27 13:40:41 arino Exp $ +// $Id: convert_html.php,v 1.51 2003/07/29 09:57:13 arino Exp $ // function convert_html($lines) { @@ -807,12 +807,6 @@ class Body extends Block $this->contents_last =& $this->contents_last->add(new Contents_UList($text,$level,$id)); return array($text.$anchor,$this->count > 1 ? $top : '',$id); } - function getContents() - { - $contents = "id}\">"; - $contents .= $this->contents->toString(); - return "
\n$contents
\n"; - } function &insert(&$obj) { if (is_a($obj,'Inline')) { @@ -827,14 +821,41 @@ class Body extends Block $text = parent::toString(); // #contents - $text = preg_replace('/]*>#contents<\/p>/',$this->getContents(),$text); + $text = preg_replace_callback('/(]*>)#contents<\/del>(.*)(<\/p>)/', + array(&$this,'replace_contents'),$text); // ´ØÏ¢¤¹¤ë¥Ú¡¼¥¸ //

¤Î¤È¤­¤Ï¹ÔƬ¤«¤é¡¢¤Î¤È¤­¤Ï¾¤ÎÍ×ÁǤλÒÍ×ÁǤȤ·¤Æ¸ºß - $text = preg_replace('/

#related<\/del><\/p>/',make_related($vars['page'],'p'),$text); + $text = preg_replace_callback('/(]*>)#related<\/del>(.*)(<\/p>)/', + array(&$this,'replace_related'),$text); $text = preg_replace('/#related<\/del>/',make_related($vars['page'],'del'),$text); return $text; } + function replace_contents($arr) + { + static $contents = NULL; + + if (is_null($contents)) + { + $contents = "

\n"; + $contents .= "id}\">"; + $contents .= $this->contents->toString(); + $contents .= "
\n"; + } + array_shift($arr); + return ($arr[1] != '') ? $contents.join('',$arr) : $contents; + } + function replace_related($arr) + { + static $related = NULL; + + if (is_null($related)) + { + $related = make_related($vars['page'],'p'); + } + array_shift($arr); + return ($arr[1] != '') ? $related.join('',$arr) : $related; + } function block(&$lines,$start,$end,$class) { if (rtrim($lines[0]) != $start) diff --git a/html.php b/html.php index ff1df63..5ab2cac 100644 --- a/html.php +++ b/html.php @@ -2,7 +2,7 @@ ///////////////////////////////////////////////// // PukiWiki - Yet another WikiWikiWeb clone. // -// $Id: html.php,v 1.90 2003/07/14 04:27:07 arino Exp $ +// $Id: html.php,v 1.91 2003/07/29 09:57:14 arino Exp $ // // ËÜʸ¤ò½ÐÎÏ @@ -240,6 +240,11 @@ function make_related($page,$tag='') "$s_page$passage"; } + if (count($_links) == 0) + { + return ''; + } + if ($tag == 'p') // ¹ÔƬ¤«¤é { $margin = $_ul_left_margin + $_ul_margin; diff --git a/init.php b/init.php index e3362d0..c18cced 100644 --- a/init.php +++ b/init.php @@ -2,7 +2,7 @@ ///////////////////////////////////////////////// // PukiWiki - Yet another WikiWikiWeb clone. // -// $Id: init.php,v 1.58 2003/07/06 15:10:27 arino Exp $ +// $Id: init.php,v 1.59 2003/07/29 09:57:14 arino Exp $ // ///////////////////////////////////////////////// @@ -280,6 +280,7 @@ $entity_pattern = trim(join('',file(CACHE_DIR.'entities.dat'))); $line_rules = array_merge(array( '&(#[0-9]+|#x[0-9a-f]+|'.$entity_pattern.');'=>'&$1;', "\r"=>"
\n", /* ¹ÔËö¤Ë¥Á¥ë¥À¤Ï²þ¹Ô */ - '#related'=>'#related' + '#related$'=>'#related', + '^#contents$'=>'#contents' ),$line_rules); ?>