/**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
	public function executeWordmark() {
		$themeSettings = new ThemeSettings();
		$settings = $themeSettings->getSettings();

		$this->wordmarkText = $settings['wordmark-text'];
		$this->wordmarkType = $settings['wordmark-type'];
		$this->wordmarkSize = $settings['wordmark-font-size'];
		$this->wordmarkFont = $settings['wordmark-font'];
		$this->wordmarkFontClass = !empty($settings["wordmark-font"]) ? "font-{$settings['wordmark-font']}" : '';
		$this->wordmarkUrl = '';
		if ($this->wordmarkType == "graphic") {
			wfProfileIn(__METHOD__ . 'graphicWordmark');
			$this->wordmarkUrl = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());			
			$imageTitle = Title::newFromText($themeSettings::WordmarkImageName,NS_IMAGE);
			if($imageTitle instanceof Title) {
				$attributes = array();
				$file = wfFindFile($imageTitle);
				if($file instanceof File) {
					$attributes []= 'width="' . $file->width . '"';
					$attributes []= 'height="' . $file->height. '"';
	
					if(!empty($attributes)) {
						$this->wordmarkStyle = ' ' . implode(' ',$attributes) . ' ';
					}
				}
			}
			wfProfileOut(__METHOD__. 'graphicWordmark');
		}

		$this->mainPageURL = Title::newMainPage()->getLocalURL();
	}
Example #3
0
 /**
  * Displays the reCAPTCHA widget.
  */
 public function getForm()
 {
     $siteKey = $this->wg->ReCaptchaPublicKey;
     $theme = \SassUtil::isThemeDark() ? 'dark' : 'light';
     $form = '<div class="g-recaptcha" data-sitekey="' . $siteKey . '" data-theme="' . $theme . '"></div>';
     return $form;
 }
	public function executeIndex() {
		OasisController::addBodyClass('wikinav2');

		$themeSettings = new ThemeSettings();
		$settings = $themeSettings->getSettings();

		$this->wordmarkText = $settings["wordmark-text"];
		$this->wordmarkType = $settings["wordmark-type"];
		$this->wordmarkSize = $settings["wordmark-font-size"];
		$this->wordmarkFont = $settings["wordmark-font"];

		if ($this->wordmarkType == "graphic") {
			wfProfileIn(__METHOD__ . 'graphicWordmarkV2');
			$this->wordmarkUrl = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());
			$imageTitle = Title::newFromText($themeSettings::WordmarkImageName,NS_IMAGE);
			if($imageTitle instanceof Title) {
				$attributes = array();
				$file = wfFindFile($imageTitle);
				if($file instanceof File) {
					$attributes []= 'width="' . $file->width . '"';
					$attributes []= 'height="' . $file->height. '"';
			
					if(!empty($attributes)) {
						$this->wordmarkStyle = ' ' . implode(' ',$attributes) . ' ';
					}
				}
			}
			wfProfileOut(__METHOD__. 'graphicWordmarkV2');
		}

		$this->mainPageURL = Title::newMainPage()->getLocalURL();
		
		$this->displaySearch = !empty($this->wg->EnableAdminDashboardExt) && AdminDashboardLogic::displayAdminDashboard($this, $this->wg->Title);
	}
 public function executeIndex()
 {
     wfProfileIn(__METHOD__);
     global $wgLang, $wgOut;
     $themeSettings = new ThemeSettings();
     // current settings
     $this->themeSettings = $themeSettings->getSettings();
     // application theme settings (not user settable)
     $this->applicationThemeSettings = SassUtil::getApplicationThemeSettings();
     // recent versions
     $themeHistory = array_reverse($themeSettings->getHistory());
     // format time (for edits older than 30 days - show timestamp)
     foreach ($themeHistory as &$entry) {
         $diff = time() - strtotime($entry['timestamp']);
         if ($diff < 30 * 86400) {
             $entry['timeago'] = wfTimeFormatAgo($entry['timestamp']);
         } else {
             $entry['timeago'] = $wgLang->date($entry['timestamp']);
         }
     }
     $this->themeHistory = $themeHistory;
     // URL user should be redirected to when settings are saved
     if (isset($_SERVER['HTTP_REFERER'])) {
         $this->returnTo = $_SERVER['HTTP_REFERER'];
     } else {
         $this->returnTo = $this->wg->Script;
     }
     // load Google Analytics code
     $this->analytics = AnalyticsEngine::track('GA_Urchin', AnalyticsEngine::EVENT_PAGEVIEW);
     $wgOut->getResourceLoader()->getModule('mediawiki');
     $ret = implode("\n", array($wgOut->getHeadLinks(null, true), $wgOut->buildCssLinks(), $wgOut->getHeadScripts(), $wgOut->getHeadItems()));
     $this->globalVariablesScript = $ret;
     wfProfileOut(__METHOD__);
 }
 public function executeIndex($params)
 {
     wfProfileIn(__METHOD__);
     // add CSS for this module
     $this->wg->Out->addStyle(AssetsManager::getInstance()->getSassCommonURL("skins/oasis/css/modules/InsightsModule.scss"));
     $this->themeClass = SassUtil::isThemeDark() ? 'insights-dark' : 'insights-light';
     $this->messageKeys = InsightsHelper::getMessageKeys();
     wfProfileOut(__METHOD__);
 }
 public function getColours()
 {
     $this->app->wf->profileIn(__METHOD__);
     $result = SassUtil::getOasisSettings();
     $colours['line'] = $result['color-buttons'];
     $colours['labels'] = $result['color-links'];
     $colours['body'] = $result['color-page'];
     $this->app->wf->profileOut(__METHOD__);
     return $colours;
 }
 public function index()
 {
     /**
      * @var $themeSettings ThemeSettings
      */
     $themeSettings = F::build('ThemeSettings');
     $settings = $themeSettings->getSettings();
     $this->response->setVal('wordmarkText', $settings["wordmark-text"]);
     $this->response->setVal('wordmarkType', $settings["wordmark-type"]);
     $this->response->setVal('wordmarkFont', $settings["wordmark-font"]);
     if ($settings["wordmark-type"] == "graphic") {
         $this->response->setVal('wordmarkUrl', wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster()));
     } else {
         $this->response->setVal('wikiName', !empty($settings['wordmark-text']) ? $settings['wordmark-text'] : $this->wg->SiteName);
     }
     //$this->response->setVal( 'searchOpen', ($this->wg->Title->getText() == SpecialPage::getTitleFor( 'Search' )->getText() ) );
 }
 private function downloadWordmark()
 {
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $wordmark = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());
     $folder_path = $this->wikiName;
     if (!is_dir($folder_path)) {
         mkdir($folder_path, 0700);
     }
     $file_path = $folder_path . '/wordmark.png';
     if (file_exists($file_path)) {
         system("rm " . $file_path);
     }
     file_put_contents($file_path, Http::get($wordmark));
     if (file_get_contents($file_path) == '') {
         system("rm " . $file_path);
         system("cp default_wordmark.png " . $file_path);
     }
 }
 /**
  * The main, initializing function
  * @throws MWException
  */
 public function index()
 {
     wfProfileIn(__METHOD__);
     $this->wg->Out->setPageTitle(wfMessage('insights')->escaped());
     $this->addAssets();
     /**
      * @var A slug of a subpage
      */
     $this->subpage = $this->getPar();
     $this->themeClass = SassUtil::isThemeDark() ? 'insights-dark' : 'insights-light';
     /**
      * Check if a user requested a subpage. If the requested subpage
      * is unknown redirect them to the landing page.
      */
     if (InsightsHelper::isInsightPage($this->subpage)) {
         $this->renderSubpage();
     } elseif (!empty($this->subpage)) {
         $this->response->redirect($this->getSpecialInsightsUrl());
     }
     wfProfileOut(__METHOD__);
 }
 public function executePlayQuiz($params)
 {
     global $wgUser, $wgOut, $wgRequest, $wgSiteName;
     $this->data = $params['data'];
     $themeSettings = new ThemeSettings();
     $settings = $themeSettings->getSettings();
     $this->wordmarkType = $settings['wordmark-type'];
     $this->wordmarkText = $settings['wordmark-text'];
     if ($this->wordmarkType == 'graphic') {
         $this->wordmarkUrl = wfReplaceImageServer($settings['wordmark-image-url'], SassUtil::getCacheBuster());
     }
     // Facebook opengraph meta data
     $wgOut->addMeta('property:og:title', $this->data['titlescreentext']);
     $wgOut->addMeta('property:og:type', 'game');
     $wgOut->addMeta('property:og:url', $wgRequest->getFullRequestURL());
     $wgOut->addMeta('property:og:site_name', $wgSiteName);
     // mech: simply stripping the tags wont work, as some tags have to be replaced with a space
     $descrition = $this->data['fbrecommendationtext'];
     if (!$descrition) {
         /* mech: fbrecommendationtext field was intoduced while fixing bug 14843.
          * For older quizes the FB recommendation description defaults to titlescreentext
          */
         $descrition = str_replace('<', ' <', $this->data['titlescreentext']);
         // introduce an extra space at in front of tags
         $descrition = strip_tags($descrition);
         $descrition = preg_replace('/\\s\\s+/u', ' ', $descrition);
         // eliminate extraneous whitespaces
     }
     $wgOut->addMeta('property:og:description', $descrition);
     $wgOut->addMeta('property:og:image', $this->wordmarkUrl);
     $this->username = $wgUser->getName();
     $this->isAnonUser = $wgUser->isAnon();
     // render this array in PHP and encode it properly for JS
     $this->quizVars = array('cadence' => array(wfMsg('wikiaquiz-game-cadence-3'), wfMsg('wikiaquiz-game-cadence-2'), wfMsg('wikiaquiz-game-cadence-1')), 'correctLabel' => wfMsg('wikiaquiz-game-correct-label'), 'incorrectLabel' => wfMsg('wikiaquiz-game-incorrect-label'));
     // prefill with user's email
     $this->defaultEmail = $wgUser->isLoggedIn() ? $wgUser->getEmail() : '';
     // use token to prevent direct requests to the backend for storing emails
     $this->token = $wgUser->getEditToken('WikiaQuiz');
 }
