• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão2d9a46989678b15d288a94512d61178a42081062 (tree)
Hora2007-09-23 00:08:44
Autorhenoheno <henoheno>
Commiterhenoheno

Mensagem de Log

BugTrack2/125: Tracker_list: refer=page-name_that_has_tracker-list

Mudança Sumário

Diff

--- a/plugin/tracker.inc.php
+++ b/plugin/tracker.inc.php
@@ -1,6 +1,6 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone
3-// $Id: tracker.inc.php,v 1.65 2007/09/22 11:27:42 henoheno Exp $
3+// $Id: tracker.inc.php,v 1.66 2007/09/22 15:08:44 henoheno Exp $
44 // Copyright (C) 2003-2005, 2007 PukiWiki Developers Team
55 // License: GPL v2 or (at your option) any later version
66 //
@@ -659,21 +659,20 @@ function plugin_tracker_list_action()
659659 {
660660 global $get, $vars;
661661
662- $base = isset($get['base']) ? $get['base'] : '';
662+ $base = isset($get['base']) ? $get['base'] : ''; // Base directory to load
663+ $refer = isset($get['refer']) ? $get['refer'] : $base; // Where to #tracker_list
664+ if ($base == '') $base = $refer; // Compat before 1.4.8
665+
663666 $config = isset($get['config']) ? $get['config'] : '';
664667 $list = isset($get['list']) ? $get['list'] : 'list';
665-
666668 $order = isset($vars['order']) ? $vars['order'] : PLUGIN_TRACKER_DEFAULT_ORDER;
667669 $limit = isset($vars['limit']) ? $vars['limit'] : 0;
668670
669- // Compat before 1.4.8
670- if ($base == '') $base = isset($get['refer']) ? $get['refer'] : '';
671-
672- $s_base = make_pagelink(trim($base));
671+ $s_refer = make_pagelink(trim($refer));
673672 return array(
674673 'msg' => plugin_tracker_message('msg_list'),
675- 'body'=> str_replace('$1', $s_base, plugin_tracker_message('msg_back')) .
676- plugin_tracker_list_render($base, $base, $config, $list, $order, $limit)
674+ 'body'=> str_replace('$1', $s_refer, plugin_tracker_message('msg_back')) .
675+ plugin_tracker_list_render($base, $refer, $config, $list, $order, $limit)
677676 );
678677 }
679678
@@ -682,7 +681,11 @@ function plugin_tracker_list_render($base, $refer, $config_name, $list, $order_c
682681 $base = trim($base);
683682 if ($base == '') return '#tracker_list: Base not specified' . '<br />';
684683
684+ // TODO: is_page
685685 $refer = trim($refer);
686+ if (! is_page($refer)) {
687+ return '#tracker_list: Refer page not found: ' . htmlspecialchars($refer) . '<br />';
688+ }
686689
687690 $config_name = trim($config_name);
688691 if ($config_name == '') $config_name = PLUGIN_TRACKER_DEFAULT_CONFIG;
@@ -691,7 +694,6 @@ function plugin_tracker_list_render($base, $refer, $config_name, $list, $order_c
691694 if (! is_numeric($limit)) return PLUGIN_TRACKER_LIST_USAGE . '<br />';
692695 $limit = intval($limit);
693696
694-
695697 $config = new Config('plugin/tracker/' . $config_name);
696698 if (! $config->read()) {
697699 return '#tracker_list: Config not found: ' . htmlspecialchars($config_name) . '<br />';
@@ -729,9 +731,10 @@ class Tracker_list
729731 var $orders = array();
730732 var $error = ''; // Error message
731733
734+ // add()
732735 var $_added = array();
733736
734- // Used by toString() only
737+ // toString()
735738 var $_itmes;
736739 var $_the_first_character_of_the_line;
737740
@@ -744,7 +747,30 @@ class Tracker_list
744747 $this->fields = plugin_tracker_get_fields($base, $refer, $config);
745748 }
746749
747- // Generate regexes
750+ // Load pages
751+ function _load()
752+ {
753+ $pattern = $this->base . '/';
754+ $pattern_len = strlen($pattern);
755+
756+ foreach (get_existpages() as $_page) {
757+ if (strpos($_page, $pattern) === 0) {
758+ $name = substr($_page, $pattern_len);
759+ if (preg_match(PLUGIN_TRACKER_LIST_EXCLUDE_PATTERN, $name)) continue;
760+
761+ // Adding $this->rows
762+ if ($this->add($_page, $name) === FALSE) return FALSE;
763+ }
764+ }
765+ if (empty($this->rows)) {
766+ $this->error = 'Pages not found under: ' . $pattern;
767+ return FALSE;
768+ }
769+
770+ return TRUE;
771+ }
772+
773+ // add(): Generate regexes
748774 function _generate_regex()
749775 {
750776 $config_page = $this->config->page;
@@ -784,29 +810,6 @@ class Tracker_list
784810 $this->pattern_fields = $pattern_fields;
785811 }
786812
787- // Load pages
788- function _load()
789- {
790- $pattern = $this->base . '/';
791- $pattern_len = strlen($pattern);
792-
793- foreach (get_existpages() as $_page) {
794- if (strpos($_page, $pattern) === 0) {
795- $name = substr($_page, $pattern_len);
796- if (preg_match(PLUGIN_TRACKER_LIST_EXCLUDE_PATTERN, $name)) continue;
797-
798- // Adding $this->rows
799- if ($this->add($_page, $name) === FALSE) return FALSE;
800- }
801- }
802- if (empty($this->rows)) {
803- $this->error = 'Pages not found under: ' . $pattern;
804- return FALSE;
805- }
806-
807- return TRUE;
808- }
809-
810813 function add($page, $name)
811814 {
812815 if (isset($this->_added[$page])) return TRUE;
@@ -899,7 +902,7 @@ class Tracker_list
899902 }
900903
901904 $this->orders = $orders;
902- return $orders;
905+ return TRUE;
903906 }
904907
905908 // Sort $this->rows by $this->orders
@@ -992,10 +995,14 @@ class Tracker_list
992995 // toString(): Called within preg_replace_callback()
993996 function _replace_title($matches = array())
994997 {
998+ static $script;
999+
9951000 $fields = $this->fields;
9961001 $orders = $this->orders;
997- $list = $this->list;
1002+ $base = $this->base;
1003+ $refer = $this->refer;
9981004 $config_name = $this->config->config_name;
1005+ $list = $this->list;
9991006
10001007 $fieldname = isset($matches[1]) ? $matches[1] : '';
10011008 if (! isset($fields[$fieldname])) {
@@ -1034,21 +1041,23 @@ class Tracker_list
10341041 $_order[] = $key . ':' . $this->_sortkey_define2string($value);
10351042 }
10361043
1044+ if (! isset($script)) $script = get_script_uri();
1045+ $r_refer = ($refer != $base) ?
1046+ '&refer=' . rawurlencode($refer) : '';
10371047 $r_config = ($config_name != PLUGIN_TRACKER_DEFAULT_CONFIG) ?
10381048 '&config=' . rawurlencode($config_name) : '';
10391049 $r_list = ($list != PLUGIN_TRACKER_DEFAULT_LIST) ?
10401050 '&list=' . rawurlencode($list) : '';
1051+ $r_order = ! empty($_order) ?
1052+ '&order=' . rawurlencode(join(';', $_order)) : '';
10411053
10421054 return
10431055 '[[' .
10441056 $fields[$fieldname]->title . $arrow .
10451057 '>' .
1046- get_script_uri() .
1047- '?plugin=tracker_list' .
1048- '&base=' . rawurlencode($this->base) .
1049- $r_config .
1050- $r_list .
1051- '&order=' . rawurlencode(join(';', $_order)) .
1058+ $script . '?plugin=tracker_list' .
1059+ '&base=' . rawurlencode($base) .
1060+ $r_refer . $r_config . $r_list . $r_order .
10521061 ']]';
10531062 }
10541063
@@ -1096,7 +1105,8 @@ class Tracker_list
10961105 // Loading template: Roughly checking listed fields
10971106 $matches = array();
10981107 $used_fieldname = array('_real' => TRUE);
1099- preg_match_all($regex, plugin_tracker_get_source($list, TRUE), $matches);
1108+ $template = plugin_tracker_get_source($list, TRUE);
1109+ preg_match_all($regex, $template, $matches);
11001110 unset($matches[0]);
11011111 foreach ($matches[1] as $match) {
11021112 $params = explode(',', $match);
@@ -1131,6 +1141,7 @@ class Tracker_list
11311141 if ($this->_sort() === FALSE) return FALSE;
11321142 $rows = $this->rows;
11331143
1144+ // toString()
11341145 $count = count($this->rows);
11351146 $limit = intval($limit);
11361147 if ($limit != 0) $limit = max(1, $limit);