예제 #1
0
 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);
     }
 }
 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
0
 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
0
 /**
  * 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
0
	function testArrayToCGI() {
		$this->assertEquals(
			"baz=AT%26T&foo=bar",
			wfArrayToCGI(
				array( 'baz' => 'AT&T', 'ignore' => '' ),
				array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
	}
 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));
 }
 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
0
 /**
  * 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
0
 /**
  * @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
0
 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
0
 /**
  * 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;
 }
	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(),
			) ) );
	}
	/**
	 * 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
0
 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
0
 /**
  * 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();
         }
     }
 }
예제 #16
0
 /**
  * This is the actual workhorse. It does everything needed to make a
  * real, honest-to-gosh query page.
  * Alas, we need to overwrite the whole beast since we do not assume
  * an SQL-based storage backend.
  *
  * @param $offset database query offset
  * @param $limit database query limit
  */
 function doQuery($offset = false, $limit = false)
 {
     global $wgOut, $wgContLang;
     $options = new SMWRequestOptions();
     $options->limit = $limit;
     $options->offset = $offset;
     $options->sort = true;
     $res = $this->getResults($options);
     $num = count($res);
     $sk = $this->getSkin();
     $sname = $this->getName();
     $wgOut->addHTML($this->getPageHeader());
     // if list is empty, show it
     if ($num == 0) {
         $wgOut->addHTML('<p>' . wfMsgHTML('specialpage-empty') . '</p>');
         return;
     }
     $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[] = $this->openList($offset);
         }
         foreach ($res as $r) {
             $format = $this->formatResult($sk, $r);
             if ($format) {
                 $s[] = $this->listoutput ? $format : "<li>{$format}</li>\n";
             }
         }
         if (!$this->listoutput) {
             $s[] = $this->closeList();
         }
         $str = $this->listoutput ? $wgContLang->listToText($s) : implode('', $s);
         $wgOut->addHTML($str);
     }
     $wgOut->addHTML("<p>{$sl}</p>\n");
     return $num;
 }
 /**
  * Execute the job
  *
  * @return bool
  */
 public function run()
 {
     //sleep() could be added here to reduce unnecessary use
     $ill = $this->params['ill'];
     foreach ($ill as $lang => $pages) {
         $iw = Interwiki::fetch($lang);
         if (!$iw) {
             continue;
         }
         $apiUrl = $iw->getAPI();
         if (!$apiUrl) {
             continue;
         }
         $apiUrl .= '?' . wfArrayToCGI(array('action' => 'purge', 'format' => 'json', 'titles' => implode('|', array_keys($pages))));
         Http::post($apiUrl);
         //TODO: error handling
     }
     return true;
 }