Example #12
0
 /**
  * @param $unused Unused
  * @param $addContentType bool
  *
  * @return string HTML tag links to be put in the header.
  */
 public function getHeadLinks($unused = null, $addContentType = false)
 {
     global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgRightsPage, $wgRightsUrl, $wgDevelEnvironment, $wgStagingEnvironment;
     $tags = array();
     if ($addContentType) {
         if ($wgHtml5) {
             # More succinct than <meta http-equiv=Content-Type>, has the
             # same effect
             $tags[] = Html::element('meta', array('charset' => 'UTF-8'));
         } else {
             $tags[] = Html::element('meta', array('http-equiv' => 'Content-Type', 'content' => "{$wgMimeType}; charset=UTF-8"));
             $tags[] = Html::element('meta', array('http-equiv' => 'Content-Style-Type', 'content' => 'text/css'));
         }
     }
     $tags[] = Html::element('meta', array('name' => 'generator', 'content' => "MediaWiki {$wgVersion}"));
     $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
     // Wikia change - begin
     if (!empty($wgDevelEnvironment) || !empty($wgStagingEnvironment)) {
         $p = "noindex,nofollow";
     }
     // Wikia change - end
     if ($p !== 'index,follow') {
         // http://www.robotstxt.org/wc/meta-user.html
         // Only show if it's different from the default robots policy
         $tags[] = Html::element('meta', array('name' => 'robots', 'content' => $p));
     }
     if (count($this->mKeywords) > 0) {
         $strip = array("/<.*?" . ">/" => '', "/_/" => ' ');
         $tags[] = Html::element('meta', array('name' => 'keywords', 'content' => preg_replace(array_keys($strip), array_values($strip), implode(',', $this->mKeywords))));
     }
     foreach ($this->mMetatags as $tag) {
         if (0 == strcasecmp('http:', substr($tag[0], 0, 5))) {
             $a = 'http-equiv';
             $tag[0] = substr($tag[0], 5);
         } elseif (0 == strcasecmp('property:', substr($tag[0], 0, 9))) {
             $a = 'property';
             $tag[0] = substr($tag[0], 9);
         } else {
             $a = 'name';
         }
         $tags[] = Html::element('meta', array($a => $tag[0], 'content' => $tag[1]));
     }
     foreach ($this->mLinktags as $tag) {
         $tags[] = Html::element('link', $tag);
     }
     # Universal edit button
     if ($wgUniversalEditButton && $this->isArticleRelated()) {
         $user = $this->getUser();
         if ($this->getTitle()->quickUserCan('edit', $user) && ($this->getTitle()->exists() || $this->getTitle()->quickUserCan('create', $user))) {
             // Original UniversalEditButton
             $msg = $this->msg('edit')->text();
             $tags[] = Html::element('link', array('rel' => 'alternate', 'type' => 'application/x-wiki', 'title' => $msg, 'href' => $this->getTitle()->getLocalURL('action=edit')));
             // Alternate edit link
             $tags[] = Html::element('link', array('rel' => 'edit', 'title' => $msg, 'href' => $this->getTitle()->getLocalURL('action=edit')));
         }
     }
     # Generally the order of the favicon and apple-touch-icon links
     # should not matter, but Konqueror (3.5.9 at least) incorrectly
     # uses whichever one appears later in the HTML source. Make sure
     # apple-touch-icon is specified first to avoid this.
     if ($wgAppleTouchIcon !== false) {
         // Wikia change begin - @author: macbre
         $appleTouchIcon = wfReplaceImageServer($wgAppleTouchIcon, SassUtil::getCacheBuster());
         // Wikia change end
         $tags[] = Html::element('link', array('rel' => 'apple-touch-icon', 'href' => $appleTouchIcon));
     }
     $tags[] = Html::element('link', array('rel' => 'shortcut icon', 'href' => Wikia::getFaviconFullUrl()));
     # OpenSearch description link
     $tags[] = Html::element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml', 'href' => wfScript('opensearch_desc'), 'title' => $this->msg('opensearch-desc')->inContentLanguage()->text()));
     if ($wgEnableAPI) {
         # Real Simple Discovery link, provides auto-discovery information
         # for the MediaWiki API (and potentially additional custom API
         # support such as WordPress or Twitter-compatible APIs for a
         # blogging extension, etc)
         $tags[] = Html::element('link', array('rel' => 'EditURI', 'type' => 'application/rsd+xml', 'href' => wfExpandUrl(wfAppendQuery(wfScript('api'), array('action' => 'rsd')), PROTO_RELATIVE)));
     }
     # Language variants
     if (!$wgDisableLangConversion && $wgCanonicalLanguageLinks) {
         $lang = $this->getTitle()->getPageLanguage();
         if ($lang->hasVariants()) {
             $urlvar = $lang->getURLVariant();
             if (!$urlvar) {
                 $variants = $lang->getVariants();
                 foreach ($variants as $_v) {
                     $tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => $_v, 'href' => $this->getTitle()->getLocalURL(array('variant' => $_v))));
                 }
             } else {
                 $tags[] = Html::element('link', array('rel' => 'canonical', 'href' => $this->getTitle()->getCanonicalUrl()));
             }
         }
     }
     # Copyright
     $copyright = '';
     if ($wgRightsPage) {
         $copy = Title::newFromText($wgRightsPage);
         if ($copy) {
             $copyright = $copy->getLocalURL();
         }
     }
     if (!$copyright && $wgRightsUrl) {
         $copyright = $wgRightsUrl;
     }
     if ($copyright) {
         $tags[] = Html::element('link', array('rel' => 'copyright', 'href' => $copyright));
     }
     # Feeds
     if ($wgFeed) {
         foreach ($this->getSyndicationLinks() as $format => $link) {
             # Use the page name for the title.  In principle, this could
             # lead to issues with having the same name for different feeds
             # corresponding to the same page, but we can't avoid that at
             # this low a level.
             $tags[] = $this->feedLink($format, $link, $this->msg("page-{$format}-feed", $this->getTitle()->getPrefixedText())->text());
         }
         # Recent changes feed should appear on every page (except recentchanges,
         # that would be redundant). Put it after the per-page feed to avoid
         # changing existing behavior. It's still available, probably via a
         # menu in your browser. Some sites might have a different feed they'd
         # like to promote instead of the RC feed (maybe like a "Recent New Articles"
         # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
         # If so, use it instead.
         if ($wgOverrideSiteFeed) {
             foreach ($wgOverrideSiteFeed as $type => $feedUrl) {
                 // Note, this->feedLink escapes the url.
                 $tags[] = $this->feedLink($type, $feedUrl, $this->msg("site-{$type}-feed", $wgSitename)->text());
             }
         } elseif (!$this->getTitle()->isSpecial('Recentchanges')) {
             $rctitle = SpecialPage::getTitleFor('Recentchanges');
             foreach ($wgAdvertisedFeedTypes as $format) {
                 $tags[] = $this->feedLink($format, $rctitle->getLocalURL("feed={$format}"), $this->msg("site-{$format}-feed", $wgSitename)->text());
             }
         }
     }
     return implode("\n", $tags);
 }
	public function executeIndex($data) {
		wfProfileIn(__METHOD__);
		global $wgTitle, $wgLang, $wgContentNamespaces, $wgExtraNamespacesLocal;
		if(empty($wgExtraNamespacesLocal)){
			$wgExtraNamespacesLocal = array();
		}

		// set the page for which we're showing comments / likes
		// used for proper linking on blog posts listings
		if (!empty($data['title'])) {
			$this->contextTitle = $data['title'];
		}
		else {
			// by default we're showing # of comments for current page
			$this->contextTitle = &$wgTitle;
		}

		// Facebook's "Like"
		// @see http://developers.facebook.com/docs/reference/plugins/like
		if (!empty($data['likes'])) {
			$this->showLike = true;

			// canonical URL
			$this->likeHref = $this->contextTitle->getFullUrl();

			// check namespaces
			$ns = $this->contextTitle->getNamespace();
			if (in_array($ns, $wgContentNamespaces)) {
				$this->likeRef = 'content_page';
			}
			// RT #74393: include custom namespaces
			else if (in_array($ns, array_keys($wgExtraNamespacesLocal))) {
				$this->likeRef = 'content_page';
			}
			else if (defined('NS_BLOG_ARTICLE') && $ns == NS_BLOG_ARTICLE) {
				$this->likeRef = 'blog_page';
			}
			else if ($ns == NS_CATEGORY) {
				$this->likeRef = 'category_page';
			}
			else if (defined('NS_TOPLIST') && $ns == NS_TOPLIST) {
				$this->likeRef = 'list_page';
			}
			else {
				$this->showLike = false;
			}

			// check lightness of skin theme
			$this->likeTheme = SassUtil::isThemeDark() ? 'dark' : 'light';
		}

		// comments / talks
		if (isset($data['comments']) && is_numeric($data['comments'])) {
			$this->comments = $data['comments'];

			// format number of comments (1200 -> 1k, 9999 -> 9k, 1.300.000 -> 1M)
			$this->formattedComments = $this->comments;

			if ($this->comments > 999999) {
				$this->formattedComments = wfMsg('oasis-page-header-comments-m', floor($this->comments / 1000000));
			}
			else if ($this->comments > 999) {
				$this->formattedComments = wfMsg('oasis-page-header-comments-k', floor($this->comments / 1000));
			}

			$this->commentsLink = $this->getCommentsLink();
			$this->commentsTooltip = $this->getCommentsTooltip();
			$this->isArticleComments = $this->checkArticleComments();

			// get source of comments number (comments / talk page revisions)
			$this->commentsEnabled = $this->checkArticleComments();

			// pass accesskey => false to this module to disable accesskey attribute (BugId:15685)
			if (!isset($data['accesskey']) || $data['accesskey'] !== false) {
				$this->commentsAccesskey = ' accesskey="t"';
			}

			// render comments count as just a bubble
			$this->commentsBubble = !empty($data['bubble']);
		}

		if ( $this->wg->OasisNavV2 ) {
			$this->response->getView()->setTemplatePath( dirname( __FILE__ ) .'/templates/CommentsLikes_IndexV2.php' );
		}
		wfProfileOut(__METHOD__);
	}
 public static function onResourceLoaderMakeQuery($modules, &$query)
 {
     // PER-58: append CB value to RL query
     global $wgStyleVersion;
     if (!empty($query['version'])) {
         $query['version'] = $wgStyleVersion . "-" . $query['version'];
     } else {
         $query['cb'] = $wgStyleVersion;
     }
     $only = isset($query['only']) ? $query['only'] : null;
     if (empty($only) || $only == 'styles') {
         $resourceLoaderInstance = self::getResourceLoaderInstance();
         $requireSass = false;
         foreach ($modules as $moduleName) {
             $module = $resourceLoaderInstance->getModule($moduleName);
             if ($module->getFlag('sass')) {
                 $requireSass = true;
                 break;
             }
         }
         if ($requireSass) {
             $sassParams = SassUtil::getSassSettings();
             foreach ($sassParams as $key => $value) {
                 $query['sass_' . $key] = (string) $value;
             }
         }
     }
     return true;
 }
