From: <var...@us...> - 2009-06-11 11:52:36
|
Revision: 6915 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6915&view=rev Author: vargenau Date: 2009-06-11 11:52:32 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Give exact number of pages listed (number was incorrect in case pages were not listed because of restrictive ACL) Modified Paths: -------------- trunk/lib/PageList.php trunk/lib/plugin/AllPages.php Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2009-06-11 09:30:10 UTC (rev 6914) +++ trunk/lib/PageList.php 2009-06-11 11:52:32 UTC (rev 6915) @@ -1436,8 +1436,11 @@ if ($tokens) $this->_pages = array_slice($this->_pages, $tokens['OFFSET'], $tokens['COUNT']); } + $nb_row = 0; foreach ($this->_pages as $pagenum => $page) { - $rows[] = $this->_renderPageRow($page, $i++); + $one_row = $this->_renderPageRow($page, $i++); + $rows[] = $one_row; + if ($one_row) $nb_row++; } $table = HTML::table(array('cellpadding' => 0, 'cellspacing' => 1, @@ -1446,6 +1449,7 @@ 'class' => 'pagelist', )); if ($caption) { + $caption = preg_replace('/{total}/', $nb_row, asString($caption)); $table->pushContent(HTML::caption(array('align'=>'top'), $caption)); } @@ -1520,9 +1524,17 @@ if (empty($this->_pages)) return; // stop recursion if (!isset($this->_options['listtype'])) $this->_options['listtype'] = ''; + $nb_row = 0; + foreach ($this->_pages as $pagenum => $page) { + $one_row = $this->_renderPageRow($page); + $rows[] = array('header' => WikiLink($page), 'render' => $one_row); + if ($one_row) $nb_row++; + } $out = HTML(); - if ($caption) + if ($caption) { + $caption = preg_replace('/{total}/', $nb_row, asString($caption)); $out->pushContent(HTML::p($caption)); + } // Semantic Search et al: only unique list entries, esp. with nopage if (!is_array($this->_pages[0]) and is_string($this->_pages[0])) { $this->_pages = array_unique($this->_pages); @@ -1626,15 +1638,15 @@ list($offset, $pagesize) = $this->limit($this->_options['limit']); else $pagesize=0; - foreach ($this->_pages as $pagenum => $page) { - $pagehtml = $this->_renderPageRow($page); + foreach (array_reverse($rows) as $one_row) { + $pagehtml = $one_row['render']; if (!$pagehtml) continue; $group = ($i++ / $this->_group_rows); //TODO: here we switch every row, in tables every third. // unification or parametrized? $class = ($group % 2) ? 'oddrow' : 'evenrow'; if ($this->_options['listtype'] == 'dl') { - $header = WikiLink($page); + $header = $one_row['header']; //if ($this->_sortby['hi_content']) $list->pushContent(HTML::dt(array('class' => $class), $header), HTML::dd(array('class' => $class), $pagehtml)); @@ -1688,8 +1700,10 @@ function _emptyList($caption) { $html = HTML(); - if ($caption) + if ($caption) { + $caption = preg_replace('/{total}/', '0', asString($caption)); $html->pushContent(HTML::p($caption)); + } if ($this->_messageIfEmpty) $html->pushContent(HTML::blockquote(HTML::p($this->_messageIfEmpty))); return $html; Modified: trunk/lib/plugin/AllPages.php =================================================================== --- trunk/lib/plugin/AllPages.php 2009-06-11 09:30:10 UTC (rev 6914) +++ trunk/lib/plugin/AllPages.php 2009-06-11 11:52:32 UTC (rev 6915) @@ -69,48 +69,45 @@ // Todo: extend given _GET args if ($args['debug']) $timer = new DebugTimer; - $caption = _("All pages in this wiki (%d total):"); + $caption = _("All pages in this wiki ({total} total):"); if ( !empty($args['userpages']) ) { $pages = PageList::allUserPages($args['include_empty'], $args['sortby'], '' ); - $caption = fmt("List of user-created pages (%d total):", count($pages)); + $caption = _("List of user-created pages ({total} total):"); $args['count'] = $request->getArg('count'); } elseif ( !empty($args['owner']) ) { $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'], $args['sortby'], '' ); - $caption = fmt("List of pages owned by [%s] (%d total):", + $caption = fmt("List of pages owned by [%s] ({total} total):", WikiLink($args['owner'] == '[]' ? $request->_user->getAuthenticatedId() : $args['owner'], - 'if_known'), - count($pages)); + 'if_known')); $args['count'] = $request->getArg('count'); $pages->_options['count'] = $args['count']; } elseif ( !empty($args['author']) ) { $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'], $args['sortby'], '' ); - $caption = fmt("List of pages last edited by [%s] (%d total):", + $caption = fmt("List of pages last edited by [%s] ({total} total):", WikiLink($args['author'] == '[]' ? $request->_user->getAuthenticatedId() : $args['author'], - 'if_known'), - count($pages)); + 'if_known')); $args['count'] = $request->getArg('count'); $pages->_options['count'] = $args['count']; } elseif ( !empty($args['creator']) ) { $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'], $args['sortby'], '' ); - $caption = fmt("List of pages created by [%s] (%d total):", + $caption = fmt("List of pages created by [%s] ({total} total):", WikiLink($args['creator'] == '[]' ? $request->_user->getAuthenticatedId() : $args['creator'], - 'if_known'), - count($pages)); + 'if_known')); $args['count'] = $request->getArg('count'); $pages->_options['count'] = $args['count']; //} elseif ($pages) { @@ -132,11 +129,9 @@ if ($pages !== false) $pagelist->addPageList($pages); - else { - $result = $dbi->getAllPages($args['include_empty'], $args['sortby'], - $args['limit']); - $pagelist->addPages( $result ); - } + else + $pagelist->addPages( $dbi->getAllPages($args['include_empty'], $args['sortby'], + $args['limit']) ); if ($args['debug']) { return HTML($pagelist, HTML::p(fmt("Elapsed time: %s s", $timer->getStats()))); @@ -144,7 +139,6 @@ return $pagelist; } } - }; // Local Variables: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |