本文整理汇总了PHP中wfArrayToCgi函数的典型用法代码示例。如果您正苦于以下问题:PHP wfArrayToCgi函数的具体用法?PHP wfArrayToCgi怎么用?PHP wfArrayToCgi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfArrayToCgi函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSyndicated
protected function setSyndicated()
{
$request = $this->getRequest();
$queryParams = array('level' => $request->getIntOrNull('level'), 'tag' => $request->getVal('tag'), 'category' => $request->getVal('category'));
$this->getOutput()->setSyndicated(true);
$this->getOutput()->setFeedAppendQuery(wfArrayToCgi($queryParams));
}
示例2: show
/**
* purge is slightly weird because it can be either formed or formless depending
* on user permissions
*/
public function show()
{
$this->setHeaders();
// This will throw exceptions if there's a problem
$this->checkCanExecute($this->getUser());
$user = $this->getUser();
if ($user->pingLimiter('purge')) {
// TODO: Display actionthrottledtext
return;
}
if ($user->isAllowed('purge')) {
// This will update the database immediately, even on HTTP GET.
// Lots of uses may exist for this feature, so just ignore warnings.
Profiler::instance()->getTransactionProfiler()->resetExpectations();
$this->redirectParams = wfArrayToCgi(array_diff_key($this->getRequest()->getQueryValues(), ['title' => null, 'action' => null]));
if ($this->onSubmit([])) {
$this->onSuccess();
}
} else {
$this->redirectParams = $this->getRequest()->getVal('redirectparams', '');
$form = $this->getForm();
if ($form->show()) {
$this->onSuccess();
}
}
}
示例3: __construct
function __construct()
{
parent::__construct();
$this->classname = "google";
$this->resourceModules[] = 'ext.MultiMaps.Google';
$urlArgs = array();
$urlArgs['sensor'] = 'false';
$urlArgs['v'] = '3.10';
$this->headerItem .= \Html::linkedScript('//maps.googleapis.com/maps/api/js?' . wfArrayToCgi($urlArgs)) . "\n";
}
示例4: passCaptcha
function passCaptcha()
{
global $wgRequest;
$ticket = $wgRequest->getVal('Asirra_Ticket');
$api = 'http://challenge.asirra.com/cgi/Asirra?';
$params = array('action' => 'ValidateTicket', 'ticket' => $ticket);
$response = Http::get($api . wfArrayToCgi($params));
$xml = simplexml_load_string($response);
$result = $xml->xpath('/AsirraValidation/Result');
return strval($result[0]) === 'Pass';
}
示例5: fetchLinks
/**
* @return array[]|bool The 'interwikimap' sub-array or false on failure.
*/
protected function fetchLinks()
{
$url = wfArrayToCgi(array('action' => 'query', 'meta' => 'siteinfo', 'siprop' => 'interwikimap', 'sifilteriw' => 'local', 'format' => 'json'));
if (!empty($this->source)) {
$url = rtrim($this->source, '?') . '?' . $url;
}
$json = Http::get($url);
$data = json_decode($json, true);
if (is_array($data)) {
return $data['query']['interwikimap'];
} else {
return false;
}
}
示例6: normalizePageName
/**
* Returns the normalized form of the given page title, using the normalization rules of the given site.
* If the given title is a redirect, the redirect weill be resolved and the redirect target is returned.
*
* @note : This actually makes an API request to the remote site, so beware that this function is slow and depends
* on an external service.
*
* @note : If MW_PHPUNIT_TEST is defined, the call to the external site is skipped, and the title
* is normalized using the local normalization rules as implemented by the Title class.
*
* @see Site::normalizePageName
*
* @since 1.21
*
* @param string $pageName
*
* @return string
* @throws MWException
*/
public function normalizePageName($pageName)
{
// Check if we have strings as arguments.
if (!is_string($pageName)) {
throw new MWException('$pageName must be a string');
}
// Go on call the external site
if (defined('MW_PHPUNIT_TEST')) {
// If the code is under test, don't call out to other sites, just normalize locally.
// Note: this may cause results to be inconsistent with the actual normalization used by the respective remote site!
$t = Title::newFromText($pageName);
return $t->getPrefixedText();
} else {
// Make sure the string is normalized into NFC (due to the bug 40017)
// but do nothing to the whitespaces, that should work appropriately.
// @see https://bugzilla.wikimedia.org/show_bug.cgi?id=40017
$pageName = UtfNormal::cleanUp($pageName);
// Build the args for the specific call
$args = array('action' => 'query', 'prop' => 'info', 'redirects' => true, 'converttitles' => true, 'format' => 'json', 'titles' => $pageName);
$url = $this->getFileUrl('api.php') . '?' . wfArrayToCgi($args);
// Go on call the external site
//@todo: we need a good way to specify a timeout here.
$ret = Http::get($url);
}
if ($ret === false) {
wfDebugLog("MediaWikiSite", "call to external site failed: {$url}");
return false;
}
$data = FormatJson::decode($ret, true);
if (!is_array($data)) {
wfDebugLog("MediaWikiSite", "call to <{$url}> returned bad json: " . $ret);
return false;
}
$page = static::extractPageRecord($data, $pageName);
if (isset($page['missing'])) {
wfDebugLog("MediaWikiSite", "call to <{$url}> returned a marker for a missing page title! " . $ret);
return false;
}
if (isset($page['invalid'])) {
wfDebugLog("MediaWikiSite", "call to <{$url}> returned a marker for an invalid page title! " . $ret);
return false;
}
if (!isset($page['title'])) {
wfDebugLog("MediaWikiSite", "call to <{$url}> did not return a page title! " . $ret);
return false;
}
return $page['title'];
}
示例7: show
/**
* purge is slightly weird because it can be either formed or formless depending
* on user permissions
*/
public function show()
{
$this->setHeaders();
// This will throw exceptions if there's a problem
$this->checkCanExecute($this->getUser());
if ($this->getUser()->isAllowed('purge')) {
$this->redirectParams = wfArrayToCgi(array_diff_key($this->getRequest()->getQueryValues(), array('title' => null, 'action' => null)));
if ($this->onSubmit(array())) {
$this->onSuccess();
}
} else {
$this->redirectParams = $this->getRequest()->getVal('redirectparams', '');
$form = $this->getForm();
if ($form->show()) {
$this->onSuccess();
}
}
}
示例8: getPageUrl
/**
* Returns the (partial) URL for the given page (including any section identifier).
*
* @param TitleValue $page The link's target
* @param array $params any additional URL parameters.
*
* @return string
*/
public function getPageUrl(TitleValue $page, $params = array())
{
//TODO: move the code from Linker::linkUrl here!
//The below is just a rough estimation!
$name = $this->formatter->getPrefixedText($page);
$name = str_replace(' ', '_', $name);
$name = wfUrlencode($name);
$url = $this->baseUrl . $name;
if ($params) {
$separator = strpos($url, '?') ? '&' : '?';
$url .= $separator . wfArrayToCgi($params);
}
$fragment = $page->getFragment();
if ($fragment !== '') {
$url = $url . '#' . wfUrlencode($fragment);
}
return $url;
}
示例9: getForm
/**
* Get the HTMLForm to control behavior
* @return HTMLForm|null
*/
protected function getForm()
{
$this->fields = $this->getFormFields();
// Give hooks a chance to alter the form, adding extra fields or text etc
wfRunHooks('ActionModifyFormFields', array($this->getName(), &$this->fields, $this->page));
$form = new HTMLForm($this->fields, $this->getContext(), $this->getName());
$form->setSubmitCallback(array($this, 'onSubmit'));
// Retain query parameters (uselang etc)
$form->addHiddenField('action', $this->getName());
// Might not be the same as the query string
$params = array_diff_key($this->getRequest()->getQueryValues(), array('action' => null, 'title' => null));
$form->addHiddenField('redirectparams', wfArrayToCgi($params));
$form->addPreText($this->preText());
$form->addPostText($this->postText());
$this->alterForm($form);
// Give hooks a chance to alter the form, adding extra fields or text etc
wfRunHooks('ActionBeforeFormDisplay', array($this->getName(), &$form, $this->page));
return $form;
}
示例10: createPDF
/**
* Gets a DOMDocument, searches it for files, uploads files and markus to webservice and generated PDF.
* @param DOMDocument $oHtmlDOM The source markup
* @return string The resulting PDF as bytes
*/
public function createPDF(&$oHtmlDOM)
{
$this->findFiles($oHtmlDOM);
$this->uploadFiles();
//HINT: http://www.php.net/manual/en/class.domdocument.php#96055
//But: Formated Output is evil because is will destroy formatting in <pre> Tags!
$sHtmlDOM = $oHtmlDOM->saveXML($oHtmlDOM->documentElement);
//Save temporary
$sTmpHtmlFile = BSDATADIR . DS . 'UEModulePDF' . DS . $this->aParams['document-token'] . '.html';
$sTmpPDFFile = BSDATADIR . DS . 'UEModulePDF' . DS . $this->aParams['document-token'] . '.pdf';
file_put_contents($sTmpHtmlFile, $sHtmlDOM);
$aOptions = array('timeout' => 120, 'postData' => array('fileType' => '', 'documentToken' => $this->aParams['document-token'], 'sourceHtmlFile_name' => basename($sTmpHtmlFile), 'sourceHtmlFile' => '@' . $sTmpHtmlFile, 'wikiId' => wfWikiID()));
if (BsConfig::get('MW::TestMode')) {
$aOptions['postData']['debug'] = "true";
}
global $bsgUEModulePDFCURLOptions;
$aOptions = array_merge_recursive($aOptions, $bsgUEModulePDFCURLOptions);
wfRunHooks('BSUEModulePDFCreatePDFBeforeSend', array($this, &$aOptions, $oHtmlDOM));
$vHttpEngine = Http::$httpEngine;
Http::$httpEngine = 'curl';
//HINT: http://www.php.net/manual/en/function.curl-setopt.php#refsect1-function.curl-setopt-notes
//Upload HTML source
//TODO: Handle $sResponse
$sResponse = Http::post($this->aParams['soap-service-url'] . '/UploadAsset', $aOptions);
//Now do the rendering
//We re-send the paramters but this time without the file.
unset($aOptions['postData']['sourceHtmlFile']);
unset($aOptions['postData']['fileType']);
//We do not want the request to be multipart/formdata because that's more difficult to handle on Servlet-side
$aOptions['postData'] = wfArrayToCgi($aOptions['postData']);
$vPdfByteArray = Http::post($this->aParams['soap-service-url'] . '/RenderPDF', $aOptions);
Http::$httpEngine = $vHttpEngine;
if ($vPdfByteArray == false) {
wfDebugLog('BS::UEModulePDF', 'BsPDFServlet::createPDF: Failed creating "' . $this->aParams['document-token'] . '"');
}
file_put_contents($sTmpPDFFile, $vPdfByteArray);
//Remove temporary file
if (!BsConfig::get('MW::TestMode')) {
unlink($sTmpHtmlFile);
unlink($sTmpPDFFile);
}
return $vPdfByteArray;
}
示例11: getForm
/**
* Get the HTMLForm to control behavior
* @return HTMLForm|null
*/
protected function getForm()
{
$this->fields = $this->getFormFields();
// Give hooks a chance to alter the form, adding extra fields or text etc
Hooks::run('ActionModifyFormFields', [$this->getName(), &$this->fields, $this->page]);
$form = new HTMLForm($this->fields, $this->getContext(), $this->getName());
$form->setSubmitCallback([$this, 'onSubmit']);
$title = $this->getTitle();
$form->setAction($title->getLocalURL(['action' => $this->getName()]));
// Retain query parameters (uselang etc)
$params = array_diff_key($this->getRequest()->getQueryValues(), ['action' => null, 'title' => null]);
if ($params) {
$form->addHiddenField('redirectparams', wfArrayToCgi($params));
}
$form->addPreText($this->preText());
$form->addPostText($this->postText());
$this->alterForm($form);
// Give hooks a chance to alter the form, adding extra fields or text etc
Hooks::run('ActionBeforeFormDisplay', [$this->getName(), &$form, $this->page]);
return $form;
}
示例12: doPairs
protected function doPairs()
{
if (!isset($this->config['key'])) {
throw new TranslationWebServiceException('API key is not set');
}
$pairs = array();
$params = array('key' => $this->config['key']);
$url = $this->config['pairs'] . '?' . wfArrayToCgi($params);
// BC MW <= 1.24
$json = Http::request('GET', $url, array('timeout' => $this->config['timeout']));
$response = FormatJson::decode($json);
if (!is_object($response)) {
$exception = 'Malformed reply from remote server: ' . strval($json);
throw new TranslationWebServiceException($exception);
}
foreach ($response->dirs as $pair) {
list($source, $target) = explode('-', $pair);
$pairs[$source][$target] = true;
}
return $pairs;
}
示例13: fetchImageQuery
protected function fetchImageQuery($query)
{
global $wgMemc;
$url = $this->mApiBase . '?' . wfArrayToCgi(array_merge($query, array('format' => 'json', 'action' => 'query')));
if (!isset($this->mQueryCache[$url])) {
$key = wfMemcKey('ForeignAPIRepo', 'Metadata', md5($url));
$data = $wgMemc->get($key);
if (!$data) {
$data = Http::get($url);
if (!$data) {
return null;
}
$wgMemc->set($key, $data, 3600);
}
if (count($this->mQueryCache) > 100) {
// Keep the cache from growing infinitely
$this->mQueryCache = array();
}
$this->mQueryCache[$url] = $data;
}
return json_decode($this->mQueryCache[$url], true);
}
示例14: show
public function show()
{
$this->setHeaders();
// This will throw exceptions if there's a problem
$this->checkCanExecute($this->getUser());
$user = $this->getUser();
if ($user->pingLimiter('purge')) {
// TODO: Display actionthrottledtext
return;
}
if ($this->getRequest()->wasPosted()) {
$this->redirectParams = wfArrayToCgi(array_diff_key($this->getRequest()->getQueryValues(), ['title' => null, 'action' => null]));
if ($this->onSubmit([])) {
$this->onSuccess();
}
} else {
$this->redirectParams = $this->getRequest()->getVal('redirectparams', '');
$form = $this->getForm();
if ($form->show()) {
$this->onSuccess();
}
}
}
示例15: threadCommands
/**
* @param $thread Thread
* Example return value:
* array (
* edit => array( 'label' => 'Edit',
* 'href' => 'http...',
* 'enabled' => false ),
* reply => array( 'label' => 'Reply',
* 'href' => 'http...',
* 'enabled' => true )
* )
*/
function threadCommands($thread)
{
$commands = array();
$isLqtPage = LqtDispatch::isLqtPage($thread->getTitle());
$history_url = self::permalinkUrlWithQuery($thread, array('action' => 'history'));
$commands['history'] = array('label' => wfMessage('history_short')->parse(), 'href' => $history_url, 'enabled' => true);
if ($thread->isHistorical()) {
return array();
}
$user_can_edit = $thread->root()->getTitle()->quickUserCan('edit');
$editMsg = $user_can_edit ? 'edit' : 'viewsource';
if ($isLqtPage) {
$commands['edit'] = array('label' => wfMessage($editMsg)->parse(), 'href' => $this->talkpageUrl($this->title, 'edit', $thread, true, $this->request), 'enabled' => true);
}
if ($this->user->isAllowed('delete')) {
$delete_url = $thread->title()->getLocalURL('action=delete');
$deleteMsg = $thread->type() == Threads::TYPE_DELETED ? 'lqt_undelete' : 'delete';
$commands['delete'] = array('label' => wfMessage($deleteMsg)->parse(), 'href' => $delete_url, 'enabled' => true);
}
if ($isLqtPage) {
if (!$thread->isTopmostThread() && $this->user->isAllowed('lqt-split')) {
$splitUrl = SpecialPage::getTitleFor('SplitThread', $thread->title()->getPrefixedText())->getLocalURL();
$commands['split'] = array('label' => wfMessage('lqt-thread-split')->parse(), 'href' => $splitUrl, 'enabled' => true);
}
if ($this->user->isAllowed('lqt-merge')) {
$mergeParams = $_GET;
$mergeParams['lqt_merge_from'] = $thread->id();
unset($mergeParams['title']);
$mergeUrl = $this->title->getLocalURL(wfArrayToCgi($mergeParams));
$label = wfMessage('lqt-thread-merge')->parse();
$commands['merge'] = array('label' => $label, 'href' => $mergeUrl, 'enabled' => true);
}
}
$commands['link'] = array('label' => wfMessage('lqt_permalink')->parse(), 'href' => $thread->title()->getLocalURL(), 'enabled' => true, 'showlabel' => true, 'tooltip' => wfMessage('lqt_permalink')->parse());
Hooks::run('LiquidThreadsThreadCommands', array($thread, &$commands));
return $commands;
}