Example #15
0
	function testSassUtil() {
		$sassParams = SassUtil::getSassParams();

		$this->assertType('string', $sassParams);
		$this->assertRegExp('/&color-page=%23[A-F0-9]{6}&/i', $sassParams);
	}
 /**
  * Generates a valid SASS URL with all the required commandline parameters for Oasis
  *
  * @author Federico "Lox" Lucignano <federico(at)wikia-inc.com>
  *
  * @param string $scssFilePath
  * @param string $prefix
  * @param bool $minify
  *
  * @return string the generated URL
  */
 private function getSassURL($scssFilePath, $prefix, $minify = null, $params = null)
 {
     wfProfileIn(__METHOD__);
     if (!is_array($params)) {
         $params = SassUtil::getSassSettings();
         if ($minify !== null ? !$minify : !$this->mMinify) {
             $params['minify'] = false;
         } else {
             unset($params['minify']);
         }
     }
     $url = $prefix . $this->getAMLocalURL('sass', $scssFilePath, $params);
     // apply domain sharding
     $url = wfReplaceAssetServer($url);
     wfProfileOut(__METHOD__);
     return $url;
 }
Example #17
0
 /**
  * Displays the reCAPTCHA widget.
  */
 function getForm()
 {
     $siteKey = F::app()->wg->ReCaptchaPublicKey;
     $theme = SassUtil::isThemeDark() ? 'dark' : 'light';
     return '<div class="g-recaptcha" data-sitekey="' . $siteKey . '" data-theme="' . $theme . '"></div>';
 }
Example #18
0
 public function getColorForLabels()
 {
     $result = SassUtil::getOasisSettings();
     return $result['color-links'];
 }
 public function index()
 {
     global $wgSuppressWikiHeader, $wgSuppressPageHeader, $wgSuppressFooter, $wgSuppressAds, $wgSuppressToolbar, $fbOnLoginJsOverride, $wgRequest, $wgUser;
     wfProfileIn(__METHOD__);
     // hide some default oasis UI things
     $wgSuppressWikiHeader = true;
     $wgSuppressPageHeader = true;
     $wgSuppressFooter = false;
     $wgSuppressAds = true;
     $wgSuppressToolbar = true;
     // store the fact we're on CNW
     $this->wg->atCreateNewWikiPage = true;
     if (!$this->wg->User->isLoggedIn() && !empty($this->wg->EnableFacebookClientExt)) {
         // required for FB Connect to work
         $this->response->addAsset('extensions/wikia/UserLogin/js/UserLoginFacebookPageInit.js');
     }
     // fbconnected means user has gone through step 2 to login via facebook.
     // Therefore, we need to reload some values and start at the step after signup/login
     $fbconnected = $wgRequest->getVal('fbconnected');
     $fbreturn = $wgRequest->getVal('fbreturn');
     if (!empty($fbconnected) && $fbconnected === '1' || !empty($fbreturn) && $fbreturn === '1') {
         $this->LoadState();
         $currentStep = 'DescWiki';
     } else {
         $currentStep = '';
     }
     $this->setupVerticalsAndCategories();
     $this->aTopLanguages = explode(',', wfMsg('autocreatewiki-language-top-list'));
     $languages = wfGetFixedLanguageNames();
     asort($languages);
     $this->aLanguages = $languages;
     $useLang = $wgRequest->getVal('uselang', $wgUser->getGlobalPreference('language'));
     // squash language dialects (same wiki language for different dialects)
     $useLang = $this->squashLanguageDialects($useLang);
     // falling back to english (BugId:3538)
     if (!array_key_exists($useLang, $this->aLanguages)) {
         $useLang = 'en';
     }
     $params['wikiLanguage'] = empty($useLang) ? $this->wg->LanguageCode : $useLang;
     // precedence: selected form field, uselang, default wiki lang
     // export info if user is logged in
     $this->isUserLoggedIn = $wgUser->isLoggedIn();
     // remove wikia plus for now for all languages
     $skipWikiaPlus = true;
     $keys = CreateNewWikiObfuscate::generateValidSeeds();
     $_SESSION['cnw-answer'] = CreateNewWikiObfuscate::generateAnswer($this->keys);
     $this->wg->Out->addJsConfigVars(['wgLangAllAgesOpt' => self::LANG_ALL_AGES_OPT]);
     // prefill
     $params['wikiName'] = $wgRequest->getVal('wikiName', '');
     $params['wikiDomain'] = $wgRequest->getVal('wikiDomain', '');
     $params['LangAllAgesOpt'] = self::LANG_ALL_AGES_OPT;
     $this->params = $params;
     $this->signupUrl = '';
     $signupTitle = Title::newFromText('UserSignup', NS_SPECIAL);
     if ($wgRequest->getInt('nocaptchatest')) {
         $this->signupUrl = $signupTitle->getFullURL('nocaptchatest=1');
     } else {
         $this->signupUrl = $signupTitle->getFullURL();
     }
     // Make various parsed messages and status available in JS
     // Necessary because JSMessages does not support parsing
     $this->wikiBuilderCfg = array('name-wiki-submit-error' => wfMessage('cnw-name-wiki-submit-error')->escaped(), 'desc-wiki-submit-error' => wfMessage('cnw-desc-wiki-submit-error')->escaped(), 'currentstep' => $currentStep, 'skipwikiaplus' => $skipWikiaPlus, 'descriptionplaceholder' => wfMessage('cnw-desc-placeholder')->escaped(), 'cnw-error-general' => wfMessage('cnw-error-general')->parse(), 'cnw-error-general-heading' => wfMessage('cnw-error-general-heading')->escaped(), 'cnw-keys' => $keys);
     // theme designer application theme settings
     $this->applicationThemeSettings = SassUtil::getApplicationThemeSettings();
     wfProfileOut(__METHOD__);
 }
