2 rcs_id('$Id: ListPages.php,v 1.8 2004-10-14 19:19:34 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, or as generic
30 * frontend for plugin-list page lists.
32 * @author: Dan Frankowski
34 class WikiPlugin_ListPages
38 return _("ListPages");
41 function getDescription() {
42 return _("List pages that are explicitly given as the pages argument.");
45 function getVersion() {
46 return preg_replace("/[Revision: $]/", '',
50 function getDefaultArguments() {
53 PageList::supportedArgs(),
54 array('pages' => false,
56 'info' => 'pagename,top3recs',
61 // info arg allows multiple columns
62 // info=mtime,hits,summary,version,author,locked,minor
63 // additional info args:
64 // top3recs : recommendations
65 // numbacklinks : number of backlinks (links to the given page)
66 // numpagelinks : number of forward links (links at the given page)
68 function run($dbi, $argstr, &$request, $basepage) {
69 $args = $this->getArgs($argstr, $request);
72 $info = split(',', $info);
75 // Fixme: if the ratings table does not exist it will break.
76 // check if Theme isa 'wikilens'?
77 if (in_array('top3recs', $info)) {
78 require_once('lib/wikilens/Buddy.php');
79 require_once('lib/wikilens/PageListColumns.php');
81 $active_user = $request->getUser();
82 $active_userid = $active_user->_userid;
84 // if userids is null or empty, fill it with just the active user
85 if (!isset($userids) || !is_array($userids) || !count($userids)) {
86 // TKL: moved getBuddies call inside if statement because it was
87 // causing the userids[] parameter to be ignored
88 if (is_string($active_userid) && strlen($active_userid) && $active_user->isSignedIn()) {
89 $userids = getBuddies($active_userid, $dbi);
92 // XXX: this wipes out the category caption...
93 $caption = _("You must be logged in to view ratings.");
97 // find out which users we should show ratings for
98 $allowed_users = array();
99 foreach ($userids as $userid) {
100 $user = new RatingsUser($userid);
101 if ($user->allow_view_ratings($active_user)) {
102 array_push($allowed_users, $user);
104 // PHP's silly references... (the behavior with this line commented
108 $options = array('dimension' => $dimension,
109 'users' => $allowed_users);
110 $args = array_merge($options, $args);
112 if (empty($pages) and $pages != '0')
115 if (in_array('numbacklinks', $info)) {
116 $args['types']['numbacklinks'] = new _PageList_Column_ListPages_count('numbacklinks', _("#"), true);
118 if (in_array('numpagelinks', $info)) {
119 $args['types']['numpagelinks'] = new _PageList_Column_ListPages_count('numpagelinks', _("#"));
122 $pagelist = new PageList($info, $exclude, $args);
123 $pages_array = is_string($pages) ? explodePageList($pages) : (is_array($pages) ? $pages : array());
124 $pagelist->addPageList($pages_array);
129 // how many back-/forwardlinks for this page
130 class _PageList_Column_ListPages_count extends _PageList_Column {
131 function _PageList_Column_ListPages_count($field, $display, $backwards = false) {
132 $this->_direction = $backwards;
133 return $this->_PageList_Column($field, $display, 'center');
135 function _getValue($page, &$revision_handle) {
136 $iter = $page->getLinks($this->_direction);
137 $count = $iter->count();
142 // $Log: not supported by cvs2svn $
143 // Revision 1.7 2004/09/25 16:33:52 rurban
144 // add support for all PageList options
146 // Revision 1.6 2004/09/14 10:33:39 rurban
147 // simplify exclude, add numbacklinks+numpagelinks
149 // Revision 1.5 2004/09/06 08:37:31 rurban
150 // plugin-list support for pages and exclude args
152 // Revision 1.4 2004/07/08 20:30:07 rurban
153 // plugin->run consistency: request as reference, added basepage.
154 // encountered strange bug in AllPages (and the test) which destroys ->_dbi
156 // Revision 1.3 2004/06/28 18:58:18 rurban
157 // fixed another pass-by-reference
159 // Revision 1.2 2004/06/18 14:42:17 rurban
160 // added wikilens libs (not yet merged good enough, some work for DanFr)
162 // Revision 1.1 2004/06/08 13:49:43 rurban
163 // List pages that are explicitly given as the pages argument, by DanFr
170 // c-hanging-comment-ender-p: nil
171 // indent-tabs-mode: nil