]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/PageList.php
support listtype=dl and ranked search
[SourceForge/phpwiki.git] / lib / PageList.php
1 <?php rcs_id('$Id: PageList.php,v 1.143 2007-07-14 12:03:19 rurban Exp $');
2
3 /**
4  * List a number of pagenames, optionally as table with various columns.
5  * This library relieves some work for these plugins:
6  *
7  * AllPages, BackLinks, LikePages, MostPopular, TitleSearch, WikiAdmin* and more
8  *
9  * It also allows dynamic expansion of those plugins to include more
10  * columns in their output.
11  *
12  * Column 'info=' arguments:
13  *
14  * 'pagename' _("Page Name")
15  * 'mtime'    _("Last Modified")
16  * 'hits'     _("Hits")
17  * 'summary'  _("Last Summary")
18  * 'version'  _("Version")),
19  * 'author'   _("Last Author")),
20  * 'locked'   _("Locked"), _("locked")
21  * 'minor'    _("Minor Edit"), _("minor")
22  * 'markup'   _("Markup")
23  * 'size'     _("Size")
24  * 'creator'  _("Creator")
25  * 'owner'    _("Owner")
26  * 'checkbox'  selectable checkbox at the left.
27  * 'content'  
28  *
29  * Special, custom columns: Either theme or plugin (WikiAdmin*) specific.
30  * 'remove'   _("Remove")     
31  * 'perm'     _("Permission Mask")
32  * 'acl'      _("ACL")
33  * 'renamed_pagename'   _("Rename to")
34  * 'ratingwidget', ... wikilens theme specific.
35  * 'custom'   See plugin/_WikiTranslation
36  *
37  * Symbolic 'info=' arguments:
38  * 'all'       All columns except the special columns
39  * 'most'      pagename, mtime, author, size, hits, ...
40  * 'some'      pagename, mtime, author
41  *
42  * FIXME: In this refactoring I (Jeff) have un-implemented _ctime, _cauthor, and
43  * number-of-revision.  Note the _ctime and _cauthor as they were implemented
44  * were somewhat flawed: revision 1 of a page doesn't have to exist in the
45  * database.  If lots of revisions have been made to a page, it's more than likely
46  * that some older revisions (include revision 1) have been cleaned (deleted).
47  *
48  * DONE: 
49  *   paging support: limit, offset args
50  *   check PagePerm "list" access-type,
51  *   all columns are sortable. Thanks to the wikilens team.
52  *   cols > 1, comma, azhead, ordered (OL lists)
53  *   ->supportedArgs() which arguments are supported, so that the plugin 
54  *                     doesn't explictly need to declare it 
55  * TODO:
56  *   fix sortby logic, fix multiple sortby and other paging args per page.
57  *   info=relation,linkto nopage=1
58  *   use custom format method (RecentChanges, rss, ...)
59  *
60  * FIXED: 
61  *   fix memory exhaustion on large pagelists with old --memory-limit php's only. 
62  *   Status: improved 2004-06-25 16:19:36 rurban 
63  */
64 class _PageList_Column_base {
65     var $_tdattr = array();
66
67     function _PageList_Column_base ($default_heading, $align = false) {
68         $this->_heading = $default_heading;
69
70         if ($align) {
71             // align="char" isn't supported by any browsers yet :(
72             //if (is_array($align))
73             //    $this->_tdattr = $align;
74             //else
75             $this->_tdattr['align'] = $align;
76         }
77     }
78
79     function format ($pagelist, $page_handle, &$revision_handle) {
80         $nbsp = HTML::raw('&nbsp;');
81         return HTML::td($this->_tdattr,
82                         $nbsp,
83                         $this->_getValue($page_handle, $revision_handle),
84                         $nbsp);
85     }
86
87     function getHeading () {
88         return $this->_heading;
89     }
90
91     function setHeading ($heading) {
92         $this->_heading = $heading;
93     }
94
95     // old-style heading
96     function heading () {
97         global $request;
98         $nbsp = HTML::raw('&nbsp;');
99         // allow sorting?
100         if (1 /* or in_array($this->_field, PageList::sortable_columns())*/) {
101             // multiple comma-delimited sortby args: "+hits,+pagename"
102             // asc or desc: +pagename, -pagename
103             $sortby = PageList::sortby($this->_field, 'flip_order');
104             //Fixme: pass all also other GET args along. (limit, p[])
105             //TODO: support GET and POST
106             $s = HTML::a(array('href' => 
107                                $request->GetURLtoSelf(array('sortby' => $sortby)),
108                                'class' => 'pagetitle',
109                                'title' => sprintf(_("Sort by %s"), $this->_field)), 
110                          $nbsp, HTML::u($this->_heading), $nbsp);
111         } else {
112             $s = HTML($nbsp, HTML::u($this->_heading), $nbsp);
113         }
114         return HTML::th(array('align' => 'center'),$s);
115     }
116
117     // new grid-style sortable heading
118     // TODO: via activeui.js ? (fast dhtml sorting)
119     function button_heading (&$pagelist, $colNum) {
120         global $WikiTheme, $request;
121         // allow sorting?
122         $nbsp = HTML::raw('&nbsp;');
123         if (1 /* or in_array($this->_field, PageList::sortable_columns()) */) {
124             // TODO: add to multiple comma-delimited sortby args: "+hits,+pagename"
125             $src = false; 
126             $noimg_src = $WikiTheme->getButtonURL('no_order');
127             if ($noimg_src)
128                 $noimg = HTML::img(array('src'    => $noimg_src,
129                                          'width'  => '7', 
130                                          'height' => '7',
131                                          'border' => 0,
132                                          'alt'    => '.'));
133             else 
134                 $noimg = $nbsp;
135             if ($pagelist->sortby($colNum, 'check')) { // show icon? request or plugin arg
136                 $sortby = $pagelist->sortby($colNum, 'flip_order');
137                 $desc = (substr($sortby,0,1) == '-'); // +pagename or -pagename
138                 $src = $WikiTheme->getButtonURL($desc ? 'asc_order' : 'desc_order');
139                 $reverse = $desc ? _("reverse")." " : "";
140             } else {
141                 // initially unsorted
142                 $sortby = $pagelist->sortby($colNum, 'get');
143             }
144             if (!$src) {
145                 $img = $noimg;
146                 $reverse = "";
147                 $img->setAttr('alt', ".");
148             } else {
149                 $img = HTML::img(array('src' => $src, 
150                                        'width' => '7', 
151                                        'height' => '7', 
152                                        'border' => 0,
153                                        'alt' => _("Click to reverse sort order")));
154             }
155             $s = HTML::a(array('href' => 
156                                  //Fixme: pass all also other GET args along. (limit is ok, p[])
157                                  $request->GetURLtoSelf(array('sortby' => $sortby, 
158                                                               'id' => $pagelist->id)),
159                                'class' => 'gridbutton', 
160                                'title' => sprintf(_("Click to sort by %s"), $reverse . $this->_field)),
161                          $nbsp, $noimg,
162                          $nbsp, $this->_heading,
163                          $nbsp, $img,
164                          $nbsp);
165         } else {
166             $s = HTML($nbsp, $this->_heading, $nbsp);
167         }
168         return HTML::th(array('align' => 'center', 'valign' => 'middle', 
169                               'class' => 'gridbutton'), $s);
170     }
171
172     /**
173      * Take two columns of this type and compare them.
174      * An undefined value is defined to be < than the smallest defined value.
175      * This base class _compare only works if the value is simple (e.g., a number).
176      *
177      * @param  $colvala  $this->_getValue() of column a
178      * @param  $colvalb  $this->_getValue() of column b
179      *
180      * @return -1 if $a < $b, 1 if $a > $b, 0 otherwise.
181      */
182     function _compare($colvala, $colvalb) {
183         if (is_string($colvala))
184             return strcmp($colvala,$colvalb);
185         $ret = 0;
186         if (($colvala === $colvalb) || (!isset($colvala) && !isset($colvalb))) {
187             ;
188         } else {
189             $ret = (!isset($colvala) || ($colvala < $colvalb)) ? -1 : 1;
190         }
191         return $ret; 
192     }
193 };
194
195 class _PageList_Column extends _PageList_Column_base {
196     function _PageList_Column ($field, $default_heading, $align = false) {
197         $this->_PageList_Column_base($default_heading, $align);
198
199         $this->_need_rev = substr($field, 0, 4) == 'rev:';
200         $this->_iscustom = substr($field, 0, 7) == 'custom:';
201         if ($this->_iscustom) {
202             $this->_field = substr($field, 7);
203         }
204         elseif ($this->_need_rev)
205             $this->_field = substr($field, 4);
206         else
207             $this->_field = $field;
208     }
209
210     function _getValue ($page_handle, &$revision_handle) {
211         if ($this->_need_rev) {
212             if (!$revision_handle)
213                 // columns which need the %content should override this. (size, hi_content)
214                 $revision_handle = $page_handle->getCurrentRevision(false);
215             return $revision_handle->get($this->_field);
216         }
217         else {
218             return $page_handle->get($this->_field);
219         }
220     }
221     
222     function _getSortableValue ($page_handle, &$revision_handle) {
223         $val = $this->_getValue($page_handle, $revision_handle);
224         if ($this->_field == 'hits')
225             return (int) $val;
226         elseif (is_object($val))
227             return $val->asString();
228         else
229             return (string) $val;
230     }
231 };
232
233 /* overcome a call_user_func limitation by not being able to do:
234  * call_user_func_array(array(&$class, $class_name), $params);
235  * So we need $class = new $classname($params);
236  * And we add a 4th param to get at the parent $pagelist object
237  */
238 class _PageList_Column_custom extends _PageList_Column {
239     function _PageList_Column_custom($params) {
240         $this->_pagelist =& $params[3];
241         $this->_PageList_Column($params[0], $params[1], $params[2]);
242     }
243 }
244
245 class _PageList_Column_size extends _PageList_Column {
246     function format (&$pagelist, $page_handle, &$revision_handle) {
247         return HTML::td($this->_tdattr,
248                         HTML::raw('&nbsp;'),
249                         $this->_getValue($pagelist, $page_handle, $revision_handle),
250                         HTML::raw('&nbsp;'));
251     }
252     
253     function _getValue (&$pagelist, $page_handle, &$revision_handle) {
254         if (!$revision_handle or (!$revision_handle->_data['%content'] 
255                                   or $revision_handle->_data['%content'] === true)) {
256             $revision_handle = $page_handle->getCurrentRevision(true);
257             unset($revision_handle->_data['%pagedata']['_cached_html']);
258         }
259         $size = $this->_getSize($revision_handle);
260         // we can safely purge the content when it is not sortable
261         if (empty($pagelist->_sortby[$this->_field]))
262             unset($revision_handle->_data['%content']);
263         return $size;
264     }
265     
266     function _getSortableValue ($page_handle, &$revision_handle) {
267         if (!$revision_handle)
268             $revision_handle = $page_handle->getCurrentRevision(true);
269         return (empty($revision_handle->_data['%content'])) 
270                ? 0 : strlen($revision_handle->_data['%content']);
271     }
272
273     function _getSize($revision_handle) {
274         $bytes = @strlen($revision_handle->_data['%content']);
275         return ByteFormatter($bytes);
276     }
277 }
278
279
280 class _PageList_Column_bool extends _PageList_Column {
281     function _PageList_Column_bool ($field, $default_heading, $text = 'yes') {
282         $this->_PageList_Column($field, $default_heading, 'center');
283         $this->_textIfTrue = $text;
284         $this->_textIfFalse = new RawXml('&#8212;'); //mdash
285     }
286
287     function _getValue ($page_handle, &$revision_handle) {
288         //FIXME: check if $this is available in the parent (->need_rev)
289         $val = _PageList_Column::_getValue($page_handle, $revision_handle);
290         return $val ? $this->_textIfTrue : $this->_textIfFalse;
291     }
292 };
293
294 class _PageList_Column_checkbox extends _PageList_Column {
295     function _PageList_Column_checkbox ($field, $default_heading, $name='p') {
296         $this->_name = $name;
297         $heading = HTML::input(array('type'  => 'button',
298                                      'title' => _("Click to de-/select all pages"),
299                                      //'width' => '100%',
300                                      'name'  => $default_heading,
301                                      'value' => $default_heading,
302                                      'onclick' => "flipAll(this.form)"
303                                      ));
304         $this->_PageList_Column($field, $heading, 'center');
305     }
306     function _getValue ($pagelist, $page_handle, &$revision_handle) {
307         $pagename = $page_handle->getName();
308         $selected = !empty($pagelist->_selected[$pagename]);
309         if (strstr($pagename,'[') or strstr($pagename,']')) {
310             $pagename = str_replace(array('[',']'),array('%5B','%5D'),$pagename);
311         }
312         if ($selected) {
313             return HTML::input(array('type' => 'checkbox',
314                                      'name' => $this->_name . "[$pagename]",
315                                      'value' => 1,
316                                      'checked' => 'CHECKED'));
317         } else {
318             return HTML::input(array('type' => 'checkbox',
319                                      'name' => $this->_name . "[$pagename]",
320                                      'value' => 1));
321         }
322     }
323     function format ($pagelist, $page_handle, &$revision_handle) {
324         return HTML::td($this->_tdattr,
325                         HTML::raw('&nbsp;'),
326                         $this->_getValue($pagelist, $page_handle, $revision_handle),
327                         HTML::raw('&nbsp;'));
328     }
329     // don't sort this javascript button
330     function button_heading ($pagelist, $colNum) {
331         $s = HTML(HTML::raw('&nbsp;'), $this->_heading, HTML::raw('&nbsp;'));
332         return HTML::th(array('align' => 'center', 'valign' => 'middle', 
333                               'class' => 'gridbutton'), $s);
334     }
335 };
336
337 class _PageList_Column_time extends _PageList_Column {
338     function _PageList_Column_time ($field, $default_heading) {
339         $this->_PageList_Column($field, $default_heading, 'right');
340         global $WikiTheme;
341         $this->Theme = &$WikiTheme;
342     }
343
344     function _getValue ($page_handle, &$revision_handle) {
345         $time = _PageList_Column::_getValue($page_handle, $revision_handle);
346         return $this->Theme->formatDateTime($time);
347     }
348
349     function _getSortableValue ($page_handle, &$revision_handle) {
350         return _PageList_Column::_getValue($page_handle, $revision_handle);
351     }
352 };
353
354 class _PageList_Column_version extends _PageList_Column {
355     function _getValue ($page_handle, &$revision_handle) {
356         if (!$revision_handle)
357             $revision_handle = $page_handle->getCurrentRevision();
358         return $revision_handle->getVersion();
359     }
360 };
361
362 // Output is hardcoded to limit of first 50 bytes. Otherwise
363 // on very large Wikis this will fail if used with AllPages
364 // (PHP memory limit exceeded)
365 class _PageList_Column_content extends _PageList_Column {
366     function _PageList_Column_content ($field, $default_heading, $align = false, $search = false) {
367         $this->_PageList_Column($field, $default_heading, $align);
368         $this->bytes = 50;
369         $this->search = $search;
370         if ($field == 'content') {
371             $this->_heading .= sprintf(_(" ... first %d bytes"),
372                                        $this->bytes);
373         } elseif ($field == 'rev:hi_content') {
374             global $HTTP_POST_VARS;
375             if (!$this->search and !empty($HTTP_POST_VARS['admin_replace'])) {
376                 $this->search = $HTTP_POST_VARS['admin_replace']['from'];
377             }
378             $this->_heading .= sprintf(_(" ... around %s"),
379                                       '»'.$this->search.'«');
380         }
381     }
382     
383     function _getValue ($page_handle, &$revision_handle) {
384         if (!$revision_handle or (!$revision_handle->_data['%content'] 
385                                   or $revision_handle->_data['%content'] === true)) {
386             $revision_handle = $page_handle->getCurrentRevision(true);
387         }
388         // Not sure why implode is needed here, I thought
389         // getContent() already did this, but it seems necessary.
390         $c = implode("\n", $revision_handle->getContent());
391         if (empty($pagelist->_sortby[$this->_field]))
392             unset($revision_handle->_data['%content']);
393         if ($this->_field == 'hi_content') {
394             if (!empty($revision_handle->_data['%pagedata']))
395                 unset($revision_handle->_data['%pagedata']['_cached_html']);
396             $search = $this->search;
397             $score = '';
398             if (!empty($page_handle->score))
399                 $score = $page_handle->score;
400             elseif (!empty($page_handle['score']))
401                 $score = $page_handle['score'];
402             if ($search and ($i = strpos(strtolower($c), strtolower($search)))) {
403                 $l = strlen($search);
404                 $j = max(0, $i - ($this->bytes / 2));
405                 return HTML::div(array('style' => 'font-size:x-small'),
406                                  HTML::div(array('class' => 'transclusion'),
407                                            HTML::span("...".substr($c, $j, ($this->bytes / 2))),
408                                            HTML::span(array("style"=>"background:yellow"),substr($c, $i, $l)),
409                                            HTML::span(substr($c, $i+$l, ($this->bytes / 2))."..."." ".($score ? sprintf("[%0.1f]",$score):""))));
410             } else {
411                 if (strpos($c," "))
412                     $c = "";
413                 else    
414                     $c = sprintf(_("%s not found"), '»'.$search.'«');
415                 return HTML::div(array('style' => 'font-size:x-small','align'=>'center'),
416                                  $c." ".($score ? sprintf("[%0.1f]",$score):""));
417             }
418         } elseif (($len = strlen($c)) > $this->bytes) {
419             $c = substr($c, 0, $this->bytes);
420         }
421         include_once('lib/BlockParser.php');
422         // false --> don't bother processing hrefs for embedded WikiLinks
423         $ct = TransformText($c, $revision_handle->get('markup'), false);
424         if (empty($pagelist->_sortby[$this->_field]))
425             unset($revision_handle->_data['%pagedata']['_cached_html']);
426         return HTML::div(array('style' => 'font-size:x-small'),
427                          HTML::div(array('class' => 'transclusion'), $ct),
428                          // Don't show bytes here if size column present too
429                          ($this->parent->_columns_seen['size'] or !$len) ? "" :
430                            ByteFormatter($len, /*$longformat = */true));
431     }
432     function _getSortableValue ($page_handle, &$revision_handle) {
433         if (!empty($page_handle->score))
434             return $page_handle->score;
435         elseif (!empty($page_handle['score']))
436             return $page_handle['score'];
437         else
438             return substr(_PageList_Column::_getValue($page_handle, $revision_handle),0,50);
439     }
440 };
441
442 class _PageList_Column_author extends _PageList_Column {
443     function _PageList_Column_author ($field, $default_heading, $align = false) {
444         _PageList_Column::_PageList_Column($field, $default_heading, $align);
445         $this->dbi =& $GLOBALS['request']->getDbh();
446     }
447
448     function _getValue ($page_handle, &$revision_handle) {
449         $author = _PageList_Column::_getValue($page_handle, $revision_handle);
450         if ($this->dbi->isWikiPage($author))
451             return WikiLink($author);
452         else
453             return $author;
454     }
455     
456     function _getSortableValue ($page_handle, &$revision_handle) {
457         return _PageList_Column::_getValue($page_handle, $revision_handle);
458     }
459 };
460
461 class _PageList_Column_owner extends _PageList_Column_author {
462     function _getValue ($page_handle, &$revision_handle) {
463         $author = $page_handle->getOwner();
464         if ($this->dbi->isWikiPage($author))
465             return WikiLink($author);
466         else
467             return $author;
468     }
469     function _getSortableValue ($page_handle, &$revision_handle) {
470         return _PageList_Column::_getValue($page_handle, $revision_handle);
471     }
472 };
473
474 class _PageList_Column_creator extends _PageList_Column_author {
475     function _getValue ($page_handle, &$revision_handle) {
476         $author = $page_handle->getCreator();
477         if ($this->dbi->isWikiPage($author))
478             return WikiLink($author);
479         else
480             return $author;
481     }
482     function _getSortableValue ($page_handle, &$revision_handle) {
483         return _PageList_Column::_getValue($page_handle, $revision_handle);
484     }
485 };
486
487 class _PageList_Column_pagename extends _PageList_Column_base {
488     var $_field = 'pagename';
489
490     function _PageList_Column_pagename () {
491         $this->_PageList_Column_base(_("Page Name"));
492         global $request;
493         $this->dbi = &$request->getDbh();
494     }
495
496     function _getValue ($page_handle, &$revision_handle) {
497         if ($this->dbi->isWikiPage($page_handle->getName()))
498             return WikiLink($page_handle, 'known');
499         else
500             return WikiLink($page_handle, 'unknown');
501     }
502
503     function _getSortableValue ($page_handle, &$revision_handle) {
504         return $page_handle->getName();
505     }
506
507     /**
508      * Compare two pagenames for sorting.  See _PageList_Column::_compare.
509      **/
510     function _compare($colvala, $colvalb) {
511         return strcmp($colvala, $colvalb);
512     }
513 };
514
515 class PageList {
516     var $_group_rows = 3;
517     var $_columns = array();
518     var $_columnsMap = array();      // Maps column name to column number.
519     var $_excluded_pages = array();
520     var $_pages = array();
521     var $_caption = "";
522     var $_pagename_seen = false;
523     var $_types = array();
524     var $_options = array();
525     var $_selected = array();
526     var $_sortby = array();
527     var $_maxlen = 0;
528
529     function PageList ($columns = false, $exclude = false, $options = false) {
530         // unique id per pagelist on each page.
531         if (!isset($GLOBALS['request']->_pagelist))
532             $GLOBALS['request']->_pagelist = 0;
533         else 
534             $GLOBALS['request']->_pagelist++;    
535         $this->id = $GLOBALS['request']->_pagelist;
536         if ($options)
537             $this->_options = $options;
538
539         $this->_initAvailableColumns();
540         // let plugins predefine only certain objects, such its own custom pagelist columns
541         $symbolic_columns = 
542             array(
543                   'all' =>  array_diff(array_keys($this->_types), // all but...
544                                        array('checkbox','remove','renamed_pagename',
545                                              'content','hi_content','perm','acl')),
546                   'most' => array('pagename','mtime','author','hits'),
547                   'some' => array('pagename','mtime','author')
548                   );
549         if ($this->_options['listtype'] == 'dl')
550             $this->_options['nopage'] = 1;
551         if ($columns) {
552             if (!is_array($columns))
553                 $columns = explode(',', $columns);
554             // expand symbolic columns:
555             foreach ($symbolic_columns as $symbol => $cols) {
556                 if (in_array($symbol,$columns)) { // e.g. 'checkbox,all'
557                     $columns = array_diff(array_merge($columns,$cols),array($symbol));
558                 }
559             }
560             unset($cols);
561             if (empty($this->_options['nopage']) and !in_array('pagename',$columns))
562                 $this->_addColumn('pagename');
563             foreach ($columns as $col) {
564                 if (!empty($col))
565                     $this->_addColumn($col);
566             }
567             unset($col);
568         }
569         // If 'pagename' is already present, _addColumn() will not add it again
570         if (empty($this->_options['nopage']))
571             $this->_addColumn('pagename');
572
573         if (!empty($this->_options['types'])) {
574             foreach ($this->_options['types'] as $type) {
575                 $this->_types[$type->_field] = $type;
576                 $this->_addColumn($type->_field);
577             }
578             unset($this->_options['types']);
579         }
580
581         global $request;
582         // explicit header options: ?id=x&sortby=... override options[]
583         // support multiple sorts. check multiple, no nested elseif
584         if (($this->id == $request->getArg("id")) 
585              and $request->getArg('sortby')) 
586         {
587             // add it to the front of the sortby array
588             $this->sortby($request->getArg('sortby'), 'init');
589             $this->_options['sortby'] = $request->getArg('sortby');
590         } // plugin options
591         if (!empty($options['sortby'])) {
592             if (empty($this->_options['sortby']))
593                 $this->_options['sortby'] = $options['sortby'];
594             $this->sortby($options['sortby'], 'init');
595         } // global options 
596         if (!isset($request->args["id"]) and $request->getArg('sortby') 
597              and empty($this->_options['sortby'])) 
598         {
599             $this->_options['sortby'] = $request->getArg('sortby');
600             $this->sortby($this->_options['sortby'], 'init');
601         }
602         // same as above but without the special sortby push, and mutually exclusive (elseif)
603         foreach ($this->pagingArgs() as $key) {
604             if ($key == 'sortby') continue;     
605             if (($this->id == $request->getArg("id")) 
606                 and $request->getArg($key)) 
607             {
608                 $this->_options[$key] = $request->getArg($key);
609             } // plugin options
610             elseif (!empty($options) and !empty($options[$key])) {
611                 $this->_options[$key] = $options[$key];
612             } // global options 
613             elseif (!isset($request->args["id"]) and $request->getArg($key)) {
614                 $this->_options[$key] = $request->getArg($key);
615             }
616         }
617         if ($exclude) {
618             if (is_string($exclude) and !is_array($exclude))
619                 $exclude = $this->explodePageList($exclude, false,
620                                                   $this->_options['sortby'],
621                                                   $this->_options['limit']);
622             $this->_excluded_pages = $exclude;
623         }
624         $this->_messageIfEmpty = _("<no matches>");
625     }
626
627     // Currently PageList takes these arguments:
628     // 1: info, 2: exclude, 3: hash of options
629     // Here we declare which options are supported, so that 
630     // the calling plugin may simply merge this with its own default arguments 
631     function supportedArgs () {
632         return array(// Currently supported options:
633                      /* what columns, what pages */
634                      'info'     => 'pagename',
635                      'exclude'  => '',          // also wildcards, comma-seperated lists 
636                                                 // and <!plugin-list !> arrays
637                      /* select pages by meta-data: */
638                      'author'   => false, // current user by []
639                      'owner'    => false, // current user by []
640                      'creator'  => false, // current user by []
641
642                      /* for the sort buttons in <th> */
643                      'sortby'   => '', // same as for WikiDB::getAllPages 
644                                        // (unsorted is faster)
645
646                      /* PageList pager options:
647                       * These options may also be given to _generate(List|Table) later
648                       * But limit and offset might help the query WikiDB::getAllPages()
649                       */
650                      'limit'    => 50,       // number of rows (pagesize)
651                      'paging'   => 'auto',  // 'auto'   top + bottom rows if applicable
652                      //                     // 'top'    top only if applicable
653                      //                     // 'bottom' bottom only if applicable
654                      //                     // 'none'   don't page at all 
655                      // (TODO: clarify what if $paging==false ?)
656
657                      /* list-style options (with single pagename column only so far) */
658                      'cols'     => 1,       // side-by-side display of list (1-3)
659                      'azhead'   => 0,       // 1: group by initials
660                                             // 2: provide shortcut links to initials also
661                      'comma'    => 0,       // condensed comma-seperated list, 
662                                             // 1 if without links, 2 if with
663                      'commasep' => false,   // Default: ', '
664                      'listtype' => '',      // ul (default), ol, dl, comma
665                      'ordered'  => false,   // OL or just UL lists (ignored for comma)
666                      'linkmore' => '',      // If count>0 and limit>0 display a link with 
667                      // the number of all results, linked to the given pagename.
668                      
669                      'nopage'   => false,   // for info=col omit the pagename column
670                      );
671     }
672     
673     function pagingArgs() {
674         return array('sortby','limit','paging','count','dosort');
675     }
676
677     function setCaption ($caption_string) {
678         $this->_caption = $caption_string;
679     }
680
681     function addCaption ($caption_string) {
682         $this->_caption = HTML($this->_caption," ",$caption_string);
683     }
684
685     function getCaption () {
686         // put the total into the caption if needed
687         if (is_string($this->_caption) && strstr($this->_caption, '%d'))
688             return sprintf($this->_caption, $this->getTotal());
689         return $this->_caption;
690     }
691
692     function setMessageIfEmpty ($msg) {
693         $this->_messageIfEmpty = $msg;
694     }
695
696
697     function getTotal () {
698         return !empty($this->_options['count'])
699                ? (integer) $this->_options['count'] : count($this->_pages);
700     }
701
702     function isEmpty () {
703         return empty($this->_pages);
704     }
705
706     function addPage($page_handle) {
707         if (!empty($this->_excluded_pages)) {
708             if (!in_array((is_string($page_handle) ? $page_handle : $page_handle->getName()),
709                           $this->_excluded_pages))
710                 $this->_pages[] = $page_handle;
711         } else {
712             $this->_pages[] = $page_handle;
713         }
714     }
715
716     function pageNames() {
717         $pages = array();
718         $limit = @$this->_options['limit'];
719         foreach ($this->_pages as $page_handle) {
720             $pages[] = $page_handle->getName();
721             if ($limit and count($pages) > $limit)
722                 break;
723         }
724         return $pages;
725     }
726
727     function _getPageFromHandle($page_handle) {
728         if (is_string($page_handle)) {
729             if (empty($page_handle)) return $page_handle;
730             //$dbi = $GLOBALS['request']->getDbh(); // no, safe some memory!
731             $page_handle = $GLOBALS['request']->_dbi->getPage($page_handle);
732         }
733         return $page_handle;
734     }
735
736     /**
737      * Take a PageList_Page object, and return an HTML object to display
738      * it in a table or list row.
739      */
740     function _renderPageRow (&$page_handle, $i = 0) {
741         $page_handle = $this->_getPageFromHandle($page_handle);
742         //FIXME. only on sf.net
743         if (!is_object($page_handle)) {
744             trigger_error("PageList: Invalid page_handle $page_handle", E_USER_WARNING);
745             return;
746         }
747         if (!isset($page_handle)
748             or empty($page_handle)
749             or (!empty($this->_excluded_pages)
750                 and in_array($page_handle->getName(), $this->_excluded_pages)))
751             return; // exclude page.
752             
753         // enforce view permission
754         if (!mayAccessPage('view', $page_handle->getName()))
755             return;
756
757         $group = (int)($i / $this->_group_rows);
758         $class = ($group % 2) ? 'oddrow' : 'evenrow';
759         $revision_handle = false;
760         $this->_maxlen = max($this->_maxlen, strlen($page_handle->getName()));
761
762         if (count($this->_columns) > 1) {
763             $row = HTML::tr(array('class' => $class));
764             $j = 0;
765             foreach ($this->_columns as $col) {
766                 $col->current_row = $i;
767                 $col->current_column = $j;
768                 $row->pushContent($col->format($this, $page_handle, $revision_handle));
769                 $j++;
770             }
771         } else {
772             $col = $this->_columns[0];
773             $col->current_row = $i;
774             $col->current_column = 0;
775             $row = $col->_getValue($page_handle, $revision_handle);
776         }
777
778         return $row;
779     }
780
781     function addPages ($page_iter) {
782         //Todo: if limit check max(strlen(pagename))
783         while ($page = $page_iter->next()) {
784             $this->addPage($page);
785         }
786     }
787
788     function addPageList (&$list) {
789         if (empty($list)) return;  // Protect reset from a null arg
790         foreach ($list as $page) {
791             if (is_object($page))
792                 $page = $page->_pagename;
793             $this->addPage((string)$page);
794         }
795     }
796
797     function maxLen() {
798         global $request;
799         $dbi =& $request->getDbh();
800         if (isa($dbi,'WikiDB_SQL')) {
801             extract($dbi->_backend->_table_names);
802             $res = $dbi->_backend->_dbh->getOne("SELECT max(length(pagename)) FROM $page_tbl");
803             if (DB::isError($res) || empty($res)) return false;
804             else return $res;
805         } elseif (isa($dbi,'WikiDB_ADODB')) {
806             extract($dbi->_backend->_table_names);
807             $row = $dbi->_backend->_dbh->getRow("SELECT max(length(pagename)) FROM $page_tbl");
808             return $row ? $row[0] : false;
809         } else 
810             return false;
811     }
812
813     function getContent() {
814         // Note that the <caption> element wants inline content.
815         $caption = $this->getCaption();
816
817         if ($this->isEmpty())
818             return $this->_emptyList($caption);
819         elseif (in_array($this->_options['listtype'], array('ol','ul','comma','dl')))
820             return $this->_generateList($caption);
821         elseif (count($this->_columns) == 1)
822             return $this->_generateList($caption);
823         else
824             return $this->_generateTable($caption);
825     }
826
827     function printXML() {
828         PrintXML($this->getContent());
829     }
830
831     function asXML() {
832         return AsXML($this->getContent());
833     }
834     
835     /** 
836      * Handle sortby requests for the DB iterator and table header links.
837      * Prefix the column with + or - like "+pagename","-mtime", ...
838      *
839      * Supported actions: 
840      *   'init'       :   unify with predefined order. "pagename" => "+pagename"
841      *   'flip_order' :   "mtime" => "+mtime" => "-mtime" ...
842      *   'db'         :   "-pagename" => "pagename DESC"
843      *   'check'      :   
844      *
845      * Now all columns are sortable. (patch by DanFr)
846      * Some columns have native DB backend methods, some not.
847      */
848     function sortby ($column, $action, $valid_fields=false) {
849         global $request;
850
851         if (empty($column)) return '';
852         if (is_int($column)) {
853             $column = $this->_columns[$column - 1]->_field;
854             //$column = $col->_field;
855         }
856         //if (!is_string($column)) return '';
857         // support multiple comma-delimited sortby args: "+hits,+pagename"
858         // recursive concat
859         if (strstr($column, ',')) {
860             $result = ($action == 'check') ? true : array();
861             foreach (explode(',', $column) as $col) {
862                 if ($action == 'check')
863                     $result = $result && $this->sortby($col, $action, $valid_fields);
864                 else
865                     $result[] = $this->sortby($col, $action, $valid_fields);
866             }
867             // 'check' returns true/false for every col. return true if all are true. 
868             // i.e. the unsupported 'every' operator in functional languages.
869             if ($action == 'check')
870                 return $result;
871             else
872                 return join(",", $result);
873         }
874         if (substr($column,0,1) == '+') {
875             $order = '+'; $column = substr($column,1);
876         } elseif (substr($column,0,1) == '-') {
877             $order = '-'; $column = substr($column,1);
878         }
879         // default initial order: +pagename, -mtime, -hits
880         if (empty($order)) {
881             if (!empty($this->_sortby[$column]))
882                 $order = $this->_sortby[$column];
883             else {
884                 if (in_array($column, array('mtime','hits')))
885                     $order = '-';
886                 else
887                     $order = '+';
888             }
889         }
890         if ($action == 'get') {
891             return $order . $column;
892         } elseif ($action == 'flip_order') {
893             if (0 and DEBUG)
894                 trigger_error("flip $order $column ".$this->id,  E_USER_NOTICE); 
895             return ($order == '+' ? '-' : '+') . $column;
896         } elseif ($action == 'init') { // only allowed from PageList::PageList
897             if ($this->sortby($column, 'clicked')) {
898                 if (0 and DEBUG)
899                     trigger_error("clicked $order $column $this->id",  E_USER_NOTICE); 
900                 //$order = ($order == '+' ? '-' : '+'); // $this->sortby($sortby, 'flip_order');
901             }
902             $this->_sortby[$column] = $order; // forces show icon
903             return $order . $column;
904         } elseif ($action == 'check') {   // show icon?
905             //if specified via arg or if clicked
906             $show = (!empty($this->_sortby[$column]) or $this->sortby($column, 'clicked'));
907             if (0 and $show and DEBUG) {
908                 trigger_error("show $order $column ".$this->id, E_USER_NOTICE);
909             }
910             return $show;            
911         } elseif ($action == 'clicked') { // flip sort order?
912             global $request;
913             $arg = $request->getArg('sortby');
914             return ($arg
915                     and strstr($arg, $column)
916                     and (!isset($request->args['id']) 
917                          or $this->id == $request->getArg('id')));
918         } elseif ($action == 'db') {
919             // Performance enhancement: use native DB sort if possible.
920             if (($valid_fields and in_array($column, $valid_fields))
921                 or (method_exists($request->_dbi->_backend, 'sortable_columns')
922                     and (in_array($column, $request->_dbi->_backend->sortable_columns())))) {
923                 // omit this sort method from the _sortPages call at rendering
924                 // asc or desc: +pagename, -pagename
925                 return $column . ($order == '+' ? ' ASC' : ' DESC');
926             } else {
927                 return '';
928             }
929         }
930         return '';
931     }
932
933     // echo implode(":",explodeList("Test*",array("xx","Test1","Test2")));
934     function explodePageList($input, $include_empty=false, $sortby='', 
935                              $limit='', $exclude='') 
936     {
937         if (empty($input)) return array();
938         // expand wildcards from list of all pages
939         if (preg_match('/[\?\*]/', $input)) {
940             include_once("lib/TextSearchQuery.php");
941             $search = new TextSearchQuery(str_replace(",", " ", $input), true, 'glob'); 
942             $dbi = $GLOBALS['request']->getDbh();
943             $iter = $dbi->titleSearch($search, $sortby, $limit, $exclude);
944             $pages = array();
945             while ($pagehandle = $iter->next()) {
946                 $pages[] = $pagehandle->getName();
947             }
948             return $pages;
949             /*
950             //TODO: need an SQL optimization here
951             $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, 
952                                                 $exclude);
953             while ($pagehandle = $allPagehandles->next()) {
954                 $allPages[] = $pagehandle->getName();
955             }
956             return explodeList($input, $allPages);
957             */
958         } else {
959             //TODO: do the sorting, normally not needed if used for exclude only
960             return explode(',', $input);
961         }
962     }
963
964     // TODO: optimize getTotal => store in count
965     function allPagesByAuthor($wildcard, $include_empty=false, $sortby='', 
966                               $limit='', $exclude='') 
967     {
968         $dbi = $GLOBALS['request']->getDbh();
969         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude);
970         $allPages = array();
971         if ($wildcard === '[]') {
972             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
973             if (!$wildcard) return $allPages;
974         }
975         $do_glob = preg_match('/[\?\*]/', $wildcard);
976         while ($pagehandle = $allPagehandles->next()) {
977             $name = $pagehandle->getName();
978             $author = $pagehandle->getAuthor();
979             if ($author) {
980                 if ($do_glob) {
981                     if (glob_match($wildcard, $author))
982                         $allPages[] = $name;
983                 } elseif ($wildcard == $author) {
984                       $allPages[] = $name;
985                 }
986             }
987             // TODO: purge versiondata_cache
988         }
989         return $allPages;
990     }
991
992     function allPagesByOwner($wildcard, $include_empty=false, $sortby='', 
993                              $limit='', $exclude='') {
994         $dbi = $GLOBALS['request']->getDbh();
995         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude);
996         $allPages = array();
997         if ($wildcard === '[]') {
998             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
999             if (!$wildcard) return $allPages;
1000         }
1001         $do_glob = preg_match('/[\?\*]/', $wildcard);
1002         while ($pagehandle = $allPagehandles->next()) {
1003             $name = $pagehandle->getName();
1004             $owner = $pagehandle->getOwner();
1005             if ($owner) {
1006                 if ($do_glob) {
1007                     if (glob_match($wildcard, $owner))
1008                         $allPages[] = $name;
1009                 } elseif ($wildcard == $owner) {
1010                       $allPages[] = $name;
1011                 }
1012             }
1013         }
1014         return $allPages;
1015     }
1016
1017     function allPagesByCreator($wildcard, $include_empty=false, $sortby='', 
1018                                $limit='', $exclude='') {
1019         $dbi = $GLOBALS['request']->getDbh();
1020         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude);
1021         $allPages = array();
1022         if ($wildcard === '[]') {
1023             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
1024             if (!$wildcard) return $allPages;
1025         }
1026         $do_glob = preg_match('/[\?\*]/', $wildcard);
1027         while ($pagehandle = $allPagehandles->next()) {
1028             $name = $pagehandle->getName();
1029             $creator = $pagehandle->getCreator();
1030             if ($creator) {
1031                 if ($do_glob) {
1032                     if (glob_match($wildcard, $creator))
1033                         $allPages[] = $name;
1034                 } elseif ($wildcard == $creator) {
1035                       $allPages[] = $name;
1036                 }
1037             }
1038         }
1039         return $allPages;
1040     }
1041
1042     ////////////////////
1043     // private
1044     ////////////////////
1045     /** Plugin and theme hooks: 
1046      *  If the pageList is initialized with $options['types'] these types are also initialized, 
1047      *  overriding the standard types.
1048      */
1049     function _initAvailableColumns() {
1050         global $customPageListColumns;
1051         $standard_types =
1052             array(
1053                   'content'
1054                   => new _PageList_Column_content('rev:content', _("Content")),
1055                   // new: plugin specific column types initialised by the relevant plugins
1056                   /*
1057                   'hi_content' // with highlighted search for SearchReplace
1058                   => new _PageList_Column_content('rev:hi_content', _("Content")),
1059                   'remove'
1060                   => new _PageList_Column_remove('remove', _("Remove")),
1061                   // initialised by the plugin
1062                   'renamed_pagename'
1063                   => new _PageList_Column_renamed_pagename('rename', _("Rename to")),
1064                   'perm'
1065                   => new _PageList_Column_perm('perm', _("Permission")),
1066                   'acl'
1067                   => new _PageList_Column_acl('acl', _("ACL")),
1068                   */
1069                   'checkbox'
1070                   => new _PageList_Column_checkbox('p', _("Select")),
1071                   'pagename'
1072                   => new _PageList_Column_pagename,
1073                   'mtime'
1074                   => new _PageList_Column_time('rev:mtime', _("Last Modified")),
1075                   'hits'
1076                   => new _PageList_Column('hits', _("Hits"), 'right'),
1077                   'size'
1078                   => new _PageList_Column_size('rev:size', _("Size"), 'right'),
1079                                               /*array('align' => 'char', 'char' => ' ')*/
1080                   'summary'
1081                   => new _PageList_Column('rev:summary', _("Last Summary")),
1082                   'version'
1083                   => new _PageList_Column_version('rev:version', _("Version"),
1084                                                  'right'),
1085                   'author'
1086                   => new _PageList_Column_author('rev:author', _("Last Author")),
1087                   'owner'
1088                   => new _PageList_Column_owner('author_id', _("Owner")),
1089                   'creator'
1090                   => new _PageList_Column_creator('author_id', _("Creator")),
1091                   /*
1092                   'group'
1093                   => new _PageList_Column_author('group', _("Group")),
1094                   */
1095                   'locked'
1096                   => new _PageList_Column_bool('locked', _("Locked"),
1097                                                _("locked")),
1098                   'minor'
1099                   => new _PageList_Column_bool('rev:is_minor_edit',
1100                                                _("Minor Edit"), _("minor")),
1101                   'markup'
1102                   => new _PageList_Column('rev:markup', _("Markup")),
1103                   // 'rating' initialised by the wikilens theme hook: addPageListColumn
1104                   /*
1105                   'rating'
1106                   => new _PageList_Column_rating('rating', _("Rate")),
1107                   */
1108                   );
1109         if (empty($this->_types))
1110             $this->_types = array();
1111         // add plugin specific pageList columns, initialized by $options['types']
1112         $this->_types = array_merge($standard_types, $this->_types);
1113         // add theme custom specific pageList columns: 
1114         //   set the 4th param as the current pagelist object.
1115         if (!empty($customPageListColumns)) {
1116             foreach ($customPageListColumns as $column => $params) {
1117                 $class_name = array_shift($params);
1118                 $params[3] =& $this;
1119                 $class = new $class_name($params);
1120                 $this->_types[$column] =& $class;
1121             }
1122         }
1123     }
1124
1125     function getOption($option) {
1126         if (array_key_exists($option, $this->_options)) {
1127             return $this->_options[$option];
1128         }
1129         else {
1130             return null;
1131         }
1132     }
1133
1134     /**
1135      * Add a column to this PageList, given a column name.
1136      * The name is a type, and optionally has a : and a label. Examples:
1137      *
1138      *   pagename
1139      *   pagename:This page
1140      *   mtime
1141      *   mtime:Last modified
1142      *
1143      * If this function is called multiple times for the same type, the
1144      * column will only be added the first time, and ignored the succeeding times.
1145      * If you wish to add multiple columns of the same type, use addColumnObject().
1146      *
1147      * @param column name
1148      * @return  true if column is added, false otherwise
1149      */
1150     function _addColumn ($column) {
1151         
1152         if (isset($this->_columns_seen[$column]))
1153             return false;       // Already have this one.
1154         if (!isset($this->_types[$column]))
1155             $this->_initAvailableColumns();
1156         $this->_columns_seen[$column] = true;
1157
1158         if (strstr($column, ':'))
1159             list ($column, $heading) = explode(':', $column, 2);
1160
1161         // FIXME: these column types have hooks (objects) elsewhere
1162         // Omitting this warning should be overridable by the extension
1163         if (!isset($this->_types[$column])) {
1164             $silently_ignore = array('numbacklinks',
1165                                      'rating',/*'ratingwidget',*/
1166                                      'coagreement', 'minmisery',
1167                                      /*'prediction',*/
1168                                      'averagerating', 'top3recs', 
1169                                      'relation', 'linkto');
1170             if (!in_array($column, $silently_ignore))
1171                 trigger_error(sprintf("%s: Bad column", $column), E_USER_NOTICE);
1172             return false;
1173         }
1174         // FIXME: anon users might rate and see ratings also. 
1175         // Defer this logic to the plugin.
1176         if ($column == 'rating' and !$GLOBALS['request']->_user->isSignedIn())
1177             return false;
1178
1179         $this->addColumnObject($this->_types[$column]);
1180
1181         return true;
1182     }
1183
1184     /**
1185      * Add a column to this PageList, given a column object.
1186      *
1187      * @param $col object   An object derived from _PageList_Column.
1188      **/
1189     function addColumnObject($col) {
1190         if (is_array($col)) {// custom column object
1191             $params =& $col;
1192             $class_name = array_shift($params);
1193             $params[3] =& $this;
1194             $col = new $class_name($params);
1195         }
1196         $heading = $col->getHeading();
1197         if (!empty($heading))
1198             $col->setHeading($heading);
1199
1200         $this->_columns[] = $col;
1201         $this->_columnsMap[$col->_field] = count($this->_columns); // start with 1
1202     }
1203
1204     /**
1205      * Compare _PageList_Page objects.
1206      **/
1207     function _pageCompare(&$a, &$b) {
1208         if (empty($this->_sortby) or count($this->_sortby) == 0) {
1209             // No columns to sort by
1210             return 0;
1211         }
1212         else {
1213             $pagea = $this->_getPageFromHandle($a);  // If a string, convert to page
1214             assert(isa($pagea, 'WikiDB_Page'));
1215             $pageb = $this->_getPageFromHandle($b);  // If a string, convert to page
1216             assert(isa($pageb, 'WikiDB_Page'));
1217             foreach ($this->_sortby as $colNum => $direction) {
1218                 // get column type object
1219                 if (!is_int($colNum)) { // or column fieldname
1220                     if ($temp = $this->_columnsMap[$colNum])
1221                         $col = $this->_columns[$temp - 1];
1222                     elseif (isset($this->_types[$colNum]))
1223                         $col = $this->_types[$colNum];
1224                 }
1225
1226                 assert(isset($col));
1227                 $revision_handle = false;
1228                 $aval = $col->_getSortableValue($pagea, $revision_handle);
1229                 $revision_handle = false;
1230                 $bval = $col->_getSortableValue($pageb, $revision_handle);
1231
1232                 $cmp = $col->_compare($aval, $bval);
1233                 if ($direction === "-")  // Reverse the sense of the comparison
1234                     $cmp *= -1;
1235
1236                 if ($cmp !== 0)
1237                     // This is the first comparison that is not equal-- go with it
1238                     return $cmp;
1239             }
1240             return 0;
1241         }
1242     }
1243
1244     /**
1245      * Put pages in order according to the sortby arg, if given
1246      * If the sortby cols are already sorted by the DB call, don't do usort.
1247      * TODO: optimize for multiple sortable cols
1248      */
1249     function _sortPages() {
1250         if (count($this->_sortby) > 0) {
1251             $need_sort = $this->_options['dosort'];
1252             if (!$need_sort)
1253               foreach ($this->_sortby as $col => $dir) {
1254                 if (! $this->sortby($col, 'db'))
1255                     $need_sort = true;
1256               }
1257             if ($need_sort) { // There are some columns to sort by
1258                 // TODO: consider nopage
1259                 usort($this->_pages, array($this, '_pageCompare'));
1260             }
1261         }
1262         //unset($GLOBALS['PhpWiki_pagelist']);
1263     }
1264
1265     function limit($limit) {
1266         if (is_array($limit)) return $limit;
1267         if (strstr($limit, ','))
1268             return split(',', $limit);
1269         else
1270             return array(0, $limit);
1271     }
1272
1273     function pagingTokens($numrows = false, $ncolumns = false, $limit = false) {
1274         if ($numrows === false)
1275             $numrows = $this->getTotal();
1276         if ($limit === false)
1277             $limit = $this->_options['limit'];
1278         if ($ncolumns === false)
1279             $ncolumns = count($this->_columns);
1280
1281         list($offset, $pagesize) = $this->limit($limit);
1282         if (!$pagesize or
1283             (!$offset and $numrows <= $pagesize) or
1284             ($offset + $pagesize < 0))
1285             return false;
1286
1287         $request = &$GLOBALS['request'];
1288         $pagename = $request->getArg('pagename');
1289         $defargs = $request->args;
1290         if (USE_PATH_INFO) unset($defargs['pagename']);
1291         if ($defargs['action'] == 'browse') unset($defargs['action']);
1292         $prev = $defargs;
1293
1294         $tokens = array();
1295         $tokens['PREV'] = false; $tokens['PREV_LINK'] = "";
1296         $tokens['COLS'] = count($this->_columns);
1297         $tokens['COUNT'] = $numrows; 
1298         $tokens['OFFSET'] = $offset; 
1299         $tokens['SIZE'] = $pagesize;
1300         $tokens['NUMPAGES'] = (int)($numrows / $pagesize)+1;
1301         $tokens['ACTPAGE'] = (int) (($offset+1) / $pagesize)+1;
1302         if ($offset > 0) {
1303             $prev['limit'] = max(0, $offset - $pagesize) . ",$pagesize";
1304             $prev['count'] = $numrows;
1305             $tokens['LIMIT'] = $prev['limit'];
1306             $tokens['PREV'] = true;
1307             $tokens['PREV_LINK'] = WikiURL($pagename, $prev);
1308             $prev['limit'] = "0,$pagesize";
1309             $tokens['FIRST_LINK'] = WikiURL($pagename, $prev);
1310         }
1311         $next = $defargs;
1312         $tokens['NEXT'] = false; $tokens['NEXT_LINK'] = "";
1313         if ($offset + $pagesize < $numrows) {
1314             $next['limit'] = min($offset + $pagesize, $numrows - $pagesize) . ",$pagesize";
1315             $next['count'] = $numrows;
1316             $tokens['LIMIT'] = $next['limit'];
1317             $tokens['NEXT'] = true;
1318             $tokens['NEXT_LINK'] = WikiURL($pagename, $next);
1319             $next['limit'] = $numrows - $pagesize . ",$pagesize";
1320             $tokens['LAST_LINK'] = WikiURL($pagename, $next);
1321         }
1322         return $tokens;
1323     }
1324     
1325     // make a table given the caption
1326     function _generateTable($caption) {
1327         if (count($this->_sortby) > 0) $this->_sortPages();
1328         
1329         // wikiadminutils hack. that's a way to pagelist non-pages
1330         $rows = isset($this->_rows) ? $this->_rows : array(); $i = 0;
1331         $count = $this->getTotal();
1332         $do_paging = ( isset($this->_options['paging']) 
1333                        and !empty($this->_options['limit']) 
1334                        and $count 
1335                        and $this->_options['paging'] != 'none' );
1336         if ($do_paging) {
1337             $tokens = $this->pagingTokens($count, 
1338                                            count($this->_columns), 
1339                                            $this->_options['limit']);
1340             if ($tokens)                               
1341                 $this->_pages = array_slice($this->_pages, $tokens['OFFSET'], $tokens['NUMPAGES']);
1342         }
1343         foreach ($this->_pages as $pagenum => $page) {
1344             $rows[] = $this->_renderPageRow($page, $i++);
1345         }
1346         $table = HTML::table(array('cellpadding' => 0,
1347                                    'cellspacing' => 1,
1348                                    'border'      => 0,
1349                                    'class'       => 'pagelist', 
1350                                    ));
1351         if ($caption) {
1352             $table->pushContent(HTML::caption(array('align'=>'top'), $caption));
1353             $table->setAttr('width', '100%');
1354         }
1355
1356         //Warning: This is quite fragile. It depends solely on a private variable
1357         //         in ->_addColumn()
1358         if (!empty($this->_columns_seen['checkbox'])) {
1359             $table->pushContent($this->_jsFlipAll());
1360         }
1361
1362         $row = HTML::tr();
1363         $table_summary = array();
1364         $i = 1; // start with 1!
1365         foreach ($this->_columns as $col) {
1366             $heading = $col->button_heading($this, $i);
1367             if ( $do_paging 
1368                  and isset($col->_field) 
1369                  and $col->_field == 'pagename' 
1370                  and ($maxlen = $this->maxLen())) {
1371                $heading->setAttr('width', $maxlen * 7);
1372             }
1373             $row->pushContent($heading);
1374             if (is_string($col->getHeading()))
1375                 $table_summary[] = $col->getHeading();
1376             $i++;
1377         }
1378         // Table summary for non-visual browsers.
1379         $table->setAttr('summary', sprintf(_("Columns: %s."), 
1380                                            join(", ", $table_summary)));
1381         $table->pushContent(HTML::colgroup(array('span' => count($this->_columns))));
1382         if ( $do_paging ) {
1383             if ($tokens === false) {
1384                 $table->pushContent(HTML::thead($row),
1385                                     HTML::tbody(false, $rows));
1386                 return $table;
1387             }
1388
1389             $paging = Template("pagelink", $tokens);
1390             if ($this->_options['paging'] != 'bottom')
1391                 $table->pushContent(HTML::thead($paging));
1392             $table->pushContent(HTML::tbody(false, HTML($row, $rows)));
1393             if ($this->_options['paging'] != 'top')
1394                 $table->pushContent(HTML::tfoot($paging));
1395             return $table;
1396         } else {
1397             $table->pushContent(HTML::thead($row),
1398                                 HTML::tbody(false, $rows));
1399             return $table;
1400         }
1401     }
1402
1403     function _jsFlipAll() {
1404       return JavaScript("
1405 function flipAll(formObj) {
1406   var isFirstSet = -1;
1407   for (var i=0; i < formObj.length; i++) {
1408       fldObj = formObj.elements[i];
1409       if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,2) == 'p[')) { 
1410          if (isFirstSet == -1)
1411            isFirstSet = (fldObj.checked) ? true : false;
1412          fldObj.checked = (isFirstSet) ? false : true;
1413        }
1414    }
1415 }");
1416     }
1417
1418     /* recursive stack for private sublist options (azhead, cols) */
1419     function _saveOptions($opts) {
1420         $stack = array('pages' => $this->_pages);
1421         foreach ($opts as $k => $v) {
1422             $stack[$k] = $this->_options[$k];
1423             $this->_options[$k] = $v;
1424         }
1425         if (empty($this->_stack))
1426             $this->_stack = new Stack();
1427         $this->_stack->push($stack);
1428     }
1429     function _restoreOptions() {
1430         assert($this->_stack);
1431         $stack = $this->_stack->pop();
1432         $this->_pages = $stack['pages'];
1433         unset($stack['pages']);
1434         foreach ($stack as $k => $v) {
1435             $this->_options[$k] = $v;
1436         }
1437     }
1438
1439     // 'cols'   - split into several columns
1440     // 'azhead' - support <h3> grouping into initials
1441     // 'ordered' - OL or UL list (not yet inherited to all plugins)
1442     // 'comma'  - condensed comma-list only, 1: no links, >1: with links
1443     // FIXME: only unique list entries, esp. with nopage
1444     function _generateList($caption='') {
1445         if (empty($this->_pages)) return; // stop recursion
1446         $out = HTML();
1447         if ($caption)
1448             $out->pushContent(HTML::p($caption));
1449         // Semantic Search et al: only unique list entries, esp. with nopage
1450         if (!is_array($this->_pages[0]) and is_string($this->_pages[0])) {
1451             $this->_pages = array_unique($this->_pages);
1452         }
1453         if (count($this->_sortby) > 0) $this->_sortPages();
1454
1455         // need a recursive switch here for the azhead and cols grouping.
1456         if (!empty($this->_options['cols']) and $this->_options['cols'] > 1) {
1457             $count = count($this->_pages);
1458             $length = $count / $this->_options['cols'];
1459             $width = sprintf("%d", 100 / $this->_options['cols']).'%';
1460             $cols = HTML::tr(array('valign' => 'top'));
1461             for ($i=0; $i < $count; $i += $length) {
1462                 $this->_saveOptions(array('cols' => 0));
1463                 $this->_pages = array_slice($this->_pages, $i, $length);
1464                 $cols->pushContent(HTML::td(/*array('width' => $width),*/ 
1465                                             $this->_generateList()));
1466                 $this->_restoreOptions();
1467             }
1468             // speed up table rendering by defining colgroups
1469             $out->pushContent(HTML::table(HTML::colgroup(array('span' => $this->_options['cols'],
1470                                                                'width' => $width)),
1471                                           $cols));
1472             return $out;
1473         }
1474         
1475         // Ignore azhead if not sorted by pagename
1476         if (!empty($this->_options['azhead']) 
1477             and strstr($this->sortby($this->_options['sortby'], 'init'), "pagename")
1478             )
1479         {
1480             $cur_h = substr($this->_pages[0]->getName(), 0, 1);
1481             $out->pushContent(HTML::h3($cur_h));
1482             // group those pages together with same $h
1483             $j = 0;
1484             for ($i=0; $i < count($this->_pages); $i++) {
1485                 $page =& $this->_pages[$i];
1486                 $h = substr($page->getName(), 0, 1);
1487                 if ($h != $cur_h and $i > $j) {
1488                     $this->_saveOptions(array('cols' => 0, 'azhead' => 0));
1489                     $this->_pages = array_slice($this->_pages, $j, $i - $j);
1490                     $out->pushContent($this->_generateList());
1491                     $this->_restoreOptions();
1492                     $j = $i;
1493                     $out->pushContent(HTML::h3($h));
1494                     $cur_h = $h;
1495                 }
1496             }
1497             if ($i > $j) { // flush the rest
1498                 $this->_saveOptions(array('cols' => 0, 'azhead' => 0));
1499                 $this->_pages = array_slice($this->_pages, $j, $i - $j);
1500                 $out->pushContent($this->_generateList());
1501                 $this->_restoreOptions();
1502             }
1503             return $out;
1504         }
1505             
1506         if ($this->_options['listtype'] == 'comma')
1507             $this->_options['comma'] = 2;
1508         if (!empty($this->_options['comma'])) {
1509             if ($this->_options['comma'] == 1)
1510                 $out->pushContent($this->_generateCommaListAsString());
1511             else
1512                 $out->pushContent($this->_generateCommaList($this->_options['comma']));
1513             return $out;
1514         }
1515
1516         $do_paging = ( isset($this->_options['paging']) 
1517                        and !empty($this->_options['limit']) 
1518                        and $this->getTotal() 
1519                        and $this->_options['paging'] != 'none' );
1520         if ( $do_paging ) {
1521             $tokens = $this->pagingTokens($this->getTotal(), 
1522                                            count($this->_columns), 
1523                                            $this->_options['limit']);
1524             if ($tokens) {
1525                 $paging = Template("pagelink", $tokens);
1526                 $out->pushContent(HTML::table($paging));
1527             }
1528         }
1529         if ($this->_options['listtype'] == 'ol')
1530             $this->_options['ordered'] = 1;
1531         elseif ($this->_options['listtype'] == 'ul')
1532             $this->_options['ordered'] = 0;
1533         if (!empty($this->_options['ordered']))
1534             $list = HTML::ol(array('class' => 'pagelist'));
1535         elseif ($this->_options['listtype'] == 'dl') {
1536             $list = HTML::dl(array('class' => 'pagelist'));
1537         } else {
1538             $list = HTML::ul(array('class' => 'pagelist'));
1539         }
1540         $i = 0;
1541         //TODO: currently we ignore limit here and hope that the backend didn't ignore it. (BackLinks)
1542         if (!empty($this->_options['limit']))
1543             list($offset, $pagesize) = $this->limit($this->_options['limit']);
1544         else 
1545             $pagesize=0;
1546         foreach ($this->_pages as $pagenum => $page) {
1547             $pagehtml = $this->_renderPageRow($page);
1548             if (!$pagehtml) continue;
1549             $group = ($i++ / $this->_group_rows);
1550             //TODO: here we switch every row, in tables every third. 
1551             //      unification or parametrized?
1552             $class = ($group % 2) ? 'oddrow' : 'evenrow';
1553             if ($this->_options['listtype'] == 'dl') {
1554                 $header = WikiLink($page);
1555                 //if ($this->_sortby['hi_content']) 
1556                 $list->pushContent(HTML::dt(array('class' => $class), $header),
1557                                    HTML::dd(array('class' => $class), $pagehtml));
1558             } else
1559                 $list->pushContent(HTML::li(array('class' => $class), $pagehtml));
1560             if ($pagesize and $i > $pagesize) break;
1561         }
1562         $out->pushContent($list);
1563         if ( $do_paging and $tokens ) {
1564             $out->pushContent(HTML::table($paging));
1565         }
1566         return $out;
1567     }
1568
1569     // comma=1
1570     // Condense list without a href links: "Page1, Page2, ..." 
1571     // Alternative $seperator = HTML::Raw(' &middot; ')
1572     // FIXME: only unique list entries, esp. with nopage
1573     function _generateCommaListAsString() {
1574         if (defined($this->_options['commasep']))
1575             $seperator = $this->_options['commasep'];
1576         else    
1577             $seperator = ', ';
1578         $pages = array();
1579         foreach ($this->_pages as $pagenum => $page) {
1580             if ($s = $this->_renderPageRow($page)) // some pages are not viewable
1581                 $pages[] = is_string($s) ? $s : $s->asString();
1582         }
1583         return HTML(join($seperator, $pages));
1584     }
1585
1586     // comma=2
1587     // Normal WikiLink list.
1588     // Future: 1 = reserved for plain string (see above)
1589     //         2 and more => HTML link specialization?
1590     // FIXME: only unique list entries, esp. with nopage
1591     function _generateCommaList($style = false) {
1592         if (defined($this->_options['commasep']))
1593             $seperator = HTLM::Raw($this->_options['commasep']);
1594         else    
1595             $seperator = ', ';
1596         $html = HTML();
1597         $html->pushContent($this->_renderPageRow($this->_pages[0]));
1598         next($this->_pages);
1599         foreach ($this->_pages as $pagenum => $page) {
1600             if ($s = $this->_renderPageRow($page)) // some pages are not viewable
1601                 $html->pushContent($seperator, $s);
1602         }
1603         return $html;
1604     }
1605     
1606     function _emptyList($caption) {
1607         $html = HTML();
1608         if ($caption)
1609             $html->pushContent(HTML::p($caption));
1610         if ($this->_messageIfEmpty)
1611             $html->pushContent(HTML::blockquote(HTML::p($this->_messageIfEmpty)));
1612         return $html;
1613     }
1614
1615 };
1616
1617 /* List pages with checkboxes to select from.
1618  * The [Select] button toggles via _jsFlipAll
1619  */
1620
1621 class PageList_Selectable
1622 extends PageList {
1623
1624     function PageList_Selectable ($columns=false, $exclude='', $options = false) {
1625         if ($columns) {
1626             if (!is_array($columns))
1627                 $columns = explode(',', $columns);
1628             if (!in_array('checkbox',$columns))
1629                 array_unshift($columns,'checkbox');
1630         } else {
1631             $columns = array('checkbox','pagename');
1632         }
1633         $this->PageList($columns, $exclude, $options);
1634     }
1635
1636     function addPageList ($array) {
1637         while (list($pagename,$selected) = each($array)) {
1638             if ($selected) $this->addPageSelected((string)$pagename);
1639             $this->addPage((string)$pagename);
1640         }
1641     }
1642
1643     function addPageSelected ($pagename) {
1644         $this->_selected[$pagename] = 1;
1645     }
1646 }
1647
1648 // $Log: not supported by cvs2svn $
1649 // Revision 1.142  2007/07/01 09:09:19  rurban
1650 // fix PageList with multiple lists: added id, fixed sortby REQUEST logic
1651 //
1652 // Revision 1.141  2007/05/24 18:40:55  rurban
1653 // display list with tokens problem
1654 //
1655 // Revision 1.140  2007/05/13 18:12:55  rurban
1656 // force adding a options[type] column: fixes LinkDatabase
1657 //
1658 // Revision 1.139  2007/01/25 07:42:01  rurban
1659 // Support nopage
1660 //
1661 // Revision 1.138  2007/01/20 11:24:15  rurban
1662 // Support paging limit if ->_pages is not yet limited by the backend (AllPagesByMe)
1663 //
1664 // Revision 1.137  2007/01/07 18:43:08  rurban
1665 // Honor predefined ->_rows: hack to (re-)allow non-pagenames, used by WikiAdminUtils
1666 //
1667 // Revision 1.136  2007/01/02 13:18:46  rurban
1668 // filter pageNames through limit, needed for xmlrpc. publish col->current_row and col->current_column counters during iteration. use table width=100% with captions. Clarify API: sortby,limit and exclude are strings.
1669 //
1670 // Revision 1.135  2005/09/14 05:59:03  rurban
1671 // optimized explodePageList to use SQL when available
1672 //   (titleSearch instead of getAllPages)
1673 //
1674 // Revision 1.134  2005/09/11 14:55:05  rurban
1675 // implement fulltext stoplist
1676 //
1677 // Revision 1.133  2005/08/27 09:41:37  rurban
1678 // new helper method
1679 //
1680 // Revision 1.132  2005/04/09 09:16:15  rurban
1681 // fix recursive PageList azhead+cols listing
1682 //
1683 // Revision 1.131  2005/02/04 10:48:06  rurban
1684 // fix usort ref warning. Thanks to Charles Corrigan
1685 //
1686 // Revision 1.130  2005/01/28 12:07:36  rurban
1687 // reformatting
1688 //
1689 // Revision 1.129  2005/01/25 06:58:21  rurban
1690 // reformatting
1691 //
1692 // Revision 1.128  2004/12/26 17:31:35  rurban
1693 // fixed prev link logic
1694 //
1695 // Revision 1.127  2004/12/26 17:19:28  rurban
1696 // dont break sideeffecting sortby flips on paging urls (MostPopular)
1697 //
1698 // Revision 1.126  2004/12/16 18:26:57  rurban
1699 // Avoid double calculation
1700 //
1701 // Revision 1.125  2004/11/25 17:20:49  rurban
1702 // and again a couple of more native db args: backlinks
1703 //
1704 // Revision 1.124  2004/11/23 15:17:14  rurban
1705 // better support for case_exact search (not caseexact for consistency),
1706 // plugin args simplification:
1707 //   handle and explode exclude and pages argument in WikiPlugin::getArgs
1708 //     and exclude in advance (at the sql level if possible)
1709 //   handle sortby and limit from request override in WikiPlugin::getArgs
1710 // ListSubpages: renamed pages to maxpages
1711 //
1712 // Revision 1.123  2004/11/23 13:35:31  rurban
1713 // add case_exact search
1714 //
1715 // Revision 1.122  2004/11/21 11:59:15  rurban
1716 // remove final \n to be ob_cache independent
1717 //
1718 // Revision 1.121  2004/11/20 17:35:47  rurban
1719 // improved WantedPages SQL backends
1720 // PageList::sortby new 3rd arg valid_fields (override db fields)
1721 // WantedPages sql pager inexact for performance reasons:
1722 //   assume 3 wantedfrom per page, to be correct, no getTotal()
1723 // support exclude argument for get_all_pages, new _sql_set()
1724 //
1725 // Revision 1.120  2004/11/20 11:28:49  rurban
1726 // fix a yet unused PageList customPageListColumns bug (merge class not decl to _types)
1727 // change WantedPages to use PageList
1728 // change WantedPages to print the list of referenced pages, not just the count.
1729 //   the old version was renamed to WantedPagesOld
1730 //   fix and add handling of most standard PageList arguments (limit, exclude, ...)
1731 // TODO: pagename sorting, dumb/WantedPagesIter and SQL optimization
1732 //
1733 // Revision 1.119  2004/11/11 14:34:11  rurban
1734 // minor clarifications
1735 //
1736 // Revision 1.118  2004/11/01 10:43:55  rurban
1737 // seperate PassUser methods into seperate dir (memory usage)
1738 // fix WikiUser (old) overlarge data session
1739 // remove wikidb arg from various page class methods, use global ->_dbi instead
1740 // ...
1741 //
1742 // Revision 1.117  2004/10/14 21:06:01  rurban
1743 // fix dumphtml with USE_PATH_INFO (again). fix some PageList refs
1744 //
1745 // Revision 1.116  2004/10/14 19:19:33  rurban
1746 // loadsave: check if the dumped file will be accessible from outside.
1747 // and some other minor fixes. (cvsclient native not yet ready)
1748 //
1749 // Revision 1.115  2004/10/14 17:15:05  rurban
1750 // remove class _PageList_Page, fix sortby=0 (start with 1, use strings), fix _PageList_Column_content for old phps, hits as int
1751 //
1752 // Revision 1.114  2004/10/12 13:13:19  rurban
1753 // php5 compatibility (5.0.1 ok)
1754 //
1755 // Revision 1.113  2004/10/05 17:00:03  rurban
1756 // support paging for simple lists
1757 // fix RatingDb sql backend.
1758 // remove pages from AllPages (this is ListPages then)
1759 //
1760 // Revision 1.112  2004/10/04 23:39:58  rurban
1761 // list of page objects
1762 //
1763 // Revision 1.111  2004/09/24 18:50:45  rurban
1764 // fix paging of SqlResult
1765 //
1766 // Revision 1.110  2004/09/17 14:43:31  rurban
1767 // typo
1768 //
1769 // Revision 1.109  2004/09/17 14:22:10  rurban
1770 // update comments
1771 //
1772 // Revision 1.108  2004/09/17 12:46:22  rurban
1773 // seperate pagingTokens()
1774 // support new default args: comma (1 and 2), commasep, ordered, cols,
1775 //                           azhead (1 only)
1776 //
1777 // Revision 1.107  2004/09/14 10:29:08  rurban
1778 // exclude pages already in addPages to simplify plugins
1779 //
1780 // Revision 1.106  2004/09/06 10:22:14  rurban
1781 // oops, forgot global request
1782 //
1783 // Revision 1.105  2004/09/06 08:38:30  rurban
1784 // modularize paging helper (for SqlResult)
1785 //
1786 // Revision 1.104  2004/08/18 11:01:55  rurban
1787 // fixed checkbox list Select button:
1788 //   no GET request on click,
1789 //   only select the list checkbox entries, no other options.
1790 //
1791 // Revision 1.103  2004/07/09 10:06:49  rurban
1792 // Use backend specific sortby and sortable_columns method, to be able to
1793 // select between native (Db backend) and custom (PageList) sorting.
1794 // Fixed PageList::AddPageList (missed the first)
1795 // Added the author/creator.. name to AllPagesBy...
1796 //   display no pages if none matched.
1797 // Improved dba and file sortby().
1798 // Use &$request reference
1799 //
1800 // Revision 1.102  2004/07/08 21:32:35  rurban
1801 // Prevent from more warnings, minor db and sort optimizations
1802 //
1803 // Revision 1.101  2004/07/08 19:04:41  rurban
1804 // more unittest fixes (file backend, metadata RatingsDb)
1805 //
1806 // Revision 1.100  2004/07/07 15:02:26  dfrankow
1807 // Take out if that prevents column sorting
1808 //
1809 // Revision 1.99  2004/07/02 18:49:02  dfrankow
1810 // Change one line so that if addPageList() is passed null, it is still
1811 // okay.  The unit tests do this (ask to list AllUsers where there are no
1812 // users, or something like that).
1813 //
1814 // Revision 1.98  2004/07/01 08:51:22  rurban
1815 // dumphtml: added exclude, print pagename before processing
1816 //
1817 // Revision 1.97  2004/06/29 09:11:10  rurban
1818 // More memory optimization:
1819 //   don't cache unneeded _cached_html and %content for content and size columns
1820 //   (only if sortable, which will fail for too many pages)
1821 //
1822 // Revision 1.96  2004/06/29 08:47:42  rurban
1823 // Memory optimization (reference to parent, smart bool %content)
1824 // Fixed class grouping in table
1825 //
1826 // Revision 1.95  2004/06/28 19:00:01  rurban
1827 // removed non-portable LIMIT 1 (it's getOne anyway)
1828 // removed size from info=most: needs to much memory
1829 //
1830 // Revision 1.94  2004/06/27 10:26:02  rurban
1831 // oci8 patch by Philippe Vanhaesendonck + some ADODB notes+fixes
1832 //
1833 // Revision 1.93  2004/06/25 14:29:17  rurban
1834 // WikiGroup refactoring:
1835 //   global group attached to user, code for not_current user.
1836 //   improved helpers for special groups (avoid double invocations)
1837 // new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write())
1838 // fixed a XHTML validation error on userprefs.tmpl
1839 //
1840 // Revision 1.92  2004/06/21 17:01:39  rurban
1841 // fix typo and rating method call
1842 //
1843 // Revision 1.91  2004/06/21 16:22:29  rurban
1844 // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps,
1845 // fixed dumping buttons locally (images/buttons/),
1846 // support pages arg for dumphtml,
1847 // optional directory arg for dumpserial + dumphtml,
1848 // fix a AllPages warning,
1849 // show dump warnings/errors on DEBUG,
1850 // don't warn just ignore on wikilens pagelist columns, if not loaded.
1851 // RateIt pagelist column is called "rating", not "ratingwidget" (Dan?)
1852 //
1853 // Revision 1.90  2004/06/18 14:38:21  rurban
1854 // adopt new PageList style
1855 //
1856 // Revision 1.89  2004/06/17 13:16:08  rurban
1857 // apply wikilens work to PageList: all columns are sortable (slightly fixed)
1858 //
1859 // Revision 1.88  2004/06/14 11:31:35  rurban
1860 // renamed global $Theme to $WikiTheme (gforge nameclash)
1861 // inherit PageList default options from PageList
1862 //   default sortby=pagename
1863 // use options in PageList_Selectable (limit, sortby, ...)
1864 // added action revert, with button at action=diff
1865 // added option regex to WikiAdminSearchReplace
1866 //
1867 // Revision 1.87  2004/06/13 16:02:12  rurban
1868 // empty list of pages if user=[] and not authenticated.
1869 //
1870 // Revision 1.86  2004/06/13 15:51:37  rurban
1871 // Support pagelist filter for current author,owner,creator by []
1872 //
1873 // Revision 1.85  2004/06/13 15:33:19  rurban
1874 // new support for arguments owner, author, creator in most relevant
1875 // PageList plugins. in WikiAdmin* via preSelectS()
1876 //
1877 // Revision 1.84  2004/06/08 13:51:56  rurban
1878 // some comments only
1879 //
1880 // Revision 1.83  2004/05/18 13:35:39  rurban
1881 //  improve Pagelist layout by equal pagename width for limited lists
1882 //
1883 // Revision 1.82  2004/05/16 22:07:35  rurban
1884 // check more config-default and predefined constants
1885 // various PagePerm fixes:
1886 //   fix default PagePerms, esp. edit and view for Bogo and Password users
1887 //   implemented Creator and Owner
1888 //   BOGOUSERS renamed to BOGOUSER
1889 // fixed syntax errors in signin.tmpl
1890 //
1891 // Revision 1.81  2004/05/13 12:30:35  rurban
1892 // fix for MacOSX border CSS attr, and if sort buttons are not found
1893 //
1894 // Revision 1.80  2004/04/20 00:56:00  rurban
1895 // more paging support and paging fix for shorter lists
1896 //
1897 // Revision 1.79  2004/04/20 00:34:16  rurban
1898 // more paging support
1899 //
1900 // Revision 1.78  2004/04/20 00:06:03  rurban
1901 // themable paging support
1902 //
1903 // Revision 1.77  2004/04/18 01:11:51  rurban
1904 // more numeric pagename fixes.
1905 // fixed action=upload with merge conflict warnings.
1906 // charset changed from constant to global (dynamic utf-8 switching)
1907 //
1908
1909 // (c-file-style: "gnu")
1910 // Local Variables:
1911 // mode: php
1912 // tab-width: 8
1913 // c-basic-offset: 4
1914 // c-hanging-comment-ender-p: nil
1915 // indent-tabs-mode: nil
1916 // End:
1917 ?>