1: 2008-12-26 (金) 01:39:38 admin |
現: 2008-12-28 (日) 12:13:39 admin |
- | <?php | + | ** title_page.inc.php [#o61ec9cb] |
| + | - ページの先頭の階層のみを表示するコマンド (2階層以降を表示しない) |
| + | - pukiWiki の list コマンドに相当 |
| | | |
- | // PukiWiki - Yet another WikiWikiWeb clone. | + | *** ソース [#r05f298b] |
- | // $Id: list.inc.php,v 1.2 2007/02/11 00:11:58 nao-pon Exp $ | + | |
- | // | + | |
- | // IndexPages plugin: Show a list of page names | + | |
- | // | + | |
- | // Modified by Fumi.Iseki '09 12/25 | + | |
- | // | + | |
- | class xpwiki_plugin_title_list extends xpwiki_plugin | + | |
- | { | + | |
- | function plugin_title_list_init () { | + | |
| | | |
- | } | + | *** プログラム内のメッセージの変更 [#rd7423f3] |
| + | -以下のファイルに ''$root->_title_page'' を追加 |
| + | xoops_trust_path/modules/xpwiki/language/xpwiki/en |
| + | xoops_trust_path/modules/xpwiki/language/xpwiki/ja_utf8 |
| + | xoops_trust_path/modules/xpwiki/language/xpwiki/ja |
| | | |
- | function plugin_title_list_action() | + | *** ナビに表示 [#j852379e] |
- | { | + | -以下のファイルに ''$root->_title_page'', ''$root->_LANG['skin']['title_page']'' を追加 |
- | // Redirected from filelist plugin? | + | xoops_trust_path/modules/xpwiki/language/xpwiki/en |
- | $filelist = (isset($this->root->vars['cmd']) && $this->root->vars['cmd'] == 'filelist'); | + | xoops_trust_path/modules/xpwiki/language/xpwiki/ja_utf8 |
| + | xoops_trust_path/modules/xpwiki/language/xpwiki/ja |
| | | |
- | if ($filelist && !empty($this->root->filelist_only_admin) && !$this->root->userinfo['admin']) { | + | - ''html/modules/xpwiki/skin/xpwiki/pukiwiki.skin.php'' の ''navigator_wiki'' に以下を追加 |
- | return array( | + | <?php $navigator($this,'title_page') ?> | |
- | 'msg' => $this->root->_msg_not_readable, | + | |
- | 'body' => ''); | + | |
- | } else { | + | |
- | return array( | + | |
- | 'msg' => $filelist ? $this->root->_title_filelist : $this->root->_title_page, | + | |
- | 'body' => $this->plugin_list_getlist($filelist)); | + | |
- | } | + | |
- | } | + | |
| | | |
- | // Get a list | + | -''xoops_trust_path/modules/xpwiki/class/func/pukiwiki_func.php'' に以下を追加 |
- | function plugin_list_getlist($withfilename = FALSE) | + | $_LINK['title_page'] = "{$this->root->script}?cmd=title_page#{$this->root->mydirname}_header"; |
- | { | + | |
- | $pages = array_diff($this->func->get_existpages(), array($this->root->whatsnew)); | + | |
- | if (! $withfilename) | + | |
- | $pages = array_diff($pages, preg_grep('/' . $this->root->non_list . '/S', $pages)); | + | |
- | if (empty($pages)) return ''; | + | |
- | | + | |
- | return $this->page_title_list($pages, 'read', $withfilename); | + | |
- | } | + | |
- | | + | |
- | | + | |
- | // Create list of pages | + | |
- | function page_title_list($pages, $cmd = 'read', $withfilename = FALSE) | + | |
- | { | + | |
- | // �\�[�g�L�[��肷��B ' ' < '[a-zA-Z]' < 'zz'�Ƃ����O��B | + | |
- | $symbol = ' '; | + | |
- | $other = 'zz'; | + | |
- | $retval = ''; | + | |
- | | + | |
- | if($this->root->pagereading_enable) { | + | |
- | mb_regex_encoding($this->cont['SOURCE_ENCODING']); | + | |
- | } | + | |
- | list($readings, $titles) = $this->func->get_readings($pages); | + | |
- | | + | |
- | $list = $matches = array(); | + | |
- | | + | |
- | // Shrink URI for read | + | |
- | if ($cmd === 'read') { | + | |
- | $href = $this->root->script . ($this->root->static_url? '' : '?'); | + | |
- | } else { | + | |
- | $href = $this->root->script . '?cmd=' . $cmd . '&page='; | + | |
- | } | + | |
- | | + | |
- | | + | |
- | // Fumi.Iseki | + | |
- | $pagesx = array(); | + | |
- | foreach($pages as $file=>$page) { | + | |
- | $topname = mb_split('/', $page); | + | |
- | $pagesx[$topname[0]][$page] = $file; | + | |
- | } | + | |
- | ksort($pagesx); | + | |
- | | + | |
- | $pcount = array(); | + | |
- | $pages = array(); | + | |
- | foreach($pagesx as $topname=>$vals) { | + | |
- | ksort($vals); | + | |
- | $pfrst = each($vals); | + | |
- | $page = $pfrst["key"]; | + | |
- | $file = $pfrst["value"]; | + | |
- | $pages[$file] = $page; | + | |
- | $pcount[$page] = count($vals); | + | |
- | } | + | |
- | | + | |
- | | + | |
- | foreach($pages as $file=>$page) { | + | |
- | $r_page = ($cmd === 'read' && $this->root->static_url)? $this->func->get_page_uri($page) : rawurlencode($page); | + | |
- | $s_page = htmlspecialchars($page, ENT_QUOTES); | + | |
- | $passage = $this->func->get_pg_passage($page); | + | |
- | $title = (empty($titles[$page]))? '' : ' [ ' . htmlspecialchars($titles[$page]) . ' ]'; | + | |
- | | + | |
- | $pcnt = "<small>(+".$pcount[$page].")</small>"; | + | |
- | $str = ' <li><a href="'.$href.$r_page.'">'.$s_page.'</a>'." ".$pcnt." ".$passage.$title; | + | |
- | | + | |
- | if ($withfilename) { | + | |
- | $s_file = htmlspecialchars($file); | + | |
- | $str .= "\n".' <ul><li>'.$s_file.'</li></ul>'."\n".' '; | + | |
- | } | + | |
- | $str .= '</li>'; | + | |
- | | + | |
- | if($this->root->pagereading_enable) { | + | |
- | // WARNING: Japanese code hard-wired | + | |
- | $katakana = '�@-��'; | + | |
- | $kanji = '��-��-�'; | + | |
- | if ($this->cont['SOURCE_ENCODING'] === 'UTF-8') { | + | |
- | $katakana = mb_convert_encoding($katakana, 'UTF-8', 'EUC-JP'); | + | |
- | $kanji = mb_convert_encoding($kanji, 'UTF-8', 'EUC-JP'); | + | |
- | } | + | |
- | if(mb_ereg('^([A-Za-z])', mb_convert_kana($page, 'a'), $matches)) { | + | |
- | $head = $matches[1]; | + | |
- | } elseif (isset($readings[$page]) && mb_ereg('^([' . $katakana . '])', $readings[$page], $matches)) { // here | + | |
- | $head = $matches[1]; | + | |
- | } elseif (mb_ereg('^[ -~]|[^' . $kanji . ']', $page)) { // and here | + | |
- | $head = $symbol; | + | |
- | } else { | + | |
- | $head = $other; | + | |
- | } | + | |
- | } else { | + | |
- | $head = (preg_match('/^([A-Za-z])/', $page, $matches)) ? $matches[1] : (preg_match('/^([ -~])/', $page) ? $symbol : $other); | + | |
- | } | + | |
- | if ($this->root->page_case_insensitive) { | + | |
- | $head = strtoupper($head); | + | |
- | } | + | |
- | $list[$head][$page] = $str; | + | |
- | } | + | |
- | //ksort($list); | + | |
- | | + | |
- | | + | |
- | $cnt = 0; | + | |
- | $arr_index = array(); | + | |
- | $retval .= '<ul>' . "\n"; | + | |
- | foreach ($list as $head=>$pages) { | + | |
- | if ($head === $symbol) { | + | |
- | $head = $this->root->_msg_symbol; | + | |
- | } else if ($head === $other) { | + | |
- | $head = $this->root->_msg_other; | + | |
- | } | + | |
- | | + | |
- | if ($this->root->list_index) { | + | |
- | ++$cnt; | + | |
- | $arr_index[] = '<a id="top_'.$cnt.'" href="#head_'.$cnt.'"> <strong>'.$head.'</strong> </a>'; | + | |
- | $retval .= ' <li><a id="head_'.$cnt.'" href="#top_'.$cnt.'"><strong>'.$head.'</strong></a>'."\n".' <ul>'."\n"; | + | |
- | } | + | |
- | ksort($pages); | + | |
- | $retval .= join("\n", $pages); | + | |
- | if ($this->root->list_index) $retval .= "\n </ul>\n </li>\n"; | + | |
- | } | + | |
- | | + | |
- | $retval .= '</ul>' . "\n"; | + | |
- | if ($this->root->list_index && $cnt > 0) { | + | |
- | $top = array(); | + | |
- | while (! empty($arr_index)) { | + | |
- | $top[] = join('|', array_splice($arr_index, 0, 16))."\n"; | + | |
- | } | + | |
- | $retval = '<div id="top" style="text-align:center">'."\n".join('<br />', $top).'</div>'."\n". $retval; | + | |
- | } | + | |
- | return $retval; | + | |
- | } | + | |
- | | + | |
- | | + | |
- | } | + | |
- | | + | |
- | ?> | + | |