예제 #18
0
 public static function getSiteCSS($combine, $minify = null, $params = null, $skinname = 'oasis', $articleName = 'Wikia.css')
 {
     wfProfileIn(__METHOD__);
     $srcs = array();
     global $wgSquidMaxage;
     $siteargs = array('action' => 'raw', 'maxage' => $wgSquidMaxage);
     // BugId:20929 tell (or trick) varnish to store the latest revisions of Wikia.css and Common.css.
     $oTitleCommonCss = Title::newFromText('Common.css', NS_MEDIAWIKI);
     $oTitleWikiaCss = Title::newFromText('Wikia.css', NS_MEDIAWIKI);
     $siteargs['maxrev'] = max((int) $oTitleWikiaCss->getLatestRevID(), (int) $oTitleCommonCss->getLatestRevID());
     unset($oTitleWikiaCss, $oTitleCommonCss);
     $query = wfArrayToCGI(array('usemsgcache' => 'yes', 'ctype' => 'text/css', 'smaxage' => $wgSquidMaxage) + $siteargs);
     $srcs[] = Title::newFromText($articleName, NS_MEDIAWIKI)->getFullURL($query);
     // user specific CSS based on user preferences (if logged-in)
     $siteargs['gen'] = 'css';
     $siteargs['useskin'] = $skinname;
     $srcs[] = Title::newFromText('-')->getFullURL(wfArrayToCGI($siteargs));
     wfProfileOut(__METHOD__);
     return $srcs;
 }
 function wfSpecialFavoritelist($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgRequest;
     global $wgRCShowFavoritingUsers, $wgEnotifFavoritelist, $wgShowUpdatedMarker;
     // Add feed links
     $flToken = $wgUser->getOption('favoritelisttoken');
     if (!$flToken) {
         $flToken = sha1(mt_rand() . microtime(true));
         $wgUser->setOption('favoritelisttoken', $flToken);
         $wgUser->saveSettings();
     }
     global $wgServer, $wgScriptPath, $wgFeedClasses;
     $apiParams = array('action' => 'feedfavoritelist', 'allrev' => 'allrev', 'flowner' => $wgUser->getName(), 'fltoken' => $flToken);
     $feedTemplate = wfScript('api') . '?';
     foreach ($wgFeedClasses as $format => $class) {
         $theseParams = $apiParams + array('feedformat' => $format);
         $url = $feedTemplate . wfArrayToCGI($theseParams);
         $wgOut->addFeedLink($format, $url);
     }
     $skin = $wgUser->getSkin();
     $specialTitle = SpecialPage::getTitleFor('Favoritelist');
     $wgOut->setRobotPolicy('noindex,nofollow');
     # Anons don't get a favoritelist
     if ($wgUser->isAnon()) {
         $wgOut->setPageTitle(wfMsg('favoritenologin'));
         $llink = $skin->linkKnown(SpecialPage::getTitleFor('Userlogin'), wfMsgHtml('loginreqlink'), array(), array('returnto' => $specialTitle->getPrefixedText()));
         $wgOut->addHTML(wfMsgWikiHtml('favoritelistanontext', $llink));
         return;
     }
     $wgOut->setPageTitle(wfMsg('favoritelist'));
     $sub = wfMsgExt('favoritelistfor', 'parseinline', $wgUser->getName());
     $sub .= '<br />' . FavoritelistEditor::buildTools($wgUser->getSkin());
     $wgOut->setSubtitle($sub);
     if (($mode = FavoritelistEditor::getMode($wgRequest, $par)) !== false) {
         $editor = new FavoritelistEditor();
         $editor->execute($wgUser, $wgOut, $wgRequest, $mode);
         return;
     }
     $this->viewFavList($wgUser, $wgOut, $wgRequest, $mode);
 }
예제 #20
0
 protected function getNavigationLinks($query = array())
 {
     global $wgUser, $wgLang, $smwgPropertyPagingLimit;
     $sk = $this->getSkin();
     $limitText = $wgLang->formatNum($this->limit);
     $ac = count($this->articles);
     if ($this->until != '') {
         if ($ac > $this->limit) {
             // (we assume that limit is at least 1)
             $first = $this->articles[1]->getSortkey();
         } else {
             $first = '';
         }
         $last = $this->until;
     } elseif ($ac > $this->limit || $this->from != '') {
         $first = $this->from;
         if ($ac > $this->limit) {
             $last = $this->articles[$ac - 1]->getSortkey();
         } else {
             $last = '';
         }
     } else {
         return '';
     }
     $prevLink = htmlspecialchars(wfMsg('prevn', $limitText));
     $this->mTitle->setFragment('#SMWResults');
     // make navigation point to the result list
     if ($first != '') {
         $prevLink = $sk->makeLinkObj($this->mTitle, $prevLink, wfArrayToCGI($query + array('until' => $first)));
     }
     $nextLink = htmlspecialchars(wfMsg('nextn', $limitText));
     if ($last != '') {
         $nextLink = $sk->makeLinkObj($this->mTitle, $nextLink, wfArrayToCGI($query + array('from' => $last, 'offset' => $this->offset + $smwgPropertyPagingLimit)));
     }
     return "({$prevLink}) ({$nextLink})";
 }
