function run($dbi, $argstr, &$request, $basepage) { include_once 'lib/BlockParser.php'; $args = $this->getArgs($argstr, $request, false); extract($args); if (!$page) { return ''; } $this->_pagename = $page; $out = ''; // get rid of this $html = HTML(); if (empty($exclude)) { $exclude = array(); } if (!$include_self) { $exclude[] = $page; } $this->ExcludedPages = empty($exclude) ? "" : "^(?:" . join("|", $exclude) . ")"; $this->_default_limit = str_pad('', 3, '*'); if (is_numeric($reclimit)) { if ($reclimit < 0) { $reclimit = 0; } if ($reclimit > 10) { $reclimit = 10; } $limit = str_pad('', $reclimit + 2, '*'); } else { $limit = '***'; } //Fixme: override given arg $description = $this->getDescription(); if (!$noheader) { $out = $this->getDescription() . " " . sprintf(_("(max. recursion level: %d)"), $reclimit) . ":\n\n"; $html->pushContent(TransformText($out, 1.0, $page)); } $pagelist = new PageList($info, $exclude); $p = $dbi->getPage($page); $pagearr = array(); if ($direction == 'back') { $pagearr = $this->recursivelyGetBackLinks($p, $pagearr, "*", $limit); } else { $this->dbi = $dbi; $this->initialpage = $page; $this->firstreversed = $firstreversed; $this->excludeunknown = $excludeunknown; $pagearr = $this->recursivelyGetLinks($p, $pagearr, "*", $limit); } reset($pagearr); if (!empty($includepages)) { // disallow direct usage, only via child class IncludeSiteMap if (!isa($this, "WikiPlugin_IncludeSiteMap")) { $includepages = ''; } if (!is_string($includepages)) { $includepages = ' '; } // avoid plugin loader problems $loader = new WikiPluginLoader(); $plugin = $loader->getPlugin('IncludePage', false); $nothing = ''; } while (list($key, $link) = each($pagearr)) { if (!empty($includepages)) { $a = substr_count($key, '*'); $indenter = str_pad($nothing, $a); //$request->setArg('IncludePage', 1); // quote linkname, by Stefan Schorn $plugin_args = 'page=\'' . $link->getName() . '\' ' . $includepages; $pagehtml = $plugin->run($dbi, $plugin_args, $request, $basepage); $html->pushContent($pagehtml); //$html->pushContent( HTML(TransformText($indenter, 1.0, $page), $pagehtml)); //$out .= $indenter . $pagehtml . "\n"; } else { $out .= $key . "\n"; } } if (empty($includepages)) { return TransformText($out, 2.0, $page); } else { return $html; } }
function action_lock() { $page = $this->getPage(); $page->set('locked', true); $this->_dbi->touch(); // check ModeratedPage hook if ($moderated = $page->get('moderated')) { require_once "lib/WikiPlugin.php"; $plugin = WikiPluginLoader::getPlugin("ModeratedPage"); if ($retval = $plugin->lock_check($this, $page, $moderated)) { $this->setArg('errormsg', $retval); } } elseif ($action_page = $page->existLink(_("ModeratedPage"))) { require_once "lib/WikiPlugin.php"; $plugin = WikiPluginLoader::getPlugin("ModeratedPage"); if ($retval = $plugin->lock_add($this, $page, $action_page)) { $this->setArg('errormsg', $retval); } } $this->action_browse(); }
function pluginPulldown() { global $WikiTheme; global $AllAllowedPlugins; $plugin_dir = 'lib/plugin'; if (defined('PHPWIKI_DIR')) { $plugin_dir = PHPWIKI_DIR . "/{$plugin_dir}"; } $pd = new fileSet($plugin_dir, '*.php'); $plugins = $pd->getFiles(); unset($pd); sort($plugins); if (!empty($plugins)) { $plugin_js = ''; require_once "lib/WikiPlugin.php"; $w = new WikiPluginLoader(); foreach ($plugins as $plugin) { $pluginName = str_replace(".php", "", $plugin); if (in_array($pluginName, $AllAllowedPlugins)) { $p = $w->getPlugin($pluginName, false); // second arg? // trap php files which aren't WikiPlugin~s if (strtolower(substr(get_parent_class($p), 0, 10)) == 'wikiplugin') { $plugin_args = ''; $desc = $p->getArgumentsDescription(); $src = array("\n", '"', "'", '|', '[', ']', '\\'); $replace = array('%0A', '%22', '%27', '%7C', '%5B', '%5D', '%5C'); $desc = str_replace("<br />", ' ', $desc->asXML()); if ($desc) { $plugin_args = ' ' . str_replace($src, $replace, $desc); } $toinsert = "%0A<<" . $pluginName . $plugin_args . ">>"; // args? $plugin_js .= ",['{$pluginName}','{$toinsert}']"; } } } $plugin_js = substr($plugin_js, 1); $more_buttons = HTML::img(array('class' => "toolbar", 'id' => 'tb-plugins', 'src' => $WikiTheme->getImageURL("ed_plugins.png"), 'title' => _("AddPlugin"), 'alt' => _("AddPlugin"), 'onclick' => "showPulldown('" . _("Insert Plugin") . "',[" . $plugin_js . "],'" . _("Insert") . "','" . _("Close") . "','tb-plugins')")); return HTML("\n", $more_buttons); } return ''; }
function run($dbi, $argstr, &$request, $basepage) { //if ($request->getArg('action') != 'browse') // return $this->disabled("(action != 'browse')"); $args = $this->getArgs($argstr, $request); $this->_args = $args; extract($args); $this->preSelectS($args, $request); $info = $args['info']; $this->debug = $args['debug']; // array_multisort($this->_list, SORT_NUMERIC, SORT_DESC); $pagename = $request->getArg('pagename'); // GetUrlToSelf() with all given params //$uri = $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']; // without s would be better. //$uri = $request->getURLtoSelf();//false, array('verify')); $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'POST')); if ($request->getArg('WikiAdminSelect') == _("Go")) { $p = false; } else { $p = $request->getArg('p'); } //$p = @$GLOBALS['HTTP_POST_VARS']['p']; $form->pushContent(HTML::p(array('class' => 'wikitext'), _("Select: "), HTML::input(array('type' => 'text', 'name' => 's', 'value' => $args['s'])), HTML::input(array('type' => 'submit', 'name' => 'WikiAdminSelect', 'value' => _("Go"))))); if ($request->isPost() && !$request->getArg('wikiadmin') && !empty($p)) { $this->_list = array(); // List all selected pages again. foreach ($p as $page => $name) { $this->_list[$name] = 1; } } elseif ($request->isPost() and $request->_user->isAdmin() and !empty($p) and $request->getArg('action') == 'WikiAdminSelect' and $request->getArg('wikiadmin')) { // handle external plugin $loader = new WikiPluginLoader(); $a = array_keys($request->getArg('wikiadmin')); $plugin_action = $a[0]; $single_arg_plugins = array("Remove"); if (in_array($plugin_action, $single_arg_plugins)) { $plugin = $loader->getPlugin($plugin_action); $ul = HTML::ul(); foreach ($p as $page => $name) { $plugin_args = "run_page={$name}"; $request->setArg($plugin_action, 1); $request->setArg('p', array($page => $name)); // if the plugin requires more args than the pagename, // then this plugin will not return. (Rename, SearchReplace, ...) $action_result = $plugin->run($dbi, $plugin_args, $request, $basepage); $ul->pushContent(HTML::li(fmt("Selected page '%s' passed to '%s'.", $name, $select))); $ul->pushContent(HTML::ul(HTML::li($action_result))); } } else { // redirect to the plugin page. // in which page is this plugin? $plugin_action = preg_replace("/^WikiAdmin/", "", $plugin_action); $args = array(); foreach ($p as $page => $x) { $args["p[{$page}]"] = 1; } header("Location: " . WikiURL(_("PhpWikiAdministration") . "/" . _($plugin_action), $args, 1)); exit; } } elseif (empty($args['s'])) { // List all pages to select from. $this->_list = $this->collectPages($this->_list, $dbi, $args['sortby'], $args['limit']); } $pagelist = new PageList_Selectable($info, $args['exclude'], $args); $pagelist->addPageList($this->_list); $form->pushContent($pagelist->getContent()); foreach ($args as $k => $v) { if (!in_array($k, array('s', 'WikiAdminSelect', 'action', 'verify'))) { $form->pushContent(HiddenInputs(array($k => $v))); } // plugin params } /* foreach ($_GET as $k => $v) { if (!in_array($k,array('s','WikiAdminSelect','action'))) $form->pushContent(HiddenInputs(array($k => $v))); // debugging params, ... } */ if (!$request->getArg('verify')) { $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'verify'))); $form->pushContent(Button('submit:verify', _("Select pages"), 'wikiadmin'), Button('submit:cancel', _("Cancel"), 'button')); } else { global $WikiTheme; $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'WikiAdminSelect'))); // Add the Buttons for all registered WikiAdmin plugins $plugin_dir = 'lib/plugin'; if (defined('PHPWIKI_DIR')) { $plugin_dir = PHPWIKI_DIR . "/{$plugin_dir}"; } $fs = new fileSet($plugin_dir, 'WikiAdmin*.php'); $actions = $fs->getFiles(); foreach ($actions as $f) { $f = preg_replace('/.php$/', '', $f); $s = preg_replace('/^WikiAdmin/', '', $f); if (!in_array($s, array("Select", "Utils"))) { // disable Select and Utils $form->pushContent(Button("submit:wikiadmin[{$f}]", _($s), "wikiadmin")); $form->pushContent($WikiTheme->getButtonSeparator()); } } $form->pushContent(Button('submit:cancel', _("Cancel"), 'button')); } if (!$request->getArg('select')) { return $form; } else { //return $action_result; } }
function callPlugin($pluginname, $pluginargs, $credentials = false) { global $server; checkCredentials($server, $credentials, 'change', "Help/" . $pluginname . "Plugin"); $basepage = ''; require_once "lib/WikiPlugin.php"; $w = new WikiPluginLoader(); $p = $w->getPlugin($pluginName, false); // second arg? $pagelist = $p->run($dbi, $pluginargs, $request, $basepage); $pages = array(); if (is_object($pagelist) and isa($pagelist, 'PageList')) { foreach ($pagelist->pageNames() as $name) { $pages[] = array('pagename' => $name); } } return $pages; }
function PluginSidebarBox($name, $args = false, $basepage = false) { $loader = new WikiPluginLoader(); $plugin = $loader->getPlugin($name); if (!$plugin) { return $loader->_error(sprintf(_("Plugin %s: undefined"), $name)); } /* if (!method_exists($plugin, 'box')) { return $loader->_error(sprintf(_("%s: has no box method"), get_class($plugin))); }*/ $this->_plugin =& $plugin; $this->_args = $args ? $args : array(); $this->_basepage = $basepage; }
function _arrayToTable($array, &$request) { $thead = HTML::thead(); $label[0] = _("Wiki Name"); $label[1] = _("Search"); $thead->pushContent(HTML::tr(HTML::th($label[0]), HTML::th($label[1]))); $tbody = HTML::tbody(); $dbi = $request->getDbh(); if ($array) { foreach ($array as $moniker => $interurl) { $monikertd = HTML::td(array('class' => 'interwiki-moniker'), $dbi->isWikiPage($moniker) ? WikiLink($moniker) : $moniker); $w = new WikiPluginLoader(); $p = $w->getPlugin('ExternalSearch'); $argstr = sprintf('url="%s"', addslashes($interurl)); $searchtd = HTML::td($p->run($dbi, $argstr, $request, $basepage)); $tbody->pushContent(HTML::tr($monikertd, $searchtd)); } } $table = HTML::table(); $table->setAttr('class', 'interwiki-map'); $table->pushContent($thead); $table->pushContent($tbody); return $table; }
function _doautocomplete(&$form, $inputtype, &$input, &$values) { global $request; $input['class'] = "dropdown"; $input['acdropdown'] = "true"; //$input['autocomplete'] = "OFF"; $input['autocomplete_complete'] = "true"; // only match begin: autocomplete_matchbegin, or $input['autocomplete_matchsubstring'] = "true"; if (empty($values)) { if ($input['method']) { if (empty($input['args'])) { if (preg_match("/^(.*?) (.*)\$/", $input['method'], $m)) { $input['method'] = $m[1]; $input['args'] = $m[2]; } else { $input['args'] = null; } } static $tmpArray = 'tmpArray00'; // deferred remote xmlrpc call if (string_starts_with($input['method'], "dynxmlrpc:")) { // how is server + method + args encoding parsed by acdropdown? $input['autocomplete_list'] = substr($input['method'], 3); if ($input['args']) { $input['autocomplete_list'] .= " " . $input['args']; } // static xmlrpc call, local only } elseif (string_starts_with($input['method'], "xmlrpc:")) { include_once "lib/XmlRpcClient.php"; $values = wiki_xmlrpc_post(substr($input['method'], 7), $input['args']); } elseif (string_starts_with($input['method'], "url:")) { include_once "lib/HttpClient.php"; $html = HttpClient::quickGet(substr($input['method'], 4)); //TODO: how to parse the HTML result into a list? } elseif (string_starts_with($input['method'], "dynurl:")) { $input['autocomplete_list'] = substr($input['method'], 3); } elseif (string_starts_with($input['method'], "plugin:")) { $dbi = $request->getDbh(); $pluginName = substr($input['method'], 7); $basepage = ''; require_once "lib/WikiPlugin.php"; $w = new WikiPluginLoader(); $p = $w->getPlugin($pluginName, false); // second arg? if (!is_object($p)) { trigger_error("invalid input['method'] " . $input['method'], E_USER_WARNING); } $pagelist = $p->run($dbi, @$input['args'], $request, $basepage); $values = array(); if (is_object($pagelist) and isa($pagelist, 'PageList')) { foreach ($pagelist->_pages as $page) { if (is_object($page)) { $values[] = $page->getName(); } else { $values[] = (string) $page; } } } } elseif (string_starts_with($input['method'], "array:")) { // some predefined values (e.g. in a template or themeinfo.php) $input['autocomplete_list'] = $input['method']; } else { trigger_error("invalid input['method'] " . $input['method'], E_USER_WARNING); } if (empty($input['autocomplete_list'])) { $tmpArray++; $input['autocomplete_list'] = "array:" . $tmpArray; $svalues = empty($values) ? "" : join("','", $values); $form->pushContent(JavaScript("var {$tmpArray} = new Array('" . $svalues . "')")); } if (count($values) == 1) { $input['value'] = $values[0]; } else { $input['value'] = ""; } unset($input['method']); unset($input['args']); //unset($input['autocomplete']); } elseif ($s = $request->getArg($input['name'])) { $input['value'] = $s; } } return true; }
/** * Main function for obtaining images from cache or generating on-the-fly * from parameters sent by url or session vars. * * @access static public * @param dbi WikiDB handle to database * @param request Request ??? * @param errorformat string outputs errors in 'png', 'gif', 'jpeg' or 'html' */ function fetchImageFromCache($dbi, $request, $errorformat = 'png') { $cache = $this->newCache(); $errorformat = $this->decideImgType($errorformat); // get id if (!$this->checkCall1($id, $plugincall, $cache, $request, $errorformat)) { return false; } // check cache $content = $cache->get($id, 'imagecache'); if (!empty($content['image'])) { $this->writeHeader($content['imagetype']); print $content['image']; return true; } if (!empty($content['html'])) { print $content['html']; return true; } // static version? if (!empty($content['file']) && !empty($content['url']) && file_exists($content['file'])) { print $this->embedImg($content['url'], $dbi, array(), $request); return true; } // re-produce image. At first, we need the plugincall parameters. // Cached args with matching id override given args to shorten getimg.php?id=md5 if (!empty($content['args'])) { $plugincall['arguments'] = $content['args']; } if (!$this->checkCall2($plugincall, $request)) { return false; } $pluginname = $plugincall['pluginname']; $argarray = $plugincall['arguments']; $loader = new WikiPluginLoader(); $plugin = $loader->getPlugin($pluginname); // cache empty, but image maps have to be created _inline_ // so ask user to reload wiki page instead if ($plugin->getPluginType() & PLUGIN_CACHED_MAP && PLUGIN_CACHED_FORCE_SYNCMAP) { $errortext = _("Image map expired. Reload wiki page to recreate its html part."); $this->printError($errorformat, $errortext); } if (!$this->produceImage($content, $plugin, $dbi, $argarray, $request, $errorformat)) { return false; } $expire = $plugin->getExpire($dbi, $argarray, $request); if ($content['image']) { $cache->save($id, $content, $expire, 'imagecache'); $this->writeHeader($content['imagetype']); print $content['image']; return true; } $errortext = "Could not create image file from imagehandle."; $this->printError($errorformat, $errortext); return false; }
function _generateTableBody(&$info, &$dbi, &$request, &$table) { $plugin_dir = 'lib/plugin'; if (defined('PHPWIKI_DIR')) { $plugin_dir = PHPWIKI_DIR . "/{$plugin_dir}"; } $pd = new fileSet($plugin_dir, '*.php'); $plugins = $pd->getFiles(); unset($pd); sort($plugins); // table body $tbody = HTML::tbody(); $row_no = 0; $w = new WikiPluginLoader(); foreach ($plugins as $pluginName) { // instantiate a plugin $pluginName = str_replace(".php", "", $pluginName); $temppluginclass = "<? plugin {$pluginName} ?>"; // hackish $p = $w->getPlugin($pluginName, false); // second arg? // trap php files which aren't WikiPlugin~s if (!strtolower(substr(get_parent_class($p), 0, 10)) == 'wikiplugin') { // Security: Hide names of extraneous files within // plugin dir from non-admins. if ($request->_user->isAdmin()) { trigger_error(sprintf(_("%s does not appear to be a WikiPlugin."), $pluginName . ".php")); } continue; // skip this non WikiPlugin file } $desc = $p->getDescription(); $ver = $p->getVersion(); $arguments = $p->getArgumentsDescription(); unset($p); //done querying plugin object, release from memory // This section was largely improved by Pierrick Meignen: // make a link if an actionpage exists $pluginNamelink = $pluginName; $pluginDocPageName = $pluginName . "Plugin"; $pluginDocPageNamelink = false; $localizedPluginName = ''; $localizedPluginDocPageName = ''; if ($GLOBALS['LANG'] != "en") { if (_($pluginName) != $pluginName) { $localizedPluginName = _($pluginName); } if ($localizedPluginName && $dbi->isWikiPage($localizedPluginName)) { $pluginDocPageNamelink = WikiLink($localizedPluginName, 'if_known'); } if (_($pluginDocPageName) != $pluginDocPageName) { $localizedPluginDocPageName = _($pluginDocPageName); } if ($localizedPluginDocPageName && $dbi->isWikiPage($localizedPluginDocPageName)) { $pluginDocPageNamelink = WikiLink($localizedPluginDocPageName, 'if_known'); } } else { $pluginNamelink = WikiLink($pluginName, 'if_known'); if ($dbi->isWikiPage($pluginDocPageName)) { $pluginDocPageNamelink = WikiLink($pluginDocPageName, 'if_known'); } } // highlight alternate rows $row_no++; $group = (int) ($row_no / 1); //_group_rows $class = $group % 2 ? 'evenrow' : 'oddrow'; // generate table row $tr = HTML::tr(array('class' => $class)); if ($pluginDocPageNamelink) { // plugin has a description page 'PluginName' . 'Plugin' $tr->pushContent(HTML::td($pluginNamelink, HTML::br(), $pluginDocPageNamelink)); $pluginDocPageNamelink = false; } else { // plugin just has an actionpage $tr->pushContent(HTML::td($pluginNamelink)); } $tr->pushContent(HTML::td($ver), HTML::td($desc)); if ($info == 'args') { // add Arguments column $style = array('style' => 'font-family:monospace;font-size:smaller'); $tr->pushContent(HTML::td($style, $arguments)); } $tbody->pushContent($tr); } $table->pushContent($tbody); }
function _approval_form(&$request, $args, $moderation, $pass = '******') { $header = HTML::h3(_("Please approve or reject this request:")); $loader = new WikiPluginLoader(); $BackendInfo = $loader->getPlugin("_BackendInfo"); $content = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0)); $myargs = $args; $BackendInfo->_fixupData($myargs); $content->pushContent($BackendInfo->_showhash("request args", $myargs)); $BackendInfo->_fixupData($moderation); $content->pushContent($BackendInfo->_showhash("moderation data", $moderation)); $approve = Button('submit:ModeratedPage[approve]', _("Approve"), $pass == 'approve' ? 'wikiadmin' : 'button'); $reject = Button('submit:ModeratedPage[reject]', _("Reject"), $pass == 'reject' ? 'wikiadmin' : 'button'); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $content, ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), HiddenInputs($args), $pass == 'approve' ? HTML::p($approve, $reject) : HTML::p($reject, $approve)); }
function _approval_form(&$request, $args, $moderation, $pass = '******') { $header = HTML::h3(_("Please approve or reject this request:")); $loader = new WikiPluginLoader(); $BackendInfo = $loader->getPlugin("_BackendInfo"); $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0)); $content = $table; $diff = ''; if ($moderation['args']['action'] == 'edit') { $pagename = $moderation['args']['pagename']; $p = $request->_dbi->getPage($pagename); $rev = $p->getCurrentRevision(true); $curr_content = $rev->getPackedContent(); $new_content = $moderation['args']['edit']['content']; include_once "lib/difflib.php"; $diff2 = new Diff($curr_content, $new_content); $fmt = new UnifiedDiffFormatter(); $diff = $pagename . " Current Version " . Iso8601DateTime($p->get('mtime')) . "\n"; $diff .= $pagename . " Edited Version " . Iso8601DateTime($moderation['timestamp']) . "\n"; $diff .= $fmt->format($diff2); } $content->pushContent($BackendInfo->_showhash("Request", array('User' => $moderation['userid'], 'When' => CTime($moderation['timestamp']), 'Pagename' => $pagename, 'Action' => $moderation['args']['action'], 'Diff' => HTML::pre($diff)))); $content_dbg = $table; $myargs = $args; $BackendInfo->_fixupData($myargs); $content_dbg->pushContent($BackendInfo->_showhash("raw request args", $myargs)); $BackendInfo->_fixupData($moderation); $content_dbg->pushContent($BackendInfo->_showhash("raw moderation data", $moderation)); $reason = HTML::div(_("Reason: "), HTML::textarea(array('name' => 'reason'))); $approve = Button('submit:ModeratedPage[approve]', _("Approve"), $pass == 'approve' ? 'wikiadmin' : 'button'); $reject = Button('submit:ModeratedPage[reject]', _("Reject"), $pass == 'reject' ? 'wikiadmin' : 'button'); $args['action'] = _("ModeratedPage"); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $content, HTML::p(""), $content_dbg, $reason, ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), HiddenInputs($args), $pass == 'approve' ? HTML::p($approve, $reject) : HTML::p($reject, $approve)); }
function getPluginSynopsis($params) { $ParamPlugin = $params->getParam(0); $pluginName = short_string_decode($ParamPlugin->scalarval()); require_once "lib/WikiPlugin.php"; $w = new WikiPluginLoader(); $synopsis = ''; $p = $w->getPlugin($pluginName, false); // second arg? // trap php files which aren't WikiPlugin~s: wikiplugin + wikiplugin_cached only if (strtolower(substr(get_parent_class($p), 0, 10)) == 'wikiplugin') { $plugin_args = ''; $desc = $p->getArgumentsDescription(); $src = array("\n", '"', "'", '|', '[', ']', '\\'); $replace = array('%0A', '%22', '%27', '%7C', '%5B', '%5D', '%5C'); $desc = str_replace("<br />", ' ', $desc->asXML()); if ($desc) { $plugin_args = '\\n' . str_replace($src, $replace, $desc); } $synopsis = "<?plugin " . $pluginName . $plugin_args . "?>"; // args? } return new xmlrpcresp(short_string($synopsis)); }
function callPlugin($params) { global $request; $dbi = $request->getDbh(); $ParamPlugin = $params->getParam(0); $pluginName = short_string_decode($ParamPlugin->scalarval()); $ParamArgs = $params->getParam(1); $plugin_args = short_string_decode($ParamArgs->scalarval()); $basepage = ''; //$pluginName; require_once "lib/WikiPlugin.php"; $w = new WikiPluginLoader(); $p = $w->getPlugin($pluginName, false); // second arg? $pagelist = $p->run($dbi, $plugin_args, $request, $basepage); $list = array(); if (is_object($pagelist) and isa($pagelist, 'PageList')) { foreach ($pagelist->_pages as $page) { $list[] = $page->getName(); } } return new xmlrpcresp(new xmlrpcval($list, "array")); }
/** A higher-level interface to createRevision. * * This takes care of computing the links, and storing * a cached version of the transformed wiki-text. * * @param string $wikitext The page content. * * @param int $version Version number for new revision. * To ensure proper serialization of edits, $version must be * exactly one higher than the current latest version. * (You can defeat this check by setting $version to * {@link WIKIDB_FORCE_CREATE} --- not usually recommended.) * * @param hash $meta Meta-data for new revision. */ function save($wikitext, $version, $meta, $formatted = null) { if ($this->_wikidb->readonly) { trigger_error("readonly database", E_USER_WARNING); return; } if (is_null($formatted)) { $formatted = new TransformedText($this, $wikitext, $meta); } $type = $formatted->getType(); $meta['pagetype'] = $type->getName(); $links = $formatted->getWikiPageLinks(); // linkto => relation $attributes = array(); foreach ($links as $link) { if ($link['linkto'] === "" and !empty($link['relation'])) { $attributes[$link['relation']] = $this->getAttribute($link['relation']); } } $meta['attribute'] = $attributes; $backend =& $this->_wikidb->_backend; $newrevision = $this->createRevision($version, $wikitext, $meta, $links); if ($newrevision and !WIKIDB_NOCACHE_MARKUP) { $this->set('_cached_html', $formatted->pack()); } // FIXME: probably should have some global state information // in the backend to control when to optimize. // // We're doing this here rather than in createRevision because // postgresql can't optimize while locked. if ((int) DEBUG & _DEBUG_SQL or DATABASE_OPTIMISE_FREQUENCY > 0 and time() % DATABASE_OPTIMISE_FREQUENCY == 0) { if ($backend->optimize()) { if ((int) DEBUG) { trigger_error(_("Optimizing database"), E_USER_NOTICE); } } } /* Generate notification emails? */ if (ENABLE_MAILNOTIFY and isa($newrevision, 'WikiDB_PageRevision')) { // Save didn't fail because of concurrent updates. $notify = $this->_wikidb->get('notify'); if (!empty($notify) and is_array($notify) and !isa($GLOBALS['request'], 'MockRequest')) { include_once "lib/MailNotify.php"; $MailNotify = new MailNotify($newrevision->getName()); $MailNotify->onChangePage($this->_wikidb, $wikitext, $version, $meta); } $newrevision->_transformedContent = $formatted; } // more pagechange callbacks: (in a hackish manner for now) if (ENABLE_RECENTCHANGESBOX and empty($meta['is_minor_edit']) and !in_array($GLOBALS['request']->getArg('action'), array('loadfile', 'upgrade'))) { require_once "lib/WikiPlugin.php"; $w = new WikiPluginLoader(); $p = $w->getPlugin("RecentChangesCached", false); $p->box_update(false, $GLOBALS['request'], $this->_pagename); } return $newrevision; }