• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revision7a194c624980a123c99384fb40efba5f040c0106 (tree)
Zeit2007-09-30 17:32:58
Autorhenoheno <henoheno>
Commiterhenoheno

Log Message

Tracker_form::initFields(): allow to limit calling addField() by fieldname

Ändern Zusammenfassung

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.91 2007-09-29 15:49:16 henoheno Exp $
3+// $Id: tracker.inc.php,v 1.92 2007-09-30 08:32:58 henoheno Exp $
44 // Copyright (C) 2003-2005, 2007 PukiWiki Developers Team
55 // License: GPL v2 or (at your option) any later version
66 //
@@ -226,20 +226,22 @@ function plugin_tracker_action()
226226 exit;
227227 }
228228
229-// Data set of XHTML form or someting
229+// Data set of XHTML form or something
230230 class Tracker_form
231231 {
232232 var $id;
233233 var $base;
234234 var $refer;
235235 var $config;
236+
237+ var $raw_fields;
236238 var $fields = array();
237239
238240 function Tracker_form($base, $refer, $config)
239241 {
240242 static $id = 0; // Unique id per instance
243+ $this->id = ++$id;
241244
242- $this->id = ++$id;
243245 $this->base = $base;
244246 $this->refer = $refer;
245247 $this->config = $config;
@@ -274,14 +276,25 @@ class Tracker_form
274276 return TRUE;
275277 }
276278
277- function initFields()
279+ function initFields($requests = array())
278280 {
279- foreach ($this->config->get('fields') as $field) {
280- $this->addField($field[0], $field[1], $field[2], $field[3], $field[4]);
281- }
282- foreach (
283- array(
284- // Reserved ones
281+ if (isset($this->raw_fields)) {
282+ $raw_fields = $this->raw_fields;
283+ } else {
284+ $raw_fields = array();
285+ // From config
286+ foreach ($this->config->get('fields') as $field) {
287+ $fieldname = isset($field[0]) ? $field[0] : '';
288+ $raw_fields[$fieldname] = array(
289+ 'display' => isset($field[1]) ? $field[1] : '',
290+ 'type' => isset($field[2]) ? $field[2] : '',
291+ 'options' => isset($field[3]) ? $field[3] : '',
292+ 'default' => isset($field[4]) ? $field[4] : '',
293+ );
294+ }
295+ // From reserved
296+ $default = array('options' => '20', 'default' => '');
297+ foreach (array(
285298 '_date' => 'text', // Post date
286299 '_update' => 'date', // Last modified date
287300 '_past' => 'past', // Elapsed time (passage)
@@ -291,10 +304,48 @@ class Tracker_form
291304 '_refer' => 'page', // Page name refer from this (Page who has forms)
292305 '_base' => 'page',
293306 '_submit' => 'submit'
294- ) as $fieldname => $type)
295- {
296- $this->addField($fieldname, plugin_tracker_message('btn' . $fieldname), $type);
307+ ) as $fieldname => $type) {
308+ if (isset($raw_fields[$fieldname])) continue;
309+ $raw_fields[$fieldname] = array(
310+ 'display' => plugin_tracker_message('btn' . $fieldname),
311+ 'type' => $type,
312+ ) + $default;
313+ }
314+ $this->raw_fields = $raw_fields;
315+ }
316+
317+ if (! is_array($requests)) $requests = array($requests);
318+ if ($requests) {
319+ // A part of
320+ foreach ($requests as $fieldname) {
321+ if (isset($raw_fields[$fieldname])) {
322+ $field = $raw_fields[$fieldname];
323+ $this->addField(
324+ $fieldname,
325+ $field['display'],
326+ $field['type'],
327+ $field['options'],
328+ $field['default']
329+ );
330+ } else{
331+ // TODO: Return an error: Invalid fieldname
332+ // return FALSE;
333+ }
334+ }
335+ } else {
336+ // All
337+ foreach ($raw_fields as $fieldname => $field) {
338+ $this->addField(
339+ $fieldname,
340+ $field['display'],
341+ $field['type'],
342+ $field['options'],
343+ $field['default']
344+ );
345+ }
297346 }
347+
348+ return TRUE;
298349 }
299350 }
300351
@@ -794,10 +845,11 @@ class Tracker_list
794845 function Tracker_list($base, $refer, & $config, $list)
795846 {
796847 $form = & new Tracker_form($base, $refer, $config);
797- $form->initFields();
798848 $this->form = $form;
799-
800849 $this->list = $list;
850+
851+ // TODO: Call with sort() and toString()
852+ $this->form->initFields();
801853 }
802854
803855 // Add multiple pages at a time