private function configure() {
		global $wgTitle, $wgContentNamespaces, $wgEnableFAST_HOME2, $wgEnableCorporatePageExt, $wgExtraNamespaces;

		self::$config = array();

		if (!AdEngine2Controller::areAdsShowableOnPage()) {
			return;
		}

		if(WikiaPageType::isWikiaHub() && AdEngine::isAdsEnabledOnWikiaHub()) {
			self::$config['HOME_TOP_LEADERBOARD'] = true;
			self::$config['TOP_BUTTON'] = true;
			return;
		}
		// Ads on corporate hub pages only
		elseif($wgEnableCorporatePageExt) {
			if (BodyController::isHubPage()) {
				self::$config['CORP_TOP_LEADERBOARD'] = true;
				self::$config['CORP_TOP_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
			}
			elseif (WikiaPageType::isSearch()) {
				if (!empty($this->wg->EnableWikiaSearchAds)) {
					// no regular ads if search ads are enabled
				} else {
					self::$config['TOP_LEADERBOARD'] = true;
					self::$config['TOP_RIGHT_BOXAD'] = true;
					self::$config['TOP_BUTTON'] = true;				
				}
			}
			return;
		}

		$namespace = $wgTitle->getNamespace();

		if(WikiaPageType::isMainPage()) {
			// main page
			self::$config['HOME_TOP_LEADERBOARD'] = true;
			self::$config['INVISIBLE_1'] = true;
			self::$config['INVISIBLE_2'] = true;
			self::$config['PREFOOTER_LEFT_BOXAD'] = true;
			self::$config['PREFOOTER_RIGHT_BOXAD'] = true;
			self::$config['HOME_INVISIBLE_TOP'] = false;	// skins used to be served from this slot, but are now served from TOP_LEADERBOARD with option dcopt=ist
			if($wgEnableFAST_HOME2) {
				self::$config['HOME_TOP_RIGHT_BOXAD'] = true;
				self::$config['TEST_HOME_TOP_RIGHT_BOXAD'] = true;
			}
			self::$config['HOME_TOP_RIGHT_BUTTON'] = true;
			self::$config['TOP_BUTTON'] = true;
		} else {
			if(in_array($namespace, $wgContentNamespaces)) {
				// content page
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TEST_TOP_RIGHT_BOXAD'] = true;
				self::$config['MIDDLE_RIGHT_BOXAD'] = true;
				self::$config['INVISIBLE_1'] = true;
				self::$config['INVISIBLE_2'] = true;
				self::$config['LEFT_SKYSCRAPER_2'] = true;
				self::$config['LEFT_SKYSCRAPER_3'] = true;
				self::$config['PREFOOTER_LEFT_BOXAD'] = true;
				self::$config['PREFOOTER_RIGHT_BOXAD'] = true;
				self::$config['INVISIBLE_TOP'] = false;	// skins used to be served from this slot, but are now served from TOP_LEADERBOARD with option dcopt=ist
				self::$config['TOP_RIGHT_BUTTON'] = true;
				self::$config['TOP_BUTTON'] = true;
			} else if($namespace == NS_FILE) {
				// file/image page
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
			} else if(WikiaPageType::isForum()) {
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
				self::$config['LEFT_SKYSCRAPER_3'] = true;
				self::$config['PREFOOTER_LEFT_BOXAD'] = true;
				self::$config['PREFOOTER_RIGHT_BOXAD'] = true;
			} else if (WikiaPageType::isSearch()) {
				// search results page
				if (empty($this->wg->EnableWikiaSearchAds)) {
					// regular ads if search ads are disabled
					self::$config['TOP_LEADERBOARD'] = true;
					self::$config['TOP_RIGHT_BOXAD'] = true;
					self::$config['TEST_TOP_RIGHT_BOXAD'] = true;
					self::$config['TOP_BUTTON'] = true;
					self::$config['LEFT_SKYSCRAPER_2'] = true;
					self::$config['LEFT_SKYSCRAPER_3'] = true;
					self::$config['PREFOOTER_LEFT_BOXAD'] = true;
					self::$config['PREFOOTER_RIGHT_BOXAD'] = true;
				}
			} else if($namespace == NS_SPECIAL) {
				if($wgTitle->isSpecial('Leaderboard')) {
					self::$config['TOP_LEADERBOARD'] = true;
					self::$config['TOP_RIGHT_BOXAD'] = true;					
					self::$config['TOP_BUTTON'] = true;
				} else if($wgTitle->isSpecial('Videos')) {
					self::$config['TOP_LEADERBOARD'] = true;
				}
			} else if($namespace == NS_CATEGORY) {
				// category page
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TEST_TOP_RIGHT_BOXAD'] = true;
				self::$config['MIDDLE_RIGHT_BOXAD'] = true;
				self::$config['LEFT_SKYSCRAPER_2'] = true;
				self::$config['PREFOOTER_LEFT_BOXAD'] = true;
				self::$config['PREFOOTER_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
			} else if($namespace == NS_PROJECT) {
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
			} else if($namespace == NS_FORUM) {
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
			} else if( BodyController::isBlogListing() ) {
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
			} else if( BodyController::isBlogPost() ) {
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_RIGHT_BOXAD'] = true;
				self::$config['TEST_TOP_RIGHT_BOXAD'] = true;
				self::$config['TOP_BUTTON'] = true;
			} else if (array_key_exists($namespace, $wgExtraNamespaces)) {
				self::$config['TOP_LEADERBOARD'] = true;
				self::$config['TOP_BUTTON'] = true;
			}
		}
	}
Example #2
0
 private function loadJs()
 {
     global $wgJsMimeType, $wgUser, $wgDevelEnvironment, $wgEnableAdEngineExt, $wgAllInOne;
     wfProfileIn(__METHOD__);
     $this->jsAtBottom = self::JsAtBottom();
     // load AbTesting files, anything that's so mandatory that we're willing to make a blocking request to load it.
     $this->globalBlockingScripts = '';
     $jsReferences = array();
     $jsAssetGroups = array('oasis_blocking');
     wfRunHooks('OasisSkinAssetGroupsBlocking', array(&$jsAssetGroups));
     $blockingScripts = $this->assetsManager->getURL($jsAssetGroups);
     foreach ($blockingScripts as $blockingFile) {
         $this->globalBlockingScripts .= "<script type=\"{$wgJsMimeType}\" src=\"{$blockingFile}\"></script>";
     }
     // move JS files added to OutputPage to list of files to be loaded
     $scripts = RequestContext::getMain()->getSkin()->getScripts();
     foreach ($scripts as $s) {
         //add inline scripts to jsFiles and move non-inline to the queue
         if (!empty($s['url'])) {
             // FIXME: quick hack to load MW core JavaScript at the top of the page - really, please fix me!
             // @author macbre
             if (strpos($s['url'], 'load.php') !== false) {
                 $this->globalVariablesScript = $s['tag'] . $this->globalVariablesScript;
             } else {
                 $url = $s['url'];
                 if ($wgAllInOne) {
                     $url = $this->minifySingleAsset($url);
                 }
                 $jsReferences[] = $url;
             }
         } else {
             $this->jsFiles .= $s['tag'];
         }
     }
     $isLoggedIn = $wgUser->isLoggedIn();
     $assetGroups = ['oasis_shared_core_js', 'oasis_shared_js'];
     if ($isLoggedIn) {
         $assetGroups[] = 'oasis_user_js';
     } else {
         $assetGroups[] = 'oasis_anon_js';
     }
     $jsLoader = '';
     wfRunHooks('OasisSkinAssetGroups', array(&$assetGroups));
     // add groups queued via OasisController::addSkinAssetGroup
     $assetGroups = array_merge($assetGroups, self::$skinAssetGroups);
     $assets = $this->assetsManager->getURL($assetGroups);
     // jQueryless version - appears only to be used by the ad-experiment at the moment.
     // disabled - not needed atm (and skipped in wsl-version anyway)
     // $assets[] = $this->assetsManager->getURL( $isLoggedIn ? 'oasis_nojquery_shared_js_user' : 'oasis_nojquery_shared_js_anon' );
     // add $jsReferences
     $assets = array_merge($assets, $jsReferences);
     // generate direct script tags
     foreach ($assets as $url) {
         $url = htmlspecialchars($url);
         $jsLoader .= "<script src=\"{$url}\"></script>\n";
     }
     $tpl = $this->app->getSkinTemplateObj();
     // $tpl->set( 'headscripts', $out->getHeadScripts() . $out->getHeadItems() );
     // FIXME: we need to remove head items - i.e. <meta> tags
     $remove = $this->wg->out->getHeadItemsArray();
     $remove[] = $this->topScripts;
     array_walk($remove, 'trim');
     $headScripts = str_replace($remove, '', $tpl->data['headscripts']);
     $this->jsFiles = $headScripts . $jsLoader . $this->jsFiles;
     // experiment: squeeze calls to mw.loader.load() to make fewer HTTP requests
     if ($this->jsAtBottom) {
         $jsFiles = $this->jsFiles;
         $bottomScripts = $this->bottomScripts;
         $this->squeezeMediawikiLoad($jsFiles, $bottomScripts);
         $this->bottomScripts = $bottomScripts;
         $this->jsFiles = $jsFiles;
     }
     if ($wgEnableAdEngineExt && AdEngine2Service::shouldLoadLiftium()) {
         $this->jsFiles = AdEngine2Controller::getLiftiumOptionsScript() . $this->jsFiles;
     }
     wfProfileOut(__METHOD__);
 }
 public static function onSkinAfterBottomScripts(Skin $skin, &$text)
 {
     // TODO: Check whether this works also on Oasis!
     if ($skin->getSkinName() === 'venus') {
         $text .= AdEngine2Controller::getLiftiumOptionsScript();
         $text .= Html::inlineScript('Liftium.init();') . "\n";
     }
     return true;
 }