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 along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
37 function getDescription()
39 return _("List pages that are explicitly given as the pages argument.");
42 function getDefaultArguments()
46 PageList::supportedArgs(),
47 array('pages' => false,
54 // info arg allows multiple columns
55 // info=mtime,hits,summary,version,author,locked,minor
56 // additional info args:
57 // top3recs : recommendations
58 // numbacklinks : number of backlinks (links to the given page)
59 // numpagelinks : number of forward links (links at the given page)
61 function run($dbi, $argstr, &$request, $basepage)
63 $args = $this->getArgs($argstr, $request);
66 // If the ratings table does not exist, or on dba it will break otherwise.
67 // Check if WikiTheme isa 'wikilens'
68 if ($info == 'pagename' and isa($GLOBALS['WikiTheme'], 'wikilens'))
71 $info = explode(',', $info);
75 if (in_array('top3recs', $info)) {
76 require_once 'lib/wikilens/Buddy.php';
77 require_once 'lib/wikilens/PageListColumns.php';
79 $active_user = $request->getUser();
80 $active_userid = $active_user->_userid;
82 // if userids is null or empty, fill it with just the active user
83 if (!isset($userids) || !is_array($userids) || !count($userids)) {
84 // TKL: moved getBuddies call inside if statement because it was
85 // causing the userids[] parameter to be ignored
86 if (is_string($active_userid)
87 and strlen($active_userid)
88 and $active_user->isSignedIn()
90 $userids = getBuddies($active_userid, $dbi);
93 // XXX: this wipes out the category caption...
94 $caption = _("You must be logged in to view ratings.");
98 // find out which users we should show ratings for
99 $allowed_users = array();
100 foreach ($userids as $userid) {
101 $user = new RatingsUser($userid);
102 if ($user->allow_view_ratings($active_user)) {
103 array_push($allowed_users, $user);
105 // PHP's silly references... (the behavior with this line commented
109 $options = array('dimension' => $dimension,
110 'users' => $allowed_users);
111 $args = array_merge($options, $args);
113 if (empty($pages) and $pages != '0')
116 if (in_array('numbacklinks', $info)) {
117 $args['types']['numbacklinks'] = new _PageList_Column_ListPages_count('numbacklinks', _("#"), true);
119 if (in_array('numpagelinks', $info)) {
120 $args['types']['numpagelinks'] = new _PageList_Column_ListPages_count('numpagelinks', _("#"));
123 $pagelist = new PageList($info, $exclude, $args);
124 $pages_array = is_string($pages) ? explodePageList($pages) : (is_array($pages) ? $pages : array());
125 $pagelist->addPageList($pages_array);
130 // how many back-/forwardlinks for this page
131 class _PageList_Column_ListPages_count extends _PageList_Column
133 function _PageList_Column_ListPages_count($field, $display, $backwards = false)
135 $this->_direction = $backwards;
136 return $this->_PageList_Column($field, $display, 'center');
139 function _getValue($page, &$revision_handle)
141 $iter = $page->getLinks($this->_direction);
142 $count = $iter->count();
151 // c-hanging-comment-ender-p: nil
152 // indent-tabs-mode: nil