4 * Copyright 2009 $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 * DynamicIncludePage - Include wikipage asynchronously. Icon to show/hide.
25 * Usage: <?plugin DynamicIncludePage page=OtherPage state=true ...?>
29 require_once('lib/plugin/IncludePage.php');
31 class WikiPlugin_DynamicIncludePage
32 extends WikiPlugin_IncludePage
35 return _("DynamicIncludePage");
38 function getDescription() {
39 return _("Dynamicly include text from another wiki page.");
42 function getVersion() {
43 return preg_replace("/[Revision: $]/", '',
47 function getDefaultArguments() {
49 (WikiPlugin_IncludePage::getDefaultArguments(),
51 'state' => false, // initial state: false <=> [+], true <=> [-]
55 function run($dbi, $argstr, &$request, $basepage) {
57 $args = $this->getArgs($argstr, $request, false);
58 $page =& $args['page'];
61 $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
63 $html = HTML(HTML::p(array('class' => 'transclusion-title'),
64 fmt(" %s :", WikiLink($page))),
65 HTML::div(array('class' => 'transclusion'), ''));
66 $ajaxuri = WikiURL($page, array('format' => 'xml'));
68 $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
70 $header = $html->_content[0];
71 $body = $html->_content[1];
72 $id = 'DynInc-'.MangleXmlIdentifier($page);
73 $body->setAttr('id', $id.'-body');
74 $png = $WikiTheme->_findData('images/folderArrow'.
75 ($args['state'] ? 'Open' : 'Closed').
77 $icon = HTML::img(array('id' => $id.'-img',
79 'onclick' => ENABLE_AJAX
80 ? "showHideAsync('".$ajaxuri."','$id')"
81 : "showHideFolder('$id')",
83 'alt' => _("Click to hide/show"),
84 'title' => _("Click to hide/show")));
85 $header = HTML::p(array('class' => 'transclusion-title',
86 'style' => "text-decoration: none;"),
88 fmt(" %s :", WikiLink($page)));
89 if ($args['state']) { // show base
90 $body->setAttr('style', 'display:block');
91 return HTML($header, $body);
92 } else { // do not show base
93 $body->setAttr('style', 'display:none');
95 return HTML($header, $body); // async (load in background and insert)
97 return HTML($header, $body); // sync (load but display:none)
107 // c-hanging-comment-ender-p: nil
108 // indent-tabs-mode: nil