]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/IncludePages.php
getName should not translate
[SourceForge/phpwiki.git] / lib / plugin / IncludePages.php
1 <?php
2
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 along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 /**
24  * IncludePages: Include a list of multiple pages, based on IncludePage.
25  * usage:   <<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 getDescription()
35     {
36         return _("Include multiple pages.");
37     }
38
39     function getDefaultArguments()
40     {
41         return array_merge(array('pages' => false, // the pages to include
42                 'exclude' => false), // the pages to exclude
43             WikiPlugin_IncludePage::getDefaultArguments()
44         );
45     }
46
47     function run($dbi, $argstr, &$request, $basepage)
48     {
49         $args = $this->getArgs($argstr, $request);
50         $html = HTML();
51         if (empty($args['pages'])) {
52             return $html;
53         }
54         $include = new WikiPlugin_IncludePage();
55
56         if (is_string($args['exclude']) and !empty($args['exclude'])) {
57             $args['exclude'] = explodePageList($args['exclude']);
58             $argstr = preg_replace("/exclude=\S*\s/", "", $argstr);
59         } elseif (is_array($args['exclude'])) {
60             $argstr = preg_replace("/exclude=<\?plugin-list.*?\>/", "", $argstr);
61         }
62         if (is_string($args['pages']) and !empty($args['pages'])) {
63             $args['pages'] = explodePageList($args['pages']);
64             $argstr = preg_replace("/pages=\S*\s/", "", $argstr);
65         } elseif (is_array($args['pages'])) {
66             $argstr = preg_replace("/pages=<\?plugin-list.*?\>/", "", $argstr);
67         }
68
69         // IncludePage plugin has no "pages" argument.
70         // Remove it to avoid warning.
71         $argstr = preg_replace('/pages=".*?"/', "", $argstr);
72         $argstr = preg_replace('/pages=\S*\s/', "", $argstr);
73         $argstr = preg_replace('/pages=\S*/', "", $argstr);
74
75         foreach ($args['pages'] as $page) {
76             if (empty($args['exclude']) or !in_array($page, $args['exclude'])) {
77                 $html = HTML($html, $include->run($dbi, "page='$page' " . $argstr, $request, $basepage));
78             }
79         }
80         return $html;
81     }
82 }
83
84 // Local Variables:
85 // mode: php
86 // tab-width: 8
87 // c-basic-offset: 4
88 // c-hanging-comment-ender-p: nil
89 // indent-tabs-mode: nil
90 // End: