/** * Check if for current page the ads can be displayed or not * We only want ads on regular article pages plug a few * special pages. The logic lays here. * * @return bool */ public static function areAdsShowableOnPage() { $wg = F::app()->wg; $runAds = $wg->Out->isArticle() || WikiaPageType::isSearch() || WikiaPageType::isForum() || WikiaPageType::isWikiaHub(); // Can be re-enabled after AdDriver2.js is implemented: // || $wg->Title->isSpecial('Leaderboard'); return $runAds; }
/** * 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; }
/** * Business-logic for determining if the javascript should be at the bottom of the page (it usually should be * at the bottom for performance reasons, but there are some exceptions for engineering reasons). * * TODO: make sure JavaScripts can be always loaded on bottom * * Note: NS_FILE pages need JS at top because AnyClips relies on jQuery. */ public static function JsAtBottom() { global $wgTitle; // decide where JS should be placed (only add JS at the top for non-search Special and edit pages) if (WikiaPageType::isSearch() || WikiaPageType::isForum()) { // Remove this whole condition when AdDriver2.js is fully implemented and deployed $jsAtBottom = true; // Liftium.js (part of AssetsManager) must be loaded after LiftiumOptions variable is set in page source } elseif ($wgTitle->getNamespace() == NS_SPECIAL || BodyController::isEditPage()) { $jsAtBottom = false; } else { $jsAtBottom = true; } return $jsAtBottom; }
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; } } }
public function getRailModuleList() { wfProfileIn(__METHOD__); global $wgTitle, $wgUser, $wgEnableAchievementsExt, $wgContentNamespaces, $wgExtraNamespaces, $wgExtraNamespacesLocal, $wgEnableCorporatePageExt, $wgEnableWikiAnswers, $wgSalesTitles, $wgEnableHuluVideoPanel, $wgEnableGamingCalendarExt, $wgEnableWallEngine, $wgRequest; $namespace = $wgTitle->getNamespace(); $subjectNamespace = MWNamespace::getSubject($namespace); $railModuleList = array(); $latestPhotosKey = $wgUser->isAnon() ? 1300 : 1250; $latestActivityKey = $wgUser->isAnon() ? 1250 : 1300; $huluVideoPanelKey = $wgUser->isAnon() ? 1390 : 1280; // Forum Extension if (WikiaPageType::isForum()) { $railModuleList = array ( 1500 => array('Search', 'Index', null), 1002 => array('Forum', 'forumRelatedThreads', null), 1001 => array('Forum', 'forumActivityModule', null), 1000 => array('Forum', 'forumParticipationModule', null), 1490 => array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BOXAD')), ); return $railModuleList; } if($namespace == NS_SPECIAL) { if (WikiaPageType::isSearch()) { if (empty($this->wg->EnableWikiaHomePageExt)) { $railModuleList = array( $latestActivityKey => array('LatestActivity', 'Index', null), ); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if( empty( $wgEnableWikiAnswers ) ) { $railModuleList[$latestPhotosKey] = array('LatestPhotos', 'Index', null); if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } elseif ($wgEnableCorporatePageExt) { $railModuleList = array( 1490 => array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BOXAD')) ); wfProfileOut(__METHOD__); return $railModuleList; } } else if ($wgTitle->isSpecial('Leaderboard')) { $railModuleList = array ( 1500 => array('Search', 'Index', null), $latestActivityKey => array('LatestActivity', 'Index', null), 1290 => array('LatestEarnedBadges', 'Index', null) ); } else if ($wgTitle->isSpecial('WikiActivity')) { $railModuleList = array ( 1500 => array('Search', 'Index', null), 1102 => array('HotSpots', 'Index', null), 1101 => array('CommunityCorner', 'Index', null), ); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); } else if ($wgTitle->isSpecial('Following') || $wgTitle->isSpecial('Contributions') ) { // intentional nothing here } else if ($wgTitle->isSpecial('ThemeDesignerPreview') ) { $railModuleList = array ( 1500 => array('Search', 'Index', null), $latestActivityKey => array('LatestActivity', 'Index', null), ); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if( empty( $wgEnableWikiAnswers ) ) { $railModuleList[$latestPhotosKey] = array('LatestPhotos', 'Index', null); if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } else if( $wgTitle->isSpecial('PageLayoutBuilderForm') ) { $railModuleList = array ( 1501 => array('Search', 'Index', null), 1500 => array('PageLayoutBuilderForm', 'Index', null) ); } else { // don't show any module for MW core special pages $railModuleList = array(); wfRunHooks( 'GetRailModuleSpecialPageList', array( &$railModuleList ) ); wfProfileOut(__METHOD__); return $railModuleList; } } else if ( !self::showUserPagesHeader() ) { // ProfilePagesV3 renders its own search box. // If this page is not a page with the UserPagesHeader on version 3, show search (majority case) $railModuleList = array ( 1500 => array('Search', 'Index', null), ); } // Content, category and forum namespaces. FB:1280 Added file,video,mw,template if( $wgTitle->isSubpage() && $wgTitle->getNamespace() == NS_USER || in_array($subjectNamespace, array (NS_CATEGORY, NS_CATEGORY_TALK, NS_FORUM, NS_PROJECT, NS_FILE, NS_VIDEO, NS_MEDIAWIKI, NS_TEMPLATE, NS_HELP)) || in_array($subjectNamespace, $wgContentNamespaces) || array_key_exists( $subjectNamespace, $wgExtraNamespaces ) ) { // add any content page related rail modules here $railModuleList[$latestActivityKey] = array('LatestActivity', 'Index', null); $railModuleList[1450] = array('PagesOnWiki', 'Index', null); if( empty( $wgEnableWikiAnswers ) ) { $railModuleList[$latestPhotosKey] = array('LatestPhotos', 'Index', null); if ($wgEnableHuluVideoPanel) { $railModuleList[$huluVideoPanelKey] = array('HuluVideoPanel', 'Index', null); } } } // User page namespaces if( in_array($wgTitle->getNamespace(), self::getUserPagesNamespaces() ) ) { $page_owner = User::newFromName($wgTitle->getText()); if($page_owner) { if( !$page_owner->getOption('hidefollowedpages') ) { $railModuleList[1101] = array('FollowedPages', 'Index', null); } if($wgEnableAchievementsExt && !(($wgUser->getId() == $page_owner->getId()) && $page_owner->getOption('hidepersonalachievements'))){ $railModuleList[1102] = array('Achievements', 'Index', null); } } } if (self::isBlogPost() || self::isBlogListing()) { $railModuleList[1500] = array('Search', 'Index', null); $railModuleList[1250] = array('PopularBlogPosts', 'Index', null); } // A/B testing leftovers, leave for now because we will do another one $useTestBoxad = false; // Special case rail modules for Corporate Skin if ($wgEnableCorporatePageExt) { $railModuleList = array ( 1500 => array('Search', 'Index', null), ); // No rail on main page or edit page for corporate skin if ( BodyController::isEditPage() || WikiaPageType::isMainPage() ) { $railModuleList = array(); } else if (self::isHubPage()) { if ($useTestBoxad) { $railModuleList[1490] = array('Ad', 'Index', array('slotname' => 'TEST_TOP_RIGHT_BOXAD')); } else { $railModuleList[1490] = array('Ad', 'Index', array('slotname' => 'CORP_TOP_RIGHT_BOXAD')); } $railModuleList[1480] = array('CorporateSite', 'HotSpots', null); // $railModuleList[1470] = array('CorporateSite', 'PopularHubPosts', null); // temp disabled - data not updating $railModuleList[1460] = array('CorporateSite', 'TopHubUsers', null); } else if ( is_array( $wgSalesTitles ) && in_array( $wgTitle->getText(), $wgSalesTitles ) ){ $railModuleList[1470] = array('CorporateSite', 'SalesSupport', null); } else { // content pages $railModuleList[1470] = array('CorporateSite', 'PopularStaffPosts', null); } wfProfileOut(__METHOD__); return $railModuleList; } // No rail on main page or edit page for oasis skin // except &action=history of wall if( !empty($wgEnableWallEngine) ) { $isEditPage = !WallHelper::isWallNamespace($namespace) && BodyController::isEditPage() || $wgRequest->getVal('diff'); } else { $isEditPage = BodyController::isEditPage(); } if ( $isEditPage || WikiaPageType::isMainPage() ) { $modules = array(); wfRunHooks( 'GetEditPageRailModuleList', array( &$modules ) ); wfProfileOut(__METHOD__); return $modules; } // No modules on Custom namespaces, unless they are in the ContentNamespaces list, those get the content rail if (is_array($wgExtraNamespacesLocal) && array_key_exists($subjectNamespace, $wgExtraNamespacesLocal) && !in_array($subjectNamespace, $wgContentNamespaces)) { wfProfileOut(__METHOD__); return array(); } // If the entire page is non readable due to permissions, don't display the rail either RT#75600 if (!$wgTitle->userCan( 'read' )) { wfProfileOut(__METHOD__); return array(); } if ($useTestBoxad) { $railModuleList[1440] = array('Ad', 'Index', array('slotname' => 'TEST_TOP_RIGHT_BOXAD')); } else { $railModuleList[1440] = array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BOXAD')); } $railModuleList[1291] = array('Ad', 'Index', array('slotname' => 'MIDDLE_RIGHT_BOXAD')); $railModuleList[1100] = array('Ad', 'Index', array('slotname' => 'LEFT_SKYSCRAPER_2')); /** * Michał Roszka <*****@*****.**> * * SSW Gaming Calendar * * This is most likely going to be replaced with something similar to: * * $railModuleList[1260] = array( 'Ad', 'Index', array( 'slotname' => 'GAMING_CALENDAR_RAIL' ) ); */ if ( !empty( $wgEnableGamingCalendarExt ) ) { $railModuleList[1430] = array( 'GamingCalendarRail', 'Index', array( ) ); } else { $railModuleList[1430] = array('Ad', 'Index', array('slotname' => 'TOP_RIGHT_BUTTON')); } // WikiNav v2 - begin // TODO: remove once it's enabled sitewide global $wgOasisNavV2; if (!empty($wgOasisNavV2)) { // remove PagesOnWiki module unset($railModuleList[1450]); } // WikiNav v2 - end wfRunHooks( 'GetRailModuleList', array( &$railModuleList ) ); wfProfileOut(__METHOD__); return $railModuleList; }