Example #20
0
 /**
  * Get a default for custom Sass variables.
  * Currently returns Sass variables associated with current wiki.
  *
  * @return array Array of Sass variables
  */
 protected static function getDefaultSassVariables()
 {
     return SassUtil::getSassSettings();
 }
 /**
  * Initialise a GeSHi object to format some code, performing
  * common setup for all our uses of it
  *
  * @param string $text
  * @param string $lang
  * @return GeSHi
  */
 public static function prepare($text, $lang)
 {
     global $wgTitle, $wgOut;
     self::initialise();
     $geshi = new GeSHi($text, $lang);
     if ($geshi->error() == GESHI_ERROR_NO_SUCH_LANG) {
         return null;
     }
     $geshi->set_encoding('UTF-8');
     $geshi->enable_classes();
     $geshi->set_overall_class("source-{$lang}");
     $geshi->enable_keyword_links(false);
     // Wikia change start
     if ($wgTitle instanceof Title && EditPageLayoutHelper::isCodeSyntaxHighlightingEnabled($wgTitle)) {
         $theme = 'solarized-light';
         if (SassUtil::isThemeDark()) {
             $theme = 'solarized-dark';
         }
         $geshi->set_language_path(GESHI_ROOT . $theme . DIRECTORY_SEPARATOR);
         $geshi->set_overall_id('theme-' . $theme);
         $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/SyntaxHighlight_GeSHi/styles/solarized.scss'));
     }
     // Wikia change end
     return $geshi;
 }
Example #22
0
 /**
  * @dataProvider isThemeDarkProvider
  */
 public function testIsThemeDark($color, $isDark)
 {
     $settings = ['color-page' => $color];
     $this->assertEquals($isDark, SassUtil::isThemeDark($settings));
 }
Example #23
0
 public function getStaticMapUrl()
 {
     $latLon = implode(',', $this->getLatLon());
     // use SASS button color for marker
     $colors = SassUtil::getOasisSettings();
     $markerColor = '0x' . ltrim($colors['color-buttons'], '#');
     $aParams = array('center' => $latLon, 'markers' => "color:{$markerColor}|{$latLon}", 'size' => $this->getWidth() . 'x' . $this->getHeight(), 'zoom' => $this->getZoom(), 'maptype' => 'roadmap', 'sensor' => 'false');
     $sParams = http_build_query($aParams);
     return 'http://maps.googleapis.com/maps/api/staticmap?' . $sParams;
 }
 /**
  * Set wiki theme setting to the ad units
  * @param array $adUnits
  * @param string $memcKey
  * @param boolean $setMemc - set to true to set data to memcache
  * @return array
  */
 public function setThemeSettings($adUnits, $memcKey, $setMemc = true)
 {
     wfProfileIn(__METHOD__);
     $adTitle = $this->wf->Message('monetization-module-ad-title')->escaped();
     $adUnits = str_replace(self::KEYWORD_AD_TITLE, $adTitle, $adUnits);
     $ecommTitle = $this->wf->Message('monetization-module-ecommerce-title')->escaped();
     $adUnits = str_replace(self::KEYWORD_ECOMMERCE_TITLE, $ecommTitle, $adUnits);
     $theme = SassUtil::getOasisSettings();
     if (SassUtil::isThemeDark()) {
         $theme['color'] = self::FONT_COLOR_DARK_THEME;
     } else {
         $theme['color'] = self::FONT_COLOR_LIGHT_THEME;
     }
     $adSettings = '';
     foreach (self::$mapThemeSettings as $key => $value) {
         if (!empty($theme[$value])) {
             $adSettings .= $key . '="' . $theme[$value] . '" ';
         }
     }
     $adUnits = str_replace(self::KEYWORD_THEME_SETTINGS, $adSettings, $adUnits);
     // set data to cache
     if ($setMemc) {
         $this->setMemcache($memcKey, $adUnits, ['method' => __METHOD__]);
     }
     wfProfileOut(__METHOD__);
     return $adUnits;
 }
 /**
  * Change the module used as an entry-point for Oasis skin and use custom class for rendering edit page
  *
  * Keep global and user nav only.
  *
  * @author macbre
  */
 function setupEditPage(Article $editedArticle, $fullScreen = true, $class = false)
 {
     global $wgHooks;
     wfProfileIn(__METHOD__);
     $user = $this->app->wg->User;
     // don't render edit area when we're in read only mode
     if (wfReadOnly()) {
         // set correct page title
         $this->out->setPageTitle(wfMessage('editing', $this->app->getGlobal('wgTitle')->getPrefixedText())->escaped());
         wfProfileOut(__METHOD__);
         return false;
     }
     // use "reskined" edit page layout
     $this->fullScreen = $fullScreen;
     if ($fullScreen) {
         // set Oasis entry-point
         Wikia::setVar('OasisEntryControllerName', 'EditPageLayout');
     }
     // Disable custom JS while loading the edit page on MediaWiki JS pages and user subpages (BugID: 41449)
     $editedArticleTitle = $editedArticle->getTitle();
     $editedArticleTitleNS = $editedArticleTitle->getNamespace();
     $editedArticleTitleText = $editedArticleTitle->getText();
     if ($editedArticleTitleNS === NS_MEDIAWIKI && substr($editedArticleTitleText, -3) === '.js' || $editedArticleTitleNS === NS_USER && preg_match('/^' . preg_quote($user->getName(), '/') . '\\/.*\\.js$/', $editedArticleTitleText)) {
         $this->out->disallowUserJs();
     }
     // Add variables for pages to edit code (css, js, lua)
     if ($this->isCodeSyntaxHighlightingEnabled($editedArticleTitle)) {
         $this->prepareVarsForCodePage($editedArticleTitle);
     }
     // initialize custom edit page
     $this->editPage = new EditPageLayout($editedArticle);
     $editedTitle = $this->editPage->getEditedTitle();
     $formCustomHandler = $this->editPage->getCustomFormHandler();
     $this->addJsVariable('wgIsEditPage', true);
     $this->addJsVariable('wgEditedTitle', $editedTitle->getPrefixedText());
     $this->addJsVariable('wgEditPageClass', $class ? $class : 'SpecialCustomEditPage');
     $this->addJsVariable('wgEditPageHandler', !is_null($formCustomHandler) ? $formCustomHandler->getLocalUrl('wpTitle=$1') : $this->app->getGlobal('wgScript') . '?action=ajax&rs=EditPageLayoutAjax&title=$1');
     $this->addJsVariable('wgEditPagePopularTemplates', TemplateService::getPromotedTemplates());
     $this->addJsVariable('wgEditPageIsWidePage', $this->isWidePage());
     $this->addJsVariable('wgIsDarkTheme', SassUtil::isThemeDark());
     if ($user->isLoggedIn()) {
         global $wgRTEDisablePreferencesChange;
         $wgRTEDisablePreferencesChange = true;
         $this->addJsVariable('wgEditPageWideSourceMode', (bool) $user->getGlobalPreference('editwidth'));
         unset($wgRTEDisablePreferencesChange);
     }
     $this->addJsVariableRef('wgEditPageFormType', $this->editPage->formtype);
     $this->addJsVariableRef('wgEditPageIsConflict', $this->editPage->isConflict);
     $this->addJsVariable('wgEditPageIsReadOnly', $this->editPage->isReadOnlyPage());
     $this->addJsVariableRef('wgEditPageHasEditPermissionError', $this->editPage->mHasPermissionError);
     $this->addJsVariableRef('wgEditPageSection', $this->editPage->section);
     // data for license module (BugId:6967)
     $titleLicensing = GlobalTitle::newFromText('Community_Central:Licensing', null, 177);
     $this->addJsVariable('wgEditPageLicensingUrl', $titleLicensing->getFullUrl());
     $this->addJsVariable('wgRightsText', $this->app->wg->RightsText);
     // copyright warning for notifications (BugId:7951)
     $this->addJsVariable('wgCopywarn', $this->editPage->getCopyrightNotice());
     // extra hooks for edit page
     $wgHooks['MakeGlobalVariablesScript'][] = 'EditPageLayoutHooks::onMakeGlobalVariablesScript';
     $wgHooks['SkinGetPageClasses'][] = 'EditPageLayoutHooks::onSkinGetPageClasses';
     $this->helper = self::getInstance();
     wfProfileOut(__METHOD__);
     return $this->editPage;
 }
