]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/PageList.php
Allow sorting by hits; test method_exists
[SourceForge/phpwiki.git] / lib / PageList.php
1 <?php rcs_id('$Id: PageList.php,v 1.152 2008-02-15 19:46:12 vargenau 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) && method_exists($val, 'asString'))
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 ($GLOBALS['request']->getArg('count'))
537             $options['count'] = $GLOBALS['request']->getArg('count');
538         if ($options)
539             $this->_options = $options;
540
541         $this->_initAvailableColumns();
542         // let plugins predefine only certain objects, such its own custom pagelist columns
543         $symbolic_columns = 
544             array(
545                   'all' =>  array_diff(array_keys($this->_types), // all but...
546                                        array('checkbox','remove','renamed_pagename',
547                                              'content','hi_content','perm','acl')),
548                   'most' => array('pagename','mtime','author','hits'),
549                   'some' => array('pagename','mtime','author')
550                   );
551         if (isset($this->_options['listtype']) 
552             and $this->_options['listtype'] == 'dl')
553             $this->_options['nopage'] = 1;
554         if ($columns) {
555             if (!is_array($columns))
556                 $columns = explode(',', $columns);
557             // expand symbolic columns:
558             foreach ($symbolic_columns as $symbol => $cols) {
559                 if (in_array($symbol,$columns)) { // e.g. 'checkbox,all'
560                     $columns = array_diff(array_merge($columns,$cols),array($symbol));
561                 }
562             }
563             unset($cols);
564             if (empty($this->_options['nopage']) and !in_array('pagename',$columns))
565                 $this->_addColumn('pagename');
566             foreach ($columns as $col) {
567                 if (!empty($col))
568                     $this->_addColumn($col);
569             }
570             unset($col);
571         }
572         // If 'pagename' is already present, _addColumn() will not add it again
573         if (empty($this->_options['nopage']))
574             $this->_addColumn('pagename');
575
576         if (!empty($this->_options['types'])) {
577             foreach ($this->_options['types'] as $type) {
578                 $this->_types[$type->_field] = $type;
579                 $this->_addColumn($type->_field);
580             }
581             unset($this->_options['types']);
582         }
583
584         global $request;
585         // explicit header options: ?id=x&sortby=... override options[]
586         // support multiple sorts. check multiple, no nested elseif
587         if (($this->id == $request->getArg("id")) 
588              and $request->getArg('sortby')) 
589         {
590             // add it to the front of the sortby array
591             $this->sortby($request->getArg('sortby'), 'init');
592             $this->_options['sortby'] = $request->getArg('sortby');
593         } // plugin options
594         if (!empty($options['sortby'])) {
595             if (empty($this->_options['sortby']))
596                 $this->_options['sortby'] = $options['sortby'];
597             $this->sortby($options['sortby'], 'init');
598         } // global options 
599         if (!isset($request->args["id"]) and $request->getArg('sortby') 
600              and empty($this->_options['sortby'])) 
601         {
602             $this->_options['sortby'] = $request->getArg('sortby');
603             $this->sortby($this->_options['sortby'], 'init');
604         }
605         // same as above but without the special sortby push, and mutually exclusive (elseif)
606         foreach ($this->pagingArgs() as $key) {
607             if ($key == 'sortby') continue;     
608             if (($this->id == $request->getArg("id")) 
609                 and $request->getArg($key)) 
610             {
611                 $this->_options[$key] = $request->getArg($key);
612             } // plugin options
613             elseif (!empty($options) and !empty($options[$key])) {
614                 $this->_options[$key] = $options[$key];
615             } // global options 
616             elseif (!isset($request->args["id"]) and $request->getArg($key)) {
617                 $this->_options[$key] = $request->getArg($key);
618             }
619             else 
620                 $this->_options[$key] = false;
621         }
622         if ($exclude) {
623             if (is_string($exclude) and !is_array($exclude))
624                 $exclude = $this->explodePageList($exclude, false,
625                                                   $this->_options['sortby'],
626                                                   $this->_options['limit']);
627             $this->_excluded_pages = $exclude;
628         }
629         $this->_messageIfEmpty = _("<no matches>");
630     }
631
632     // Currently PageList takes these arguments:
633     // 1: info, 2: exclude, 3: hash of options
634     // Here we declare which options are supported, so that 
635     // the calling plugin may simply merge this with its own default arguments 
636     function supportedArgs () {
637         return array(// Currently supported options:
638                      /* what columns, what pages */
639                      'info'     => 'pagename',
640                      'exclude'  => '',          // also wildcards, comma-seperated lists 
641                                                 // and <!plugin-list !> arrays
642                      /* select pages by meta-data: */
643                      'author'   => false, // current user by []
644                      'owner'    => false, // current user by []
645                      'creator'  => false, // current user by []
646
647                      /* for the sort buttons in <th> */
648                      'sortby'   => '', // same as for WikiDB::getAllPages 
649                                        // (unsorted is faster)
650
651                      /* PageList pager options:
652                       * These options may also be given to _generate(List|Table) later
653                       * But limit and offset might help the query WikiDB::getAllPages()
654                       */
655                      'limit'    => 50,       // number of rows (pagesize)
656                      'paging'   => 'auto',  // 'auto'   top + bottom rows if applicable
657                      //                     // 'top'    top only if applicable
658                      //                     // 'bottom' bottom only if applicable
659                      //                     // 'none'   don't page at all 
660                      // (TODO: clarify what if $paging==false ?)
661
662                      /* list-style options (with single pagename column only so far) */
663                      'cols'     => 1,       // side-by-side display of list (1-3)
664                      'azhead'   => 0,       // 1: group by initials
665                                             // 2: provide shortcut links to initials also
666                      'comma'    => 0,       // condensed comma-seperated list, 
667                                             // 1 if without links, 2 if with
668                      'commasep' => false,   // Default: ', '
669                      'listtype' => '',      // ul (default), ol, dl, comma
670                      'ordered'  => false,   // OL or just UL lists (ignored for comma)
671                      'linkmore' => '',      // If count>0 and limit>0 display a link with 
672                      // the number of all results, linked to the given pagename.
673                      
674                      'nopage'   => false,   // for info=col omit the pagename column
675                      );
676     }
677     
678     function pagingArgs() {
679         return array('sortby','limit','paging','count','dosort');
680     }
681
682     function setCaption ($caption_string) {
683         $this->_caption = $caption_string;
684     }
685
686     function addCaption ($caption_string) {
687         $this->_caption = HTML($this->_caption," ",$caption_string);
688     }
689
690     function getCaption () {
691         // put the total into the caption if needed
692         if (is_string($this->_caption) && strstr($this->_caption, '%d'))
693             return sprintf($this->_caption, $this->getTotal());
694         return $this->_caption;
695     }
696
697     function setMessageIfEmpty ($msg) {
698         $this->_messageIfEmpty = $msg;
699     }
700
701
702     function getTotal () {
703         return !empty($this->_options['count'])
704                ? (integer) $this->_options['count'] : count($this->_pages);
705     }
706
707     function isEmpty () {
708         return empty($this->_pages);
709     }
710
711     function addPage($page_handle) {
712         if (!empty($this->_excluded_pages)) {
713             if (!in_array((is_string($page_handle) ? $page_handle : $page_handle->getName()),
714                           $this->_excluded_pages))
715                 $this->_pages[] = $page_handle;
716         } else {
717             $this->_pages[] = $page_handle;
718         }
719     }
720
721     function pageNames() {
722         $pages = array();
723         $limit = @$this->_options['limit'];
724         foreach ($this->_pages as $page_handle) {
725             $pages[] = $page_handle->getName();
726             if ($limit and count($pages) > $limit)
727                 break;
728         }
729         return $pages;
730     }
731
732     function _getPageFromHandle($page_handle) {
733         if (is_string($page_handle)) {
734             if (empty($page_handle)) return $page_handle;
735             //$dbi = $GLOBALS['request']->getDbh(); // no, safe some memory!
736             $page_handle = $GLOBALS['request']->_dbi->getPage($page_handle);
737         }
738         return $page_handle;
739     }
740
741     /**
742      * Take a PageList_Page object, and return an HTML object to display
743      * it in a table or list row.
744      */
745     function _renderPageRow (&$page_handle, $i = 0) {
746         $page_handle = $this->_getPageFromHandle($page_handle);
747         //FIXME. only on sf.net
748         if (!is_object($page_handle)) {
749             trigger_error("PageList: Invalid page_handle $page_handle", E_USER_WARNING);
750             return;
751         }
752         if (!isset($page_handle)
753             or empty($page_handle)
754             or (!empty($this->_excluded_pages)
755                 and in_array($page_handle->getName(), $this->_excluded_pages)))
756             return; // exclude page.
757             
758         // enforce view permission
759         if (!mayAccessPage('view', $page_handle->getName()))
760             return;
761
762         $group = (int)($i / $this->_group_rows);
763         $class = ($group % 2) ? 'oddrow' : 'evenrow';
764         $revision_handle = false;
765         $this->_maxlen = max($this->_maxlen, strlen($page_handle->getName()));
766
767         if (count($this->_columns) > 1) {
768             $row = HTML::tr(array('class' => $class));
769             $j = 0;
770             foreach ($this->_columns as $col) {
771                 $col->current_row = $i;
772                 $col->current_column = $j;
773                 $row->pushContent($col->format($this, $page_handle, $revision_handle));
774                 $j++;
775             }
776         } else {
777             $col = $this->_columns[0];
778             $col->current_row = $i;
779             $col->current_column = 0;
780             $row = $col->_getValue($page_handle, $revision_handle);
781         }
782
783         return $row;
784     }
785
786     /* ignore from, but honor limit */
787     function addPages ($page_iter) {
788         // TODO: if limit check max(strlen(pagename))
789         $i = 0;
790         if (isset($this->_options['limit'])) { // extract from,count from limit
791             list($from, $limit) = WikiDB_backend::limit($this->_options['limit']);
792             $limit += $from;
793         } else {
794             $limit = 0;
795         }
796         while ($page = $page_iter->next()) {
797             $i++;       
798             if ($from and $i < $from) 
799                 continue;
800             if (!$limit or ($limit and $i < $limit))
801                 $this->addPage($page);
802         }
803         if (empty($this->_options['count']))
804             $this->_options['count'] = $i;
805     }
806
807     function addPageList (&$list) {
808         if (empty($list)) return;  // Protect reset from a null arg
809         if (isset($this->_options['limit'])) { // extract from,count from limit
810             list($from, $limit) = WikiDB_backend::limit($this->_options['limit']);
811             $limit += $from;
812         } else {
813             $limit = 0;
814         }
815         $i = 0;
816         foreach ($list as $page) {
817             $i++;       
818             if ($from and $i < $from) 
819                 continue;
820             if (!$limit or ($limit and $i < $limit)) {
821                 if (is_object($page)) $page = $page->_pagename;
822                 $this->addPage((string)$page);
823             }
824         }
825     }
826
827     function maxLen() {
828         global $request;
829         $dbi =& $request->getDbh();
830         if (isa($dbi,'WikiDB_SQL')) {
831             extract($dbi->_backend->_table_names);
832             $res = $dbi->_backend->_dbh->getOne("SELECT max(length(pagename)) FROM $page_tbl");
833             if (DB::isError($res) || empty($res)) return false;
834             else return $res;
835         } elseif (isa($dbi,'WikiDB_ADODB')) {
836             extract($dbi->_backend->_table_names);
837             $row = $dbi->_backend->_dbh->getRow("SELECT max(length(pagename)) FROM $page_tbl");
838             return $row ? $row[0] : false;
839         } else 
840             return false;
841     }
842
843     function getContent() {
844         // Note that the <caption> element wants inline content.
845         $caption = $this->getCaption();
846
847         if ($this->isEmpty())
848             return $this->_emptyList($caption);
849         elseif (isset($this->_options['listtype']) 
850                 and in_array($this->_options['listtype'], 
851                              array('ol','ul','comma','dl')))
852             return $this->_generateList($caption);
853         elseif (count($this->_columns) == 1)
854             return $this->_generateList($caption);
855         else
856             return $this->_generateTable($caption);
857     }
858
859     function printXML() {
860         PrintXML($this->getContent());
861     }
862
863     function asXML() {
864         return AsXML($this->getContent());
865     }
866     
867     /** 
868      * Handle sortby requests for the DB iterator and table header links.
869      * Prefix the column with + or - like "+pagename","-mtime", ...
870      *
871      * Supported actions: 
872      *   'init'       :   unify with predefined order. "pagename" => "+pagename"
873      *   'flip_order' :   "mtime" => "+mtime" => "-mtime" ...
874      *   'db'         :   "-pagename" => "pagename DESC"
875      *   'check'      :   
876      *
877      * Now all columns are sortable. (patch by DanFr)
878      * Some columns have native DB backend methods, some not.
879      */
880     function sortby ($column, $action, $valid_fields=false) {
881         global $request;
882
883         if (empty($column)) return '';
884         if (is_int($column)) {
885             $column = $this->_columns[$column - 1]->_field;
886             //$column = $col->_field;
887         }
888         //if (!is_string($column)) return '';
889         // support multiple comma-delimited sortby args: "+hits,+pagename"
890         // recursive concat
891         if (strstr($column, ',')) {
892             $result = ($action == 'check') ? true : array();
893             foreach (explode(',', $column) as $col) {
894                 if ($action == 'check')
895                     $result = $result && $this->sortby($col, $action, $valid_fields);
896                 else
897                     $result[] = $this->sortby($col, $action, $valid_fields);
898             }
899             // 'check' returns true/false for every col. return true if all are true. 
900             // i.e. the unsupported 'every' operator in functional languages.
901             if ($action == 'check')
902                 return $result;
903             else
904                 return join(",", $result);
905         }
906         if (substr($column,0,1) == '+') {
907             $order = '+'; $column = substr($column,1);
908         } elseif (substr($column,0,1) == '-') {
909             $order = '-'; $column = substr($column,1);
910         }
911         // default initial order: +pagename, -mtime, -hits
912         if (empty($order)) {
913             if (!empty($this->_sortby[$column]))
914                 $order = $this->_sortby[$column];
915             else {
916                 if (in_array($column, array('mtime','hits')))
917                     $order = '-';
918                 else
919                     $order = '+';
920             }
921         }
922         if ($action == 'get') {
923             return $order . $column;
924         } elseif ($action == 'flip_order') {
925             if (0 and DEBUG)
926                 trigger_error("flip $order $column ".$this->id,  E_USER_NOTICE); 
927             return ($order == '+' ? '-' : '+') . $column;
928         } elseif ($action == 'init') { // only allowed from PageList::PageList
929             if ($this->sortby($column, 'clicked')) {
930                 if (0 and DEBUG)
931                     trigger_error("clicked $order $column $this->id",  E_USER_NOTICE); 
932                 //$order = ($order == '+' ? '-' : '+'); // $this->sortby($sortby, 'flip_order');
933             }
934             $this->_sortby[$column] = $order; // forces show icon
935             return $order . $column;
936         } elseif ($action == 'check') {   // show icon?
937             //if specified via arg or if clicked
938             $show = (!empty($this->_sortby[$column]) or $this->sortby($column, 'clicked'));
939             if (0 and $show and DEBUG) {
940                 trigger_error("show $order $column ".$this->id, E_USER_NOTICE);
941             }
942             return $show;            
943         } elseif ($action == 'clicked') { // flip sort order?
944             global $request;
945             $arg = $request->getArg('sortby');
946             return ($arg
947                     and strstr($arg, $column)
948                     and (!isset($request->args['id']) 
949                          or $this->id == $request->getArg('id')));
950         } elseif ($action == 'db') {
951             // Performance enhancement: use native DB sort if possible.
952             if (($valid_fields and in_array($column, $valid_fields))
953                 or (method_exists($request->_dbi->_backend, 'sortable_columns')
954                     and (in_array($column, $request->_dbi->_backend->sortable_columns())))) {
955                 // omit this sort method from the _sortPages call at rendering
956                 // asc or desc: +pagename, -pagename
957                 return $column . ($order == '+' ? ' ASC' : ' DESC');
958             } else {
959                 return '';
960             }
961         }
962         return '';
963     }
964
965     /* Splits pagelist string into array.
966      * Test* or Test1,Test2
967      * Limitation: Doesn't split into comma-sep and then expand wildcards.
968      * "Test1*,Test2*" is expanded into TextSearch "Test1* Test2*"
969      *
970      * echo implode(":",explodeList("Test*",array("xx","Test1","Test2")));
971      */
972     function explodePageList($input, $include_empty=false, $sortby='', 
973                              $limit='', $exclude='') 
974     {
975         if (empty($input)) return array();
976         if (is_array($input)) return $input;
977         // expand wildcards from list of all pages
978         if (preg_match('/[\?\*]/', $input) or substr($input,0,1) == "^") {
979             include_once("lib/TextSearchQuery.php");
980             $search = new TextSearchQuery(str_replace(",", " ", $input), true, 
981                                          (substr($input,0,1) == "^") ? 'posix' : 'glob'); 
982             $dbi = $GLOBALS['request']->getDbh();
983             $iter = $dbi->titleSearch($search, $sortby, $limit, $exclude);
984             $pages = array();
985             while ($pagehandle = $iter->next()) {
986                 $pages[] = $pagehandle->getName();
987             }
988             return $pages;
989             /*
990             //TODO: need an SQL optimization here
991             $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, 
992                                                 $exclude);
993             while ($pagehandle = $allPagehandles->next()) {
994                 $allPages[] = $pagehandle->getName();
995             }
996             return explodeList($input, $allPages);
997             */
998         } else {
999             //TODO: do the sorting, normally not needed if used for exclude only
1000             return explode(',', $input);
1001         }
1002     }
1003
1004     // TODO: optimize getTotal => store in count
1005     function allPagesByAuthor($wildcard, $include_empty=false, $sortby='', 
1006                               $limit='', $exclude='') 
1007     {
1008         $dbi = $GLOBALS['request']->getDbh();
1009         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude);
1010         $allPages = array();
1011         if ($wildcard === '[]') {
1012             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
1013             if (!$wildcard) return $allPages;
1014         }
1015         $do_glob = preg_match('/[\?\*]/', $wildcard);
1016         while ($pagehandle = $allPagehandles->next()) {
1017             $name = $pagehandle->getName();
1018             $author = $pagehandle->getAuthor();
1019             if ($author) {
1020                 if ($do_glob) {
1021                     if (glob_match($wildcard, $author))
1022                         $allPages[] = $name;
1023                 } elseif ($wildcard == $author) {
1024                       $allPages[] = $name;
1025                 }
1026             }
1027             // TODO: purge versiondata_cache
1028         }
1029         return $allPages;
1030     }
1031
1032     function allPagesByOwner($wildcard, $include_empty=false, $sortby='', 
1033                              $limit='', $exclude='') {
1034         $dbi = $GLOBALS['request']->getDbh();
1035         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude);
1036         $allPages = array();
1037         if ($wildcard === '[]') {
1038             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
1039             if (!$wildcard) return $allPages;
1040         }
1041         $do_glob = preg_match('/[\?\*]/', $wildcard);
1042         while ($pagehandle = $allPagehandles->next()) {
1043             $name = $pagehandle->getName();
1044             $owner = $pagehandle->getOwner();
1045             if ($owner) {
1046                 if ($do_glob) {
1047                     if (glob_match($wildcard, $owner))
1048                         $allPages[] = $name;
1049                 } elseif ($wildcard == $owner) {
1050                       $allPages[] = $name;
1051                 }
1052             }
1053         }
1054         return $allPages;
1055     }
1056
1057     function allPagesByCreator($wildcard, $include_empty=false, $sortby='', 
1058                                $limit='', $exclude='') {
1059         $dbi = $GLOBALS['request']->getDbh();
1060         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude);
1061         $allPages = array();
1062         if ($wildcard === '[]') {
1063             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
1064             if (!$wildcard) return $allPages;
1065         }
1066         $do_glob = preg_match('/[\?\*]/', $wildcard);
1067         while ($pagehandle = $allPagehandles->next()) {
1068             $name = $pagehandle->getName();
1069             $creator = $pagehandle->getCreator();
1070             if ($creator) {
1071                 if ($do_glob) {
1072                     if (glob_match($wildcard, $creator))
1073                         $allPages[] = $name;
1074                 } elseif ($wildcard == $creator) {
1075                       $allPages[] = $name;
1076                 }
1077             }
1078         }
1079         return $allPages;
1080     }
1081
1082     ////////////////////
1083     // private
1084     ////////////////////
1085     /** Plugin and theme hooks: 
1086      *  If the pageList is initialized with $options['types'] these types are also initialized, 
1087      *  overriding the standard types.
1088      */
1089     function _initAvailableColumns() {
1090         global $customPageListColumns;
1091         $standard_types =
1092             array(
1093                   'content'
1094                   => new _PageList_Column_content('rev:content', _("Content")),
1095                   // new: plugin specific column types initialised by the relevant plugins
1096                   /*
1097                   'hi_content' // with highlighted search for SearchReplace
1098                   => new _PageList_Column_content('rev:hi_content', _("Content")),
1099                   'remove'
1100                   => new _PageList_Column_remove('remove', _("Remove")),
1101                   // initialised by the plugin
1102                   'renamed_pagename'
1103                   => new _PageList_Column_renamed_pagename('rename', _("Rename to")),
1104                   'perm'
1105                   => new _PageList_Column_perm('perm', _("Permission")),
1106                   'acl'
1107                   => new _PageList_Column_acl('acl', _("ACL")),
1108                   */
1109                   'checkbox'
1110                   => new _PageList_Column_checkbox('p', _("All")),
1111                   'pagename'
1112                   => new _PageList_Column_pagename,
1113                   'mtime'
1114                   => new _PageList_Column_time('rev:mtime', _("Last Modified")),
1115                   'hits'
1116                   => new _PageList_Column('hits', _("Hits"), 'right'),
1117                   'size'
1118                   => new _PageList_Column_size('rev:size', _("Size"), 'right'),
1119                                               /*array('align' => 'char', 'char' => ' ')*/
1120                   'summary'
1121                   => new _PageList_Column('rev:summary', _("Last Summary")),
1122                   'version'
1123                   => new _PageList_Column_version('rev:version', _("Version"),
1124                                                  'right'),
1125                   'author'
1126                   => new _PageList_Column_author('rev:author', _("Last Author")),
1127                   'owner'
1128                   => new _PageList_Column_owner('author_id', _("Owner")),
1129                   'creator'
1130                   => new _PageList_Column_creator('author_id', _("Creator")),
1131                   /*
1132                   'group'
1133                   => new _PageList_Column_author('group', _("Group")),
1134                   */
1135                   'locked'
1136                   => new _PageList_Column_bool('locked', _("Locked"),
1137                                                _("locked")),
1138                   'minor'
1139                   => new _PageList_Column_bool('rev:is_minor_edit',
1140                                                _("Minor Edit"), _("minor")),
1141                   'markup'
1142                   => new _PageList_Column('rev:markup', _("Markup")),
1143                   // 'rating' initialised by the wikilens theme hook: addPageListColumn
1144                   /*
1145                   'rating'
1146                   => new _PageList_Column_rating('rating', _("Rate")),
1147                   */
1148                   );
1149         if (empty($this->_types))
1150             $this->_types = array();
1151         // add plugin specific pageList columns, initialized by $options['types']
1152         $this->_types = array_merge($standard_types, $this->_types);
1153         // add theme custom specific pageList columns: 
1154         //   set the 4th param as the current pagelist object.
1155         if (!empty($customPageListColumns)) {
1156             foreach ($customPageListColumns as $column => $params) {
1157                 $class_name = array_shift($params);
1158                 $params[3] =& $this;
1159                 // ref to a class does not work with php-4
1160                 $this->_types[$column] = new $class_name($params);
1161             }
1162         }
1163     }
1164
1165     function getOption($option) {
1166         if (array_key_exists($option, $this->_options)) {
1167             return $this->_options[$option];
1168         }
1169         else {
1170             return null;
1171         }
1172     }
1173
1174     /**
1175      * Add a column to this PageList, given a column name.
1176      * The name is a type, and optionally has a : and a label. Examples:
1177      *
1178      *   pagename
1179      *   pagename:This page
1180      *   mtime
1181      *   mtime:Last modified
1182      *
1183      * If this function is called multiple times for the same type, the
1184      * column will only be added the first time, and ignored the succeeding times.
1185      * If you wish to add multiple columns of the same type, use addColumnObject().
1186      *
1187      * @param column name
1188      * @return  true if column is added, false otherwise
1189      */
1190     function _addColumn ($column) {
1191         
1192         if (isset($this->_columns_seen[$column]))
1193             return false;       // Already have this one.
1194         if (!isset($this->_types[$column]))
1195             $this->_initAvailableColumns();
1196         $this->_columns_seen[$column] = true;
1197
1198         if (strstr($column, ':'))
1199             list ($column, $heading) = explode(':', $column, 2);
1200
1201         // FIXME: these column types have hooks (objects) elsewhere
1202         // Omitting this warning should be overridable by the extension
1203         if (!isset($this->_types[$column])) {
1204             $silently_ignore = array('numbacklinks',
1205                                      'rating','ratingvalue',
1206                                      'coagreement', 'minmisery',
1207                                      /*'prediction',*/
1208                                      'averagerating', 'top3recs', 
1209                                      'relation', 'linkto');
1210             if (!in_array($column, $silently_ignore))
1211                 trigger_error(sprintf("%s: Bad column", $column), E_USER_NOTICE);
1212             return false;
1213         }
1214         // FIXME: anon users might rate and see ratings also. 
1215         // Defer this logic to the plugin.
1216         if ($column == 'rating' and !$GLOBALS['request']->_user->isSignedIn())
1217             return false;
1218
1219         $this->addColumnObject($this->_types[$column]);
1220
1221         return true;
1222     }
1223
1224     /**
1225      * Add a column to this PageList, given a column object.
1226      *
1227      * @param $col object   An object derived from _PageList_Column.
1228      **/
1229     function addColumnObject($col) {
1230         if (is_array($col)) {// custom column object
1231             $params =& $col;
1232             $class_name = array_shift($params);
1233             $params[3] =& $this;
1234             $col = new $class_name($params);
1235         }
1236         $heading = $col->getHeading();
1237         if (!empty($heading))
1238             $col->setHeading($heading);
1239
1240         $this->_columns[] = $col;
1241         $this->_columnsMap[$col->_field] = count($this->_columns); // start with 1
1242     }
1243
1244     /**
1245      * Compare _PageList_Page objects.
1246      **/
1247     function _pageCompare(&$a, &$b) {
1248         if (empty($this->_sortby) or count($this->_sortby) == 0) {
1249             // No columns to sort by
1250             return 0;
1251         }
1252         else {
1253             $pagea = $this->_getPageFromHandle($a);  // If a string, convert to page
1254             assert(isa($pagea, 'WikiDB_Page'));
1255             $pageb = $this->_getPageFromHandle($b);  // If a string, convert to page
1256             assert(isa($pageb, 'WikiDB_Page'));
1257             foreach ($this->_sortby as $colNum => $direction) {
1258                 // get column type object
1259                 if (!is_int($colNum)) { // or column fieldname
1260                     if (isset($this->_columnsMap[$colNum]))
1261                         $col = $this->_columns[$this->_columnsMap[$colNum] - 1];
1262                     elseif (isset($this->_types[$colNum]))
1263                         $col = $this->_types[$colNum];
1264                 }
1265
1266                 assert(isset($col));
1267                 $revision_handle = false;
1268                 $aval = $col->_getSortableValue($pagea, $revision_handle);
1269                 $revision_handle = false;
1270                 $bval = $col->_getSortableValue($pageb, $revision_handle);
1271
1272                 $cmp = $col->_compare($aval, $bval);
1273                 if ($direction === "-")  // Reverse the sense of the comparison
1274                     $cmp *= -1;
1275
1276                 if ($cmp !== 0)
1277                     // This is the first comparison that is not equal-- go with it
1278                     return $cmp;
1279             }
1280             return 0;
1281         }
1282     }
1283
1284     /**
1285      * Put pages in order according to the sortby arg, if given
1286      * If the sortby cols are already sorted by the DB call, don't do usort.
1287      * TODO: optimize for multiple sortable cols
1288      */
1289     function _sortPages() {
1290         if (count($this->_sortby) > 0) {
1291             $need_sort = $this->_options['dosort'];
1292             if (!$need_sort)
1293               foreach ($this->_sortby as $col => $dir) {
1294                 if (! $this->sortby($col, 'db'))
1295                     $need_sort = true;
1296               }
1297             if ($need_sort) { // There are some columns to sort by
1298                 // TODO: consider nopage
1299                 usort($this->_pages, array($this, '_pageCompare'));
1300             }
1301         }
1302         //unset($GLOBALS['PhpWiki_pagelist']);
1303     }
1304
1305     function limit($limit) {
1306         if (is_array($limit)) return $limit;
1307         if (strstr($limit, ','))
1308             return split(',', $limit);
1309         else
1310             return array(0, $limit);
1311     }
1312
1313     function pagingTokens($numrows = false, $ncolumns = false, $limit = false) {
1314         if ($numrows === false)
1315             $numrows = $this->getTotal();
1316         if ($limit === false)
1317             $limit = $this->_options['limit'];
1318         if ($ncolumns === false)
1319             $ncolumns = count($this->_columns);
1320
1321         list($offset, $pagesize) = $this->limit($limit);
1322         if (!$pagesize or
1323             (!$offset and $numrows < $pagesize) or
1324             (($offset + $pagesize) < 0))
1325             return false;
1326
1327         $request = &$GLOBALS['request'];
1328         $pagename = $request->getArg('pagename');
1329         $defargs = array_merge(array('id' => $this->id), $request->args);
1330         if (USE_PATH_INFO) unset($defargs['pagename']);
1331         if ($defargs['action'] == 'browse') unset($defargs['action']);
1332         $prev = $defargs;
1333
1334         $tokens = array();
1335         $tokens['PREV'] = false; $tokens['PREV_LINK'] = "";
1336         $tokens['COLS'] = $ncolumns;
1337         $tokens['COUNT'] = $numrows; 
1338         $tokens['OFFSET'] = $offset; 
1339         $tokens['SIZE'] = $pagesize;
1340         $tokens['NUMPAGES'] = (int) ceil($numrows / $pagesize);
1341         $tokens['ACTPAGE'] = (int) (($offset+1) / $pagesize)+1;
1342         if ($offset > 0) {
1343             $prev['limit'] = max(0, $offset - $pagesize) . ",$pagesize";
1344             $prev['count'] = $numrows;
1345             $tokens['LIMIT'] = $prev['limit'];
1346             $tokens['PREV'] = true;
1347             $tokens['PREV_LINK'] = WikiURL($pagename, $prev);
1348             $prev['limit'] = "0,$pagesize";
1349             $tokens['FIRST_LINK'] = WikiURL($pagename, $prev);
1350         }
1351         $next = $defargs;
1352         $tokens['NEXT'] = false; $tokens['NEXT_LINK'] = "";
1353         if (($offset + $pagesize) < $numrows) {
1354             $next['limit'] = min($offset + $pagesize, $numrows - $pagesize) . ",$pagesize";
1355             $next['count'] = $numrows;
1356             $tokens['LIMIT'] = $next['limit'];
1357             $tokens['NEXT'] = true;
1358             $tokens['NEXT_LINK'] = WikiURL($pagename, $next);
1359             $next['limit'] = $numrows - $pagesize . ",$pagesize";
1360             $tokens['LAST_LINK'] = WikiURL($pagename, $next);
1361         }
1362         return $tokens;
1363     }
1364     
1365     // make a table given the caption
1366     function _generateTable($caption) {
1367         if (count($this->_sortby) > 0) $this->_sortPages();
1368         
1369         // wikiadminutils hack. that's a way to pagelist non-pages
1370         $rows = isset($this->_rows) ? $this->_rows : array(); $i = 0;
1371         $count = $this->getTotal();
1372         $do_paging = ( isset($this->_options['paging']) 
1373                        and !empty($this->_options['limit']) 
1374                        and $count 
1375                        and $this->_options['paging'] != 'none' );
1376         if ($do_paging) {
1377             $tokens = $this->pagingTokens($count, 
1378                                            count($this->_columns), 
1379                                            $this->_options['limit']);
1380             if ($tokens)                               
1381                 $this->_pages = array_slice($this->_pages, $tokens['OFFSET'], $tokens['COUNT']);
1382         }
1383         foreach ($this->_pages as $pagenum => $page) {
1384             $rows[] = $this->_renderPageRow($page, $i++);
1385         }
1386         $table = HTML::table(array('cellpadding' => 0,
1387                                    'cellspacing' => 1,
1388                                    'border'      => 0,
1389                                    'class'       => 'pagelist', 
1390                                    ));
1391         if ($caption) {
1392             $table->pushContent(HTML::caption(array('align'=>'top'), $caption));
1393             $table->setAttr('width', '100%');
1394         }
1395
1396         //Warning: This is quite fragile. It depends solely on a private variable
1397         //         in ->_addColumn()
1398         if (!empty($this->_columns_seen['checkbox'])) {
1399             $table->pushContent($this->_jsFlipAll());
1400         }
1401
1402         $row = HTML::tr();
1403         $table_summary = array();
1404         $i = 1; // start with 1!
1405         foreach ($this->_columns as $col) {
1406             $heading = $col->button_heading($this, $i);
1407             if ( $do_paging 
1408                  and isset($col->_field) 
1409                  and $col->_field == 'pagename' 
1410                  and ($maxlen = $this->maxLen())) {
1411                $heading->setAttr('width', $maxlen * 7);
1412             }
1413             $row->pushContent($heading);
1414             if (is_string($col->getHeading()))
1415                 $table_summary[] = $col->getHeading();
1416             $i++;
1417         }
1418         // Table summary for non-visual browsers.
1419         $table->setAttr('summary', sprintf(_("Columns: %s."), 
1420                                            join(", ", $table_summary)));
1421         $table->pushContent(HTML::colgroup(array('span' => count($this->_columns))));
1422         if ( $do_paging ) {
1423             if ($tokens === false) {
1424                 $table->pushContent(HTML::thead($row),
1425                                     HTML::tbody(false, $rows));
1426                 return $table;
1427             }
1428
1429             $paging = Template("pagelink", $tokens);
1430             if ($this->_options['paging'] != 'bottom')
1431                 $table->pushContent(HTML::thead($paging));
1432             if ($this->_options['paging'] != 'top')
1433                 $table->pushContent(HTML::tfoot($paging));
1434             $table->pushContent(HTML::tbody(false, HTML($row, $rows)));
1435             return $table;
1436         } else {
1437             $table->pushContent(HTML::thead($row),
1438                                 HTML::tbody(false, $rows));
1439             return $table;
1440         }
1441     }
1442
1443     function _jsFlipAll() {
1444       return JavaScript("
1445 function flipAll(formObj) {
1446   var isFirstSet = -1;
1447   for (var i=0; i < formObj.length; i++) {
1448       fldObj = formObj.elements[i];
1449       if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,2) == 'p[')) { 
1450          if (isFirstSet == -1)
1451            isFirstSet = (fldObj.checked) ? true : false;
1452          fldObj.checked = (isFirstSet) ? false : true;
1453        }
1454    }
1455 }");
1456     }
1457
1458     /* recursive stack for private sublist options (azhead, cols) */
1459     function _saveOptions($opts) {
1460         $stack = array('pages' => $this->_pages);
1461         foreach ($opts as $k => $v) {
1462             $stack[$k] = $this->_options[$k];
1463             $this->_options[$k] = $v;
1464         }
1465         if (empty($this->_stack))
1466             $this->_stack = new Stack();
1467         $this->_stack->push($stack);
1468     }
1469     function _restoreOptions() {
1470         assert($this->_stack);
1471         $stack = $this->_stack->pop();
1472         $this->_pages = $stack['pages'];
1473         unset($stack['pages']);
1474         foreach ($stack as $k => $v) {
1475             $this->_options[$k] = $v;
1476         }
1477     }
1478
1479     // 'cols'   - split into several columns
1480     // 'azhead' - support <h3> grouping into initials
1481     // 'ordered' - OL or UL list (not yet inherited to all plugins)
1482     // 'comma'  - condensed comma-list only, 1: no links, >1: with links
1483     // FIXME: only unique list entries, esp. with nopage
1484     function _generateList($caption='') {
1485         if (empty($this->_pages)) return; // stop recursion
1486         if (!isset($this->_options['listtype'])) 
1487             $this->_options['listtype'] = '';
1488         $out = HTML();
1489         if ($caption)
1490             $out->pushContent(HTML::p($caption));
1491         // Semantic Search et al: only unique list entries, esp. with nopage
1492         if (!is_array($this->_pages[0]) and is_string($this->_pages[0])) {
1493             $this->_pages = array_unique($this->_pages);
1494         }
1495         if (count($this->_sortby) > 0) $this->_sortPages();
1496         $count = $this->getTotal();
1497         $do_paging = ( isset($this->_options['paging']) 
1498                        and !empty($this->_options['limit']) 
1499                        and $count 
1500                        and $this->_options['paging'] != 'none' );
1501         if ( $do_paging ) {
1502             $tokens = $this->pagingTokens($count, 
1503                                           count($this->_columns), 
1504                                           $this->_options['limit']);
1505             if ($tokens) {
1506                 $paging = Template("pagelink", $tokens);
1507                 $out->pushContent(HTML::table(array('width'=>'50%'), $paging));
1508             }
1509         }
1510
1511         // need a recursive switch here for the azhead and cols grouping.
1512         if (!empty($this->_options['cols']) and $this->_options['cols'] > 1) {
1513             $count = count($this->_pages);
1514             $length = $count / $this->_options['cols'];
1515             $width = sprintf("%d", 100 / $this->_options['cols']).'%';
1516             $cols = HTML::tr(array('valign' => 'top'));
1517             for ($i=0; $i < $count; $i += $length) {
1518                 $this->_saveOptions(array('cols' => 0, 'paging' => 'none'));
1519                 $this->_pages = array_slice($this->_pages, $i, $length);
1520                 $cols->pushContent(HTML::td(/*array('width' => $width),*/ 
1521                                             $this->_generateList()));
1522                 $this->_restoreOptions();
1523             }
1524             // speed up table rendering by defining colgroups
1525             $out->pushContent(HTML::table(HTML::colgroup(array('span' => $this->_options['cols'],
1526                                                                'width' => $width)),
1527                                           $cols));
1528             return $out;
1529         }
1530         
1531         // Ignore azhead if not sorted by pagename
1532         if (!empty($this->_options['azhead']) 
1533             and strstr($this->sortby($this->_options['sortby'], 'init'), "pagename")
1534             )
1535         {
1536             $cur_h = substr($this->_pages[0]->getName(), 0, 1);
1537             $out->pushContent(HTML::h3($cur_h));
1538             // group those pages together with same $h
1539             $j = 0;
1540             for ($i=0; $i < count($this->_pages); $i++) {
1541                 $page =& $this->_pages[$i];
1542                 $h = substr($page->getName(), 0, 1);
1543                 if ($h != $cur_h and $i > $j) {
1544                     $this->_saveOptions(array('cols' => 0, 'azhead' => 0));
1545                     $this->_pages = array_slice($this->_pages, $j, $i - $j);
1546                     $out->pushContent($this->_generateList());
1547                     $this->_restoreOptions();
1548                     $j = $i;
1549                     $out->pushContent(HTML::h3($h));
1550                     $cur_h = $h;
1551                 }
1552             }
1553             if ($i > $j) { // flush the rest
1554                 $this->_saveOptions(array('cols' => 0, 'azhead' => 0));
1555                 $this->_pages = array_slice($this->_pages, $j, $i - $j);
1556                 $out->pushContent($this->_generateList());
1557                 $this->_restoreOptions();
1558             }
1559             return $out;
1560         }
1561             
1562         if ($this->_options['listtype'] == 'comma')
1563             $this->_options['comma'] = 2;
1564         if (!empty($this->_options['comma'])) {
1565             if ($this->_options['comma'] == 1)
1566                 $out->pushContent($this->_generateCommaListAsString());
1567             else
1568                 $out->pushContent($this->_generateCommaList($this->_options['comma']));
1569             return $out;
1570         }
1571
1572         if ($this->_options['listtype'] == 'ol')
1573             $this->_options['ordered'] = 1;
1574         elseif ($this->_options['listtype'] == 'ul')
1575             $this->_options['ordered'] = 0;
1576         if (!empty($this->_options['ordered']))
1577             $list = HTML::ol(array('class' => 'pagelist'));
1578         elseif ($this->_options['listtype'] == 'dl') {
1579             $list = HTML::dl(array('class' => 'pagelist'));
1580         } else {
1581             $list = HTML::ul(array('class' => 'pagelist'));
1582         }
1583         $i = 0;
1584         //TODO: currently we ignore limit here and hope that the backend didn't ignore it. (BackLinks)
1585         if (!empty($this->_options['limit']))
1586             list($offset, $pagesize) = $this->limit($this->_options['limit']);
1587         else 
1588             $pagesize=0;
1589         foreach ($this->_pages as $pagenum => $page) {
1590             $pagehtml = $this->_renderPageRow($page);
1591             if (!$pagehtml) continue;
1592             $group = ($i++ / $this->_group_rows);
1593             //TODO: here we switch every row, in tables every third. 
1594             //      unification or parametrized?
1595             $class = ($group % 2) ? 'oddrow' : 'evenrow';
1596             if ($this->_options['listtype'] == 'dl') {
1597                 $header = WikiLink($page);
1598                 //if ($this->_sortby['hi_content']) 
1599                 $list->pushContent(HTML::dt(array('class' => $class), $header),
1600                                    HTML::dd(array('class' => $class), $pagehtml));
1601             } else
1602                 $list->pushContent(HTML::li(array('class' => $class), $pagehtml));
1603             if ($pagesize and $i > $pagesize) break;
1604         }
1605         $out->pushContent($list);
1606         if ( $do_paging and $tokens ) {
1607             $out->pushContent(HTML::table($paging));
1608         }
1609         return $out;
1610     }
1611
1612     // comma=1
1613     // Condense list without a href links: "Page1, Page2, ..." 
1614     // Alternative $seperator = HTML::Raw(' &middot; ')
1615     // FIXME: only unique list entries, esp. with nopage
1616     function _generateCommaListAsString() {
1617         if (defined($this->_options['commasep']))
1618             $seperator = $this->_options['commasep'];
1619         else    
1620             $seperator = ', ';
1621         $pages = array();
1622         foreach ($this->_pages as $pagenum => $page) {
1623             if ($s = $this->_renderPageRow($page)) // some pages are not viewable
1624                 $pages[] = is_string($s) ? $s : $s->asString();
1625         }
1626         return HTML(join($seperator, $pages));
1627     }
1628
1629     // comma=2
1630     // Normal WikiLink list.
1631     // Future: 1 = reserved for plain string (see above)
1632     //         2 and more => HTML link specialization?
1633     // FIXME: only unique list entries, esp. with nopage
1634     function _generateCommaList($style = false) {
1635         if (defined($this->_options['commasep']))
1636             $seperator = HTLM::Raw($this->_options['commasep']);
1637         else    
1638             $seperator = ', ';
1639         $html = HTML();
1640         $html->pushContent($this->_renderPageRow($this->_pages[0]));
1641         next($this->_pages);
1642         foreach ($this->_pages as $pagenum => $page) {
1643             if ($s = $this->_renderPageRow($page)) // some pages are not viewable
1644                 $html->pushContent($seperator, $s);
1645         }
1646         return $html;
1647     }
1648     
1649     function _emptyList($caption) {
1650         $html = HTML();
1651         if ($caption)
1652             $html->pushContent(HTML::p($caption));
1653         if ($this->_messageIfEmpty)
1654             $html->pushContent(HTML::blockquote(HTML::p($this->_messageIfEmpty)));
1655         return $html;
1656     }
1657
1658 };
1659
1660 /* List pages with checkboxes to select from.
1661  * The [Select] button toggles via _jsFlipAll
1662  */
1663
1664 class PageList_Selectable
1665 extends PageList {
1666
1667     function PageList_Selectable ($columns=false, $exclude='', $options = false) {
1668         if ($columns) {
1669             if (!is_array($columns))
1670                 $columns = explode(',', $columns);
1671             if (!in_array('checkbox',$columns))
1672                 array_unshift($columns,'checkbox');
1673         } else {
1674             $columns = array('checkbox','pagename');
1675         }
1676         $this->PageList($columns, $exclude, $options);
1677     }
1678
1679     function addPageList ($array) {
1680         while (list($pagename,$selected) = each($array)) {
1681             if ($selected) $this->addPageSelected((string)$pagename);
1682             $this->addPage((string)$pagename);
1683         }
1684     }
1685
1686     function addPageSelected ($pagename) {
1687         $this->_selected[$pagename] = 1;
1688     }
1689 }
1690
1691 // $Log: not supported by cvs2svn $
1692 // Revision 1.151  2008/02/14 18:42:53  rurban
1693 // ref to a class does not work with php-4, add ratingvalue
1694 //
1695 // Revision 1.150  2008/01/31 20:28:47  vargenau
1696 // Valid HTML code: tfoot must be before tbody
1697 //
1698 // Revision 1.149  2008/01/26 14:13:29  vargenau
1699 // XHTML is case-sensitive; use correct case
1700 //
1701 // Revision 1.148  2007/09/19 18:00:49  rurban
1702 // enable "^A or ^B" pages argument for PageLists: e.g. large htmldump-s
1703 //
1704 // Revision 1.147  2007/09/15 12:26:25  rurban
1705 // add explodePageList comments
1706 //
1707 // Revision 1.146  2007/09/12 19:33:29  rurban
1708 // allow array to be exploded (comma problem)
1709 //
1710 // Revision 1.145  2007/08/25 17:58:14  rurban
1711 // more limit fixes: limit earlier, fix COUNT slice
1712 //
1713 // Revision 1.143  2007/07/14 12:03:19  rurban
1714 // support listtype=dl and ranked search
1715 //
1716 // Revision 1.142  2007/07/01 09:09:19  rurban
1717 // fix PageList with multiple lists: added id, fixed sortby REQUEST logic
1718 //
1719 // Revision 1.141  2007/05/24 18:40:55  rurban
1720 // display list with tokens problem
1721 //
1722 // Revision 1.140  2007/05/13 18:12:55  rurban
1723 // force adding a options[type] column: fixes LinkDatabase
1724 //
1725 // Revision 1.139  2007/01/25 07:42:01  rurban
1726 // Support nopage
1727 //
1728 // Revision 1.138  2007/01/20 11:24:15  rurban
1729 // Support paging limit if ->_pages is not yet limited by the backend (AllPagesByMe)
1730 //
1731 // Revision 1.137  2007/01/07 18:43:08  rurban
1732 // Honor predefined ->_rows: hack to (re-)allow non-pagenames, used by WikiAdminUtils
1733 //
1734 // Revision 1.136  2007/01/02 13:18:46  rurban
1735 // 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.
1736 //
1737 // Revision 1.135  2005/09/14 05:59:03  rurban
1738 // optimized explodePageList to use SQL when available
1739 //   (titleSearch instead of getAllPages)
1740 //
1741 // Revision 1.134  2005/09/11 14:55:05  rurban
1742 // implement fulltext stoplist
1743 //
1744 // Revision 1.133  2005/08/27 09:41:37  rurban
1745 // new helper method
1746 //
1747 // Revision 1.132  2005/04/09 09:16:15  rurban
1748 // fix recursive PageList azhead+cols listing
1749 //
1750 // Revision 1.131  2005/02/04 10:48:06  rurban
1751 // fix usort ref warning. Thanks to Charles Corrigan
1752 //
1753 // Revision 1.130  2005/01/28 12:07:36  rurban
1754 // reformatting
1755 //
1756 // Revision 1.129  2005/01/25 06:58:21  rurban
1757 // reformatting
1758 //
1759 // Revision 1.128  2004/12/26 17:31:35  rurban
1760 // fixed prev link logic
1761 //
1762 // Revision 1.127  2004/12/26 17:19:28  rurban
1763 // dont break sideeffecting sortby flips on paging urls (MostPopular)
1764 //
1765 // Revision 1.126  2004/12/16 18:26:57  rurban
1766 // Avoid double calculation
1767 //
1768 // Revision 1.125  2004/11/25 17:20:49  rurban
1769 // and again a couple of more native db args: backlinks
1770 //
1771 // Revision 1.124  2004/11/23 15:17:14  rurban
1772 // better support for case_exact search (not caseexact for consistency),
1773 // plugin args simplification:
1774 //   handle and explode exclude and pages argument in WikiPlugin::getArgs
1775 //     and exclude in advance (at the sql level if possible)
1776 //   handle sortby and limit from request override in WikiPlugin::getArgs
1777 // ListSubpages: renamed pages to maxpages
1778 //
1779 // Revision 1.123  2004/11/23 13:35:31  rurban
1780 // add case_exact search
1781 //
1782 // Revision 1.122  2004/11/21 11:59:15  rurban
1783 // remove final \n to be ob_cache independent
1784 //
1785 // Revision 1.121  2004/11/20 17:35:47  rurban
1786 // improved WantedPages SQL backends
1787 // PageList::sortby new 3rd arg valid_fields (override db fields)
1788 // WantedPages sql pager inexact for performance reasons:
1789 //   assume 3 wantedfrom per page, to be correct, no getTotal()
1790 // support exclude argument for get_all_pages, new _sql_set()
1791 //
1792 // Revision 1.120  2004/11/20 11:28:49  rurban
1793 // fix a yet unused PageList customPageListColumns bug (merge class not decl to _types)
1794 // change WantedPages to use PageList
1795 // change WantedPages to print the list of referenced pages, not just the count.
1796 //   the old version was renamed to WantedPagesOld
1797 //   fix and add handling of most standard PageList arguments (limit, exclude, ...)
1798 // TODO: pagename sorting, dumb/WantedPagesIter and SQL optimization
1799 //
1800 // Revision 1.119  2004/11/11 14:34:11  rurban
1801 // minor clarifications
1802 //
1803 // Revision 1.118  2004/11/01 10:43:55  rurban
1804 // seperate PassUser methods into seperate dir (memory usage)
1805 // fix WikiUser (old) overlarge data session
1806 // remove wikidb arg from various page class methods, use global ->_dbi instead
1807 // ...
1808 //
1809 // Revision 1.117  2004/10/14 21:06:01  rurban
1810 // fix dumphtml with USE_PATH_INFO (again). fix some PageList refs
1811 //
1812 // Revision 1.116  2004/10/14 19:19:33  rurban
1813 // loadsave: check if the dumped file will be accessible from outside.
1814 // and some other minor fixes. (cvsclient native not yet ready)
1815 //
1816 // Revision 1.115  2004/10/14 17:15:05  rurban
1817 // remove class _PageList_Page, fix sortby=0 (start with 1, use strings), fix _PageList_Column_content for old phps, hits as int
1818 //
1819 // Revision 1.114  2004/10/12 13:13:19  rurban
1820 // php5 compatibility (5.0.1 ok)
1821 //
1822 // Revision 1.113  2004/10/05 17:00:03  rurban
1823 // support paging for simple lists
1824 // fix RatingDb sql backend.
1825 // remove pages from AllPages (this is ListPages then)
1826 //
1827 // Revision 1.112  2004/10/04 23:39:58  rurban
1828 // list of page objects
1829 //
1830 // Revision 1.111  2004/09/24 18:50:45  rurban
1831 // fix paging of SqlResult
1832 //
1833 // Revision 1.110  2004/09/17 14:43:31  rurban
1834 // typo
1835 //
1836 // Revision 1.109  2004/09/17 14:22:10  rurban
1837 // update comments
1838 //
1839 // Revision 1.108  2004/09/17 12:46:22  rurban
1840 // seperate pagingTokens()
1841 // support new default args: comma (1 and 2), commasep, ordered, cols,
1842 //                           azhead (1 only)
1843 //
1844 // Revision 1.107  2004/09/14 10:29:08  rurban
1845 // exclude pages already in addPages to simplify plugins
1846 //
1847 // Revision 1.106  2004/09/06 10:22:14  rurban
1848 // oops, forgot global request
1849 //
1850 // Revision 1.105  2004/09/06 08:38:30  rurban
1851 // modularize paging helper (for SqlResult)
1852 //
1853 // Revision 1.104  2004/08/18 11:01:55  rurban
1854 // fixed checkbox list Select button:
1855 //   no GET request on click,
1856 //   only select the list checkbox entries, no other options.
1857 //
1858 // Revision 1.103  2004/07/09 10:06:49  rurban
1859 // Use backend specific sortby and sortable_columns method, to be able to
1860 // select between native (Db backend) and custom (PageList) sorting.
1861 // Fixed PageList::AddPageList (missed the first)
1862 // Added the author/creator.. name to AllPagesBy...
1863 //   display no pages if none matched.
1864 // Improved dba and file sortby().
1865 // Use &$request reference
1866 //
1867 // Revision 1.102  2004/07/08 21:32:35  rurban
1868 // Prevent from more warnings, minor db and sort optimizations
1869 //
1870 // Revision 1.101  2004/07/08 19:04:41  rurban
1871 // more unittest fixes (file backend, metadata RatingsDb)
1872 //
1873 // Revision 1.100  2004/07/07 15:02:26  dfrankow
1874 // Take out if that prevents column sorting
1875 //
1876 // Revision 1.99  2004/07/02 18:49:02  dfrankow
1877 // Change one line so that if addPageList() is passed null, it is still
1878 // okay.  The unit tests do this (ask to list AllUsers where there are no
1879 // users, or something like that).
1880 //
1881 // Revision 1.98  2004/07/01 08:51:22  rurban
1882 // dumphtml: added exclude, print pagename before processing
1883 //
1884 // Revision 1.97  2004/06/29 09:11:10  rurban
1885 // More memory optimization:
1886 //   don't cache unneeded _cached_html and %content for content and size columns
1887 //   (only if sortable, which will fail for too many pages)
1888 //
1889 // Revision 1.96  2004/06/29 08:47:42  rurban
1890 // Memory optimization (reference to parent, smart bool %content)
1891 // Fixed class grouping in table
1892 //
1893 // Revision 1.95  2004/06/28 19:00:01  rurban
1894 // removed non-portable LIMIT 1 (it's getOne anyway)
1895 // removed size from info=most: needs to much memory
1896 //
1897 // Revision 1.94  2004/06/27 10:26:02  rurban
1898 // oci8 patch by Philippe Vanhaesendonck + some ADODB notes+fixes
1899 //
1900 // Revision 1.93  2004/06/25 14:29:17  rurban
1901 // WikiGroup refactoring:
1902 //   global group attached to user, code for not_current user.
1903 //   improved helpers for special groups (avoid double invocations)
1904 // new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write())
1905 // fixed a XHTML validation error on userprefs.tmpl
1906 //
1907 // Revision 1.92  2004/06/21 17:01:39  rurban
1908 // fix typo and rating method call
1909 //
1910 // Revision 1.91  2004/06/21 16:22:29  rurban
1911 // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps,
1912 // fixed dumping buttons locally (images/buttons/),
1913 // support pages arg for dumphtml,
1914 // optional directory arg for dumpserial + dumphtml,
1915 // fix a AllPages warning,
1916 // show dump warnings/errors on DEBUG,
1917 // don't warn just ignore on wikilens pagelist columns, if not loaded.
1918 // RateIt pagelist column is called "rating", not "ratingwidget" (Dan?)
1919 //
1920 // Revision 1.90  2004/06/18 14:38:21  rurban
1921 // adopt new PageList style
1922 //
1923 // Revision 1.89  2004/06/17 13:16:08  rurban
1924 // apply wikilens work to PageList: all columns are sortable (slightly fixed)
1925 //
1926 // Revision 1.88  2004/06/14 11:31:35  rurban
1927 // renamed global $Theme to $WikiTheme (gforge nameclash)
1928 // inherit PageList default options from PageList
1929 //   default sortby=pagename
1930 // use options in PageList_Selectable (limit, sortby, ...)
1931 // added action revert, with button at action=diff
1932 // added option regex to WikiAdminSearchReplace
1933 //
1934 // Revision 1.87  2004/06/13 16:02:12  rurban
1935 // empty list of pages if user=[] and not authenticated.
1936 //
1937 // Revision 1.86  2004/06/13 15:51:37  rurban
1938 // Support pagelist filter for current author,owner,creator by []
1939 //
1940 // Revision 1.85  2004/06/13 15:33:19  rurban
1941 // new support for arguments owner, author, creator in most relevant
1942 // PageList plugins. in WikiAdmin* via preSelectS()
1943 //
1944 // Revision 1.84  2004/06/08 13:51:56  rurban
1945 // some comments only
1946 //
1947 // Revision 1.83  2004/05/18 13:35:39  rurban
1948 //  improve Pagelist layout by equal pagename width for limited lists
1949 //
1950 // Revision 1.82  2004/05/16 22:07:35  rurban
1951 // check more config-default and predefined constants
1952 // various PagePerm fixes:
1953 //   fix default PagePerms, esp. edit and view for Bogo and Password users
1954 //   implemented Creator and Owner
1955 //   BOGOUSERS renamed to BOGOUSER
1956 // fixed syntax errors in signin.tmpl
1957 //
1958 // Revision 1.81  2004/05/13 12:30:35  rurban
1959 // fix for MacOSX border CSS attr, and if sort buttons are not found
1960 //
1961 // Revision 1.80  2004/04/20 00:56:00  rurban
1962 // more paging support and paging fix for shorter lists
1963 //
1964 // Revision 1.79  2004/04/20 00:34:16  rurban
1965 // more paging support
1966 //
1967 // Revision 1.78  2004/04/20 00:06:03  rurban
1968 // themable paging support
1969 //
1970 // Revision 1.77  2004/04/18 01:11:51  rurban
1971 // more numeric pagename fixes.
1972 // fixed action=upload with merge conflict warnings.
1973 // charset changed from constant to global (dynamic utf-8 switching)
1974 //
1975
1976 // (c-file-style: "gnu")
1977 // Local Variables:
1978 // mode: php
1979 // tab-width: 8
1980 // c-basic-offset: 4
1981 // c-hanging-comment-ender-p: nil
1982 // indent-tabs-mode: nil
1983 // End:
1984 ?>