function _export($args, $our) { global $request; $reaction = 'export '; if ($args['noexport']) { return $reaction . _("skipped"); } $userid = $request->_user->_userid; $name = $our->getName(); $ourrev = $our->getCurrentRevision(true); $content = $ourrev->getPackedContent(); $extdata = wiki_xmlrpc_post('wiki.getPage', $name, $args['url']); if (is_object($extdata)) { $extdata = $extdata->scalar; if ($extdata == $content) { return $reaction . _("skipped") . ' ' . _("same content"); } } $mypass = $request->getPref('passwd'); // this usually fails $success = wiki_xmlrpc_post('wiki.putPage', array($name, $content, $userid, $mypass), $args['url']); if (is_array($success)) { if ($success['code'] == 200) { $reaction .= _("OK") . ' ' . $success['code'] . " " . $success['message']; } else { $reaction .= _("FAILED") . ' ' . $success['code'] . " " . $success['message']; } } else { $reaction .= _("FAILED"); } return $reaction; }
function testSelfAPI_v1() { $v = wiki_xmlrpc_post("wiki.getRPCVersionSupported"); $this->assertTrue($v >= 1); }
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; }