public function searchIndex() { global $wgRequest, $wgSitename, $wgUser; $lang = $this->helper->getLangForSearchResults(); $centralUrl = $this->helper->getCentralUrlFromGlobalTitle($lang); $globalSearchUrl = $this->helper->getGlobalSearchUrl($centralUrl); $localSearchUrl = SpecialPage::getTitleFor('Search')->getFullUrl(); $fulltext = $wgUser->getGlobalPreference('enableGoSearch') ? 0 : 'Search'; $query = $wgRequest->getVal('search', $wgRequest->getVal('query', '')); $localSearchPlaceholder = html_entity_decode(wfMessage('global-navigation-local-search-placeholder', $wgSitename)->parse()); if (WikiaPageType::isCorporatePage() && !WikiaPageType::isWikiaHub()) { $this->response->setVal('disableLocalSearchOptions', true); $this->response->setVal('defaultSearchPlaceholder', wfMessage('global-navigation-global-search')->escaped()); $this->response->setVal('defaultSearchUrl', $globalSearchUrl); } else { $this->response->setVal('globalSearchUrl', $globalSearchUrl); $this->response->setVal('localSearchUrl', $localSearchUrl); $this->response->setVal('localSearchPlaceholder', $localSearchPlaceholder); $this->response->setVal('defaultSearchPlaceholder', $localSearchPlaceholder); $this->response->setVal('defaultSearchUrl', $localSearchUrl); } $this->response->setVal('fulltext', $fulltext); $this->response->setVal('query', $query); $this->response->setVal('lang', $lang); }
/** * Check if the page is sitemap page * @param Title $title * @return bool */ public function isSitemapPage($title) { if (WikiaPageType::isCorporatePage() && $title->getDBkey() == self::SITEMAP_PAGE) { return true; } return false; }
/** * @param array $vars JS variables to be added at the top of the page * @param array $scripts JS scripts to add to the top of the page * @return bool return true - it's a hook */ function wfJSVariablesTopScripts(array &$vars, &$scripts) { $wg = F::app()->wg; $title = $wg->Title; $out = $wg->Out; // ads need it $vars['wgAfterContentAndJS'] = array(); if (is_array($wg->WikiFactoryTags)) { $vars['wgWikiFactoryTagIds'] = array_keys($wg->WikiFactoryTags); $vars['wgWikiFactoryTagNames'] = array_values($wg->WikiFactoryTags); } $vars['wgCdnRootUrl'] = $wg->CdnRootUrl; $vars['wgCdnApiUrl'] = $wg->CdnApiUrl; // analytics needs it (from here till the end of the function) $vars['wgDBname'] = $wg->DBname; $vars['wgCityId'] = $wg->CityId; // c&p from OutputPage::getJSVars with an old 1.16 name $vars['wgContentLanguage'] = $title->getPageLanguage()->getCode(); // c&p from OutputPage::getJSVars, it's needed earlier $user = $wg->User; /** @var $user User */ if ($user->isAnon()) { $vars['wgUserName'] = null; } else { $vars['wgUserName'] = $user->getName(); /* * Remove when SOC-217 ABTest is finished */ $vars['wgNotConfirmedEmail'] = $user->getGlobalAttribute(UserLoginSpecialController::NOT_CONFIRMED_LOGIN_OPTION_NAME); /* * End remove */ } if ($out->isArticle()) { $vars['wgArticleId'] = $out->getWikiPage()->getId(); } $vars['wgCategories'] = $out->getCategories(); $vars['wgPageName'] = $title->getPrefixedDBKey(); $vars['wikiaPageType'] = WikiaPageType::getPageType(); $vars['wikiaPageIsCorporate'] = WikiaPageType::isCorporatePage(); $vars['wgArticleType'] = WikiaPageType::getArticleType(); // missing in 1.19 $skin = RequestContext::getMain()->getSkin(); $vars['skin'] = $skin->getSkinName(); // for Google Analytics $vars['_gaq'] = array(); $vars['wgIsGASpecialWiki'] = $wg->IsGASpecialWiki; // PER-58: moved wgStyleVersion to <head> $vars['wgStyleVersion'] = (string) $wg->StyleVersion; $wg->NoExternals = $wg->Request->getBool('noexternals', $wg->NoExternals); if (!empty($wg->NoExternals)) { $vars["wgNoExternals"] = $wg->NoExternals; } $vars['wgTransactionContext'] = Transaction::getAttributes(); $scripts .= Html::inlineScript("var wgNow = new Date();") . "\n"; return true; }
/** * Register monetization-related scripts on the top of the page * @param array $jsAssetGroups * @return true */ public static function onOasisSkinAssetGroupsBlocking(&$jsAssetGroups) { wfProfileIn(__METHOD__); $app = F::app(); $script = 'monetization_module_top_script_js'; if (!WikiaPageType::isCorporatePage() && $app->wg->User->isAnon() && $app->checkSkin('oasis') && !in_array($script, $jsAssetGroups)) { $jsAssetGroups[] = $script; } wfProfileOut(__METHOD__); return true; }
/** * Show the Module only on File pages, Article pages, and Main pages * @return boolean */ public static function canShowModule() { wfProfileIn(__METHOD__); $app = F::app(); $status = false; $showableNameSpaces = array_merge($app->wg->ContentNamespaces, [NS_FILE]); if (!WikiaPageType::isCorporatePage() && $app->wg->Title->exists() && !$app->wg->Title->isMainPage() && in_array($app->wg->Title->getNamespace(), $showableNameSpaces) && in_array($app->wg->request->getVal('action'), ['view', null]) && $app->wg->request->getVal('diff') === null && $app->wg->User->isAnon() && $app->checkSkin('oasis')) { $status = true; } wfProfileOut(__METHOD__); return $status; }
/** * 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; }
public function index() { if (WikiaPageType::isCorporatePage()) { return false; } $categoryLinks = $this->request->getVal('categoryLinks', ''); //$catlinks are always returned even empty if (strpos($categoryLinks, ' catlinks-allhidden\'></div>') !== false) { $categoryLinks = ''; } $this->response->setVal('categoryLinks', $categoryLinks); }
public function index() { $this->interlang = WikiaPageType::isCorporatePage(); $this->response->addAsset('extensions/wikia/CorporateFooter/styles/CorporateFooter.scss'); $helper = new WikiaHomePageHelper(); $wikisIncludedInCorporateFooterDropdown = $helper->getWikisIncludedInCorporateFooterDropdown(); $this->selectedLang = $this->wg->ContLang->getCode(); $this->dropDownItems = $this->prepareDropdownItems($wikisIncludedInCorporateFooterDropdown, $this->selectedLang); if ($this->app->wg->EnableWAMPageExt) { $wamModel = new WAMPageModel(); $this->wamPageUrl = $wamModel->getWAMMainPageUrl(); } }
/** * @group Slow * @slowExecutionTime 0.08448 ms * @covers WikiaSearchController::isCorporateWiki */ public function testIsCorporatePage() { $this->mockGlobalVariable('wgEnableWikiaHomePageExt', false); $this->mockGlobalVariable('wgEnableWikiaHubsV3Ext', false); $this->assertFalse(WikiaPageType::isCorporatePage()); $this->mockGlobalVariable('wgEnableWikiaHomePageExt', null); $this->mockGlobalVariable('wgEnableWikiaHubsV3Ext', null); $this->assertFalse(WikiaPageType::isCorporatePage()); $this->mockGlobalVariable('wgEnableWikiaHomePageExt', true); $this->mockGlobalVariable('wgEnableWikiaHubsV3Ext', false); $this->assertTrue(WikiaPageType::isCorporatePage()); $this->mockGlobalVariable('wgEnableWikiaHomePageExt', false); $this->mockGlobalVariable('wgEnableWikiaHubsV3Ext', true); $this->assertTrue(WikiaPageType::isCorporatePage()); $this->mockGlobalVariable('wgEnableWikiaHomePageExt', false); $this->mockGlobalVariable('wgEnableWikiaHubsV3Ext', true); $this->assertTrue(WikiaPageType::isCorporatePage()); }
/** * Get canonical vertical name for given cityId. * For Lifestyle and Gaming return their names. * For corporate pages return false - we don't want to track traffic from there in Comscore * For rest of values return Entertainment. * @param $cityId * @return Boolean|String */ public static function getVerticalNameForComscore($cityId) { $verticalId = WikiFactoryHub::getInstance()->getVerticalId($cityId); switch ($verticalId) { case WikiFactoryHub::VERTICAL_ID_VIDEO_GAMES: return 'gaming'; case WikiFactoryHub::VERTICAL_ID_LIFESTYLE: return 'lifestyle'; case WikiFactoryHub::VERTICAL_ID_OTHER: if (WikiaPageType::isCorporatePage()) { return false; } else { return 'lifestyle'; } default: return 'entertainment'; } }
public function getContext(Title $title, $skinName) { $wrapper = new GlobalStateWrapper(['wgTitle' => $title]); $wg = F::app()->wg; return $wrapper->wrap(function () use($title, $wg, $skinName) { $wikiFactoryHub = WikiFactoryHub::getInstance(); $hubService = new HubService(); $adPageTypeService = new AdEngine2PageTypeService(); $wikiaPageType = new WikiaPageType(); $sevenOneMediaCombinedUrl = null; if (!empty($wg->AdDriverUseSevenOneMedia)) { // TODO: implicitly gets the skin from the context! $sevenOneMediaCombinedUrl = ResourceLoader::makeCustomURL($wg->Out, ['wikia.ext.adengine.sevenonemedia'], 'scripts'); } $monetizationServiceAds = null; if (!empty($wg->AdDriverUseMonetizationService) && !empty($wg->EnableMonetizationModuleExt)) { $monetizationServiceAds = F::app()->sendRequest('MonetizationModule', 'index')->getData()['data']; } $langCode = $title->getPageLanguage()->getCode(); return ['opts' => $this->filterOutEmptyItems(['adsInContent' => $wg->EnableAdsInContent, 'delayBtf' => $wg->AdDriverDelayBelowTheFold, 'enableAdsInMaps' => $wg->AdDriverEnableAdsInMaps, 'pageType' => $adPageTypeService->getPageType(), 'paidAssetDropConfig' => $wg->PaidAssetDropConfig, 'showAds' => $adPageTypeService->areAdsShowableOnPage(), 'trackSlotState' => $wg->AdDriverTrackState, 'usePostScribe' => $wg->Request->getBool('usepostscribe', false)]), 'targeting' => $this->filterOutEmptyItems(['enablePageCategories' => array_search($langCode, $wg->AdPageLevelCategoryLangs) !== false, 'pageArticleId' => $title->getArticleId(), 'pageIsArticle' => !!$title->getArticleId(), 'pageIsHub' => $wikiaPageType->isWikiaHub(), 'pageName' => $title->getPrefixedDBKey(), 'pageType' => $wikiaPageType->getPageType(), 'sevenOneMediaSub2Site' => $wg->AdDriverSevenOneMediaOverrideSub2Site, 'skin' => $skinName, 'wikiCategory' => $wikiFactoryHub->getCategoryShort($wg->CityId), 'wikiCustomKeyValues' => $wg->DartCustomKeyValues, 'wikiDbName' => $wg->DBname, 'wikiDirectedAtChildren' => $wg->WikiDirectedAtChildrenByFounder || $wg->WikiDirectedAtChildrenByStaff, 'wikiIsCorporate' => $wikiaPageType->isCorporatePage(), 'wikiIsTop1000' => $wg->AdDriverWikiIsTop1000, 'wikiLanguage' => $langCode, 'wikiVertical' => $hubService->getCategoryInfoForCity($wg->CityId)->cat_name]), 'providers' => $this->filterOutEmptyItems(['monetizationService' => $wg->AdDriverUseMonetizationService, 'monetizationServiceAds' => $monetizationServiceAds, 'sevenOneMedia' => $wg->AdDriverUseSevenOneMedia, 'sevenOneMediaCombinedUrl' => $sevenOneMediaCombinedUrl, 'taboola' => $wg->AdDriverUseTaboola]), 'slots' => $this->filterOutEmptyItems(['exitstitial' => $wg->EnableOutboundScreenExt, 'exitstitialRedirectDelay' => $wg->OutboundScreenRedirectDelay, 'invisibleHighImpact' => $wg->AdDriverEnableInvisibleHighImpactSlot]), 'forcedProvider' => $wg->AdDriverForcedProvider]; }); }
public function executeIndex() { global $wgOut, $wgTitle, $wgEnableInfoBoxTest, $wgMaximizeArticleAreaArticleIds, $wgEnableAdminDashboardExt, $wgEnableWikiaHomePageExt; wfProfileIn(__METHOD__); // set up global vars if (is_array($wgMaximizeArticleAreaArticleIds) && in_array($wgTitle->getArticleId(), $wgMaximizeArticleAreaArticleIds)) { $this->wg->SuppressRail = true; $this->wg->SuppressPageHeader = true; } // Double-click to edit $this->body_ondblclick = ''; // FIXME handling moved to OutputPage::addDefaultModules() // InfoBox - Testing $this->wg->EnableInfoBoxTest = $wgEnableInfoBoxTest; // Replaces ContentDisplayModule->index() $this->bodytext = $this->app->getSkinTemplateObj()->data['bodytext']; $this->railModuleList = $this->getRailModuleList(); // this hook allows adding extra HTML just after <body> opening tag // append your content to $html variable instead of echoing // (taken from Monaco skin) $skin = RequestContext::getMain()->getSkin(); $afterBodyHtml = ''; wfRunHooks('GetHTMLAfterBody', array($skin, &$afterBodyHtml)); $this->afterBodyHtml = $afterBodyHtml; // this hook is needed for SMW's factbox $afterContentHookText = ''; wfRunHooks('SkinAfterContent', array(&$afterContentHookText)); $this->afterContentHookText = $afterContentHookText; $this->headerModuleAction = 'Index'; $this->headerModuleParams = array('showSearchBox' => false); // show user pages header on this page? if (self::showUserPagesHeader()) { $this->headerModuleName = 'UserPagesHeader'; // is this page a blog post? if (self::isBlogPost()) { $this->headerModuleAction = 'BlogPost'; } else { if (self::isBlogListing()) { $this->headerModuleAction = 'BlogListing'; } } // show corporate header on this page? } else { if (WikiaPageType::isCorporatePage() || WikiaPageType::isWikiaHub()) { $this->headerModuleName = 'PageHeader'; if (self::isEditPage()) { $this->headerModuleAction = 'EditPage'; } else { $this->headerModuleAction = 'Corporate'; } if (WikiaPageType::isWikiaHubMain()) { $this->headerModuleAction = 'Hubs'; } elseif (WikiaPageType::isMainPage()) { $this->wg->SuppressFooter = true; $this->wg->SuppressArticleCategories = true; $this->wg->SuppressPageHeader = true; $this->wg->SuppressWikiHeader = true; $this->wg->SuppressSlider = true; } } else { $this->headerModuleName = 'PageHeader'; if (self::isEditPage()) { $this->headerModuleAction = 'EditPage'; } } } // Display Control Center Header on certain special pages if (!empty($wgEnableAdminDashboardExt) && AdminDashboardLogic::displayAdminDashboard($this->app, $wgTitle)) { $this->headerModuleName = null; $this->wgSuppressAds = true; $this->displayAdminDashboard = true; $this->displayAdminDashboardChromedArticle = $wgTitle->getText() != SpecialPage::getTitleFor('AdminDashboard')->getText(); } else { $this->displayAdminDashboard = false; $this->displayAdminDashboardChromedArticle = false; } $this->railModulesExist = true; // use one column layout for pages with no right rail modules if (count($this->railModuleList) == 0 || !empty($this->wg->SuppressRail)) { // Special:AdminDashboard doesn't need this class, but pages chromed with it do if (!$this->displayAdminDashboard || $this->displayAdminDashboardChromedArticle) { OasisController::addBodyClass('oasis-one-column'); } $this->headerModuleParams = array('showSearchBox' => true); $this->railModulesExist = false; } // determine if WikiaGridLayout needs to be enabled $this->isGridLayoutEnabled = self::isGridLayoutEnabled(); if ($this->isGridLayoutEnabled) { OasisController::addBodyClass('wikia-grid'); } if ($this->isOasisBreakpoints()) { OasisController::addBodyClass('oasis-breakpoints'); } //@TODO remove this check after deprecating responsive (July 2015) if ($this->isResponsiveLayoutEnabled()) { OasisController::addBodyClass('oasis-responsive'); } // if we are on a special search page, pull in the css file and don't render a header if ($wgTitle && $wgTitle->isSpecial('Search') && !$this->wg->WikiaSearchIsDefault) { $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL("skins/oasis/css/modules/SpecialSearch.scss")); $this->headerModuleName = null; } // Inter-wiki search if ($wgTitle && ($wgTitle->isSpecial('WikiaSearch') || $wgTitle->isSpecial('Search') && $this->wg->WikiaSearchIsDefault)) { $this->headerModuleName = null; } // load CSS for Special:Preferences if (!empty($wgTitle) && $wgTitle->isSpecial('Preferences')) { $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('skins/oasis/css/modules/SpecialPreferences.scss')); } // load CSS for Special:Upload if (!empty($wgTitle) && $wgTitle->isSpecial('Upload')) { $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('skins/oasis/css/modules/SpecialUpload.scss')); } // load CSS for Special:MultipleUpload if (!empty($wgTitle) && $wgTitle->isSpecial('MultipleUpload')) { $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('skins/oasis/css/modules/SpecialMultipleUpload.scss')); } // load CSS for Special:Allpages if (!empty($wgTitle) && $wgTitle->isSpecial('Allpages')) { $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('skins/oasis/css/modules/SpecialAllpages.scss')); } // Forum Extension if (!empty($this->wg->EnableForumExt) && ForumHelper::isForum()) { $this->wg->SuppressPageHeader = true; } // MonetizationModule Extension if (!empty($this->wg->EnableMonetizationModuleExt)) { if (empty($this->wg->AdDriverUseMonetizationService)) { $this->monetizationModules = $this->sendRequest('MonetizationModule', 'index')->getData()['data']; $this->headerModuleParams['monetizationModules'] = $this->monetizationModules; } else { $this->monetizationModules = [MonetizationModuleHelper::SLOT_TYPE_IN_CONTENT => $this->app->renderView('Ad', 'Index', ['slotName' => 'MON_IN_CONTENT']), MonetizationModuleHelper::SLOT_TYPE_BELOW_CATEGORY => $this->app->renderView('Ad', 'Index', ['slotName' => 'MON_BELOW_CATEGORY'])]; } $this->bodytext = MonetizationModuleHelper::insertIncontentUnit($this->bodytext, $this->monetizationModules); } $namespace = $wgTitle->getNamespace(); // extra logic for subpages (RT #74091) if (!empty($this->subtitle)) { switch ($namespace) { // for user subpages add link to theirs talk pages case NS_USER: $talkPage = $wgTitle->getTalkPage(); // get number of revisions for talk page $service = new PageStatsService($wgTitle->getArticleId()); $comments = $service->getCommentsCount(); // render comments bubble $bubble = F::app()->renderView('CommentsLikes', 'Index', array('comments' => $comments, 'bubble' => true)); $this->subtitle .= ' | '; $this->subtitle .= $bubble; $this->subtitle .= Wikia::link($talkPage); break; case NS_USER_TALK: $subjectPage = $wgTitle->getSubjectPage(); $this->subtitle .= ' | '; $this->subtitle .= Wikia::link($subjectPage); break; } } // bugid-70243: optionally hide navigation h1s for SEO $this->setVal('displayHeader', !$this->wg->HideNavigationHeaders); wfProfileOut(__METHOD__); }
protected function isCorporateMainPageNonAnon() { return WikiaPageType::isCorporatePage() && Wikia::isMainPage() && !F::app()->wg->User->isAnon(); }
/** * Determines whether we are on the corporate wiki * @see SearchControllerTest::testIsCorporateWiki */ protected function isCorporateWiki() { return WikiaPageType::isCorporatePage(); }
echo $body_ondblclick ? ' ondblclick="' . htmlspecialchars($body_ondblclick) . '"' : ''; ?> > <?php if ($displayAdminDashboardChromedArticle) { ?> <?php echo (string) $app->sendRequest('AdminDashboardSpecialPage', 'chromedArticleHeader', array('headerText' => $wg->Title->getText())); ?> <?php } ?> <div class="home-top-right-ads"> <?php if (!WikiaPageType::isCorporatePage() && !$wg->EnableVideoPageToolExt && WikiaPageType::isMainPage()) { echo $app->renderView('Ad', 'Index', ['slotName' => 'HOME_TOP_RIGHT_BOXAD', 'pageTypes' => ['homepage_logged', 'corporate', 'all_ads']]); } ?> </div> <?php if ($runNjord) { echo $app->renderView('Njord', 'Summary'); echo $app->renderView($headerModuleName, $headerModuleAction, $headerModuleParams); } ?> <?php // for InfoBox-Testing if ($wg->EnableInfoBoxTest) { echo $app->renderView('ArticleInfoBox', 'Index'); }