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 along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * DynamicIncludePage - Include wikipage asynchronously. Icon to show/hide.
25 * Usage: <<DynamicIncludePage page=OtherPage state=true ...>>
29 require_once 'lib/plugin/IncludePage.php';
31 class WikiPlugin_DynamicIncludePage
32 extends WikiPlugin_IncludePage
36 return _("DynamicIncludePage");
39 function getDescription()
41 return _("Dynamically include the content from another wiki page.");
44 function getDefaultArguments()
47 (WikiPlugin_IncludePage::getDefaultArguments(),
49 'state' => false, // initial state: false <=> [+], true <=> [-]
53 function run($dbi, $argstr, &$request, $basepage)
56 $args = $this->getArgs($argstr, $request, false);
57 $page =& $args['page'];
60 $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
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'));
67 $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
69 $header = $html->_content[0];
70 $body = $html->_content[1];
71 $id = 'DynInc-' . MangleXmlIdentifier($page);
72 $body->setAttr('id', $id . '-body');
73 $png = $WikiTheme->_findData('images/folderArrow' .
74 ($args['state'] ? 'Open' : 'Closed') .
76 $icon = HTML::img(array('id' => $id . '-img',
78 'onclick' => ENABLE_AJAX
79 ? "showHideAsync('" . $ajaxuri . "','$id')"
80 : "showHideFolder('$id')",
81 'alt' => _("Click to hide/show"),
82 'title' => _("Click to hide/show")));
83 $header = HTML::p(array('class' => 'transclusion-title',
84 'style' => "text-decoration: none;"),
86 fmt(" %s :", WikiLink($page)));
87 if ($args['state']) { // show base
88 $body->setAttr('style', 'display:block');
89 return HTML($header, $body);
90 } else { // do not show base
91 $body->setAttr('style', 'display:none');
93 return HTML($header, $body); // async (load in background and insert)
95 return HTML($header, $body); // sync (load but display:none)
104 // c-hanging-comment-ender-p: nil
105 // indent-tabs-mode: nil