예제 #21
0
 public static function doMemoryInfoTable($c, $mem, $title)
 {
     global $wgLang;
     $s = APCUtils::tableHeader(wfMsg('viewapc-info-memory'), 'mw-apc-img-table');
     if ($mem['num_seg'] > 1 || $mem['num_seg'] == 1 && count($mem['block_lists'][0]) > 1) {
         $memHeader = wfMsgExt('viewapc-memory-usage-detailed', 'parseinline');
     } else {
         $memHeader = wfMsgExt('viewapc-memory-usage', 'parseinline');
     }
     $hitHeader = wfMsgExt('viewapc-cache-efficiency', 'parseinline');
     $s .= APCUtils::tableRow(null, $memHeader, $hitHeader);
     if (APCImages::graphics_avail()) {
         $attribs = array('alt' => '', 'width' => APCImages::GRAPH_SIZE + 10, 'height' => APCImages::GRAPH_SIZE + 10);
         $param1 = wfArrayToCGI(array('image' => APCImages::IMG_MEM_USAGE));
         $param2 = wfArrayToCGI(array('image' => APCImages::IMG_HITS));
         $attribs1 = array('src' => $title->getLocalURL($param1)) + $attribs;
         $attribs2 = array('src' => $title->getLocalURL($param2)) + $attribs;
         $s .= APCUtils::tableRow(null, Xml::element('img', $attribs1), Xml::element('img', $attribs2));
     }
     $size = $mem['num_seg'] * $mem['seg_size'];
     $free = $mem['avail_mem'];
     $used = $size - $free;
     $freeMem = wfMsgExt('viewapc-memory-free', 'parseinline', $wgLang->formatSize($free), $wgLang->formatNum(sprintf('%.1f%%', $free * 100 / $size)));
     $usedMem = wfMsgExt('viewapc-memory-used', 'parseinline', $wgLang->formatSize($used), $wgLang->formatNum(sprintf('%.1f%%', $used * 100 / $size)));
     $hits = $c['num_hits'];
     $miss = $c['num_misses'];
     $reqs = $hits + $miss;
     $greenbox = Xml::element('span', array('class' => 'green box'), ' ');
     $redbox = Xml::element('span', array('class' => 'red box'), ' ');
     $memHits = wfMsgExt('viewapc-memory-hits', 'parseinline', $wgLang->formatNum($hits), $wgLang->formatNum(@sprintf('%.1f%%', $hits * 100 / $reqs)));
     $memMiss = wfMsgExt('viewapc-memory-miss', 'parseinline', $wgLang->formatNum($miss), $wgLang->formatNum(@sprintf('%.1f%%', $miss * 100 / $reqs)));
     $s .= APCUtils::tableRow(null, $greenbox . $freeMem, $greenbox . $memHits);
     $s .= APCUtils::tableRow(null, $redbox . $usedMem, $redbox . $memMiss);
     $s .= APCUtils::tableFooter();
     return $s;
 }
예제 #22
0
 /**
  * Execute a special page path.
  * The path may contain parameters, e.g. Special:Name/Params
  * Extracts the special page name and call the execute method, passing the parameters
  *
  * Returns a title object if the page is redirected, false if there was no such special
  * page, and true if it was successful.
  *
  * @param $title          Title object
  * @param $context        IContextSource
  * @param $including      Bool output is being captured for use in {{special:whatever}}
  *
  * @return bool
  */
 public static function executePath(Title &$title, IContextSource &$context, $including = false)
 {
     wfProfileIn(__METHOD__);
     // @todo FIXME: Redirects broken due to this call
     $bits = explode('/', $title->getDBkey(), 2);
     $name = $bits[0];
     if (!isset($bits[1])) {
         // bug 2087
         $par = null;
     } else {
         $par = $bits[1];
     }
     $page = self::getPage($name);
     // Nonexistent?
     if (!$page) {
         $context->getOutput()->setArticleRelated(false);
         $context->getOutput()->setRobotPolicy('noindex,nofollow');
         global $wgSend404Code;
         if ($wgSend404Code) {
             $context->getOutput()->setStatusCode(404);
         }
         $context->getOutput()->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         wfProfileOut(__METHOD__);
         return false;
     }
     // Page exists, set the context
     $page->setContext($context);
     if (!$including) {
         // Redirect to canonical alias for GET commands
         // Not for POST, we'd lose the post data, so it's best to just distribute
         // the request. Such POST requests are possible for old extensions that
         // generate self-links without being aware that their default name has
         // changed.
         if ($name != $page->getLocalName() && !$context->getRequest()->wasPosted()) {
             $query = $context->getRequest()->getQueryValues();
             unset($query['title']);
             $query = wfArrayToCGI($query);
             $title = $page->getTitle($par);
             $url = $title->getFullUrl($query);
             $context->getOutput()->redirect($url);
             wfProfileOut(__METHOD__);
             return $title;
         } else {
             $context->setTitle($page->getTitle($par));
         }
     } elseif (!$page->isIncludable()) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $page->including($including);
     // Wikia change - begin - @author: wladek
     if (!$including) {
         Transaction::setAttribute(Transaction::PARAM_SPECIAL_PAGE_NAME, $page->getName());
     }
     // Wikia change - end
     // Execute special page
     $profName = 'Special:' . $page->getName();
     wfProfileIn($profName);
     $page->execute($par);
     wfProfileOut($profName);
     wfProfileOut(__METHOD__);
     return true;
 }
