2 rcs_id('$Id: ListSubpages.php,v 1.3 2004-02-17 12:11:36 rurban Exp $');
4 Copyright 2002 $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
24 * ListSubpages: Lists the names of all SubPages of the current page.
25 * Based on UnfoldSubpages.
26 * Usage: <?plugin ListSubpages noheader=1 info=pagename,hits,mtime ?>
28 require_once('lib/PageList.php');
30 class WikiPlugin_ListSubpages
34 return _("ListSubpages");
37 function getDescription () {
38 return _("Lists the names of all SubPages of the current page.");
41 function getVersion() {
42 return preg_replace("/[Revision: $]/", '',
46 function getDefaultArguments() {
47 return array('noheader' => false, // no header
48 'pages' => '', // maximum number of pages
51 /*'relative' => false, */
55 // info arg allows multiple columns
56 // info=mtime,hits,summary,version,author,locked,minor
57 // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges
59 function run($dbi, $argstr, &$request, $basepage) {
60 $pagename = $request->getArg('pagename');
63 // FIXME: explodePageList from stdlib doesn't seem to work as
64 // expected when there are no subpages. (see also
65 // UnfoldSubPages plugin)
66 $subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*');
68 return $this->error(_("The current page has no subpages defined."));
72 extract($this->getArgs($argstr, $request));
75 $subpages = array_reverse($subpages);
77 $subpages = array_slice ($subpages, 0, $pages);
80 $descrip = fmt("SubPages of %s:",
81 WikiLink($pagename, 'auto'));
82 $pagelist = new PageList($info, $exclude);
84 $pagelist->setCaption($descrip);
86 foreach ($subpages as $page) {
87 // A page cannot include itself. Avoid doublettes.
88 static $included_pages = array();
89 if (in_array($page, $included_pages)) {
90 $content->pushContent(HTML::p(sprintf(_("recursive inclusion of page %s ignored"),
94 array_push($included_pages, $page);
96 // TODO: add relative subpage name display to PageList class
98 $pagelist->addPage($page);
100 array_pop($included_pages);
102 $content->pushContent($pagelist);
107 // $Log: not supported by cvs2svn $
108 // Revision 1.2 2003/11/30 18:23:48 carstenklapp
109 // Code housekeeping: PEAR coding standards reformatting only.
111 // Revision 1.1 2003/11/23 16:33:02 carstenklapp
112 // New plugin to list names of SubPages of the currrent
113 // page. (Unfortunately this plugin reveals a bug in
114 // stdlib/explodePageList(), the function doesn't seem to work as
115 // expected when there are no subpages (see also UnfoldSubPages plugin).
123 // c-hanging-comment-ender-p: nil
124 // indent-tabs-mode: nil