検索条件
全7件
(1/2ページ)
最初に出現したレベル1見出しをページタイトル(titleとh1)に反映する改造です。
改造前のconvert_htmlにbodycache用の記述も含まれているので、使っていない場合は無視してください。
function convert_html($lines) { global $vars, $digest; global $bodycache_status; static $contents_id = 0; if ( $bodycache_status === 'cached' ) { $contents_id += 90 ; } // Set digest $digest = md5(join('', get_source($vars['page']))); if (! is_array($lines)) $lines = explode("\n", $lines); $body = new Body(++$contents_id); $body->parse($lines); return $body->toString(); }
function convert_html($lines) { global $vars, $digest; global $title, $page; global $bodycache_status; static $contents_id = 0; if ( $bodycache_status === 'cached' ) { $contents_id += 90 ; } // Set digest $digest = md5(join('', get_source($vars['page']))); if (! is_array($lines)) $lines = explode("\n", $lines); $body = new Body(++$contents_id); $body->parse($lines); if ( isset( $body->title ) ){ $page = $title = htmlsc(trim($body->title)); } return $body->toString(); }
function Heading(& $root, $text) { parent::Element(); $this->level = min(3, strspn($text, '*')); list($text, $this->msg_top, $this->id) = $root->getAnchor($text, $this->level); $this->insert(Factory_Inline($text)); $this->level++; // h2,h3,h4 }
function Heading(& $root, $text) { parent::Element(); $this->level = min(3, strspn($text, '*')); if( $this->level === 1 && !isset( $root->title ) && $root->id === 1 ){ $root->title = preg_replace('|\s*\[#.*|', '', $text); $root->title = preg_replace('|^\*\s*|', '', $root->title); $root->title = preg_replace('|\[\[([^>\]]+)(>[^>\]]+)?\]\]|', '$1', $root->title); } list($text, $this->msg_top, $this->id) = $root->getAnchor($text, $this->level); $this->insert(Factory_Inline($text)); $this->level++; // h2,h3,h4 }
多重include(includeの中でincludeを使う)の深さを制限できる改造版includeを作成しました。
制限を超えると、エラーメッセージ
#include(): Limit exceeded (recursive): ページ名
が表示されます。
// Max depth of recursive include define('PLUGIN_INCLUDE_MAX_DEPTH', 2);
// Max depth of recursive include define('PLUGIN_INCLUDE_MAX_DEPTH', 2); // e.g. // PLUGIN_INCLUDE_MAX_DEPTH=0: no prohibition // PLUGIN_INCLUDE_MAX_DEPTH=1: prohibit recursive include
function plugin_include_convert() { global $script, $vars, $get, $post, $menubar, $_msg_include_restrict; static $included = array(); static $count = 1; static $depth = 1; //追加
if (isset($included[$page])) { return '#include(): Included already: ' . $link . '<br />' . "\n"; } if (! is_page($page)) { return '#include(): No such page: ' . $s_page . '<br />' . "\n"; } if ($count > PLUGIN_INCLUDE_MAX) { return '#include(): Limit exceeded: ' . $link . '<br />' . "\n"; } if ($depth > PLUGIN_INCLUDE_MAX_DEPTH && PLUGIN_INCLUDE_MAX_DEPTH > 0) { //追加 return '#include(): Limit exceeded (recursive): ' . $link . '<br />' . "\n"; //追加 } else { ++$count; }
if (check_readable($page, false, false)) { ++$depth; //追加 $body = convert_html(get_source($page)); --$depth; //追加 } else { $body = str_replace('$1', $page, $_msg_include_restrict); }
ライセンスはGPLv2 or laterです。(PukiWikiと同じ。)
ECO-Wiki (acronia)で使っている改良したPukiWiki bodycacheの改良内容とソースコード(パッチ)。