• 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

Revisionbbd6b28ca8c2ac6b2f70663c44e930b6c61c85f0 (tree)
Time2007-10-20 19:46:42
Authorhenoheno <henoheno>
Commiterhenoheno

Log Message

Simplify

Change Summary

Incremental Difference

--- 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.117 2007/10/17 15:16:19 henoheno Exp $
3+// $Id: tracker.inc.php,v 1.118 2007/10/20 10:46:42 henoheno Exp $
44 // Copyright (C) 2003-2005, 2007 PukiWiki Developers Team
55 // License: GPL v2 or (at your option) any later version
66 //
@@ -41,6 +41,21 @@ define('PLUGIN_TRACKER_SORT_ORDER_ASC', 4);
4141 define('PLUGIN_TRACKER_SORT_ORDER_DEFAULT', PLUGIN_TRACKER_SORT_ORDER_ASC);
4242
4343
44+// ----
45+// Basic interface and strategy
46+
47+// $refer : Where the plugin had been set / Where to return back to
48+// Compat: If ($base == '') $base = $refer;
49+// $base : "$base/nnn" will be added by plugin_tracker_action(), or will be shown by Tracker_list
50+// $config : ":config/plugin/tracker/$config" will be load to the Config
51+// $form : ":config/plugin/tracker/$config/$form" will be load as template for XHTML form by Tracker_form
52+// $page : ":config/plugin/tracker/$config/$page" will be load as template for a new page written by Tracker_form
53+// $list : ":config/plugin/tracker/$config/$list" will be load as template of Tracker_list
54+// $order : order command string for Tracker_list
55+// $limit : Show top N rows at a time
56+
57+// ----
58+
4459 // Show a form
4560 function plugin_tracker_convert()
4661 {
@@ -48,22 +63,23 @@ function plugin_tracker_convert()
4863
4964 if (PKWK_READONLY) return ''; // Show nothing
5065
51- $base = $refer = isset($vars['page']) ? $vars['page'] : '';
52- $config = PLUGIN_TRACKER_DEFAULT_CONFIG;
53- $form = PLUGIN_TRACKER_DEFAULT_FORM;
54-
55- $args = func_get_args();
5666 $argc = count($args);
67+ $args = func_get_args();
5768 if ($argc > 2) {
5869 return PLUGIN_TRACKER_USAGE . '<br />';
5970 }
71+
72+ $base = $refer = isset($vars['page']) ? $vars['page'] : '';
73+ $config = '';
74+ $form = '';
6075 switch ($argc) {
6176 case 2:
77+ // Set $base
6278 $arg = get_fullname($args[1], $base);
6379 if (is_pagename($arg)) $base = $arg;
6480 /*FALLTHROUGH*/
6581 case 1:
66- // Config/form
82+ // Set "$config/$form"
6783 if ($args[0] != '') {
6884 $arg = explode('/', trim($args[0]), 2);
6985 if ($arg[0] != '' ) $config = trim($arg[0]);
@@ -73,19 +89,20 @@ function plugin_tracker_convert()
7389 unset($args, $argc, $arg);
7490
7591 $tracker_form = & new Tracker_form($base, $refer);
76- if ($tracker_form->loadConfig($config) === FALSE) {
92+ if (! $tracker_form->loadConfig($config)) {
7793 return '#tracker: ' . htmlspecialchars($tracker_form->error);
7894 }
7995
8096 // Load $template
81- $form = $tracker_form->config->page . '/' . $form;
97+ $form = ($form != '') ? $form : PLUGIN_TRACKER_DEFAULT_FORM;
98+ $form = $tracker_form->config->page . '/' . $form;
8299 $template = plugin_tracker_get_source($form, TRUE);
83100 if ($template === FALSE || empty($template)) {
84101 return '#tracker: Form \'' . make_pagelink($form) . '\' not found<br />';
85102 }
86103
87- if ($tracker_form->initFields(plugin_tracker_field_pickup($template)) === FALSE ||
88- $tracker_form->initHiddenFields() === FALSE) {
104+ if (! $tracker_form->initFields(plugin_tracker_field_pickup($template)) ||
105+ ! $tracker_form->initHiddenFields()) {
89106 return '#tracker: ' . htmlspecialchars($tracker_form->error);
90107 }
91108 $fields = $tracker_form->fields;
@@ -125,6 +142,7 @@ function plugin_tracker_action()
125142 if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
126143
127144 $base = isset($post['_base']) ? $post['_base'] : '';
145+
128146 $refer = isset($post['_refer']) ? $post['_refer'] : $base;
129147 if (! is_pagename($refer)) {
130148 return array(
@@ -165,7 +183,7 @@ function plugin_tracker_action()
165183 $from = $to = array();
166184
167185 $tracker_form = & new Tracker_form($base, $refer);
168- if ($tracker_form->loadConfig($config) === FALSE) {
186+ if (! $tracker_form->loadConfig($config)) {
169187 return array(
170188 'msg' => 'Cannot write',
171189 'body' => htmlspecialchars($tracker_form->error)
@@ -182,7 +200,7 @@ function plugin_tracker_action()
182200 );
183201 }
184202
185- if ($tracker_form->initFields(plugin_tracker_field_pickup(implode('', $template))) === FALSE) {
203+ if (! $tracker_form->initFields(plugin_tracker_field_pickup(implode('', $template)))) {
186204 return array(
187205 'msg' => 'Cannot write',
188206 'body' => htmlspecialchars($tracker_form->error)
@@ -336,7 +354,7 @@ class Tracker_form
336354 $field['default']
337355 );
338356 unset($raw_fields[$fieldname]);
339- if ($err === FALSE) return FALSE;
357+ if (! $err) return FALSE;
340358 }
341359 }
342360
@@ -812,11 +830,12 @@ function plugin_tracker_list_convert()
812830 {
813831 global $vars;
814832
815- $base = $refer = isset($vars['page']) ? $vars['page'] : '';
833+ $base = isset($vars['page']) ? $vars['page'] : '';
834+ $refer = $base;
816835 $config = '';
836+ $order = '';
817837 $list = '';
818838 $limit = NULL;
819- $order = '';
820839
821840 $args = func_get_args();
822841 $argc = count($args);
@@ -827,11 +846,12 @@ function plugin_tracker_list_convert()
827846 case 4: $limit = $args[3]; /*FALLTHROUGH*/
828847 case 3: $order = $args[2]; /*FALLTHROUGH*/
829848 case 2:
849+ // Set $base
830850 $arg = get_fullname($args[1], $base);
831851 if (is_pagename($arg)) $base = $arg;
832852 /*FALLTHROUGH*/
833853 case 1:
834- // Config/list
854+ // Set "$config/$list"
835855 if ($args[0] != '') {
836856 $arg = explode('/', $args[0], 2);
837857 if ($arg[0] != '' ) $config = $arg[0];
@@ -845,26 +865,23 @@ function plugin_tracker_list_convert()
845865
846866 function plugin_tracker_list_action()
847867 {
848- global $get, $vars;
849-
850- $base = isset($get['base']) ? $get['base'] : ''; // Base directory to load
851-
852- if (isset($get['refer'])) {
853- $refer = $get['refer']; // Where to #tracker_list
854- if ($base == '') $base = $refer;
855- } else {
856- $refer = $base;
857- }
868+ global $get;
858869
870+ $base = isset($get['base']) ? $get['base'] : '';
871+ $refer = isset($get['refer']) ? $get['refer'] : $base;
859872 $config = isset($get['config']) ? $get['config'] : '';
860- $list = isset($get['list']) ? $get['list'] : '';
861873 $order = isset($get['order']) ? $get['order'] : '';
874+ $list = isset($get['list']) ? $get['list'] : '';
862875 $limit = isset($get['limit']) ? $get['limit'] : NULL;
863876
877+ if ($base == '') $base = $refer; // Compat
878+
864879 $s_refer = make_pagelink($refer);
880+
865881 return array(
866882 'msg' => plugin_tracker_message('msg_list'),
867- 'body'=> str_replace('$1', $s_refer, plugin_tracker_message('msg_back')) .
883+ 'body'=>
884+ str_replace('$1', $s_refer, plugin_tracker_message('msg_back')) .
868885 plugin_tracker_list_render($base, $refer, $config, $order, $list, $limit)
869886 );
870887 }
@@ -877,16 +894,16 @@ function plugin_tracker_list_render($base, $refer, $config = '', $order = '', $l
877894 $order = trim($order);
878895 $list = trim($list);
879896 if ($config == '' ) $config = PLUGIN_TRACKER_DEFAULT_CONFIG;
880- if ($list == '' ) $list = PLUGIN_TRACKER_DEFAULT_LIST;
881897 if ($order == '' ) $order = PLUGIN_TRACKER_DEFAULT_ORDER;
898+ if ($list == '' ) $list = PLUGIN_TRACKER_DEFAULT_LIST;
882899 if ($limit == NULL) $limit = PLUGIN_TRACKER_DEFAULT_LIMIT;
883900
884901 if ($base == '') return '#tracker_list: Base not specified' . '<br />';
885902 if (! is_page($refer)) return '#tracker_list: Refer page not found: ' . htmlspecialchars($refer) . '<br />';
886903
887904 $tracker_list = & new Tracker_list($base, $refer);
888- if ($tracker_list->loadConfig($config) === FALSE ||
889- $tracker_list->setSortOrder($order) === FALSE) {
905+ if (! $tracker_list->loadConfig($config) ||
906+ ! $tracker_list->setSortOrder($order)) {
890907 return '#tracker_list: ' . htmlspecialchars($tracker_list->error) . '<br />';
891908 }
892909