• 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ão862d2c905f0252cc24a66b6bdaf5aa78cb0dbafe (tree)
Hora2007-09-18 01:05:28
Autorhenoheno <henoheno>
Commiterhenoheno

Mensagem de Log

KISS
* Do one thing best: Tracker_list::toString() now returns a wiki text, not a xhtml.
* Correct / Clear tracker_list not-sorting bug inserted these days.

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.53 2007/09/16 04:06:39 henoheno Exp $
3+// $Id: tracker.inc.php,v 1.54 2007/09/17 16:05:28 henoheno Exp $
44 // Copyright (C) 2003-2005, 2007 PukiWiki Developers Team
55 // License: GPL v2 or (at your option) any later version
66 //
@@ -707,9 +707,9 @@ function plugin_tracker_list_render($base, $refer, $config_name, $list, $order_c
707707 $result = $list->toString($limit);
708708 if ($result === FALSE) {
709709 return '#tracker_list: ' . htmlspecialchars($list->error) . '<br />';
710+ } else {
711+ return convert_html($result);
710712 }
711-
712- return $result;
713713 }
714714
715715 // Listing class
@@ -728,6 +728,10 @@ class Tracker_list
728728
729729 var $error = ''; // Error message
730730
731+ // Used by toString() only
732+ var $_itmes;
733+ var $_escape;
734+
731735 // TODO: Why list here
732736 function Tracker_list($base, $refer, & $config, $list)
733737 {
@@ -832,9 +836,10 @@ class Tracker_list
832836 return TRUE;
833837 }
834838
839+ $fields = $this->fields;
835840 $orders = array();
836841 $params = array(); // Arguments for array_multisort()
837- $names = array_flip(array_keys($this->fields));
842+ $names = array_flip(array_keys($fields));
838843
839844 foreach (explode(';', $order_commands) as $command) {
840845 // TODO: ???
@@ -847,21 +852,26 @@ class Tracker_list
847852 }
848853
849854 $order = $this->_sortkey_string2define($order);
850- if ($order === FALSE) return FALSE;
851- if ($order !== NULL) $orders[$fieldname] = $order;
855+ if ($order === NULL) continue;
856+ if ($order === FALSE) {
857+ $this->error = 'Invalid sortkey: ' . $order;
858+ return FALSE;
859+ }
860+
861+ $orders[$fieldname] = $order; // Set or override
852862 }
853- // TODO: LIMIT (count($orders) < N < count(fields)) TO LIMIT array_multisort()
863+ // TODO: LIMIT (count($orders) < N < count(fields_effective)) TO LIMIT array_multisort()
854864
855865 foreach ($orders as $fieldname => $order) {
856866 // One column set (one-dimensional array(), sort type, and order-by)
857867 $array = array();
858868 foreach ($this->rows as $row) {
859869 $array[] = isset($row[$fieldname]) ?
860- $this->fields[$fieldname]->get_value($row[$fieldname]) :
870+ $fields[$fieldname]->get_value($row[$fieldname]) :
861871 '';
862872 }
863873 $params[] = $array;
864- $params[] = $this->fields[$fieldname]->sort_type;
874+ $params[] = $fields[$fieldname]->sort_type;
865875 $params[] = $order;
866876 }
867877 $params[] = & $this->rows;
@@ -910,7 +920,7 @@ class Tracker_list
910920 function _replace_item($matches = array())
911921 {
912922 $fields = $this->fields;
913- $items = $this->items;
923+ $items = $this->_items;
914924 $escape = isset($this->_escape) ? (bool)$this->_escape : FALSE;
915925
916926 $params = isset($matches[1]) ? explode(',', $matches[1]) : array();
@@ -948,34 +958,36 @@ class Tracker_list
948958
949959 $fieldname = isset($matches[1]) ? $matches[1] : '';
950960 if (! isset($fields[$fieldname])) {
951- return isset($matches[0]) ? $matches[0] : ''; // Nothing to do
961+ // Invalid sortkey or user's own string or something. Nothing to do
962+ return isset($matches[0]) ? $matches[0] : '';
952963 }
953964
954- $sort = $fieldname;
955- if ($sort == '_name' || $sort == '_page') $sort = '_real';
965+ if ($fieldname == '_name' || $fieldname == '_page') {
966+ $sort = '_real';
967+ } else {
968+ $sort = $fieldname;
969+ }
956970
957971 $arrow = '';
958- $order = PLUGIN_TRACKER_LIST_SORT_ASC;
959- $_order = array();
960972 if (isset($orders[$sort])) {
961- // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
962- $order_keys = array_keys($orders); // with array_shift();
963-
973+ // Sorted
974+ $order_keys = array_keys($orders);
964975 $index = array_flip($order_keys);
965976 $pos = 1 + $index[$sort];
966- $b_end = ($sort == $order_keys[0]);
977+ $b_end = ($sort == isset($order_keys[0]) ? $order_keys[0] : '');
967978 $b_order = ($orders[$sort] === PLUGIN_TRACKER_LIST_SORT_ASC);
968979 $order = ($b_end xor $b_order)
969980 ? PLUGIN_TRACKER_LIST_SORT_ASC
970981 : PLUGIN_TRACKER_LIST_SORT_DESC;
971982 $arrow = '&br;' . ($b_order ? '&uarr;' : '&darr;') . '(' . $pos . ')';
972-
973983 unset($order_keys, $index);
974-
975- // $sort become the first
976- unset($orders[$sort]);
977- $_order[] = $sort . ':' . $this->_sortkey_define2string($order);
984+ unset($orders[$sort]); // $sort become the first if you click this
985+ } else {
986+ // Not sorted yet, but $sort become the first if you click this
987+ $order = PLUGIN_TRACKER_LIST_SORT_ASC;
978988 }
989+
990+ $_order = array($sort . ':' . $this->_sortkey_define2string($order));
979991 foreach ($orders as $key => $value) {
980992 $_order[] = $key . ':' . $this->_sortkey_define2string($value);
981993 }
@@ -991,7 +1003,7 @@ class Tracker_list
9911003 ']]';
9921004 }
9931005
994- // Output part of XHTML
1006+ // Output a part of Wiki text
9951007 function toString($limit = 0)
9961008 {
9971009 if (empty($this->rows)) {
@@ -999,8 +1011,8 @@ class Tracker_list
9991011 return FALSE;
10001012 }
10011013
1002- $source = array();
10031014 $rows = $this->rows;
1015+ $source = array();
10041016
10051017 $count = count($this->rows);
10061018 $limit = intval($limit);
@@ -1014,19 +1026,23 @@ class Tracker_list
10141026 $rows = array_slice($this->rows, 0, $limit);
10151027 }
10161028
1017- $body = array();
1029+ // Loading template
1030+ $header = $body = array();
10181031 foreach (plugin_tracker_get_source($this->config->page . '/' . $this->list) as $line) {
10191032 if (preg_match('/^\|(.+)\|[hfc]$/i', $line)) {
1020- // Table decolations
1021- $source[] = preg_replace_callback('/\[([^\[\]]+)\]/', array(& $this, '_replace_title'), $line);
1033+ // TODO: Why c and f here
1034+ $header[] = $line; // Table header, footer, and decoration
10221035 } else {
1023- $body[] = $line;
1036+ $body[] = $line; // The others
10241037 }
10251038 }
1039+
1040+ foreach($header as $line) {
1041+ $source[] = preg_replace_callback('/\[([^\[\]]+)\]/', array(& $this, '_replace_title'), $line);
1042+ }
10261043 foreach ($rows as $row) {
10271044 if (! PLUGIN_TRACKER_LIST_SHOW_ERROR_PAGE && ! $row['_match']) continue;
1028-
1029- $this->items = $row;
1045+ $this->_items = $row;
10301046 foreach ($body as $line) {
10311047 if (ltrim($line) != '') {
10321048 $this->_escape = ($line[0] == '|' || $line[0] == ':'); // The first letter
@@ -1036,7 +1052,7 @@ class Tracker_list
10361052 }
10371053 }
10381054
1039- return convert_html(implode('', $source));
1055+ return implode('', $source);
10401056 }
10411057 }
10421058