Example #26
0
 public function executeIndex($params)
 {
     global $wgOut, $wgUser, $wgTitle, $wgRequest, $wgCityId, $wgEnableAdminDashboardExt, $wgAllInOne, $wgOasisThemeSettings;
     wfProfileIn(__METHOD__);
     //Add Smart banner for My Wikia App
     //See: https://wikia-inc.atlassian.net/browse/MOB-167
     $wgOut->addHeadItem('My Wikia Smart Banner', '<meta name="apple-itunes-app" content="app-id=623705389">');
     /* set the grid if passed in, otherwise, respect the default */
     $grid = $wgRequest->getVal('wikiagrid', '');
     if ('1' === $grid) {
         $this->wg->OasisGrid = true;
     } else {
         if ('0' === $grid) {
             $this->wg->OasisGrid = false;
         }
     }
     /* end grid or full width */
     $jsPackages = array();
     $scssPackages = array();
     $this->app->runHook('WikiaAssetsPackages', array(&$wgOut, &$jsPackages, &$scssPackages));
     $this->isUserLoggedIn = $wgUser->isLoggedIn();
     // TODO: move to CreateNewWiki extension - this code should use a hook
     $wikiWelcome = $wgRequest->getVal('wiki-welcome');
     if (!empty($wikiWelcome)) {
         $wgOut->addStyle($this->assetsManager->getSassCommonURL('extensions/wikia/CreateNewWiki/css/WikiWelcome.scss'));
         $wgOut->addScript('<script src="' . $this->wg->ExtensionsPath . '/wikia/CreateNewWiki/js/WikiWelcome.js"></script>');
     }
     if (RenderContentOnlyHelper::isRenderContentOnlyEnabled()) {
         $this->body = F::app()->renderView('BodyContentOnly', 'Index');
     } else {
         // macbre: let extensions modify content of the page (e.g. EditPageLayout)
         wfProfileIn(__METHOD__ . ' - renderBody');
         $this->body = !empty($params['body']) ? $params['body'] : F::app()->renderView('Body', 'Index');
         wfProfileOut(__METHOD__ . ' - renderBody');
     }
     // get microdata for body tag
     $this->itemType = self::getItemType();
     $skin = RequestContext::getMain()->getSkin();
     /* @var $skin WikiaSkin */
     // this is bad but some extensions could have added some scripts to bottom queue
     // todo: make it not run twice during each request
     $this->bottomScripts = $skin->bottomScripts();
     // generate list of CSS classes for <body> tag
     $bodyClasses = array('mediawiki', $this->dir, $this->pageClass);
     $bodyClasses = array_merge($bodyClasses, self::$extraBodyClasses);
     $bodyClasses[] = $this->skinNameClass;
     if (Wikia::isMainPage()) {
         $bodyClasses[] = 'mainpage';
     }
     wfProfileIn(__METHOD__ . ' - skin Operations');
     // add skin theme name
     if (!empty($skin->themename)) {
         $bodyClasses[] = "oasis-{$skin->themename}";
     }
     // mark dark themes
     if (SassUtil::isThemeDark()) {
         $bodyClasses[] = 'oasis-dark-theme';
     }
     /**
      * Login status based CSS class
      */
     $bodyClasses[] = $skin->getUserLoginStatusClass();
     // sets background settings by adding classes to <body>
     $bodyClasses = array_merge($bodyClasses, $this->getOasisBackgroundClasses($wgOasisThemeSettings));
     $this->bodyClasses = $bodyClasses;
     if (is_array($scssPackages)) {
         foreach ($scssPackages as $package) {
             $wgOut->addStyle($this->assetsManager->getSassCommonURL('extensions/' . $package));
         }
     }
     // Reset (this ensures no duplication in CSS links)
     $sassFiles = ['skins/oasis/css/oasis.scss'];
     $this->cssLinks = $skin->getStylesWithCombinedSASS($sassFiles);
     // $sassFiles will be updated by getStylesWithCombinedSASS method will all extracted and concatenated SASS files
     $this->bottomScripts .= Html::inlineScript("var wgSassLoadedScss = " . json_encode($sassFiles) . ";");
     $this->headLinks = $wgOut->getHeadLinks();
     $this->headItems = $skin->getHeadItems();
     $this->pageTitle = htmlspecialchars($this->pageTitle);
     $this->displayTitle = htmlspecialchars($this->displayTitle);
     $this->mimeType = htmlspecialchars($this->mimeType);
     $this->charset = htmlspecialchars($this->charset);
     wfProfileOut(__METHOD__ . ' - skin Operations');
     $this->topScripts = $wgOut->topScripts;
     if (is_array($jsPackages)) {
         foreach ($jsPackages as $package) {
             $wgOut->addScriptFile($this->wg->ExtensionsPath . '/' . $package);
         }
     }
     // setup loading of JS/CSS
     $this->loadJs();
     // macbre: RT #25697 - hide Comscore & QuantServe tags on edit pages
     if (!in_array($wgRequest->getVal('action'), array('edit', 'submit'))) {
         $this->comScore = AnalyticsEngine::track('Comscore', AnalyticsEngine::EVENT_PAGEVIEW);
         $this->quantServe = AnalyticsEngine::track('QuantServe', AnalyticsEngine::EVENT_PAGEVIEW);
         $this->amazonMatch = AnalyticsEngine::track('AmazonMatch', AnalyticsEngine::EVENT_PAGEVIEW);
         $this->rubiconRtp = AnalyticsEngine::track('RubiconRTP', AnalyticsEngine::EVENT_PAGEVIEW);
         $this->dynamicYield = AnalyticsEngine::track('DynamicYield', AnalyticsEngine::EVENT_PAGEVIEW);
         $this->ivw2 = AnalyticsEngine::track('IVW2', AnalyticsEngine::EVENT_PAGEVIEW);
     }
     if (!empty($wgEnableAdminDashboardExt) && AdminDashboardLogic::displayAdminDashboard($this->app, $wgTitle)) {
         $this->displayAdminDashboard = true;
     } else {
         $this->displayAdminDashboard = false;
     }
     wfProfileOut(__METHOD__);
 }