예제 #23
0
 /**
  * Get a real URL referring to this title
  *
  * @param string $query an optional query string
  * @param string|bool $variant language variant of url (for sr, zh..)
  *
  * @return string the URL
  */
 public function getFullURL($query = '', $variant = false)
 {
     $this->loadAll();
     $namespace = wfUrlencode($this->getNsText());
     if ($this->mNamespace != NS_MAIN) {
         $namespace .= ":";
     }
     /**
      * replace $1 with article title with namespace
      */
     if (is_array($query)) {
         $query = wfArrayToCGI($query);
     }
     $url = str_replace('$1', $namespace . $this->mUrlform, $this->mArticlePath);
     $url = wfAppendQuery($this->mServer . $url, $query);
     return $url;
 }
예제 #24
0
파일: Pager.php 프로젝트: ErdemA/wikihow
 /**
  * Make a self-link
  */
 function makeLink($text, $query = NULL)
 {
     if ($query === null) {
         return $text;
     } else {
         return $this->getSkin()->makeKnownLinkObj($this->getTitle(), $text, wfArrayToCGI($query, $this->getDefaultQuery()));
     }
 }
예제 #25
0
 /**
  * Appends or replaces value of query variables.
  * @param $array Array of values to replace/add to query
  * @param $onlyquery Bool: whether to only return the query string and not
  *                   the complete URL
  * @return string
  */
 public function appendQueryArray($array, $onlyquery = false)
 {
     global $wgTitle;
     $newquery = $_GET;
     unset($newquery['title']);
     $newquery = array_merge($newquery, $array);
     $query = wfArrayToCGI($newquery);
     return $onlyquery ? $query : $wgTitle->getLocalURL($query);
 }
/**
 * Makes change an option link which carries all the other options
 * @param $title see Title
 * @param $override
 * @param $options
 */
function makeOptionsLink($title, $override, $options)
{
    global $wgUser, $wgContLang;
    $sk = $wgUser->getSkin();
    return $sk->makeKnownLink($wgContLang->specialPage('Recentchanges'), htmlspecialchars($title), wfArrayToCGI($override, $options));
}
예제 #27
0
파일: Skin.php 프로젝트: ruizrube/spdef
 /**
  * @private
  */
 function setupUserCss(OutputPage $out)
 {
     global $wgRequest, $wgContLang, $wgUser;
     global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
     wfProfileIn(__METHOD__);
     $this->setupSkinUserCss($out);
     $siteargs = array('action' => 'raw', 'maxage' => $wgSquidMaxage);
     // Add any extension CSS
     foreach ($out->getExtStyle() as $tag) {
         $out->addStyle($tag['href']);
     }
     // If we use the site's dynamic CSS, throw that in, too
     // Per-site custom styles
     if ($wgUseSiteCss) {
         global $wgHandheldStyle;
         $query = wfArrayToCGI(array('usemsgcache' => 'yes', 'ctype' => 'text/css', 'smaxage' => $wgSquidMaxage) + $siteargs);
         # Site settings must override extension css! (bug 15025)
         $out->addStyle(self::makeNSUrl('Common.css', $query, NS_MEDIAWIKI));
         $out->addStyle(self::makeNSUrl('Print.css', $query, NS_MEDIAWIKI), 'print');
         if ($wgHandheldStyle) {
             $out->addStyle(self::makeNSUrl('Handheld.css', $query, NS_MEDIAWIKI), 'handheld');
         }
         $out->addStyle(self::makeNSUrl($this->getSkinName() . '.css', $query, NS_MEDIAWIKI));
     }
     if ($wgUser->isLoggedIn()) {
         // Ensure that logged-in users' generated CSS isn't clobbered
         // by anons' publicly cacheable generated CSS.
         $siteargs['smaxage'] = '0';
         $siteargs['ts'] = $wgUser->mTouched;
     }
     // Per-user styles based on preferences
     $siteargs['gen'] = 'css';
     if (($us = $wgRequest->getVal('useskin', '')) !== '') {
         $siteargs['useskin'] = $us;
     }
     $out->addStyle(self::makeUrl('-', wfArrayToCGI($siteargs)));
     // Per-user custom style pages
     if ($wgAllowUserCss && $wgUser->isLoggedIn()) {
         $action = $wgRequest->getVal('action');
         # If we're previewing the CSS page, use it
         if ($this->mTitle->isCssSubpage() && $this->userCanPreview($action)) {
             $previewCss = $wgRequest->getText('wpTextbox1');
             // @FIXME: properly escape the cdata!
             $this->usercss = "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
         } else {
             $out->addStyle(self::makeUrl($this->userpage . '/' . $this->getSkinName() . '.css', 'action=raw&ctype=text/css'));
         }
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * Redirect users out to review the changes to the stable version.
  * Only for people who can review and for pages that have a stable version.
  */
 public function injectPostEditURLParams(&$sectionAnchor, &$extraQuery)
 {
     $reqUser = $this->getUser();
     $this->load();
     $this->article->loadPageData('fromdbmaster');
     # Get the stable version from the master
     $frev = $this->article->getStableRev();
     if (!$frev || !$this->article->revsArePending()) {
         return true;
         // only for pages with pending edits
     }
     $params = array();
     // If the edit was not autoreviewed, and the user can actually make a
     // new stable version, then go to the diff...
     if ($frev->userCanSetFlags($reqUser)) {
         $params += array('oldid' => $frev->getRevId(), 'diff' => 'cur', 'shownotice' => 1);
         $params += FlaggedRevs::diffOnlyCGI();
         // ...otherwise, go to the draft revision after completing an edit.
         // This allows for users to immediately see their changes.
     } else {
         $params += array('stable' => 0);
         // Show a notice at the top of the page for non-reviewers...
         if (!$reqUser->isAllowed('review') && $this->article->isStableShownByDefault()) {
             $params += array('shownotice' => 1);
             if ($sectionAnchor) {
                 // Pass a section parameter in the URL as needed to add a link to
                 // the "your changes are pending" box on the top of the page...
                 $section = str_replace(array(':', '.'), array('%3A', '%'), substr($sectionAnchor, 1));
                 $params += array('fromsection' => $section);
                 $sectionAnchor = '';
                 // go to the top of the page to see notice
             }
         }
     }
     if ($extraQuery !== '') {
         $extraQuery .= '&';
     }
     $extraQuery .= wfArrayToCGI($params);
     // note: EditPage will add initial "&"
     return true;
 }
예제 #29
0
 public static function onLogLine($logType, $logaction, $title, $paramArray, &$comment, &$revert, $logTimestamp)
 {
     global $wgUser, $wgCityId;
     if (strpos($logaction, 'chatban') === 0) {
         $user = User::newFromId($paramArray[1]);
         if (!empty($user) && Chat::getBanInformation($wgCityId, $user) !== false && $wgUser->isAllowed('chatmoderator')) {
             $revert = "(" . "<a class='chat-change-ban' data-user-id='{$paramArray[1]}' href='#'>" . wfMsg('chat-ban-log-change-ban-link') . "</a>" . ")";
         }
     } elseif ($logaction === 'chatconnect' && !empty($paramArray)) {
         $ipLinks = array();
         if ($wgUser->isAllowed('multilookup')) {
             $mlTitle = GlobalTitle::newFromText('MultiLookup', NS_SPECIAL, 177);
             // Need to make the link manually for this as Linker's normaliseSpecialPage
             // makes the link local if the special page exists locally, rather than
             // keeping the global title
             $ipLinks[] = Xml::tags('a', array('href' => $mlTitle->getFullURL('target=' . urlencode($paramArray[0]))), wfMessage('multilookup')->escaped());
             $ipLinks[] = Linker::makeKnownLinkObj(GlobalTitle::newFromText('Phalanx', NS_SPECIAL, 177), wfMessage('phalanx')->escaped(), wfArrayToCGI(array('type' => '8', 'target' => $paramArray[0], 'wpPhalanxCheckBlocker' => $paramArray[0])));
             $ipLinks[] = Linker::blockLink(0, $paramArray[0]);
             $revert = '(' . implode(wfMessage('pipe-separator')->plain(), $ipLinks) . ')';
         }
     }
     return true;
 }
예제 #30
0
 /**
  * Get the URL of the stylesheet to apply to description pages
  *
  * @return string|false
  */
 public function getDescriptionStylesheetUrl()
 {
     if (isset($this->scriptDirUrl)) {
         return $this->makeUrl('title=MediaWiki:Filepage.css&' . wfArrayToCGI(Skin::getDynamicStylesheetQuery()));
     }
     return false;
 }