2 rcs_id('$Id: ListPages.php,v 1.5 2004-09-06 08:37:31 rurban Exp $');
4 Copyright 2004 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 require_once('lib/PageList.php');
26 * ListPages - List pages that are explicitly given as the pages argument.
28 * Mainly used to see some ratings and recommendations.
29 * But also possible to list some Categories or Users.
31 * @author: Dan Frankowski
33 class WikiPlugin_ListPages
37 return _("ListPages");
40 function getDescription() {
41 return _("List pages that are explicitly given as the pages argument.");
44 function getVersion() {
45 return preg_replace("/[Revision: $]/", '',
49 function getDefaultArguments() {
50 return array('pages' => false,
52 'info' => 'pagename,top3recs',
57 // info arg allows multiple columns
58 // info=mtime,hits,summary,version,author,locked,minor
60 function run($dbi, $argstr, &$request, $basepage) {
61 $args = $this->getArgs($argstr, $request);
64 if (in_array('top3recs', split(',', $info))) {
66 require_once('lib/wikilens/Buddy.php');
67 require_once('lib/wikilens/PageListColumns.php');
69 $active_user = $request->getUser();
70 $active_userid = $active_user->_userid;
72 // if userids is null or empty, fill it with just the active user
73 if (!isset($userids) || !is_array($userids) || !count($userids)) {
74 // TKL: moved getBuddies call inside if statement because it was
75 // causing the userids[] parameter to be ignored
76 if (is_string($active_userid) && strlen($active_userid) && $active_user->isSignedIn()) {
77 $userids = getBuddies($active_userid, $dbi);
80 // XXX: this wipes out the category caption...
81 $caption = _("You must be logged in to view ratings.");
85 // find out which users we should show ratings for
86 $allowed_users = array();
87 foreach ($userids as $userid) {
88 $user = new RatingsUser($userid);
89 if ($user->allow_view_ratings($active_user)) {
90 array_push($allowed_users, $user);
92 // PHP's silly references... (the behavior with this line commented
97 //What we really want is passing the pagelist object to the column
98 //$top3 = new _PageList_Column_top3recs('top3recs', _("Top Recommendations"),
99 // 'left', 0, $allowed_users);
100 $options = array('dimension' => $dimension,
101 'users' => $allowed_users);
109 $pagelist = new PageList($info, false, $options);
110 // FIXME: This should be not neccessary with the new custom pagelist columns
112 if (!empty($options)) {
113 $pagelist->addColumnObject(new _PageList_Column_top3recs('custom:top3recs', _("Top Recommendations"),
117 if (is_string($exclude) and !empty($exclude)) {
118 $exclude = explodePageList($exclude);
119 // $argstr = preg_replace("/exclude=\S*\s/", "", $argstr);
122 $pages_array = is_string($pages) ? explodePageList($pages) : (is_array($pages) ? $pages : array());
123 foreach ($pages_array as $pagename) {
124 if (empty($exclude) or !in_array($pagename, $exclude)) {
125 $page = $dbi->getPage($pagename);
126 $pagelist->addPage($page);
134 // $Log: not supported by cvs2svn $
135 // Revision 1.4 2004/07/08 20:30:07 rurban
136 // plugin->run consistency: request as reference, added basepage.
137 // encountered strange bug in AllPages (and the test) which destroys ->_dbi
139 // Revision 1.3 2004/06/28 18:58:18 rurban
140 // fixed another pass-by-reference
142 // Revision 1.2 2004/06/18 14:42:17 rurban
143 // added wikilens libs (not yet merged good enough, some work for DanFr)
145 // Revision 1.1 2004/06/08 13:49:43 rurban
146 // List pages that are explicitly given as the pages argument, by DanFr
153 // c-hanging-comment-ender-p: nil
154 // indent-tabs-mode: nil