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