]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/DynamicIncludePage.php
Remove unused variables
[SourceForge/phpwiki.git] / lib / plugin / DynamicIncludePage.php
1 <?php
2
3 /*
4  * Copyright 2009 $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  * DynamicIncludePage - Include wikipage asynchronously. Icon to show/hide.
25  * Usage:   <<DynamicIncludePage page=OtherPage state=true ...>>
26  * Author:  Reini Urban
27  */
28
29 require_once 'lib/plugin/IncludePage.php';
30
31 class WikiPlugin_DynamicIncludePage
32     extends WikiPlugin_IncludePage
33 {
34     function getName()
35     {
36         return _("DynamicIncludePage");
37     }
38
39     function getDescription()
40     {
41         return _("Dynamically include the content from another wiki page.");
42     }
43
44     function getDefaultArguments()
45     {
46         return array_merge
47         (WikiPlugin_IncludePage::getDefaultArguments(),
48             array(
49                 'state' => false, // initial state: false <=> [+], true <=> [-]
50             ));
51     }
52
53     function run($dbi, $argstr, &$request, $basepage)
54     {
55         global $WikiTheme;
56         $args = $this->getArgs($argstr, $request, false);
57         $page =& $args['page'];
58         if (ENABLE_AJAX) {
59             if ($args['state'])
60                 $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
61             else
62                 $html = HTML(HTML::p(array('class' => 'transclusion-title'),
63                         fmt(" %s :", WikiLink($page))),
64                     HTML::div(array('class' => 'transclusion'), ''));
65             $ajaxuri = WikiURL($page, array('format' => 'xml'));
66         } else {
67             $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
68         }
69         $body = $html->_content[1];
70         $id = 'DynInc-' . MangleXmlIdentifier($page);
71         $body->setAttr('id', $id . '-body');
72         $png = $WikiTheme->_findData('images/folderArrow' .
73             ($args['state'] ? 'Open' : 'Closed') .
74             '.png');
75         $icon = HTML::img(array('id' => $id . '-img',
76             'src' => $png,
77             'onclick' => ENABLE_AJAX
78                 ? "showHideAsync('" . $ajaxuri . "','$id')"
79                 : "showHideFolder('$id')",
80             'alt' => _("Click to hide/show"),
81             'title' => _("Click to hide/show")));
82         $header = HTML::p(array('class' => 'transclusion-title',
83                 'style' => "text-decoration: none;"),
84             $icon,
85             fmt(" %s :", WikiLink($page)));
86         if ($args['state']) { // show base
87             $body->setAttr('style', 'display:block');
88             return HTML($header, $body);
89         } else { // do not show base
90             $body->setAttr('style', 'display:none');
91             if (ENABLE_AJAX)
92                 return HTML($header, $body); // async (load in background and insert)
93             else
94                 return HTML($header, $body); // sync (load but display:none)
95         }
96     }
97 }
98
99 // Local Variables:
100 // mode: php
101 // tab-width: 8
102 // c-basic-offset: 4
103 // c-hanging-comment-ender-p: nil
104 // indent-tabs-mode: nil
105 // End: