• 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ãof1bf06fc8d706e09c40d5d9f6f0189b7b03602dd (tree)
Hora2007-09-11 01:07:21
Autorhenoheno <henoheno>
Commiterhenoheno

Mensagem de Log

Cleanup/Simplify/Todo
* $page => $base
* plugin_tracker_list_render(): Added some validations except $refer
* Tracker_list: Hidden column '_refer' seems to be the same ($this->base), and seems not used.

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.49 2007/09/09 13:41:52 henoheno Exp $
3+// $Id: tracker.inc.php,v 1.50 2007/09/10 16:07:21 henoheno Exp $
44 // Copyright (C) 2003-2005, 2007 PukiWiki Developers Team
55 // License: GPL v2 or (at your option) any later version
66 //
@@ -241,21 +241,20 @@ function plugin_tracker_get_fields($base, $refer, & $config)
241241 }
242242
243243 // Field classes
244-// TODO: Not to use static variables (except $id)
245244 class Tracker_field
246245 {
247246 var $name;
248247 var $title;
249248 var $values;
250249 var $default_value;
251- var $page;
250+ var $base;
252251 var $refer;
253252 var $config;
254253 var $data;
255254 var $sort_type = SORT_REGULAR;
256255 var $id = 0;
257256
258- function Tracker_field($field, $page, $refer, & $config)
257+ function Tracker_field($field, $base, $refer, & $config)
259258 {
260259 global $post;
261260 static $id = 0; // Unique id per instance
@@ -265,7 +264,7 @@ class Tracker_field
265264 $this->title = $field[1];
266265 $this->values = explode(',', $field[3]);
267266 $this->default_value = $field[4];
268- $this->page = $page;
267+ $this->base = $base;
269268 $this->refer = $refer;
270269 $this->config = & $config;
271270 $this->data = isset($post[$this->name]) ? $post[$this->name] : '';
@@ -370,9 +369,9 @@ class Tracker_field_format extends Tracker_field
370369 var $styles = array();
371370 var $formats = array();
372371
373- function Tracker_field_format($field, $page, $refer, & $config)
372+ function Tracker_field_format($field, $base, $refer, & $config)
374373 {
375- parent::Tracker_field($field, $page, $refer, $config);
374+ parent::Tracker_field($field, $base, $refer, $config);
376375
377376 foreach ($this->config->get($this->name) as $option) {
378377 list($key, $style, $format) =
@@ -428,10 +427,10 @@ class Tracker_field_file extends Tracker_field_format
428427
429428 require_once(PLUGIN_DIR . 'attach.inc.php');
430429
431- $result = attach_upload($_FILES[$this->name], $this->page);
432- if ($result['result']) {
430+ $result = attach_upload($_FILES[$this->name], $this->base);
431+ if (isset($result['result']) && $result['result']) {
433432 // Upload success
434- return parent::format_value($this->page . '/' . $_FILES[$this->name]['name']);
433+ return parent::format_value($this->base . '/' . $_FILES[$this->name]['name']);
435434 }
436435 }
437436
@@ -565,15 +564,15 @@ class Tracker_field_submit extends Tracker_field
565564 function get_tag()
566565 {
567566 $s_title = htmlspecialchars($this->title);
568- $s_page = htmlspecialchars($this->page);
567+ $s_base = htmlspecialchars($this->base);
569568 $s_refer = htmlspecialchars($this->refer);
570569 $s_config = htmlspecialchars($this->config->config_name);
571570
572571 return <<<EOD
573572 <input type="submit" value="$s_title" />
574-<input type="hidden" name="plugin" value="tracker" />
575-<input type="hidden" name="_refer" value="$s_refer" />
576-<input type="hidden" name="_base" value="$s_page" />
573+<input type="hidden" name="plugin" value="tracker" />
574+<input type="hidden" name="_refer" value="$s_refer" />
575+<input type="hidden" name="_base" value="$s_base" />
577576 <input type="hidden" name="_config" value="$s_config" />
578577 EOD;
579578 }
@@ -612,7 +611,7 @@ function plugin_tracker_list_convert()
612611 global $vars;
613612
614613 $config = PLUGIN_TRACKER_DEFAULT_CONFIG;
615- $page = $refer = isset($vars['page']) ? $vars['page'] : '';
614+ $base = $refer = isset($vars['page']) ? $vars['page'] : '';
616615 $order = '';
617616 $list = 'list';
618617 $limit = 0;
@@ -621,42 +620,57 @@ function plugin_tracker_list_convert()
621620 if (func_num_args()) {
622621 $args = func_get_args();
623622 switch (count($args)) {
624- case 4:
625- if (! is_numeric($args[3])) return PLUGIN_TRACKER_LIST_USAGE . '<br />';
626- $limit = intval($args[3]);
627- case 3:
628- $order = $args[2];
629- case 2:
630- $arg = get_fullname($args[1], $page);
631- if (is_pagename($arg)) $page = $arg;
623+ case 4: $limit = $args[3]; /*FALLTHROUGH*/
624+ case 3: $order = $args[2]; /*FALLTHROUGH*/
625+ case 2: /*FALLTHROUGH*/
626+ $arg = get_fullname($args[1], $base);
627+ if (is_pagename($arg)) $base = $arg;
632628 case 1:
633629 if ($args[0] != '') $config = $args[0];
634630 list($config, $list) = array_pad(explode('/', $config, 2), 2, $list);
635631 }
636632 }
637- return plugin_tracker_list_render($page, $refer, $config, $list, $order, $limit);
633+
634+ return plugin_tracker_list_render($base, $refer, $config, $list, $order, $limit);
638635 }
639636
640637 function plugin_tracker_list_action()
641638 {
642639 global $vars;
643640
644- $page = $refer = isset($vars['refer']) ? $vars['refer'] : '';
641+ $base = isset($vars['base']) ? $vars['base'] : '';
645642 $config = isset($vars['config']) ? $vars['config'] : '';
646643 $list = isset($vars['list']) ? $vars['list'] : 'list';
647644 $order = isset($vars['order']) ? $vars['order'] : '_real:SORT_DESC';
648- $limit = isset($vars['limit']) ? intval($vars['limit']) : 0;
645+ $limit = isset($vars['limit']) ? $vars['limit'] : 0;
649646
650- $s_page = make_pagelink($page);
647+ $s_base = make_pagelink(trim($base));
651648 return array(
652649 'msg' => plugin_tracker_message('msg_list'),
653- 'body'=> str_replace('$1', $s_page, plugin_tracker_message('msg_back')) .
654- plugin_tracker_list_render($page, $refer, $config, $list, $order, $limit)
650+ 'body'=> str_replace('$1', $s_base, plugin_tracker_message('msg_back')) .
651+ plugin_tracker_list_render($base, $base, $config, $list, $order, $limit)
655652 );
656653 }
657654
658-function plugin_tracker_list_render($page, $refer, $config_name, $list, $order_commands = '', $limit = 0)
655+function plugin_tracker_list_render($base, $refer, $config_name, $list, $order_commands = '', $limit = 0)
659656 {
657+ $base = trim($base);
658+ $refer = trim($refer);
659+ $list = trim($list);
660+ $config_name = trim($config_name);
661+ $order_commands = trim($order_commands);
662+
663+ if ($base == '') {
664+ return '#tracker_list: Base not specified' . '<br />';
665+ }
666+ if (! is_numeric($limit)) {
667+ return PLUGIN_TRACKER_LIST_USAGE . '<br />';
668+ }
669+ $limit = intval($limit);
670+
671+ if ($config_name == '') {
672+ return '#tracker_list: Config not specified<br />';
673+ }
660674 $config = new Config('plugin/tracker/' . $config_name);
661675 if (! $config->read()) {
662676 return '#tracker_list: Config \'' . htmlspecialchars($config_name) . '\' not found<br />';
@@ -666,21 +680,20 @@ function plugin_tracker_list_render($page, $refer, $config_name, $list, $order_c
666680 return '#tracker_list: List \'' . make_pagelink($config->page . '/' . $list) . '\' not found<br />';
667681 }
668682
669- $list = & new Tracker_list($page, $refer, $config, $list);
683+ $list = & new Tracker_list($base, $refer, $config, $list);
670684 $list->sort($order_commands);
671685 $result = $list->toString($limit);
672686 if ($result == FALSE) {
673- $result = '#tracker_list: Pages under \'' . htmlspecialchars($page) . '/\' not found' . '<br />';
687+ $result = '#tracker_list: Pages under \'' . htmlspecialchars($base) . '/\' not found' . '<br />';
674688 }
675689
676690 return $result;
677691 }
678692
679693 // Listing class
680-// TODO: Not to use static variable
681694 class Tracker_list
682695 {
683- var $page;
696+ var $base;
684697 var $config;
685698 var $list;
686699 var $fields;
@@ -691,13 +704,14 @@ class Tracker_list
691704 var $order = array();
692705 var $_added = array();
693706
694- function Tracker_list($page, $refer, & $config, $list)
707+ // TODO: Why list here
708+ function Tracker_list($base, $refer, & $config, $list)
695709 {
696- $this->page = $page;
710+ $this->base = $base;
697711 $this->config = & $config;
698712 $this->list = $list;
699713
700- $fields = plugin_tracker_get_fields($page, $refer, $config);
714+ $fields = plugin_tracker_get_fields($base, $refer, $config);
701715 $pattern = array();
702716 $pattern_fields = array();
703717
@@ -730,7 +744,7 @@ class Tracker_list
730744 $this->pattern_fields = $pattern_fields;
731745
732746 // Listing
733- $pattern = $page . '/';
747+ $pattern = $base . '/';
734748 $pattern_len = strlen($pattern);
735749 foreach (get_existpages() as $_page) {
736750 if (strpos($_page, $pattern) === 0) {
@@ -766,7 +780,6 @@ class Tracker_list
766780 $row = array(
767781 // column => default data of the cell
768782 '_page' => '[[' . $page . ']]',
769- '_refer' => $this->page,
770783 '_real' => $name,
771784 '_update' => $filetime,
772785 '_past' => $filetime,
@@ -813,13 +826,13 @@ class Tracker_list
813826 switch (strtoupper(trim($order))) {
814827 case '':
815828 break;
816- case SORT_ASC:
817- case 'SORT_ASC':
829+ case SORT_ASC: /*FALLTHROUGH*/
830+ case 'SORT_ASC': /*FALLTHROUGH*/
818831 case 'ASC':
819832 $orders[$fieldname] = SORT_ASC;
820833 break;
821- case SORT_DESC:
822- case 'SORT_DESC':
834+ case SORT_DESC: /*FALLTHROUGH*/
835+ case 'SORT_DESC': /*FALLTHROUGH*/
823836 case 'DESC':
824837 $orders[$fieldname] = SORT_DESC;
825838 break;
@@ -899,7 +912,7 @@ class Tracker_list
899912 unset($order[$sort], $order_keys);
900913 }
901914 $title = $this->fields[$field]->title;
902- $r_page = rawurlencode($this->page);
915+ $r_base = rawurlencode($this->base);
903916 $r_config = rawurlencode($this->config->config_name);
904917 $r_list = rawurlencode($this->list);
905918 $_order = array($sort . ':' . $dir);
@@ -912,7 +925,7 @@ class Tracker_list
912925
913926 $script = get_script_uri();
914927 return '[[' . $title . $arrow . '>' .
915- $script . '?plugin=tracker_list&refer=' . $r_page .
928+ $script . '?plugin=tracker_list&base=' . $r_base .
916929 '&config=' . $r_config .
917930 '&list=' . $r_list . '&order=' . $r_order . ']]';
918931 }
@@ -946,7 +959,7 @@ class Tracker_list
946959 ) . "\n";
947960 }
948961
949- $body = array();
962+ $body = array();
950963 foreach (plugin_tracker_get_source($this->config->page . '/' . $this->list) as $line) {
951964 if (preg_match('/^\|(.+)\|[hfc]$/i', $line)) {
952965 // Table decolations