本文整理汇总了PHP中wfArrayToCGI函数的典型用法代码示例。如果您正苦于以下问题:PHP wfArrayToCGI函数的具体用法?PHP wfArrayToCGI怎么用?PHP wfArrayToCGI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfArrayToCGI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($sub)
{
global $wgOut, $wgRequest;
global $wgLandingPageBase, $wgChapterLandingPages, $wgLandingPageDefaultTarget;
$lang = preg_match('/^[A-Za-z-]+$/', $wgRequest->getVal('lang')) ? $wgRequest->getVal('lang') : 'en';
$utm_source = $wgRequest->getVal('utm_source');
$utm_medium = $wgRequest->getVal('utm_medium');
$utm_campaign = $wgRequest->getVal('utm_campaign');
$referrer = $wgRequest->getHeader('referer');
$target = $wgRequest->getVal('target', null);
if (!$target) {
$target = $wgLandingPageDefaultTarget;
}
$tracking = '?' . wfArrayToCGI(array('utm_source' => "{$utm_source}", 'utm_medium' => "{$utm_medium}", 'utm_campaign' => "{$utm_campaign}", 'referrer' => "{$referrer}", 'target' => "{$target}"));
$ip = $wgRequest->getVal('ip') ? $wgRequest->getVal('ip') : wfGetIP();
if (IP::isValid($ip)) {
$country = geoip_country_code_by_name($ip);
if (is_string($country) && array_key_exists($country, $wgChapterLandingPages)) {
$wgOut->redirect($this->getDestination($utm_source) . '/' . $wgChapterLandingPages[$country] . $tracking);
return;
}
}
// No valid IP or chapter page - let's just go for the passed in url or our fallback
if (Http::isValidURI($target)) {
$wgOut->redirect($target . '/' . $lang . $tracking);
return;
} else {
$wgOut->redirect($wgLandingPageBase . $target . '/' . $lang . $tracking);
}
}
示例2: getGoogleChartParams
function getGoogleChartParams($stats)
{
global $wgPrefStatsChartDimensions;
$max = max($stats[0]) + max($stats[1]);
$min = min(min($stats[0]), min($stats[1]));
return "http://chart.apis.google.com/chart?" . wfArrayToCGI(array('chs' => implode('x', $wgPrefStatsChartDimensions), 'cht' => 'bvs', 'chds' => '0,' . $max, 'chd' => 't:' . implode(',', $stats[0]) . '|' . implode(',', $stats[1]), 'chxt' => 'x,y,x', 'chxr' => '1,' . $min . ',' . $max, 'chxl' => '2:|' . wfMsg('prefstats-xaxis') . '|0:|' . implode('|', array_keys($stats[0])), 'chm' => 'N*f0zy*,000000,0,-1,11|N*f0zy*,000000,1,-1,11', 'chco' => '4D89F9,C6D9FD', 'chbh' => 'a', 'chdl' => wfMsg('prefstats-legend-out') . '|' . wfMsg('prefstats-legend-in')));
}
示例3: personalUrls
public static function personalUrls(&$personal_urls, &$title)
{
global $wgUser, $wgOptInAlwaysShowPersonalLink;
global $wgOptInNeverShowPersonalLink, $wgRequest;
if ($wgOptInNeverShowPersonalLink || !SpecialOptIn::isOptedIn($wgUser) && !$wgOptInAlwaysShowPersonalLink) {
// Don't show the link
return true;
}
// Loads opt-in messages
wfLoadExtensionMessages('OptInLink');
$fromquery = array();
if (!$wgRequest->wasPosted()) {
$fromquery = $wgRequest->getValues();
unset($fromquery['title']);
}
$query = array('from' => $title->getPrefixedDBKey(), 'fromquery' => wfArrayToCGI($fromquery));
// Make sure we don't create links that return to
// Special:UsabilityOptIn itself
if ($title->equals(SpecialPage::getTitleFor('OptIn'))) {
$query['from'] = $wgRequest->getVal('from');
$query['fromquery'] = $wgRequest->getVal('fromquery');
}
$addLinks = array();
// For opted-in users, add a feedback link
if (SpecialOptIn::isOptedIn($wgUser)) {
$addLinks['optin-feedback'] = array('text' => wfMsg('optin-feedback'), 'key' => 'optin-feedback', 'href' => SpecialPage::getTitleFor('OptIn')->getFullURL(array_merge($query, array('opt' => 'feedback'))), 'class' => 'no-text-transform');
}
// Inserts a link into personal tools
$key = SpecialOptIn::isOptedIn($wgUser) ? 'optin-leave' : 'optin-try';
$addLinks[$key] = array('text' => wfMsg($key), 'href' => SpecialPage::getTitleFor('OptIn')->getFullURL($query), 'class' => 'no-text-transform');
// Add the links
$personal_urls = array_merge($addLinks, $personal_urls);
return true;
}
示例4: run
/**
* Run a refreshLinks job
* @return boolean success
*/
function run()
{
global $wgTitle, $wgUser, $wgLang, $wrGedcomExportDirectory;
$wgTitle = $this->title;
// FakeTitle (the default) generates errors when accessed, and sometimes I log wgTitle, so set it to something else
$wgUser = User::newFromName('WeRelate agent');
// set the user
$treeId = $this->params['tree_id'];
$treeName = $this->params['name'];
$treeUser = $this->params['user'];
$filename = "{$wrGedcomExportDirectory}/{$treeId}.ged";
$ge = new GedcomExporter();
$error = $ge->exportGedcom($treeId, $filename);
if ($error) {
$this->error = $error;
return false;
}
// leave a message for the tree requester
$userTalkTitle = Title::newFromText($treeUser, NS_USER_TALK);
$article = new Article($userTalkTitle, 0);
if ($article->getID() != 0) {
$text = $article->getContent();
} else {
$text = '';
}
$title = Title::makeTitle(NS_SPECIAL, 'Trees');
$msg = wfMsg('GedcomExportReady', $wgLang->date(wfTimestampNow(), true, false), $treeName, $title->getFullURL(wfArrayToCGI(array('action' => 'downloadExport', 'user' => $treeUser, 'name' => $treeName))));
$text .= "\n\n" . $msg;
$success = $article->doEdit($text, 'GEDCOM export ready');
if (!$success) {
$this->error = 'Unable to edit user talk page: ' . $treeUser;
return false;
}
return true;
}
示例5: testArrayToCGI
function testArrayToCGI() {
$this->assertEquals(
"baz=AT%26T&foo=bar",
wfArrayToCGI(
array( 'baz' => 'AT&T', 'ignore' => '' ),
array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
}
示例6: setSyndicated
protected function setSyndicated()
{
$request = $this->getRequest();
$queryParams = array('namespace' => $request->getIntOrNull('namespace'), 'level' => $request->getIntOrNull('level'), 'category' => $request->getVal('category'));
$this->getOutput()->setSyndicated(true);
$this->getOutput()->setFeedAppendQuery(wfArrayToCGI($queryParams));
}
示例7: performUploadInit
public function performUploadInit($comment, $pageText, $watch, $user)
{
$check = $this->mUpload->validateNameAndOverwrite();
if ($check !== true) {
$this->getVerificationError($check);
}
$session = $this->mUpload->setupChunkSession($comment, $pageText, $watch);
return array('uploadUrl' => wfExpandUrl(wfScript('api')) . "?" . wfArrayToCGI(array('action' => 'firefoggupload', 'token' => $user->editToken(), 'format' => 'json', 'chunksession' => $session, 'filename' => $this->mUpload->getDesiredName())));
}
示例8: loadLinks
/**
* Add a link to central:Special:Phalanx from Special:Contributions/USERNAME
* if the user has 'phalanx' permission
*
* @param $id Integer: user ID
* @param $nt Title: user page title
* @param $links Array: tool links
* @return boolean true
*/
public static function loadLinks($id, $nt, &$links)
{
wfProfileIn(__METHOD__);
$user = RequestContext::getMain()->getUser();
if ($user->isAllowed('phalanx')) {
$links[] = Linker::makeKnownLinkObj(GlobalTitle::newFromText('Phalanx', NS_SPECIAL, WikiFactory::COMMUNITY_CENTRAL), 'PhalanxBlock', wfArrayToCGI(['type' => Phalanx::TYPE_USER, 'wpPhalanxCheckBlocker' => $nt->getText(), 'target' => $nt->getText()]));
}
wfProfileOut(__METHOD__);
return true;
}
示例9: buildUrl
/**
* @param string $url uri for blob resource
*/
private function buildUrl($url)
{
wfProfileIn(__METHOD__);
$app = F::app();
$path = explode('/', $url);
$cluster = $path[2];
$id = $path[3];
$query = wfArrayToCGI(array("action" => "blob", "blobid" => $id, "cluster" => $cluster));
$url = sprintf("%s/api.php?%s", $app->getGlobal("wgServer"), $query);
wfProfileOut(__METHOD__);
return $url;
}
示例10: testUrlsPolishWiki
function testUrlsPolishWiki()
{
$title = GlobalTitle::newFromText("WikiFactory", NS_SPECIAL, 1686);
# pl.wikia.com
$url = "http://spolecznosc.wikia.com/wiki/Special:WikiFactory";
$this->assertTrue($title->getFullURL() === $url, sprintf("%s = %s, NOT MATCH", $title->getFullURL(), $url));
$url = "http://spolecznosc.wikia.com/wiki/Special:WikiFactory?diff=0&oldid=500";
$this->assertTrue($title->getFullURL(wfArrayToCGI(array("diff" => 0, "oldid" => 500))) === $url, sprintf("%s = %s, NOT MATCH", $title->getFullURL(), $url));
$title = GlobalTitle::newFromText("Strona główna", false, 1686);
# pl.wikia.com
$url = "http://spolecznosc.wikia.com/wiki/Strona_g%C5%82%C3%B3wna?diff=0&oldid=500";
$this->assertTrue($title->getFullURL(wfArrayToCGI(array("diff" => 0, "oldid" => 500))) === $url, "NOT MATCH");
}
示例11: doQuery
/**
* As with QueryPage, this is the actual workhorse. It does everything
* needed to make a real, honest-to-gosh query page.
*
* @param $offset database query offset
* @param $limit database query limit
* @param $shownavigation show navigation like "next 200"?
*/
function doQuery($offset, $limit, $shownavigation = true)
{
global $wgUser, $wgOut, $wgContLang;
$this->offset = $offset;
$this->limit = $limit;
$sname = $this->getName();
$fname = get_class($this) . '::doQuery';
$sk = $wgUser->getSkin();
$wgOut->setSyndicated($this->isSyndicated());
$query = MwRdf::Query($this->getQuery(), $this->getBaseUrl(), $this->getQueryLanguage());
$librdf_res = $query->execute(MwRdf::StoredModel());
# let's just dump the tuples into a normal php array shall
# we? This will avoid memory management hassels.
$res = array();
foreach ($librdf_res as $tuple) {
$res[] = $tuple;
}
$num = count($res);
$res = $this->preprocessResults($res);
if ($shownavigation) {
$wgOut->addHTML($this->getPageHeader());
$top = wfShowingResults($offset, $num);
$wgOut->addHTML("<p>{$top}\n");
# often disable 'next' link when we reach the end
$atend = $num < $limit;
$sl = wfViewPrevNext($offset, $limit, $wgContLang->specialPage($sname), wfArrayToCGI($this->linkParameters()), $atend);
$wgOut->addHTML("<br />{$sl}</p>\n");
}
if ($num > 0) {
$s = array();
if (!$this->listoutput) {
$s[] = "<ol start='" . ($offset + 1) . "' class='special'>";
}
# here's where we do the offset and limit
for ($i = $offset; $i < $num && $i < $offset + $limit; $i++) {
$format = $this->formatResult($sk, $res[$i]);
if ($format) {
$s[] = $this->listoutput ? $format : "<li>{$format}</li>\n";
}
}
if (!$this->listoutput) {
$s[] = '</ol>';
}
$str = $this->listoutput ? $wgContLang->listToText($s) : implode('', $s);
$wgOut->addHTML($str);
}
if ($shownavigation) {
$wgOut->addHTML("<p>{$sl}</p>\n");
}
return $num;
}
示例12: performUploadInit
public function performUploadInit($comment, $pageText, $watchlist, $user) {
// Verify the initial upload request
$this->verifyUploadInit();
$session = $this->mUpload->setupChunkSession( $comment, $pageText, $watchlist );
return array('uploadUrl' =>
wfExpandUrl( wfScript( 'api' ) ) . "?" .
wfArrayToCGI( array(
'action' => 'resumableupload',
'token' => $user->editToken(),
'format' => 'json',
'chunksession' => $session,
'filename' => $this->mUpload->getDesiredName(),
) ) );
}
示例13: personalUrls
/**
* PersonalUrls hook
*/
public static function personalUrls( &$personal_urls, &$title ) {
global $wgUser, $wgRequest, $wgPrefSwitchShowLinks;
if ( !$wgPrefSwitchShowLinks ) {
return true;
}
// Figure out the orgin to include in the link
$fromquery = array();
if ( !( $wgRequest->wasPosted() ) ) {
$fromquery = $wgRequest->getValues();
unset( $fromquery['title'] );
}
// Make sure we don't create links that return to Special:UsabilityPrefSwitch itself
if ( $title->equals( SpecialPage::getTitleFor( 'PrefSwitch' ) ) ) {
$query = array( 'from' => $wgRequest->getVal( 'from' ), 'fromquery' => $wgRequest->getVal( 'fromquery' ) );
} else {
$query = array( 'from' => $title->getPrefixedDBKey(), 'fromquery' => wfArrayToCGI( $fromquery ) );
}
$state = SpecialPrefSwitch::userState( $wgUser );
if ( $state == 'on' ) {
// Inserts a link into personal tools - this just gets people to the generic new features page
$personal_urls = array_merge(
array(
"prefswitch-link-anon" => array(
'text' => wfMsg( 'prefswitch-link-anon' ),
'href' => SpecialPage::getTitleFor( 'PrefSwitch' )->getFullURL( $query ),
'class' => 'no-text-transform',
),
),
$personal_urls
);
// Make the next link go to the opt-out page
$query['mode'] = 'off';
}
// Inserts a link into personal tools - Uses prefswitch-link-anon, prefswitch-link-on and prefswitch-link-off
$personal_urls = array_merge(
array(
"prefswitch-link-{$state}" => array(
'text' => wfMsg( 'prefswitch-link-' . $state ),
'href' => SpecialPage::getTitleFor( 'PrefSwitch' )->getFullURL( $query ),
'class' => 'no-text-transform',
),
),
$personal_urls
);
return true;
}
示例14: onView
public function onView()
{
$title = $this->getTitle();
$redirectParams = wfArrayToCGI(array_diff_key($this->getRequest()->getQueryValues(), ['title' => null, 'action' => null]));
if (!$title->exists()) {
$this->addBannerNotificationMessage('templatedraft-approval-no-page-error');
$redirectTitle = $title;
} elseif (!TemplateDraftHelper::isTitleDraft($title)) {
$this->addBannerNotificationMessage('templatedraft-approval-no-templatedraft-error');
$redirectTitle = $title;
} else {
$this->approveDraft($title);
$redirectTitle = $title->getBaseText();
$redirectTitle = Title::newFromText($redirectTitle, $title->getNamespace());
}
$this->getOutput()->redirect($redirectTitle->getFullUrl($redirectParams));
}
示例15: 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)));
$this->onSubmit(array());
$this->onSuccess();
} else {
$this->redirectParams = $this->getRequest()->getVal('redirectparams', '');
$form = $this->getForm();
if ($form->show()) {
$this->onSuccess();
}
}
}