]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/IncludePages.php
rcs_id no longer makes sense with Subversion global version number
[SourceForge/phpwiki.git] / lib / plugin / IncludePages.php
1 <?php // -*-php-*-
2 // rcs_id('$Id$');
3 /*
4  * Copyright 2004 $ThePhpWikiProgrammingTeam
5  *
6  * This file is part of PhpWiki.
7  *
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.
12  *
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.
17  *
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
21  */
22
23 /**
24  * IncludePages: Include a list of multiple pages, based on IncludePage.
25  * usage:   <?plugin IncludePages pages=<!plugin-list BackLinks !> ?>
26  * author:  ReiniUrban
27  */
28
29 include_once("lib/plugin/IncludePage.php");
30
31 class WikiPlugin_IncludePages
32 extends WikiPlugin_IncludePage
33 {
34     function getName() {
35         return _("IncludePages");
36     }
37
38     function getDescription() {
39         return _("Include multiple pages.");
40     }
41
42     function getDefaultArguments() {
43             return array_merge(
44                            array( 'pages'   => false,  // the pages to include
45                                   'exclude' => false), // the pages to exclude
46                            WikiPlugin_IncludePage::getDefaultArguments()
47                            );
48     }
49
50     function run($dbi, $argstr, &$request, $basepage) {
51         $args = $this->getArgs($argstr, $request);
52             $html = HTML();
53         if (empty($args['pages']))
54             return $html;
55         $include = new WikiPlugin_IncludePage();
56
57         if (is_string($args['exclude']) and !empty($args['exclude'])) {
58             $args['exclude'] = explodePageList($args['exclude']);
59             $argstr = preg_replace("/exclude=\S*\s/", "", $argstr);
60         } elseif (is_array($args['exclude'])) {
61             $argstr = preg_replace("/exclude=<\?plugin-list.*?\>/", "", $argstr);
62         }
63         if (is_string($args['pages']) and !empty($args['pages'])) {
64             $args['pages'] = explodePageList($args['pages']);
65             $argstr = preg_replace("/pages=\S*\s/", "", $argstr);
66         } elseif (is_array($args['pages'])) {
67             $argstr = preg_replace("/pages=<\?plugin-list.*?\>/", "", $argstr);
68         }
69
70             foreach ($args['pages'] as $page) {
71             if (empty($args['exclude']) or !in_array($page, $args['exclude'])) {
72                 $html = HTML($html, $include->run($dbi, "page='$page' ".$argstr, $request, $basepage));
73             }
74             }
75         return $html;
76     }
77 };
78
79 // For emacs users
80 // Local Variables:
81 // mode: php
82 // tab-width: 8
83 // c-basic-offset: 4
84 // c-hanging-comment-ender-p: nil
85 // indent-tabs-mode: nil
86 // End:
87 ?>