サマリ | 足跡表示プラグイン |
---|---|
リビジョン | 0.2 |
対応バージョン | 1.4.5 |
投稿者 | choi |
投稿日 | 2005-02-14 (月) 20:29:51 |
ユーザの足跡(訪問ページ)を表示します。
PHPのことはまだよくわかってません。なので至らない点があるかと思いますがご了承下さい。
自作プラグイン/topicpath.inc.phpを拡張して作りましたので、ライセンスはGPLです。
パンくずリストを自動生成する自作プラグイン/topicpath_related.inc.phpもご覧下さい。
footprint http://slashmall.s203.xrea.com/pukiwiki/myplugin/footprint.zip
スキンに書くならこんな感じで
<?php require_once(PLUGIN_DIR. 'footprint.inc.php'); echo plugin_footprint_convert() ?>
プラグインとしてページ内に記述するなら
#footprint &footprint;
また、ブロック要素として呼んだ場合
<div class="footprint">足跡の内容</div>
となるように出力されます(スタイルシート用に)
「FrontPage -> 質問箱 -> PukiWiki -> PukiWiki/Install -> 質問箱」の順で踏んで
PLUGIN_FOOTPRINT_BACK が 1, PLUGIN_FOOTPRINT_TOPICPATH が 1 のとき
FrontPage FrontPage > 質問箱 FrontPage > 質問箱 > PukiWiki FrontPage > 質問箱 > PukiWiki / Install FrontPage > 質問箱
PLUGIN_FOOTPRINT_BACK が 0, PLUGIN_FOOTPRINT_TOPICPATH が 1 のとき
FrontPage FrontPage > 質問箱 FrontPage > 質問箱 > PukiWiki FrontPage > 質問箱 > PukiWiki / Install FrontPage > PukiWiki / Install > 質問箱
PLUGIN_FOOTPRINT_BACK が -1, PLUGIN_FOOTPRINT_TOPICPATH が 0 のとき
FrontPage FrontPage > 質問箱 FrontPage > 質問箱 > PukiWiki FrontPage > 質問箱 > PukiWiki > PukiWiki/Install FrontPage > 質問箱 > PukiWiki > PukiWiki/Install > 質問箱
<span class="small"> Footprints: <?php require_once(PLUGIN_DIR . 'footprint.inc.php'); echo plugin_footprint_inline(); ?> </span> <br /><br /> |
<?php // $Id: footprint.inc.php,v 0.2 2005/02/12 17:59:26 choi Exp $ // // show user's footprint, available under GPL // extend topicpath.inc.php v 1.6 //-------------------------------------------- // ページ間のセパレータ define('PLUGIN_FOOTPRINT_PAGE_SEPARATOR',' > '); // Separetor / of / topic / path define('PLUGIN_FOOTPRINT_TREE_SEPARATOR', ' / '); // すでに通ったページを踏んだとき // 1 : そのページまでの足跡を消す // 0 : 二重に表示されないように追加する // -1 : 消さない define('PLUGIN_FOOTPRINT_BACK',1); // topicpath機能を使用する define('PLUGIN_FOOTPRINT_TOPICPATH',1); // Show a link to $defaultpage or not define('PLUGIN_FOOTPRINT_TOP_DISPLAY', 1); // Label for $defaultpage ('' as disable) define('PLUGIN_FOOTPRINT_TOP_LABEL', ''); // Show the page itself or not define('PLUGIN_FOOTPRINT_THIS_PAGE_DISPLAY', 1); // If PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY, add a link to itself define('PLUGIN_FOOTPRINT_THIS_PAGE_LINK', 0); //-------------------------------------------- function plugin_footprint_convert() { return '<div class="footprint">' . plugin_footprint_inline() . '</div>'; } function plugin_footprint_inline() { global $script, $vars, $defaultpage; //セッション変数から取得 $footprints = ''; if($_SESSION['footprints']){ $footprints = $_SESSION['footprints']; } $page = $vars['page']; $splited = explode(PKWK_SPLITTER,$footprints); $str = ''; $newfootprints = array(); //新しいfootprintを作成する foreach($splited as $passedpage){ //すでに通ったページ if($passedpage == $page || $page == $defaultpage){ if( PLUGIN_FOOTPRINT_BACK == 1){ break; }else if( PLUGIN_FOOTPRINT_BACK == 0){ continue; } } //すでに通った階層 if( PLUGIN_FOOTPRINT_TOPICPATH and ( strstr($passedpage,'/') or strstr($page,'/') ) ){ $a = explode('/',$passedpage); $b = explode('/',$page); if($a[0] == $b[0]){ break; } } if($passedpage){ array_push($newfootprints,$passedpage); } } array_push($newfootprints,$page); $_SESSION['footprints'] = join(PKWK_SPLITTER,$newfootprints); //トップページをつけるかどうか if(PLUGIN_FOOTPRINT_TOP_DISPLAY){ if($newfootprints[0] != $defaultpage){ array_unshift($newfootprints,$defaultpage); } }else{ if($newfootprints[0] == $defaultpage){ array_shift($newfootprints); } } //現在ページを取り除く場合 if(!PLUGIN_FOOTPRINT_THIS_PAGE_DISPLAY){ array_pop($newfootprints); } $str = ''; foreach($newfootprints as $p){ if( PLUGIN_FOOTPRINT_TOPICPATH and strstr($p,'/')){ $str .= topicpath($p); }else{ $label = $p; //トップページのラベルを任意のラベルにする if($p == $defaultpage and PLUGIN_FOOTPRINT_TOP_LABEL){ $label = PLUGIN_FOOTPRINT_TOP_LABEL; } //現在ページにリンクをつけるかどうか if($p == $page and !PLUGIN_FOOTPRINT_THIS_PAGE_LINK){ $str .= $label; }else{ //それ以外 $str .= make_pagelink($p,$label); } } $str .= PLUGIN_FOOTPRINT_PAGE_SEPARATOR; } //最後の余分なseparatorをとっぱらって返す return substr($str,0,strlen(PLUGIN_FOOTPRINT_PAGE_SEPARATOR) * -1); } function topicpath($page) { global $script, $vars, $defaultpage; $parts = explode('/', $page); $b_link = TRUE; if($page == $vars['page']){ if (PLUGIN_FOOTPRINT_THIS_PAGE_DISPLAY) { $b_link = PLUGIN_FOOTPRINT_THIS_PAGE_LINK; } else { array_pop($parts); // Remove the page itself } } $topic_path = array(); while (! empty($parts)) { $_landing = join('/', $parts); $landing = rawurlencode($_landing); $element = htmlspecialchars(array_pop($parts)); if (! $b_link) { // This page ($_landing == $page) $b_link = TRUE; $topic_path[] = $element; } else if (PKWK_READONLY && ! is_page($_landing)) { // Page not exists $topic_path[] = $element; } else { // Page exists or not exists $topic_path[] = '<a href="' . $script . '?' . $landing . '">' . $element . '</a>'; } } return join(PLUGIN_FOOTPRINT_TREE_SEPARATOR, array_reverse($topic_path)); } ?>