1 <?php rcs_id('$Id: PageList.php,v 1.72 2004-03-31 06:22:22 rurban Exp $');
4 * List a number of pagenames, optionally as table with various columns.
5 * This library relieves some work for these plugins:
7 * AllPages, BackLinks, LikePages, Mostpopular, TitleSearch and more
9 * It also allows dynamic expansion of those plugins to include more
10 * columns in their output.
12 * Column 'info=' arguments:
14 * 'pagename' _("Page Name")
15 * 'mtime' _("Last Modified")
17 * 'summary' _("Last Summary")
18 * 'version' _("Version")),
19 * 'author' _("Last Author")),
20 * 'locked' _("Locked"), _("locked")
21 * 'minor' _("Minor Edit"), _("minor")
22 * 'markup' _("Markup")
24 * 'owner' _("Owner"), //todo: implement this again for PagePerm
25 * 'group' _("Group"), //todo: implement this for PagePerm
26 * 'checkbox' A selectable checkbox appears at the left.
27 * Todo: move this admin action away, not really an info column
29 * Special, custom columns:
30 * 'remove' _("Remove")
31 * 'perm' _("Permission Mask")
33 * 'renamed_pagename' _("Rename to")
35 * 'custom' TODO: implement the above as custom columns.
36 * See plugin/WikiTranslation
38 * Symbolic 'info=' arguments:
39 * 'all' All columns except the special columns
40 * 'most' pagename, mtime, author, size, hits, ...
41 * 'some' pagename, mtime, author
43 * FIXME: In this refactoring I (Jeff) have un-implemented _ctime, _cauthor, and
44 * number-of-revision. Note the _ctime and _cauthor as they were implemented
45 * were somewhat flawed: revision 1 of a page doesn't have to exist in the
46 * database. If lots of revisions have been made to a page, it's more than likely
47 * that some older revisions (include revision 1) have been cleaned (deleted).
50 * check PagePerm "list" access-type
53 * limit, offset, rows arguments for multiple pages/multiple rows.
55 * ->supportedArgs() which arguments are supported, so that the plugin
56 * doesn't explictly need to declare it
58 * list not as <ul> or table, but as simple comma-seperated list
60 class _PageList_Column_base {
61 var $_tdattr = array();
63 function _PageList_Column_base ($default_heading, $align = false) {
64 $this->_heading = $default_heading;
67 // align="char" isn't supported by any browsers yet :(
68 //if (is_array($align))
69 // $this->_tdattr = $align;
71 $this->_tdattr['align'] = $align;
75 function format ($pagelist, $page_handle, &$revision_handle) {
76 return HTML::td($this->_tdattr,
78 $this->_getValue($page_handle, $revision_handle),
82 function setHeading ($heading) {
83 $this->_heading = $heading;
88 if (in_array($this->_field,PageList::sortable_columns())) {
89 // multiple comma-delimited sortby args: "+hits,+pagename"
90 // asc or desc: +pagename, -pagename
91 $sortby = PageList::sortby($this->_field,'flip_order');
92 //Fixme: pass all also other GET args along. (limit, p[])
93 $s = HTML::a(array('href' =>
94 $GLOBALS['request']->GetURLtoSelf(array('sortby' => $sortby,
96 'class' => 'pagetitle',
97 'title' => sprintf(_("Sort by %s"),$this->_field)),
98 HTML::raw(' '), HTML::u($this->_heading), HTML::raw(' '));
100 $s = HTML(HTML::raw(' '), HTML::u($this->_heading), HTML::raw(' '));
102 return HTML::th(array('align' => 'center'),$s);
107 function button_heading () {
108 global $Theme, $request;
110 if (in_array($this->_field,PageList::sortable_columns())) {
111 // multiple comma-delimited sortby args: "+hits,+pagename"
113 $noimg = HTML::img(array('src' => $Theme->getButtonURL('no_order'),
117 if ($request->getArg('sortby')) {
118 if (PageList::sortby($this->_field,'check')) { // show icon?
119 $sortby = PageList::sortby($request->getArg('sortby'),'flip_order');
120 $request->setArg('sortby',$sortby);
121 $desc = (substr($sortby,0,1) == '-'); // asc or desc? (+pagename, -pagename)
122 $src = $Theme->getButtonURL($desc ? 'asc_order' : 'desc_order');
124 $sortby = PageList::sortby($this->_field,'init');
127 $sortby = PageList::sortby($this->_field,'init');
131 $img->setAttr('alt', _("Click to sort"));
133 $img = HTML::img(array('src' => $src,
136 'alt' => _("Click to reverse sort order")));
138 $s = HTML::a(array('href' =>
139 //Fixme: pass all also other GET args along. (limit, p[])
140 //Fixme: convert to POST submit[sortby]
141 $request->GetURLtoSelf(array('sortby' => $sortby,
143 'class' => 'gridbutton',
144 'title' => sprintf(_("Click to sort by %s"),$this->_field)),
151 HTML::raw(' '));
153 $s = HTML(HTML::raw(' '), $this->_heading, HTML::raw(' '));
155 return HTML::th(array('align' => 'center', 'valign' => 'middle',
156 'class' => 'gridbutton'), $s);
160 class _PageList_Column extends _PageList_Column_base {
161 function _PageList_Column ($field, $default_heading, $align = false) {
162 $this->_PageList_Column_base($default_heading, $align);
164 $this->_need_rev = substr($field, 0, 4) == 'rev:';
165 $this->_iscustom = substr($field, 0, 7) == 'custom:';
166 if ($this->_iscustom)
167 $this->_field = substr($field, 7);
168 elseif ($this->_need_rev)
169 $this->_field = substr($field, 4);
171 $this->_field = $field;
174 function _getValue ($page_handle, &$revision_handle) {
175 if ($this->_need_rev) {
176 if (!$revision_handle)
177 $revision_handle = $page_handle->getCurrentRevision();
178 return $revision_handle->get($this->_field);
181 return $page_handle->get($this->_field);
186 class _PageList_Column_size extends _PageList_Column {
187 function _getValue ($page_handle, &$revision_handle) {
188 if (!$revision_handle)
189 $revision_handle = $page_handle->getCurrentRevision();
190 return $this->_getSize($revision_handle);
193 function _getSize($revision_handle) {
194 $bytes = @strlen($revision_handle->_data['%content']);
195 return ByteFormatter($bytes);
200 class _PageList_Column_bool extends _PageList_Column {
201 function _PageList_Column_bool ($field, $default_heading, $text = 'yes') {
202 $this->_PageList_Column($field, $default_heading, 'center');
203 $this->_textIfTrue = $text;
204 $this->_textIfFalse = new RawXml('—'); //mdash
207 function _getValue ($page_handle, &$revision_handle) {
208 $val = _PageList_Column::_getValue($page_handle, $revision_handle);
209 return $val ? $this->_textIfTrue : $this->_textIfFalse;
213 class _PageList_Column_checkbox extends _PageList_Column {
214 function _PageList_Column_checkbox ($field, $default_heading, $name='p') {
215 $this->_name = $name;
216 $heading = HTML::input(array('type' => 'button',
217 'title' => _("Click to de-/select all pages"),
219 'name' => $default_heading,
220 'value' => $default_heading,
221 'onclick' => "flipAll(this.form)"
223 $this->_PageList_Column($field, $heading, 'center');
225 function _getValue ($pagelist, $page_handle, &$revision_handle) {
226 $pagename = $page_handle->getName();
227 $selected = !empty($pagelist->_selected[$pagename]);
228 if (strstr($pagename,'[') or strstr($pagename,']')) {
229 $pagename = str_replace(array('[',']'),array('%5B','%5D'),$pagename);
232 return HTML::input(array('type' => 'checkbox',
233 'name' => $this->_name . "[$pagename]",
235 'checked' => 'CHECKED'));
237 return HTML::input(array('type' => 'checkbox',
238 'name' => $this->_name . "[$pagename]",
242 function format ($pagelist, $page_handle, &$revision_handle) {
243 return HTML::td($this->_tdattr,
245 $this->_getValue($pagelist, $page_handle, $revision_handle),
246 HTML::raw(' '));
250 class _PageList_Column_time extends _PageList_Column {
251 function _PageList_Column_time ($field, $default_heading) {
252 $this->_PageList_Column($field, $default_heading, 'right');
254 $this->Theme = &$Theme;
257 function _getValue ($page_handle, &$revision_handle) {
258 $time = _PageList_Column::_getValue($page_handle, $revision_handle);
259 return $this->Theme->formatDateTime($time);
263 class _PageList_Column_version extends _PageList_Column {
264 function _getValue ($page_handle, &$revision_handle) {
265 if (!$revision_handle)
266 $revision_handle = $page_handle->getCurrentRevision();
267 return $revision_handle->getVersion();
271 // If needed this could eventually become a subclass
272 // of a new _PageList_Column_action class for other actions.
273 // only for WikiAdminRemove or WikiAdminSelect
274 class _PageList_Column_remove extends _PageList_Column {
275 function _getValue ($page_handle, &$revision_handle) {
276 return Button(array('action' => 'remove'), _("Remove"),
277 $page_handle->getName());
281 // only for WikiAdminRename
282 class _PageList_Column_renamed_pagename extends _PageList_Column {
283 function _getValue ($page_handle, &$revision_handle) {
284 $post_args = $GLOBALS['request']->getArg('admin_rename');
285 $value = str_replace($post_args['from'], $post_args['to'],$page_handle->getName());
286 $div = HTML::div(" => ",HTML::input(array('type' => 'text',
287 'name' => 'rename[]',
288 'value' => $value)));
289 $new_page = $GLOBALS['request']->getPage($value);
290 if ($new_page->exists()) {
291 $div->setAttr('class','error');
292 $div->setAttr('title',_("This page already exists"));
298 // Output is hardcoded to limit of first 50 bytes. Otherwise
299 // on very large Wikis this will fail if used with AllPages
300 // (PHP memory limit exceeded)
301 class _PageList_Column_content extends _PageList_Column {
302 function _PageList_Column_content ($field, $default_heading, $align = false) {
303 _PageList_Column::_PageList_Column($field, $default_heading, $align);
305 if ($field == 'content') {
306 $this->_heading .= sprintf(_(" ... first %d bytes"),
308 } elseif ($field == 'hi_content') {
309 if (!empty($_POST['admin_replace'])) {
310 $search = $_POST['admin_replace']['from'];
311 $this->_heading .= sprintf(_(" ... around %s"),
316 function _getValue ($page_handle, &$revision_handle) {
317 if (!$revision_handle)
318 $revision_handle = $page_handle->getCurrentRevision();
319 // Not sure why implode is needed here, I thought
320 // getContent() already did this, but it seems necessary.
321 $c = implode("\n", $revision_handle->getContent());
322 if ($this->_field == 'hi_content') {
323 $search = $_POST['admin_replace']['from'];
324 if ($search and ($i = strpos($c,$search))) {
325 $l = strlen($search);
326 $j = max(0,$i - ($this->bytes / 2));
327 return HTML::div(array('style' => 'font-size:x-small'),
328 HTML::div(array('class' => 'transclusion'),
329 HTML::span(substr($c, $j, ($this->bytes / 2))),
330 HTML::span(array("style"=>"background:yellow"),$search),
331 HTML::span(substr($c, $i+$l, ($this->bytes / 2))))
334 $c = sprintf(_("%s not found"),
336 return HTML::div(array('style' => 'font-size:x-small','align'=>'center'),
339 } elseif (($len = strlen($c)) > $this->bytes) {
340 $c = substr($c, 0, $this->bytes);
342 include_once('lib/BlockParser.php');
343 // false --> don't bother processing hrefs for embedded WikiLinks
344 $ct = TransformText($c, $revision_handle->get('markup'), false);
345 return HTML::div(array('style' => 'font-size:x-small'),
346 HTML::div(array('class' => 'transclusion'), $ct),
347 // Don't show bytes here if size column present too
348 ($this->parent->_columns_seen['size'] or !$len) ? "" :
349 ByteFormatter($len, /*$longformat = */true));
353 class _PageList_Column_author extends _PageList_Column {
354 function _PageList_Column_author ($field, $default_heading, $align = false) {
355 _PageList_Column::_PageList_Column($field, $default_heading, $align);
356 global $WikiNameRegexp, $request;
357 $this->WikiNameRegexp = $WikiNameRegexp;
358 $this->dbi = &$request->getDbh();
361 function _getValue ($page_handle, &$revision_handle) {
362 $author = _PageList_Column::_getValue($page_handle, $revision_handle);
363 if (preg_match("/^$this->WikiNameRegexp\$/", $author) && $this->dbi->isWikiPage($author))
364 return WikiLink($author);
370 class _PageList_Column_perm extends _PageList_Column {
371 function _getValue ($page_handle, &$revision_handle) {
372 $perm_array = pagePermissions($page_handle->_pagename);
373 return pagePermissionsSimpleFormat($perm_array,
374 $page_handle->get('author'),$page_handle->get('group'));
377 var_dump($perm_array);
378 $xml = ob_get_contents();
385 class _PageList_Column_acl extends _PageList_Column {
386 function _getValue ($page_handle, &$revision_handle) {
387 $perm_tree = pagePermissions($page_handle->_pagename);
388 return pagePermissionsAclFormat($perm_tree);
391 var_dump($perm_array);
392 $xml = ob_get_contents();
398 // TODO: only if RateIt is used
399 class _PageList_Column_rating extends _PageList_Column {
400 function _getValue ($page_handle, &$revision_handle) {
402 $loader = new WikiPluginLoader();
403 $args = "pagename=".$page_handle->_pagename;
405 $args .= " imgPrefix=".$prefix++;
406 return $loader->expandPi('<'."?plugin RateIt $args ?".'>',$GLOBALS['request'],$page_handle);
410 class _PageList_Column_pagename extends _PageList_Column_base {
411 var $_field = 'pagename';
413 function _PageList_Column_pagename () {
414 $this->_PageList_Column_base(_("Page Name"));
416 $this->dbi = &$request->getDbh();
419 function _getValue ($page_handle, &$revision_handle) {
420 if ($this->dbi->isWikiPage($page_handle->getName()))
421 return WikiLink($page_handle);
423 return WikiLink($page_handle, 'unknown');
430 var $_group_rows = 3;
431 var $_columns = array();
432 var $_excluded_pages = array();
433 var $_rows = array();
435 var $_pagename_seen = false;
436 var $_types = array();
437 var $_options = array();
438 var $_selected = array();
439 var $_sortby = array();
441 function PageList ($columns = false, $exclude = false, $options = false) {
442 $this->_initAvailableColumns();
445 'all' => array_diff(array_keys($this->_types), // all but...
446 array('checkbox','remove','renamed_pagename',
447 'content','hi_content','perm','acl')),
448 'most' => array('pagename','mtime','author','size','hits'),
449 'some' => array('pagename','mtime','author')
452 if (!is_array($columns))
453 $columns = explode(',', $columns);
454 // expand symbolic columns:
455 foreach ($symbolic_columns as $symbol => $cols) {
456 if (in_array($symbol,$columns)) { // e.g. 'checkbox,all'
457 $columns = array_diff(array_merge($columns,$cols),array($symbol));
460 if (!in_array('pagename',$columns))
461 $this->_addColumn('pagename');
462 foreach ($columns as $col) {
463 $this->_addColumn($col);
466 $this->_addColumn('pagename');
468 $this->_options = $options;
469 if (!empty($options) and !empty($options['sortby'])) {
470 $sortby = $options['sortby'];
472 $sortby = $GLOBALS['request']->getArg('sortby');
474 $this->sortby($sortby,'init');
475 if (!empty($options) and !empty($options['limit'])) {
476 $limit = $options['limit'];
478 $limit = $GLOBALS['request']->getArg('limit');
481 if (!is_array($exclude))
482 $exclude = $this->explodePageList($exclude,false,$sortby,$limit);
483 $this->_excluded_pages = $exclude;
486 $this->_messageIfEmpty = _("<no matches>");
489 // Currently PageList takes these arguments:
490 // 1: info, 2: exclude, 3: hash of options
491 // Here we declare which options are supported, so that
492 // the calling plugin may simply merge this with its own default arguments
493 function supportedArgs () {
494 return array(//Currently supported options:
495 'info' => 'pagename',
496 'exclude' => '', // also wildcards and comma-seperated lists
498 // for the sort buttons in <th>
499 'sortby' => '', // same as for WikiDB::getAllPages
501 //PageList pager options:
502 // These options may also be given to _generate(List|Table) later
503 // But limit and offset might help the query WikiDB::getAllPages()
504 //cols => 1, // side-by-side display of list (1-3)
505 //limit => 50, // length of one column
506 //offset => 0, // needed internally for the pager
507 //paging => 'auto', // '': normal paging mode
508 // // 'auto': drop 'info' columns and enhance rows
509 // // when the list becomes large
510 // // 'none': don't page at all
514 function setCaption ($caption_string) {
515 $this->_caption = $caption_string;
518 function getCaption () {
519 // put the total into the caption if needed
520 if (is_string($this->_caption) && strstr($this->_caption, '%d'))
521 return sprintf($this->_caption, $this->getTotal());
522 return $this->_caption;
525 function setMessageIfEmpty ($msg) {
526 $this->_messageIfEmpty = $msg;
530 function getTotal () {
531 return count($this->_rows);
534 function isEmpty () {
535 return empty($this->_rows);
538 function addPage ($page_handle) {
539 if (is_string($page_handle)) {
540 if (empty($page_handle)) return;
541 if (in_array($page_handle, $this->_excluded_pages))
542 return; // exclude page.
543 $dbi = $GLOBALS['request']->getDbh();
544 $page_handle = $dbi->getPage($page_handle);
545 } elseif (is_object($page_handle)) {
546 if (in_array($page_handle->getName(), $this->_excluded_pages))
547 return; // exclude page.
549 //FIXME. only on sf.net
550 if (!is_object($page_handle)) {
551 trigger_error("PageList: Invalid page_handle $page_handle", E_USER_WARNING);
554 // enforce view permission
555 if (!mayAccessPage('view',$page_handle->getName()))
558 $group = (int)(count($this->_rows) / $this->_group_rows);
559 $class = ($group % 2) ? 'oddrow' : 'evenrow';
560 $revision_handle = false;
562 if (count($this->_columns) > 1) {
563 $row = HTML::tr(array('class' => $class));
564 foreach ($this->_columns as $col)
565 $row->pushContent($col->format($this, $page_handle, $revision_handle));
568 $col = $this->_columns[0];
569 $row = $col->_getValue($page_handle, $revision_handle);
572 $this->_rows[] = $row;
575 function addPages ($page_iter) {
576 while ($page = $page_iter->next())
577 $this->addPage($page);
580 function addPageList (&$list) {
582 while ($page = next($list))
583 $this->addPage($page);
586 function getContent() {
587 // Note that the <caption> element wants inline content.
588 $caption = $this->getCaption();
590 if ($this->isEmpty())
591 return $this->_emptyList($caption);
592 elseif (count($this->_columns) == 1)
593 return $this->_generateList($caption);
595 return $this->_generateTable($caption);
598 function printXML() {
599 PrintXML($this->getContent());
603 return AsXML($this->getContent());
606 function sortable_columns() {
607 return array('pagename','mtime','hits');
611 * Handle sortby requests for the DB iterator and table header links.
612 * Prefix the column with + or - like "+pagename","-mtime", ...
613 * db supported columns: 'pagename','mtime','hits'
614 * supported actions: 'flip_order' "mtime" => "+mtime" => "-mtime" ...
615 * 'db' "-pagename" => "pagename DESC"
616 * which other column types should be sortable?
618 function sortby ($column, $action) {
619 if (empty($column)) return;
620 //support multiple comma-delimited sortby args: "+hits,+pagename"
621 if (strstr($column,',')) {
623 foreach (explode(',',$column) as $col) {
624 $result[] = $this->sortby($col,$action);
626 return join(",",$result);
628 if (substr($column,0,1) == '+') {
629 $order = '+'; $column = substr($column,1);
630 } elseif (substr($column,0,1) == '-') {
631 $order = '-'; $column = substr($column,1);
633 if (in_array($column,PageList::sortable_columns())) {
634 // default order: +pagename, -mtime, -hits
636 if (in_array($column,array('mtime','hits')))
640 if ($action == 'flip_order') {
641 return ($order == '+' ? '-' : '+') . $column;
642 } elseif ($action == 'init') {
643 $this->_sortby[$column] = $order;
644 return $order . $column;
645 } elseif ($action == 'check') {
646 return (!empty($this->_sortby[$column]) or
647 ($GLOBALS['request']->getArg('sortby') and
648 strstr($GLOBALS['request']->getArg('sortby'),$column)));
649 } elseif ($action == 'db') {
650 // asc or desc: +pagename, -pagename
651 return $column . ($order == '+' ? ' ASC' : ' DESC');
657 // echo implode(":",explodeList("Test*",array("xx","Test1","Test2")));
658 function explodePageList($input, $perm = false, $sortby=false, $limit=false) {
659 // expand wildcards from list of all pages
660 if (preg_match('/[\?\*]/',$input)) {
661 $dbi = $GLOBALS['request']->getDbh();
662 $allPagehandles = $dbi->getAllPages($perm,$sortby,$limit);
663 while ($pagehandle = $allPagehandles->next()) {
664 $allPages[] = $pagehandle->getName();
666 return explodeList($input, $allPages);
668 //TODO: do the sorting, normally not needed if used for exclude only
669 return explode(',',$input);
677 //Performance Fixme: Initialize only the requested objects
678 function _initAvailableColumns() {
679 if (!empty($this->_types))
685 => new _PageList_Column_content('rev:content', _("Content")),
686 'hi_content' // with highlighted search for SearchReplace
687 => new _PageList_Column_content('rev:hi_content', _("Content")),
689 => new _PageList_Column_remove('remove', _("Remove")),
691 => new _PageList_Column_renamed_pagename('rename', _("Rename to")),
693 => new _PageList_Column_perm('perm', _("Permission")),
695 => new _PageList_Column_acl('acl', _("ACL")),
697 => new _PageList_Column_checkbox('p', _("Select")),
699 => new _PageList_Column_pagename,
701 => new _PageList_Column_time('rev:mtime', _("Last Modified")),
703 => new _PageList_Column('hits', _("Hits"), 'right'),
705 => new _PageList_Column_size('rev:size', _("Size"), 'right'),
706 /*array('align' => 'char', 'char' => ' ')*/
708 => new _PageList_Column('rev:summary', _("Last Summary")),
710 => new _PageList_Column_version('rev:version', _("Version"),
713 => new _PageList_Column_author('rev:author', _("Last Author")),
715 => new _PageList_Column_author('owner', _("Owner")),
717 => new _PageList_Column_author('group', _("Group")),
719 => new _PageList_Column_bool('locked', _("Locked"),
722 => new _PageList_Column_bool('rev:is_minor_edit',
723 _("Minor Edit"), _("minor")),
725 => new _PageList_Column('rev:markup', _("Markup")),
727 => new _PageList_Column_rating('rating', _("Rate")),
731 function _addColumn ($column) {
733 $this->_initAvailableColumns();
735 if (isset($this->_columns_seen[$column]))
736 return false; // Already have this one.
737 $this->_columns_seen[$column] = true;
739 if (strstr($column, ':'))
740 list ($column, $heading) = explode(':', $column, 2);
742 if (!isset($this->_types[$column])) {
743 trigger_error(sprintf("%s: Bad column", $column), E_USER_NOTICE);
746 if ($column == 'rating' and !$GLOBALS['request']->_user->isSignedIn())
749 $col = $this->_types[$column];
750 if (!empty($heading))
751 $col->setHeading($heading);
753 $this->_columns[] = $col;
758 // make a table given the caption
759 function _generateTable($caption) {
760 $table = HTML::table(array('cellpadding' => 0,
763 'class' => 'pagelist'));
765 $table->pushContent(HTML::caption(array('align'=>'top'), $caption));
767 //Warning: This is quite fragile. It depends solely on a private variable
769 if (!empty($this->_columns_seen['checkbox'])) {
770 $table->pushContent($this->_jsFlipAll());
773 $table_summary = array();
774 foreach ($this->_columns as $col) {
775 $row->pushContent($col->button_heading());
776 if (is_string($col->_heading))
777 $table_summary[] = $col->_heading;
779 // Table summary for non-visual browsers.
780 $table->setAttr('summary', sprintf(_("Columns: %s."),
781 implode(", ", $table_summary)));
783 $table->pushContent(HTML::thead($row),
784 HTML::tbody(false, $this->_rows));
788 function _jsFlipAll() {
790 function flipAll(formObj) {
792 for (var i=0;i < formObj.length;i++) {
793 fldObj = formObj.elements[i];
794 if (fldObj.type == 'checkbox') {
795 if (isFirstSet == -1)
796 isFirstSet = (fldObj.checked) ? true : false;
797 fldObj.checked = (isFirstSet) ? false : true;
803 function _generateList($caption) {
804 $list = HTML::ul(array('class' => 'pagelist'));
806 foreach ($this->_rows as $page) {
807 $group = ($i++ / $this->_group_rows);
808 $class = ($group % 2) ? 'oddrow' : 'evenrow';
809 $list->pushContent(HTML::li(array('class' => $class),$page));
812 //Warning: This is quite fragile. It depends solely on a private variable
814 // Questionable if its of use here anyway. This is a one-col pagename list only.
815 //if (!empty($this->_columns_seen['checkbox'])) $out->pushContent($this->_jsFlipAll());
817 $out->pushContent(HTML::p($caption));
818 $out->pushContent($list);
822 function _emptyList($caption) {
825 $html->pushContent(HTML::p($caption));
826 if ($this->_messageIfEmpty)
827 $html->pushContent(HTML::blockquote(HTML::p($this->_messageIfEmpty)));
831 // Condense list: "Page1, Page2, ..."
832 // Alternative $seperator = HTML::Raw(' · ')
833 function _generateCommaList($seperator = ', ') {
834 return HTML(join($seperator, $list));
839 /* List pages with checkboxes to select from.
840 * The [Select] button toggles via _jsFlipAll
843 class PageList_Selectable
846 function PageList_Selectable ($columns=false, $exclude=false) {
848 if (!is_array($columns))
849 $columns = explode(',', $columns);
850 if (!in_array('checkbox',$columns))
851 array_unshift($columns,'checkbox');
853 $columns = array('checkbox','pagename');
855 PageList::PageList($columns,$exclude);
858 function addPageList ($array) {
859 while (list($pagename,$selected) = each($array)) {
860 if ($selected) $this->addPageSelected($pagename);
861 $this->addPage($pagename);
865 function addPageSelected ($pagename) {
866 $this->_selected[$pagename] = 1;
869 //insert javascript when clicked on Selected Select/Deselect all
872 // (c-file-style: "gnu")
877 // c-hanging-comment-ender-p: nil
878 // indent-tabs-mode: nil