/**
  * Get page type for the current page (ad-wise).
  * Take into account type of the page and user status.
  * Return one of the PAGE_TYPE_* constants
  *
  * @return string
  */
 public function getPageType()
 {
     $title = null;
     if (WikiaPageType::isActionPage() || $this->wg->Request->getBool('noexternals', $this->wg->NoExternals) || $this->wg->Request->getBool('noads', false) || $this->wg->ShowAds === false || $this->wg->EnableAdEngineExt === false || !$this->app->checkSkin(['oasis', 'wikiamobile', 'venus'])) {
         $pageLevel = self::PAGE_TYPE_NO_ADS;
         return $pageLevel;
     }
     $runAds = WikiaPageType::isFilePage() || WikiaPageType::isForum() || WikiaPageType::isSearch() || WikiaPageType::isWikiaHub();
     if (!$runAds) {
         if ($this->wg->Title) {
             $title = $this->wg->Title;
             $namespace = $title->getNamespace();
             $runAds = in_array($namespace, $this->wg->ContentNamespaces) || isset($this->wg->ExtraNamespaces[$namespace]) || BodyController::isBlogListing() || BodyController::isBlogPost() || defined('NS_WIKIA_PLAYQUIZ') && $title->inNamespace(NS_WIKIA_PLAYQUIZ) || defined('NS_CATEGORY') && $namespace == NS_CATEGORY || defined('NS_PROJECT') && $namespace == NS_PROJECT || $title->isSpecial('Leaderboard') || $title->isSpecial('Maps') || $title->isSpecial('Newimages') || $title->isSpecial('Videos');
         }
     }
     if (!$runAds) {
         $pageLevel = self::PAGE_TYPE_NO_ADS;
         return $pageLevel;
     }
     $user = $this->wg->User;
     if (!$user->isLoggedIn() || $user->getGlobalPreference('showAds')) {
         // Only leaderboard, medrec and invisible on corporate sites for anonymous users
         if (WikiaPageType::isCorporatePage()) {
             $pageLevel = self::PAGE_TYPE_CORPORATE;
             return $pageLevel;
         }
         if (WikiaPageType::isSearch()) {
             $pageLevel = self::PAGE_TYPE_SEARCH;
             return $pageLevel;
         }
         if ($title && $title->isSpecial('Maps')) {
             $pageLevel = self::PAGE_TYPE_MAPS;
             return $pageLevel;
         }
         // All ads everywhere else
         $pageLevel = self::PAGE_TYPE_ALL_ADS;
         return $pageLevel;
     }
     // Logged in users get some ads on the main pages (except on the corporate sites)
     if (!WikiaPageType::isCorporatePage() && WikiaPageType::isMainPage()) {
         $pageLevel = self::PAGE_TYPE_HOMEPAGE_LOGGED;
         return $pageLevel;
     }
     // Override ad level for a (set of) specific page(s)
     // Use case: sponsor ads on a landing page targeted to Wikia editors (=logged in)
     if ($title && !empty($this->wg->PagesWithNoAdsForLoggedInUsersOverriden) && in_array($title->getDBkey(), $this->wg->PagesWithNoAdsForLoggedInUsersOverriden)) {
         $pageLevel = self::PAGE_TYPE_CORPORATE;
         return $pageLevel;
     }
     // And no other ads
     $pageLevel = self::PAGE_TYPE_NO_ADS;
     return $pageLevel;
 }
Ejemplo n.º 2
0
	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;
			}
		}
	}