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,
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);
71 // If the ratings table does not exist, or on dba it will break otherwise.
72 // Check if WikiTheme isa 'wikilens'
73 if ($info == 'pagename' and isa($GLOBALS['WikiTheme'], 'wikilens'))
76 $info = split(',', $info);
80 if (in_array('top3recs', $info)) {
81 require_once('lib/wikilens/Buddy.php');
82 require_once('lib/wikilens/PageListColumns.php');
84 $active_user = $request->getUser();
85 $active_userid = $active_user->_userid;
87 // if userids is null or empty, fill it with just the active user
88 if (!isset($userids) || !is_array($userids) || !count($userids)) {
89 // TKL: moved getBuddies call inside if statement because it was
90 // causing the userids[] parameter to be ignored
91 if (is_string($active_userid)
92 and strlen($active_userid)
93 and $active_user->isSignedIn())
95 $userids = getBuddies($active_userid, $dbi);
98 // XXX: this wipes out the category caption...
99 $caption = _("You must be logged in to view ratings.");
103 // find out which users we should show ratings for
104 $allowed_users = array();
105 foreach ($userids as $userid) {
106 $user = new RatingsUser($userid);
107 if ($user->allow_view_ratings($active_user)) {
108 array_push($allowed_users, $user);
110 // PHP's silly references... (the behavior with this line commented
114 $options = array('dimension' => $dimension,
115 'users' => $allowed_users);
116 $args = array_merge($options, $args);
118 if (empty($pages) and $pages != '0')
121 if (in_array('numbacklinks', $info)) {
122 $args['types']['numbacklinks'] = new _PageList_Column_ListPages_count('numbacklinks', _("#"), true);
124 if (in_array('numpagelinks', $info)) {
125 $args['types']['numpagelinks'] = new _PageList_Column_ListPages_count('numpagelinks', _("#"));
128 $pagelist = new PageList($info, $exclude, $args);
129 $pages_array = is_string($pages) ? explodePageList($pages) : (is_array($pages) ? $pages : array());
130 $pagelist->addPageList($pages_array);
135 // how many back-/forwardlinks for this page
136 class _PageList_Column_ListPages_count extends _PageList_Column {
137 function _PageList_Column_ListPages_count($field, $display, $backwards = false) {
138 $this->_direction = $backwards;
139 return $this->_PageList_Column($field, $display, 'center');
141 function _getValue($page, &$revision_handle) {
142 $iter = $page->getLinks($this->_direction);
143 $count = $iter->count();
152 // c-hanging-comment-ender-p: nil
153 // indent-tabs-mode: nil