Example #27
0
 /**
  * Get wiki background full, up-to-date URL
  *
  * This method returns URL based on "background-image" and performs URL rewrite
  * for migrated wikis with short Swift bucket name
  *
  * @see  $wgUploadPath - "http://images.wikia.com/24_/es/images"
  *
  * @author macbre
  * @return string background URL or empty string if not found
  */
 public function getBackgroundUrl()
 {
     global $wgUploadPath;
     $backgroundUrl = $this->getSettings()['background-image'];
     if (!VignetteRequest::isVignetteUrl($backgroundUrl)) {
         if (empty($backgroundUrl)) {
             return $backgroundUrl;
         }
         $backgroundPath = explode('/images/', $backgroundUrl)[0];
         if (!empty($wordmarkPath)) {
             $backgroundUrl = str_replace($backgroundPath . '/images', $wgUploadPath, $backgroundUrl);
         }
         $backgroundUrl = wfReplaceImageServer($backgroundUrl, SassUtil::getCacheBuster());
     }
     return $backgroundUrl;
 }
Example #28
0
 /**
  * Return color scheme name to be used based on SASS color calculation
  *
  * @return string color scheme to be used ("light" or "dark")
  */
 protected function getColorScheme()
 {
     return SassUtil::isThemeDark() ? 'dark' : 'light';
 }
 private function setBodyClasses()
 {
     // generate list of CSS classes for <body> tag
     $bodyClasses = ['mediawiki', $this->skinNameClass, $this->dir, $this->pageClass];
     // add skin theme name
     if (!empty($this->skin->themename)) {
         $bodyClasses[] = 'venus-' . $this->skin->themename;
     }
     // mark dark themes
     if (SassUtil::isThemeDark()) {
         $bodyClasses[] = 'venus-dark-theme';
     }
     $this->bodyClasses = implode(' ', array_merge($bodyClasses, self::getBackgroundClasses(), self::$bodyClassArray));
 }
 public static function onResourceLoaderMakeQuery($modules, &$query)
 {
     $only = isset($query['only']) ? $query['only'] : null;
     if (empty($only) || $only == 'styles') {
         $resourceLoaderInstance = self::getResourceLoaderInstance();
         $requireSass = false;
         foreach ($modules as $moduleName) {
             $module = $resourceLoaderInstance->getModule($moduleName);
             if ($module->getFlag('sass')) {
                 $requireSass = true;
                 break;
             }
         }
         if ($requireSass) {
             $sassParams = SassUtil::getSassSettings();
             foreach ($sassParams as $key => $value) {
                 $query['sass_' . $key] = (string) $value;
             }
         }
     }
     return true;
 }