]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/PageList.php
Use backend specific sortby and sortable_columns method, to be able to
[SourceForge/phpwiki.git] / lib / PageList.php
1 <?php rcs_id('$Id: PageList.php,v 1.103 2004-07-09 10:06:49 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  *
53  * TODO: 
54  *   rows arguments for multiple pages/multiple rows.
55  *
56  *   ->supportedArgs() which arguments are supported, so that the plugin 
57  *                     doesn't explictly need to declare it 
58  *   Status: already merged in some plugins calls
59  *
60  *   new method:
61  *     list not as <ul> or table, but as simple comma-seperated list
62  *
63  *   fix memory exhaustion on large pagelists. 
64  *   Status: fixed 2004-06-25 16:19:36 rurban but needs further testing.
65  */
66 class _PageList_Column_base {
67     var $_tdattr = array();
68
69     function _PageList_Column_base ($default_heading, $align = false) {
70         $this->_heading = $default_heading;
71
72         if ($align) {
73             // align="char" isn't supported by any browsers yet :(
74             //if (is_array($align))
75             //    $this->_tdattr = $align;
76             //else
77             $this->_tdattr['align'] = $align;
78         }
79     }
80
81     function format ($pagelist, $page_handle, &$revision_handle) {
82         return HTML::td($this->_tdattr,
83                         HTML::raw('&nbsp;'),
84                         $this->_getValue($page_handle, $revision_handle),
85                         HTML::raw('&nbsp;'));
86     }
87
88     function getHeading () {
89         return $this->_heading;
90     }
91
92     function setHeading ($heading) {
93         $this->_heading = $heading;
94     }
95
96     // old-style heading
97     function heading () {
98         // allow sorting?
99         if (1 /* or in_array($this->_field, PageList::sortable_columns())*/) {
100             // multiple comma-delimited sortby args: "+hits,+pagename"
101             // asc or desc: +pagename, -pagename
102             $sortby = PageList::sortby($this->_field, 'flip_order');
103             //Fixme: pass all also other GET args along. (limit, p[])
104             //TODO: support GET and POST
105             $s = HTML::a(array('href' => 
106                                $GLOBALS['request']->GetURLtoSelf(array('sortby' => $sortby,
107                                                                        'nocache' => '1')),
108                                'class' => 'pagetitle',
109                                'title' => sprintf(_("Sort by %s"), $this->_field)), 
110                          HTML::raw('&nbsp;'), HTML::u($this->_heading), HTML::raw('&nbsp;'));
111         } else {
112             $s = HTML(HTML::raw('&nbsp;'), HTML::u($this->_heading), HTML::raw('&nbsp;'));
113         }
114         return HTML::th(array('align' => 'center'),$s);
115     }
116
117     // new grid-style
118     // see activeui.js 
119     function button_heading ($pagelist, $colNum) {
120         global $WikiTheme, $request;
121         // allow sorting?
122         if (1 /* or in_array($this->_field, PageList::sortable_columns()) */) {
123             // multiple comma-delimited sortby args: "+hits,+pagename"
124             $src = false; 
125             $noimg_src = $WikiTheme->getButtonURL('no_order');
126             if ($noimg_src)
127                 $noimg = HTML::img(array('src' => $noimg_src,
128                                          'width' => '7', 
129                                          'height' => '7',
130                                          'border' => 0,
131                                          'alt'    => '.'));
132             else 
133                 $noimg = HTML::raw('&nbsp;');
134             if ($request->getArg('sortby')) {
135                 if ($pagelist->sortby($colNum, 'check')) { // show icon?
136                     $sortby = $pagelist->sortby($request->getArg('sortby'), 'flip_order');
137                     $request->setArg('sortby', $sortby);
138                     $desc = (substr($sortby,0,1) == '-'); // asc or desc? (+pagename, -pagename)
139                     $src = $WikiTheme->getButtonURL($desc ? 'asc_order' : 'desc_order');
140                 } else {
141                     $sortby = $pagelist->sortby($colNum, 'init');
142                 }
143             } else {
144                 $sortby = $pagelist->sortby($colNum, 'init');
145             }
146             if (!$src) {
147                 $img = $noimg;
148                 //$img->setAttr('alt', _("Click to sort"));
149             } else {
150                 $img = HTML::img(array('src' => $src, 
151                                        'width' => '7', 
152                                        'height' => '7', 
153                                        'border' => 0,
154                                        'alt' => _("Click to reverse sort order")));
155             }
156             $s = HTML::a(array('href' => 
157                                //Fixme: pass all also other GET args along. (limit, p[])
158                                //Fixme: convert to POST submit[sortby]
159                                $request->GetURLtoSelf(array('sortby' => $sortby,
160                                                             'nocache' => '1')),
161                                'class' => 'gridbutton', 
162                                'title' => sprintf(_("Click to sort by %s"), $this->_field)),
163                          HTML::raw('&nbsp;'),
164                          $noimg,
165                          HTML::raw('&nbsp;'),
166                          $this->_heading,
167                          HTML::raw('&nbsp;'),
168                          $img,
169                          HTML::raw('&nbsp;'));
170         } else {
171             $s = HTML(HTML::raw('&nbsp;'), $this->_heading, HTML::raw('&nbsp;'));
172         }
173         return HTML::th(array('align' => 'center', 'valign' => 'middle', 
174                               'class' => 'gridbutton'), $s);
175     }
176
177     /**
178      * Take two columns of this type and compare them.
179      * An undefined value is defined to be < than the smallest defined value.
180      * This base class _compare only works if the value is simple (e.g., a number).
181      *
182      * @param  $colvala  $this->_getValue() of column a
183      * @param  $colvalb  $this->_getValue() of column b
184      *
185      * @return -1 if $a < $b, 1 if $a > $b, 0 otherwise.
186      */
187     function _compare($colvala, $colvalb) {
188         if (is_string($colvala))
189             return strcmp($colvala,$colvalb);
190         $ret = 0;
191         if (($colvala === $colvalb) || (!isset($colvala) && !isset($colvalb))) {
192             ;
193         } else {
194             $ret = (!isset($colvala) || ($colvala < $colvalb)) ? -1 : 1;
195         }
196         return $ret; 
197     }
198 };
199
200 class _PageList_Column extends _PageList_Column_base {
201     function _PageList_Column ($field, $default_heading, $align = false) {
202         $this->_PageList_Column_base($default_heading, $align);
203
204         $this->_need_rev = substr($field, 0, 4) == 'rev:';
205         $this->_iscustom = substr($field, 0, 7) == 'custom:';
206         if ($this->_iscustom) {
207             $this->_field = substr($field, 7);
208         }
209         elseif ($this->_need_rev)
210             $this->_field = substr($field, 4);
211         else
212             $this->_field = $field;
213     }
214
215     function _getValue ($page_handle, &$revision_handle) {
216         if ($this->_need_rev) {
217             if (!$revision_handle)
218                 // columns which need the %content should override this. (size, hi_content)
219                 $revision_handle = $page_handle->getCurrentRevision(false);
220             return $revision_handle->get($this->_field);
221         }
222         else {
223             return $page_handle->get($this->_field);
224         }
225     }
226     
227     function _getSortableValue ($page_handle, &$revision_handle) {
228         return _PageList_Column::_getValue($page_handle, $revision_handle);
229     }
230 };
231
232 /* overcome a call_user_func limitation by not being able to do:
233  * call_user_func_array(array(&$class, $class_name), $params);
234  * So we need $class = new $classname($params);
235  * And we add a 4th param for the parent $pagelist object
236  */
237 class _PageList_Column_custom extends _PageList_Column {
238     function _PageList_Column_custom($params) {
239         $this->_pagelist =& $params[3];
240         $this->_PageList_Column($params[0], $params[1], $params[2]);
241     }
242 }
243
244 class _PageList_Column_size extends _PageList_Column {
245     function format (&$pagelist, $page_handle, &$revision_handle) {
246         return HTML::td($this->_tdattr,
247                         HTML::raw('&nbsp;'),
248                         $this->_getValue($pagelist, $page_handle, $revision_handle),
249                         HTML::raw('&nbsp;'));
250     }
251     
252     function _getValue (&$pagelist, $page_handle, &$revision_handle) {
253         if (!$revision_handle or (!$revision_handle->_data['%content'] 
254                                   or $revision_handle->_data['%content'] === true)) {
255             $revision_handle = $page_handle->getCurrentRevision(true);
256             unset($revision_handle->_data['%pagedata']['_cached_html']);
257         }
258         $size = $this->_getSize($revision_handle);
259         // we can safely purge the content when it is not sortable
260         if (empty($pagelist->_sortby[$this->_field]))
261             unset($revision_handle->_data['%content']);
262         return $size;
263     }
264     
265     function _getSortableValue ($page_handle, &$revision_handle) {
266         if (!$revision_handle)
267             $revision_handle = $page_handle->getCurrentRevision(true);
268         return (empty($revision_handle->_data['%content'])) 
269                ? 0 : strlen($revision_handle->_data['%content']);
270     }
271
272     function _getSize($revision_handle) {
273         $bytes = @strlen($revision_handle->_data['%content']);
274         return ByteFormatter($bytes);
275     }
276 }
277
278
279 class _PageList_Column_bool extends _PageList_Column {
280     function _PageList_Column_bool ($field, $default_heading, $text = 'yes') {
281         $this->_PageList_Column($field, $default_heading, 'center');
282         $this->_textIfTrue = $text;
283         $this->_textIfFalse = new RawXml('&#8212;'); //mdash
284     }
285
286     function _getValue ($page_handle, &$revision_handle) {
287         //FIXME: check if $this is available in the parent (->need_rev)
288         $val = _PageList_Column::_getValue($page_handle, $revision_handle);
289         return $val ? $this->_textIfTrue : $this->_textIfFalse;
290     }
291 };
292
293 class _PageList_Column_checkbox extends _PageList_Column {
294     function _PageList_Column_checkbox ($field, $default_heading, $name='p') {
295         $this->_name = $name;
296         $heading = HTML::input(array('type'  => 'button',
297                                      'title' => _("Click to de-/select all pages"),
298                                      //'width' => '100%',
299                                      'name'  => $default_heading,
300                                      'value' => $default_heading,
301                                      'onclick' => "flipAll(this.form)"
302                                      ));
303         $this->_PageList_Column($field, $heading, 'center');
304     }
305     function _getValue ($pagelist, $page_handle, &$revision_handle) {
306         $pagename = $page_handle->getName();
307         $selected = !empty($pagelist->_selected[$pagename]);
308         if (strstr($pagename,'[') or strstr($pagename,']')) {
309             $pagename = str_replace(array('[',']'),array('%5B','%5D'),$pagename);
310         }
311         if ($selected) {
312             return HTML::input(array('type' => 'checkbox',
313                                      'name' => $this->_name . "[$pagename]",
314                                      'value' => 1,
315                                      'checked' => 'CHECKED'));
316         } else {
317             return HTML::input(array('type' => 'checkbox',
318                                      'name' => $this->_name . "[$pagename]",
319                                      'value' => 1));
320         }
321     }
322     function format ($pagelist, $page_handle, &$revision_handle) {
323         return HTML::td($this->_tdattr,
324                         HTML::raw('&nbsp;'),
325                         $this->_getValue($pagelist, $page_handle, $revision_handle),
326                         HTML::raw('&nbsp;'));
327     }
328 };
329
330 class _PageList_Column_time extends _PageList_Column {
331     function _PageList_Column_time ($field, $default_heading) {
332         $this->_PageList_Column($field, $default_heading, 'right');
333         global $WikiTheme;
334         $this->Theme = &$WikiTheme;
335     }
336
337     function _getValue ($page_handle, &$revision_handle) {
338         $time = _PageList_Column::_getValue($page_handle, $revision_handle);
339         return $this->Theme->formatDateTime($time);
340     }
341 };
342
343 class _PageList_Column_version extends _PageList_Column {
344     function _getValue ($page_handle, &$revision_handle) {
345         if (!$revision_handle)
346             $revision_handle = $page_handle->getCurrentRevision();
347         return $revision_handle->getVersion();
348     }
349 };
350
351 // Output is hardcoded to limit of first 50 bytes. Otherwise
352 // on very large Wikis this will fail if used with AllPages
353 // (PHP memory limit exceeded)
354 // FIXME: old PHP without superglobals
355 class _PageList_Column_content extends _PageList_Column {
356     function _PageList_Column_content ($field, $default_heading, $align = false) {
357         $this->_PageList_Column($field, $default_heading, $align);
358         $this->bytes = 50;
359         if ($field == 'content') {
360             $this->_heading .= sprintf(_(" ... first %d bytes"),
361                                        $this->bytes);
362         } elseif ($field == 'hi_content') {
363             if (!empty($_POST['admin_replace'])) {
364                 $search = $_POST['admin_replace']['from'];
365                 $this->_heading .= sprintf(_(" ... around %s"),
366                                            '»'.$search.'«');
367             }
368         }
369     }
370     
371     function _getValue ($page_handle, &$revision_handle) {
372         if (!$revision_handle or (!$revision_handle->_data['%content'] 
373                                   or $revision_handle->_data['%content'] === true)) {
374             $revision_handle = $page_handle->getCurrentRevision(true);
375         }
376         // Not sure why implode is needed here, I thought
377         // getContent() already did this, but it seems necessary.
378         $c = implode("\n", $revision_handle->getContent());
379         if (empty($pagelist->_sortby[$this->_field]))
380             unset($revision_handle->_data['%content']);
381         if ($this->_field == 'hi_content') {
382             unset($revision_handle->_data['%pagedata']['_cached_html']);
383             $search = $_POST['admin_replace']['from'];
384             if ($search and ($i = strpos($c,$search))) {
385                 $l = strlen($search);
386                 $j = max(0,$i - ($this->bytes / 2));
387                 return HTML::div(array('style' => 'font-size:x-small'),
388                                  HTML::div(array('class' => 'transclusion'),
389                                            HTML::span(substr($c, $j, ($this->bytes / 2))),
390                                            HTML::span(array("style"=>"background:yellow"),$search),
391                                            HTML::span(substr($c, $i+$l, ($this->bytes / 2))))
392                                  );
393             } else {
394                 $c = sprintf(_("%s not found"),
395                              '»'.$search.'«');
396                 return HTML::div(array('style' => 'font-size:x-small','align'=>'center'),
397                                  $c);
398             }
399         } elseif (($len = strlen($c)) > $this->bytes) {
400             $c = substr($c, 0, $this->bytes);
401         }
402         include_once('lib/BlockParser.php');
403         // false --> don't bother processing hrefs for embedded WikiLinks
404         $ct = TransformText($c, $revision_handle->get('markup'), false);
405         if (empty($pagelist->_sortby[$this->_field]))
406             unset($revision_handle->_data['%pagedata']['_cached_html']);
407         return HTML::div(array('style' => 'font-size:x-small'),
408                          HTML::div(array('class' => 'transclusion'), $ct),
409                          // Don't show bytes here if size column present too
410                          ($this->parent->_columns_seen['size'] or !$len) ? "" :
411                            ByteFormatter($len, /*$longformat = */true));
412     }
413     
414     function _getSortableValue ($page_handle, &$revision_handle) {
415         return substr(_PageList_Column::_getValue($page_handle, $revision_handle),0,50);
416     }
417 };
418
419 class _PageList_Column_author extends _PageList_Column {
420     function _PageList_Column_author ($field, $default_heading, $align = false) {
421         _PageList_Column::_PageList_Column($field, $default_heading, $align);
422         $this->dbi =& $GLOBALS['request']->getDbh();
423     }
424
425     function _getValue ($page_handle, &$revision_handle) {
426         $author = _PageList_Column::_getValue($page_handle, $revision_handle);
427         if (isWikiWord($author) && $this->dbi->isWikiPage($author))
428             return WikiLink($author);
429         else
430             return $author;
431     }
432 };
433
434 class _PageList_Column_owner extends _PageList_Column_author {
435     function _getValue ($page_handle, &$revision_handle) {
436         $author = $page_handle->getOwner();
437         if (isWikiWord($author) && $this->dbi->isWikiPage($author))
438             return WikiLink($author);
439         else
440             return $author;
441     }
442 };
443
444 class _PageList_Column_creator extends _PageList_Column_author {
445     function _getValue ($page_handle, &$revision_handle) {
446         $author = $page_handle->getCreator();
447         if (isWikiWord($author) && $this->dbi->isWikiPage($author))
448             return WikiLink($author);
449         else
450             return $author;
451     }
452 };
453
454 class _PageList_Column_pagename extends _PageList_Column_base {
455     var $_field = 'pagename';
456
457     function _PageList_Column_pagename () {
458         $this->_PageList_Column_base(_("Page Name"));
459         global $request;
460         $this->dbi = &$request->getDbh();
461     }
462
463     function _getValue ($page_handle, &$revision_handle) {
464         if ($this->dbi->isWikiPage($page_handle->getName()))
465             return WikiLink($page_handle);
466         else
467             return WikiLink($page_handle, 'unknown');
468     }
469     
470     function _getSortableValue ($page_handle, &$revision_handle) {
471         return $page_handle->getName();
472     }
473
474     /**
475      * Compare two pagenames for sorting.  See _PageList_Column::_compare.
476      **/
477     function _compare($colvala, $colvalb) {
478         return strcmp($colvala, $colvalb);
479     }
480 };
481
482 /**
483  * A class to bundle up a page with a reference to PageList, so that
484  * the compare function for usort() has access to it all.
485  * This is a hack necessitated by the interface to usort()-- comparators
486  * can't get information upon construction; you get a comparator by class
487  * name, not by instance.
488  * @author: Dan Frankowski
489  */
490 class _PageList_Page {
491     var $_pagelist;
492     var $_page;
493
494     function _PageList_Page(&$pagelist, &$page_handle) {
495         $this->_pagelist = $pagelist;
496         $this->_page = $page_handle;
497     }
498
499     function & getPageList() {
500         return $this->_pagelist;
501     }
502
503     function & getPage() {
504         return $this->_page;
505     }
506 }
507
508 class PageList {
509     var $_group_rows = 3;
510     var $_columns = array();
511     var $_columnsMap = array();      // Maps column name to column number.
512     var $_excluded_pages = array();
513     var $_pages = array();
514     var $_caption = "";
515     var $_pagename_seen = false;
516     var $_types = array();
517     var $_options = array();
518     var $_selected = array();
519     var $_sortby = array();
520     var $_maxlen = 0;
521
522     function PageList ($columns = false, $exclude = false, $options = false) {
523         if ($options)
524             $this->_options = $options;
525
526         // let plugins predefine only certain objects, such its own custom pagelist columns
527         if (!empty($this->_options['types'])) {
528             $this->_types = $this->_options['types'];
529             unset($this->_options['types']);
530         }
531         $this->_initAvailableColumns();
532         $symbolic_columns = 
533             array(
534                   'all' =>  array_diff(array_keys($this->_types), // all but...
535                                        array('checkbox','remove','renamed_pagename',
536                                              'content','hi_content','perm','acl')),
537                   'most' => array('pagename','mtime','author','hits'),
538                   'some' => array('pagename','mtime','author')
539                   );
540         if ($columns) {
541             if (!is_array($columns))
542                 $columns = explode(',', $columns);
543             // expand symbolic columns:
544             foreach ($symbolic_columns as $symbol => $cols) {
545                 if (in_array($symbol,$columns)) { // e.g. 'checkbox,all'
546                     $columns = array_diff(array_merge($columns,$cols),array($symbol));
547                 }
548             }
549             if (!in_array('pagename',$columns))
550                 $this->_addColumn('pagename');
551             foreach ($columns as $col) {
552                 $this->_addColumn($col);
553             }
554         }
555         // If 'pagename' is already present, _addColumn() will not add it again
556         $this->_addColumn('pagename');
557
558         foreach (array('sortby','limit','paging','count') as $key) {
559           if (!empty($options) and !empty($options[$key])) {
560             $this->_options[$key] = $options[$key];
561           } else {
562             $this->_options[$key] = $GLOBALS['request']->getArg($key);
563           }
564         }
565         $this->_options['sortby'] = $this->sortby($this->_options['sortby'], 'init');
566         if ($exclude) {
567             if (!is_array($exclude))
568                 $exclude = $this->explodePageList($exclude, false,
569                                                   $this->_options['sortby'],
570                                                   $this->_options['limit']);
571             $this->_excluded_pages = $exclude;
572         }
573         $this->_messageIfEmpty = _("<no matches>");
574     }
575
576     // Currently PageList takes these arguments:
577     // 1: info, 2: exclude, 3: hash of options
578     // Here we declare which options are supported, so that 
579     // the calling plugin may simply merge this with its own default arguments 
580     function supportedArgs () {
581         return array(//Currently supported options:
582                      'info'     => 'pagename',
583                      'exclude'  => '',          // also wildcards and comma-seperated lists
584
585                      /* select pages by meta-data: */
586                      'author'   => false, // current user by []
587                      'owner'    => false, // current user by []
588                      'creator'  => false, // current user by []
589
590                      // for the sort buttons in <th>
591                      'sortby'   => '', // same as for WikiDB::getAllPages (unsorted is faster)
592
593                      //PageList pager options:
594                      // These options may also be given to _generate(List|Table) later
595                      // But limit and offset might help the query WikiDB::getAllPages()
596                      'cols'     => 1,       // side-by-side display of list (1-3)
597                      'limit'    => 0,       // number of rows (pagesize)
598                      'paging'   => 'auto',  // 'auto'  normal paging mode
599                      //                     // 'smart' drop 'info' columns and enhance rows 
600                      //                     //         when the list becomes large
601                      //                     // 'none'  don't page at all
602                      //'azhead' => 0        // provide shortcut links to pages starting with different letters
603                      );
604     }
605
606     function setCaption ($caption_string) {
607         $this->_caption = $caption_string;
608     }
609
610     function getCaption () {
611         // put the total into the caption if needed
612         if (is_string($this->_caption) && strstr($this->_caption, '%d'))
613             return sprintf($this->_caption, $this->getTotal());
614         return $this->_caption;
615     }
616
617     function setMessageIfEmpty ($msg) {
618         $this->_messageIfEmpty = $msg;
619     }
620
621
622     function getTotal () {
623         return !empty($this->_options['count'])
624                ? (integer) $this->_options['count'] : count($this->_pages);
625     }
626
627     function isEmpty () {
628         return empty($this->_pages);
629     }
630
631     function addPage($page_handle) {
632         $this->_pages[] = new _PageList_Page($this, $page_handle);
633     }
634
635     function _getPageFromHandle($ph) {
636         $page_handle = $ph;
637         if (is_string($page_handle)) {
638             if (empty($page_handle)) return $page_handle;
639             $dbi = $GLOBALS['request']->getDbh();
640             $page_handle = $dbi->getPage($page_handle);
641         }
642         return $page_handle;
643     }
644
645     /**
646      * Take a PageList_Page object, and return an HTML object to display
647      * it in a table or list row.
648      */
649     function _renderPageRow ($pagelist_page, $i = 0) {
650         $page_handle = $pagelist_page->getPage();
651
652         $page_handle = $this->_getPageFromHandle($page_handle);
653         if (!isset($page_handle) || empty($page_handle)
654             || in_array($page_handle->getName(), $this->_excluded_pages))
655             return; // exclude page.
656             
657         //FIXME. only on sf.net
658         if (!is_object($page_handle)) {
659             trigger_error("PageList: Invalid page_handle $page_handle", E_USER_WARNING);
660             return;
661         }
662         // enforce view permission
663         if (!mayAccessPage('view', $page_handle->getName()))
664             return;
665
666         $group = (int)($i / $this->_group_rows);
667         $class = ($group % 2) ? 'oddrow' : 'evenrow';
668         $revision_handle = false;
669         $this->_maxlen = max($this->_maxlen, strlen($page_handle->getName()));
670
671         if (count($this->_columns) > 1) {
672             $row = HTML::tr(array('class' => $class));
673             foreach ($this->_columns as $col)
674                 $row->pushContent($col->format($this, $page_handle, $revision_handle));
675         }
676         else {
677             $col = $this->_columns[0];
678             $row = $col->_getValue($page_handle, $revision_handle);
679         }
680
681         return $row;
682     }
683
684     function addPages ($page_iter) {
685         //Todo: if limit check max(strlen(pagename))
686         while ($page = $page_iter->next()) {
687             $this->addPage($page);
688         }
689     }
690
691     function addPageList (&$list) {
692         if (empty($list)) return;  // Protect reset from a null arg
693         foreach ($list as $page) {
694             $this->addPage((string)$page);
695         }
696     }
697
698     function maxLen() {
699         global $request;
700         $dbi =& $request->getDbh();
701         if (isa($dbi,'WikiDB_SQL')) {
702             extract($dbi->_backend->_table_names);
703             $res = $dbi->_backend->_dbh->getOne("SELECT max(length(pagename)) FROM $page_tbl");
704             if (DB::isError($res) || empty($res)) return false;
705             else return $res;
706         } elseif (isa($dbi,'WikiDB_ADODB')) {
707             extract($dbi->_backend->_table_names);
708             $row = $dbi->_backend->_dbh->getRow("SELECT max(length(pagename)) FROM $page_tbl");
709             return $row ? $row[0] : false;
710         } else 
711             return false;
712     }
713
714     function getContent() {
715         // Note that the <caption> element wants inline content.
716         $caption = $this->getCaption();
717
718         if ($this->isEmpty())
719             return $this->_emptyList($caption);
720         elseif (count($this->_columns) == 1)
721             return $this->_generateList($caption);
722         else
723             return $this->_generateTable($caption);
724     }
725
726     function printXML() {
727         PrintXML($this->getContent());
728     }
729
730     function asXML() {
731         return AsXML($this->getContent());
732     }
733     
734     /** Now all columns are sortable. 
735      *  These are the colums which have native WikiDB backend methods.
736      *  FIXME: use this method at the db backends
737      */
738     //function sortable_columns() {
739     //    return array('pagename','mtime','hits');
740     //}
741
742     /** 
743      * Handle sortby requests for the DB iterator and table header links.
744      * Prefix the column with + or - like "+pagename","-mtime", ...
745      * supported actions: 'flip_order' "mtime" => "+mtime" => "-mtime" ...
746      *                    'db'         "-pagename" => "pagename DESC"
747      * Now all columns are sortable. (patch by DanFr)
748      */
749     function sortby ($column, $action) {
750         if (empty($column)) return '';
751         //support multiple comma-delimited sortby args: "+hits,+pagename"
752         if (strstr($column,',')) {
753             $result = array();
754             foreach (explode(',',$column) as $col) {
755                 $result[] = $this->sortby($col,$action);
756             }
757             return join(",",$result);
758         }
759         if (substr($column,0,1) == '+') {
760             $order = '+'; $column = substr($column,1);
761         } elseif (substr($column,0,1) == '-') {
762             $order = '-'; $column = substr($column,1);
763         }
764         // default order: +pagename, -mtime, -hits
765         if (empty($order))
766             if (in_array($column,array('mtime','hits')))
767                 $order = '-';
768             else
769                 $order = '+';
770         if ($action == 'flip_order') {
771             return ($order == '+' ? '-' : '+') . $column;
772         } elseif ($action == 'init') {
773             $this->_sortby[$column] = $order;
774             return $order . $column;
775         } elseif ($action == 'check') {
776             return (!empty($this->_sortby[$column]) or 
777                     ($GLOBALS['request']->getArg('sortby') and 
778                      strstr($GLOBALS['request']->getArg('sortby'),$column)));
779         } elseif ($action == 'db') {
780             // native sort possible?
781             $sortable_columns = $GLOBALS['request']->_dbi->_backend->sortable_columns();
782             /*
783             if (method_exists($this,'sortable_columns'))
784                 $sortable_columns = $this->sortable_columns();
785             else
786                 $sortable_columns = PageList::sortable_columns();
787             */
788             if (in_array($column, $sortable_columns))
789                 // asc or desc: +pagename, -pagename
790                 return $column . ($order == '+' ? ' ASC' : ' DESC');
791             else 
792                 return '';
793         }
794         return '';
795     }
796
797     // echo implode(":",explodeList("Test*",array("xx","Test1","Test2")));
798     function explodePageList($input, $include_empty = false, $sortby=false, $limit=false) {
799         // expand wildcards from list of all pages
800         if (preg_match('/[\?\*]/',$input)) {
801             $dbi = $GLOBALS['request']->getDbh();
802             $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit);
803             while ($pagehandle = $allPagehandles->next()) {
804                 $allPages[] = $pagehandle->getName();
805             }
806             return explodeList($input, $allPages);
807         } else {
808             //TODO: do the sorting, normally not needed if used for exclude only
809             return explode(',',$input);
810         }
811     }
812
813     function allPagesByAuthor(&$wildcard, $include_empty=false, $sortby=false, $limit=false) {
814         $dbi = $GLOBALS['request']->getDbh();
815         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit);
816         $allPages = array();
817         if ($wildcard === '[]') {
818             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
819             if (!$wildcard) return $allPages;
820         }
821         $do_glob = preg_match('/[\?\*]/', $wildcard);
822         while ($pagehandle = $allPagehandles->next()) {
823             $name = $pagehandle->getName();
824             $author = $pagehandle->getAuthor();
825             if ($author) {
826                 if ($do_glob) {
827                     if (glob_match($wildcard, $author))
828                         $allPages[] = $name;
829                 } elseif ($wildcard == $author) {
830                       $allPages[] = $name;
831                 }
832             }
833             // TODO: purge versiondata_cache
834         }
835         return $allPages;
836     }
837
838     function allPagesByOwner(&$wildcard, $include_empty=false, $sortby=false, $limit=false) {
839         $dbi = $GLOBALS['request']->getDbh();
840         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit);
841         $allPages = array();
842         if ($wildcard === '[]') {
843             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
844             if (!$wildcard) return $allPages;
845         }
846         $do_glob = preg_match('/[\?\*]/', $wildcard);
847         while ($pagehandle = $allPagehandles->next()) {
848             $name = $pagehandle->getName();
849             $owner = $pagehandle->getOwner();
850             if ($owner) {
851                 if ($do_glob) {
852                     if (glob_match($wildcard, $owner))
853                         $allPages[] = $name;
854                 } elseif ($wildcard == $owner) {
855                       $allPages[] = $name;
856                 }
857             }
858         }
859         return $allPages;
860     }
861
862     function allPagesByCreator(&$wildcard, $include_empty=false, $sortby=false, $limit=false) {
863         $dbi = $GLOBALS['request']->getDbh();
864         $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit);
865         $allPages = array();
866         if ($wildcard === '[]') {
867             $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
868             if (!$wildcard) return $allPages;
869         }
870         $do_glob = preg_match('/[\?\*]/', $wildcard);
871         while ($pagehandle = $allPagehandles->next()) {
872             $name = $pagehandle->getName();
873             $creator = $pagehandle->getCreator();
874             if ($creator) {
875                 if ($do_glob) {
876                     if (glob_match($wildcard, $creator))
877                         $allPages[] = $name;
878                 } elseif ($wildcard == $creator) {
879                       $allPages[] = $name;
880                 }
881             }
882         }
883         return $allPages;
884     }
885
886     ////////////////////
887     // private
888     ////////////////////
889     /** Plugin and theme hooks: 
890      *  If the pageList is initialized with $options['types'] these types are also initialized, 
891      *  overriding the standard types.
892      */
893     function _initAvailableColumns() {
894         global $customPageListColumns;
895         $standard_types =
896             array(
897                   'content'
898                   => new _PageList_Column_content('rev:content', _("Content")),
899                   // new: plugin specific column types initialised by the relevant plugins
900                   /*
901                   'hi_content' // with highlighted search for SearchReplace
902                   => new _PageList_Column_content('rev:hi_content', _("Content")),
903                   'remove'
904                   => new _PageList_Column_remove('remove', _("Remove")),
905                   // initialised by the plugin
906                   'renamed_pagename'
907                   => new _PageList_Column_renamed_pagename('rename', _("Rename to")),
908                   'perm'
909                   => new _PageList_Column_perm('perm', _("Permission")),
910                   'acl'
911                   => new _PageList_Column_acl('acl', _("ACL")),
912                   */
913                   'checkbox'
914                   => new _PageList_Column_checkbox('p', _("Select")),
915                   'pagename'
916                   => new _PageList_Column_pagename,
917                   'mtime'
918                   => new _PageList_Column_time('rev:mtime', _("Last Modified")),
919                   'hits'
920                   => new _PageList_Column('hits', _("Hits"), 'right'),
921                   'size'
922                   => new _PageList_Column_size('rev:size', _("Size"), 'right'),
923                                               /*array('align' => 'char', 'char' => ' ')*/
924                   'summary'
925                   => new _PageList_Column('rev:summary', _("Last Summary")),
926                   'version'
927                   => new _PageList_Column_version('rev:version', _("Version"),
928                                                  'right'),
929                   'author'
930                   => new _PageList_Column_author('rev:author', _("Last Author")),
931                   'owner'
932                   => new _PageList_Column_owner('author_id', _("Owner")),
933                   'creator'
934                   => new _PageList_Column_creator('author_id', _("Creator")),
935                   /*
936                   'group'
937                   => new _PageList_Column_author('group', _("Group")),
938                   */
939                   'locked'
940                   => new _PageList_Column_bool('locked', _("Locked"),
941                                                _("locked")),
942                   'minor'
943                   => new _PageList_Column_bool('rev:is_minor_edit',
944                                                _("Minor Edit"), _("minor")),
945                   'markup'
946                   => new _PageList_Column('rev:markup', _("Markup")),
947                   // 'rating' initialised by the wikilens theme hook: addPageListColumn
948                   /*
949                   'rating'
950                   => new _PageList_Column_rating('rating', _("Rate")),
951                   */
952                   );
953         if (empty($this->_types))
954             $this->_types = array();
955         // add plugin specific pageList columns, initialized by $options['types']
956         $this->_types = array_merge($standard_types, $this->_types);
957         // add theme custom specific pageList columns: 
958         //   set the 4th param as the current pagelist object.
959         if (!empty($customPageListColumns)) {
960             foreach ($customPageListColumns as $column => $params) {
961                 $class_name = array_shift($params);
962                 $params[3] =& $this;
963                 $class = new $class_name($params);
964             }
965             $this->_types = array_merge($this->_types, $customPageListColumns);
966         }
967     }
968
969     function getOption($option) {
970         if (array_key_exists($option, $this->_options)) {
971             return $this->_options[$option];
972         }
973         else {
974             return null;
975         }
976     }
977
978     /**
979      * Add a column to this PageList, given a column name.
980      * The name is a type, and optionally has a : and a label. Examples:
981      *
982      *   pagename
983      *   pagename:This page
984      *   mtime
985      *   mtime:Last modified
986      *
987      * If this function is called multiple times for the same type, the
988      * column will only be added the first time, and ignored the succeeding times.
989      * If you wish to add multiple columns of the same type, use addColumnObject().
990      *
991      * @param column name
992      * @return  true if column is added, false otherwise
993      */
994     function _addColumn ($column) {
995         
996         if (isset($this->_columns_seen[$column]))
997             return false;       // Already have this one.
998         if (!isset($this->_types[$column]))
999             $this->_initAvailableColumns();
1000         $this->_columns_seen[$column] = true;
1001
1002         if (strstr($column, ':'))
1003             list ($column, $heading) = explode(':', $column, 2);
1004
1005         if (!isset($this->_types[$column])) {
1006             $silently_ignore = array('numbacklinks','rating','coagreement','minmisery',
1007                                      'averagerating','top3recs');
1008             if (!in_array($column,$silently_ignore))
1009                 trigger_error(sprintf("%s: Bad column", $column), E_USER_NOTICE);
1010             return false;
1011         }
1012         if ($column == 'ratingwidget' and !$GLOBALS['request']->_user->isSignedIn())
1013             return false;
1014
1015         $this->addColumnObject($this->_types[$column]);
1016
1017         return true;
1018     }
1019
1020     /**
1021      * Add a column to this PageList, given a column object.
1022      *
1023      * @param $col object   An object derived from _PageList_Column.
1024      **/
1025     function addColumnObject($col) {
1026         if (is_array($col)) {// custom column object
1027             $params =& $col;
1028             $class_name = array_shift($params);
1029             $params[3] =& $this;
1030             $col = new $class_name($params);
1031         }
1032         $heading = $col->getHeading();
1033         if (!empty($heading))
1034             $col->setHeading($heading);
1035
1036         $this->_columns[] = $col;
1037         $this->_columnsMap[$col->_field] = count($this->_columns)-1;
1038     }
1039
1040     /**
1041      * Compare _PageList_Page objects.
1042      **/
1043     function _pageCompare($a, $b) {
1044         $pagelist =& $a->_pagelist;
1045         $pagea = $a->getPage();
1046         $pageb = $b->getPage();
1047         if (count($pagelist->_sortby) == 0) {
1048             // No columns to sort by
1049             return 0;
1050         }
1051         else {
1052             foreach ($pagelist->_sortby as $colNum => $direction) {
1053                 $colkey = $colNum;
1054                 if (!is_int($colkey)) { // or column fieldname
1055                     $colkey = $pagelist->_columnsMap[$colNum];
1056                 }
1057                 $col = $pagelist->_columns[$colkey];
1058
1059                 $revision_handle = false;
1060                 $pagea = PageList::_getPageFromHandle($pagea);  // If a string, convert to page
1061                 assert(isa($pagea, 'WikiDB_Page'));
1062                 assert(isset($col));
1063                 $aval = $col->_getSortableValue($pagea, $revision_handle);
1064                 $pageb = PageList::_getPageFromHandle($pageb);  // If a string, convert to page
1065                 
1066                 $revision_handle = false;
1067                 assert(isa($pageb, 'WikiDB_Page'));
1068                 $bval = $col->_getSortableValue($pageb, $revision_handle);
1069
1070                 $cmp = $col->_compare($aval, $bval);
1071                 if ($direction === "-") {
1072                     // Reverse the sense of the comparison
1073                     $cmp *= -1;
1074                 }
1075
1076                 if ($cmp !== 0) {
1077                     // This is the first comparison that is not equal-- go with it
1078                     return $cmp;
1079                 }
1080             }
1081             return 0;
1082         }
1083     }
1084
1085     /**
1086      * Put pages in order according to the sortby arg, if given
1087      */
1088     function _sortPages() {
1089         //TODO: if the sortby cols are already sorted by the DB call don't do usort.
1090         if (count($this->_sortby) > 0) {
1091             $need_sort = 0;
1092             foreach ($this->_sortby as $col) {
1093                 if (!$this->sortby($col, 'db'))
1094                     $need_sort = 1;
1095             }
1096             if ($need_sort) {
1097                 // There are columns to sort by
1098                 usort($this->_pages, array('PageList', '_pageCompare'));
1099             }
1100         }        
1101     }
1102
1103     function limit($limit) {
1104         if (strstr($limit, ','))
1105             return split(',', $limit);
1106         else
1107             return array(0, $limit);
1108     }
1109     
1110     // make a table given the caption
1111     function _generateTable($caption) {
1112         if (count($this->_sortby) > 0) $this->_sortPages();
1113
1114         $rows = array(); $i = 0;
1115         foreach ($this->_pages as $pagenum => $page) {
1116             $rows[] = $this->_renderPageRow($page, $i++);
1117         }
1118
1119         $table = HTML::table(array('cellpadding' => 0,
1120                                    'cellspacing' => 1,
1121                                    'border'      => 0,
1122                                    'class'       => 'pagelist'));
1123         if ($caption)
1124             $table->pushContent(HTML::caption(array('align'=>'top'), $caption));
1125
1126         //Warning: This is quite fragile. It depends solely on a private variable
1127         //         in ->_addColumn()
1128         if (!empty($this->_columns_seen['checkbox'])) {
1129             $table->pushContent($this->_jsFlipAll());
1130         }
1131         $do_paging = ( isset($this->_options['paging']) and 
1132                        !empty($this->_options['limit']) and $this->getTotal() and
1133                        $this->_options['paging'] != 'none' );
1134         $row = HTML::tr();
1135         $table_summary = array();
1136         $i = 0;
1137         foreach ($this->_columns as $col) {
1138             $heading = $col->button_heading($this, $i);
1139             if ($do_paging and 
1140                 isset($col->_field) and $col->_field == 'pagename' and 
1141                 ($maxlen = $this->maxLen()))
1142                 $heading->setAttr('width',$maxlen * 7);
1143             $row->pushContent($heading);
1144             if (is_string($col->getHeading()))
1145                 $table_summary[] = $col->getHeading();
1146             $i++;
1147         }
1148         // Table summary for non-visual browsers.
1149         $table->setAttr('summary', sprintf(_("Columns: %s."), 
1150                                            implode(", ", $table_summary)));
1151
1152         if ( $do_paging ) {
1153             // if there are more pages than the limit, show a table-header, -footer
1154             list($offset,$pagesize) = $this->limit($this->_options['limit']);
1155             $numrows = $this->getTotal();
1156             if (!$pagesize or
1157                 (!$offset and $numrows <= $pagesize) or
1158                 ($offset + $pagesize < 0)) 
1159             {
1160                 $table->pushContent(HTML::thead($row),
1161                                     HTML::tbody(false, $rows));
1162                 return $table;
1163             }
1164             global $request;
1165             include_once('lib/Template.php');
1166
1167             $tokens = array();
1168             $pagename = $request->getArg('pagename');
1169             $defargs = $request->args;
1170             unset($defargs['pagename']); unset($defargs['action']);
1171             //$defargs['nocache'] = 1;
1172             $prev = $defargs;
1173             $tokens['PREV'] = false; $tokens['PREV_LINK'] = "";
1174             $tokens['COLS'] = count($this->_columns);
1175             $tokens['COUNT'] = $numrows; 
1176             $tokens['OFFSET'] = $offset; 
1177             $tokens['SIZE'] = $pagesize;
1178             $tokens['NUMPAGES'] = (int)($numrows / $pagesize)+1;
1179             $tokens['ACTPAGE'] = (int) (($offset+1) / $pagesize)+1;
1180             if ($offset > 0) {
1181                 $prev['limit'] = min(0,$offset - $pagesize) . ",$pagesize";
1182                 $prev['count'] = $numrows;
1183                 $tokens['LIMIT'] = $prev['limit'];
1184                 $tokens['PREV'] = true;
1185                 $tokens['PREV_LINK'] = WikiURL($pagename,$prev);
1186                 $prev['limit'] = "0,$pagesize";
1187                 $tokens['FIRST_LINK'] = WikiURL($pagename,$prev);
1188             }
1189             $next = $defargs;
1190             $tokens['NEXT'] = false; $tokens['NEXT_LINK'] = "";
1191             if ($offset + $pagesize < $numrows) {
1192                 $next['limit'] = min($offset + $pagesize,$numrows - $pagesize) . ",$pagesize";
1193                 $next['count'] = $numrows;
1194                 $tokens['LIMIT'] = $next['limit'];
1195                 $tokens['NEXT'] = true;
1196                 $tokens['NEXT_LINK'] = WikiURL($pagename,$next);
1197                 $next['limit'] = $numrows - $pagesize . ",$pagesize";
1198                 $tokens['LAST_LINK'] = WikiURL($pagename,$next);
1199             }
1200             $paging = new Template("pagelink", $request, $tokens);
1201             $table->pushContent(HTML::thead($paging),
1202                                 HTML::tbody(false, HTML($row, $rows)),
1203                                 HTML::tfoot($paging));
1204             return $table;
1205         }
1206         $table->pushContent(HTML::thead($row),
1207                             HTML::tbody(false, $rows));
1208         return $table;
1209     }
1210
1211     function _jsFlipAll() {
1212       return JavaScript("
1213 function flipAll(formObj) {
1214   var isFirstSet = -1;
1215   for (var i=0;i < formObj.length;i++) {
1216       fldObj = formObj.elements[i];
1217       if (fldObj.type == 'checkbox') { 
1218          if (isFirstSet == -1)
1219            isFirstSet = (fldObj.checked) ? true : false;
1220          fldObj.checked = (isFirstSet) ? false : true;
1221        }
1222    }
1223 }");
1224     }
1225
1226     function _generateList($caption) {
1227         $list = HTML::ul(array('class' => 'pagelist'));
1228         $i = 0;
1229         foreach ($this->_pages as $pagenum => $page) {
1230             $pagehtml = $this->_renderPageRow($page);
1231             $group = ($i++ / $this->_group_rows);
1232             $class = ($group % 2) ? 'oddrow' : 'evenrow';
1233             $list->pushContent(HTML::li(array('class' => $class),$pagehtml));
1234         }
1235         $out = HTML();
1236         //Warning: This is quite fragile. It depends solely on a private variable
1237         //         in ->_addColumn()
1238         // Questionable if its of use here anyway. This is a one-col pagename list only.
1239         //if (!empty($this->_columns_seen['checkbox'])) $out->pushContent($this->_jsFlipAll());
1240         if ($caption)
1241             $out->pushContent(HTML::p($caption));
1242         $out->pushContent($list);
1243         return $out;
1244     }
1245
1246     function _emptyList($caption) {
1247         $html = HTML();
1248         if ($caption)
1249             $html->pushContent(HTML::p($caption));
1250         if ($this->_messageIfEmpty)
1251             $html->pushContent(HTML::blockquote(HTML::p($this->_messageIfEmpty)));
1252         return $html;
1253     }
1254
1255     // Condense list: "Page1, Page2, ..." 
1256     // Alternative $seperator = HTML::Raw(' &middot; ')
1257     function _generateCommaList($seperator = ', ') {
1258         return HTML(join($seperator, $list));
1259     }
1260
1261 };
1262
1263 /* List pages with checkboxes to select from.
1264  * The [Select] button toggles via _jsFlipAll
1265  */
1266
1267 class PageList_Selectable
1268 extends PageList {
1269
1270     function PageList_Selectable ($columns=false, $exclude=false, $options = false) {
1271         if ($columns) {
1272             if (!is_array($columns))
1273                 $columns = explode(',', $columns);
1274             if (!in_array('checkbox',$columns))
1275                 array_unshift($columns,'checkbox');
1276         } else {
1277             $columns = array('checkbox','pagename');
1278         }
1279         $this->PageList($columns, $exclude, $options);
1280     }
1281
1282     function addPageList ($array) {
1283         while (list($pagename,$selected) = each($array)) {
1284             if ($selected) $this->addPageSelected((string)$pagename);
1285             $this->addPage((string)$pagename);
1286         }
1287     }
1288
1289     function addPageSelected ($pagename) {
1290         $this->_selected[$pagename] = 1;
1291     }
1292 }
1293
1294 // $Log: not supported by cvs2svn $
1295 // Revision 1.102  2004/07/08 21:32:35  rurban
1296 // Prevent from more warnings, minor db and sort optimizations
1297 //
1298 // Revision 1.101  2004/07/08 19:04:41  rurban
1299 // more unittest fixes (file backend, metadata RatingsDb)
1300 //
1301 // Revision 1.100  2004/07/07 15:02:26  dfrankow
1302 // Take out if that prevents column sorting
1303 //
1304 // Revision 1.99  2004/07/02 18:49:02  dfrankow
1305 // Change one line so that if addPageList() is passed null, it is still
1306 // okay.  The unit tests do this (ask to list AllUsers where there are no
1307 // users, or something like that).
1308 //
1309 // Revision 1.98  2004/07/01 08:51:22  rurban
1310 // dumphtml: added exclude, print pagename before processing
1311 //
1312 // Revision 1.97  2004/06/29 09:11:10  rurban
1313 // More memory optimization:
1314 //   don't cache unneeded _cached_html and %content for content and size columns
1315 //   (only if sortable, which will fail for too many pages)
1316 //
1317 // Revision 1.96  2004/06/29 08:47:42  rurban
1318 // Memory optimization (reference to parent, smart bool %content)
1319 // Fixed class grouping in table
1320 //
1321 // Revision 1.95  2004/06/28 19:00:01  rurban
1322 // removed non-portable LIMIT 1 (it's getOne anyway)
1323 // removed size from info=most: needs to much memory
1324 //
1325 // Revision 1.94  2004/06/27 10:26:02  rurban
1326 // oci8 patch by Philippe Vanhaesendonck + some ADODB notes+fixes
1327 //
1328 // Revision 1.93  2004/06/25 14:29:17  rurban
1329 // WikiGroup refactoring:
1330 //   global group attached to user, code for not_current user.
1331 //   improved helpers for special groups (avoid double invocations)
1332 // new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write())
1333 // fixed a XHTML validation error on userprefs.tmpl
1334 //
1335 // Revision 1.92  2004/06/21 17:01:39  rurban
1336 // fix typo and rating method call
1337 //
1338 // Revision 1.91  2004/06/21 16:22:29  rurban
1339 // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps,
1340 // fixed dumping buttons locally (images/buttons/),
1341 // support pages arg for dumphtml,
1342 // optional directory arg for dumpserial + dumphtml,
1343 // fix a AllPages warning,
1344 // show dump warnings/errors on DEBUG,
1345 // don't warn just ignore on wikilens pagelist columns, if not loaded.
1346 // RateIt pagelist column is called "rating", not "ratingwidget" (Dan?)
1347 //
1348 // Revision 1.90  2004/06/18 14:38:21  rurban
1349 // adopt new PageList style
1350 //
1351 // Revision 1.89  2004/06/17 13:16:08  rurban
1352 // apply wikilens work to PageList: all columns are sortable (slightly fixed)
1353 //
1354 // Revision 1.88  2004/06/14 11:31:35  rurban
1355 // renamed global $Theme to $WikiTheme (gforge nameclash)
1356 // inherit PageList default options from PageList
1357 //   default sortby=pagename
1358 // use options in PageList_Selectable (limit, sortby, ...)
1359 // added action revert, with button at action=diff
1360 // added option regex to WikiAdminSearchReplace
1361 //
1362 // Revision 1.87  2004/06/13 16:02:12  rurban
1363 // empty list of pages if user=[] and not authenticated.
1364 //
1365 // Revision 1.86  2004/06/13 15:51:37  rurban
1366 // Support pagelist filter for current author,owner,creator by []
1367 //
1368 // Revision 1.85  2004/06/13 15:33:19  rurban
1369 // new support for arguments owner, author, creator in most relevant
1370 // PageList plugins. in WikiAdmin* via preSelectS()
1371 //
1372 // Revision 1.84  2004/06/08 13:51:56  rurban
1373 // some comments only
1374 //
1375 // Revision 1.83  2004/05/18 13:35:39  rurban
1376 //  improve Pagelist layout by equal pagename width for limited lists
1377 //
1378 // Revision 1.82  2004/05/16 22:07:35  rurban
1379 // check more config-default and predefined constants
1380 // various PagePerm fixes:
1381 //   fix default PagePerms, esp. edit and view for Bogo and Password users
1382 //   implemented Creator and Owner
1383 //   BOGOUSERS renamed to BOGOUSER
1384 // fixed syntax errors in signin.tmpl
1385 //
1386 // Revision 1.81  2004/05/13 12:30:35  rurban
1387 // fix for MacOSX border CSS attr, and if sort buttons are not found
1388 //
1389 // Revision 1.80  2004/04/20 00:56:00  rurban
1390 // more paging support and paging fix for shorter lists
1391 //
1392 // Revision 1.79  2004/04/20 00:34:16  rurban
1393 // more paging support
1394 //
1395 // Revision 1.78  2004/04/20 00:06:03  rurban
1396 // themable paging support
1397 //
1398 // Revision 1.77  2004/04/18 01:11:51  rurban
1399 // more numeric pagename fixes.
1400 // fixed action=upload with merge conflict warnings.
1401 // charset changed from constant to global (dynamic utf-8 switching)
1402 //
1403
1404 // (c-file-style: "gnu")
1405 // Local Variables:
1406 // mode: php
1407 // tab-width: 8
1408 // c-basic-offset: 4
1409 // c-hanging-comment-ender-p: nil
1410 // indent-tabs-mode: nil
1411 // End:
1412 ?>