function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); $html = HTML(); if (empty($args['pages'])) { return $html; } $include = new WikiPlugin_IncludePage(); if (is_string($args['exclude']) and !empty($args['exclude'])) { $args['exclude'] = explodePageList($args['exclude']); $argstr = preg_replace("/exclude=\\S*\\s/", "", $argstr); } elseif (is_array($args['exclude'])) { $argstr = preg_replace("/exclude=<\\?plugin-list.*?\\>/", "", $argstr); } if (is_string($args['pages']) and !empty($args['pages'])) { $args['pages'] = explodePageList($args['pages']); $argstr = preg_replace("/pages=\\S*\\s/", "", $argstr); } elseif (is_array($args['pages'])) { $argstr = preg_replace("/pages=<\\?plugin-list.*?\\>/", "", $argstr); } foreach ($args['pages'] as $page) { if (empty($args['exclude']) or !in_array($page, $args['exclude'])) { $html = HTML($html, $include->run($dbi, "page='{$page}' " . $argstr, $request, $basepage)); } } return $html; }
/** * Test the plugin with the typical editpage template call. */ function testIncludePageSynopsis() { global $request; $pagename = 'Help/TextFormattingRules'; $lp = new WikiPlugin_IncludePage(); $this->assertEquals("IncludePage", $lp->getName()); $dbi = $request->getDbh(); $result = $lp->run($dbi, "page={$pagename} section=Synopsis quiet=1", $request, "IncludePage"); $this->assertType('object', $result, 'isa HtmlElement'); //TODO: check content for found and extracted section }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $args = $this->getArgs($argstr, $request, false); $page =& $args['page']; if (ENABLE_AJAX) { if ($args['state']) { $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage); } else { $html = HTML(HTML::p(array('class' => 'transclusion-title'), fmt(" %s :", WikiLink($page))), HTML::div(array('class' => 'transclusion'), '')); } $ajaxuri = WikiURL($page, array('format' => 'xml')); } else { $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage); } $header = $html->_content[0]; $body = $html->_content[1]; $id = 'DynInc-' . MangleXmlIdentifier($page); $body->setAttr('id', $id . '-body'); $png = $WikiTheme->_findData('images/folderArrow' . ($args['state'] ? 'Open' : 'Closed') . '.png'); $icon = HTML::img(array('id' => $id . '-img', 'src' => $png, 'onclick' => ENABLE_AJAX ? "showHideAsync('" . $ajaxuri . "','{$id}')" : "showHideFolder('{$id}')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show"))); $header = HTML::p(array('class' => 'transclusion-title', 'style' => "text-decoration: none;"), $icon, fmt(" %s :", WikiLink($page))); if ($args['state']) { // show base $body->setAttr('style', 'display:block'); return HTML($header, $body); } else { // do not show base $body->setAttr('style', 'display:none'); if (ENABLE_AJAX) { return HTML($header, $body); } else { return HTML($header, $body); } // sync (load but display:none) } }