Revisão | 5b4382f0d3b67a4cddf582ac78a1de284e3d9b50 (tree) |
---|---|
Hora | 2007-09-22 20:04:47 |
Autor | henoheno <henoheno> |
Commiter | henoheno |
Tracker_list: Rough but works: Don't load unused fields
@@ -1,6 +1,6 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | -// $Id: tracker.inc.php,v 1.63 2007/09/22 08:24:41 henoheno Exp $ | |
3 | +// $Id: tracker.inc.php,v 1.64 2007/09/22 11:04:47 henoheno Exp $ | |
4 | 4 | // Copyright (C) 2003-2005, 2007 PukiWiki Developers Team |
5 | 5 | // License: GPL v2 or (at your option) any later version |
6 | 6 | // |
@@ -769,30 +769,39 @@ class Tracker_list | ||
769 | 769 | |
770 | 770 | $fieldname = array_shift($source); |
771 | 771 | if (isset($fields[$fieldname])) { |
772 | - $pattern[] = '(.*)'; // Just capture it | |
772 | + $pattern[] = '(.*?)'; // Just capture it | |
773 | 773 | $pattern_fields[] = $fieldname; // Capture it as this $filedname |
774 | 774 | } else { |
775 | - $pattern[] = '.*'; // Just ignore pseudo fields etc | |
775 | + $pattern[] = '.*?'; // Just ignore pseudo fields etc | |
776 | 776 | } |
777 | 777 | } |
778 | - $this->pattern = '/' . implode('', $pattern) . '/s'; | |
778 | + $this->pattern = '/' . implode('', $pattern) . '/sS'; | |
779 | 779 | $this->pattern_fields = $pattern_fields; |
780 | 780 | } |
781 | 781 | |
782 | 782 | // Load pages |
783 | 783 | function _load() |
784 | 784 | { |
785 | - $base = $this->base; | |
786 | - | |
787 | - $pattern = $base . '/'; | |
785 | + $pattern = $this->base . '/'; | |
788 | 786 | $pattern_len = strlen($pattern); |
787 | + | |
789 | 788 | foreach (get_existpages() as $_page) { |
790 | 789 | if (strpos($_page, $pattern) === 0) { |
791 | 790 | $name = substr($_page, $pattern_len); |
792 | 791 | if (preg_match(PLUGIN_TRACKER_LIST_EXCLUDE_PATTERN, $name)) continue; |
793 | - $this->add($_page, $name); | |
792 | + | |
793 | + // Adding $this->rows | |
794 | + if ($this->add($_page, $name) === FALSE) { | |
795 | + return FALSE; | |
796 | + } | |
794 | 797 | } |
795 | 798 | } |
799 | + if (empty($this->rows)) { | |
800 | + $this->error = 'Pages not found under: ' . $pattern; | |
801 | + return FALSE; | |
802 | + } | |
803 | + | |
804 | + return TRUE; | |
796 | 805 | } |
797 | 806 | |
798 | 807 | function add($page, $name) |
@@ -808,10 +817,10 @@ class Tracker_list | ||
808 | 817 | $to_page = strip_bracket(trim($matches[1])); |
809 | 818 | if (is_page($to_page)) { |
810 | 819 | unset($source); // Release |
811 | - $this->add($to_page, $name); // Recurse(Rescan) | |
812 | - return; | |
820 | + return $this->add($to_page, $name); // Recurse(Rescan) | |
813 | 821 | } else { |
814 | - return; // Invalid | |
822 | + $this->error = 'add(): Invalid pagename'; | |
823 | + return FALSE; | |
815 | 824 | } |
816 | 825 | } |
817 | 826 |
@@ -839,6 +848,7 @@ class Tracker_list | ||
839 | 848 | } |
840 | 849 | |
841 | 850 | $this->rows[$name] = $row; |
851 | + return TRUE; | |
842 | 852 | } |
843 | 853 | |
844 | 854 | // sort() |
@@ -1115,14 +1125,10 @@ class Tracker_list | ||
1115 | 1125 | $this->_generate_regex(); |
1116 | 1126 | |
1117 | 1127 | // Load $this->rows |
1118 | - $this->_load(); | |
1119 | - if (empty($this->rows)) { | |
1120 | - $this->error = 'Pages not found under: ' . $this->base . '/'; | |
1121 | - return FALSE; | |
1122 | - } | |
1128 | + if ($this->_load() === FALSE) return FALSE; | |
1123 | 1129 | |
1124 | 1130 | // Sort $this->rows |
1125 | - $this->_sort(); | |
1131 | + if ($this->_sort() === FALSE) return FALSE; | |
1126 | 1132 | $rows = $this->rows; |
1127 | 1133 | |
1128 | 1134 | $count = count($this->rows); |