/** * 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; }
/** * @param WikiaApp $app * @param WikiaResponse $response * @param string $className Full class name (with Controller/Service suffix) * @param string $methodName Base method name from requeset * @return mixed $callStack if post-controller routing is involved, otherwise false */ protected function applyRouting(WikiaApp $app, WikiaResponse $response, $className, $methodName) { // Starting with requested or default method name which is passed in by dispatch $response->setControllerName($className); $response->setMethodName($methodName); $callNext = array(); // Check to see if we have a defined route for this controller to another controller if (isset($this->routes[$className]["*"])) { $route = $this->routes[$className]["*"]; } else { if (isset($this->routes[$className][$methodName])) { $route = $this->routes[$className][$methodName]; } else { return false; } } // skin routing, also allows possibility to override template if (isset($route['notSkin']) && !$app->checkSkin($route['notSkin']) || isset($route['skin']) && $app->checkSkin($route['skin'])) { if (isset($route['controller'])) { $response->setControllerName($route['controller']); } if (isset($route['method'])) { $response->setMethodName($route['method']); } if (isset($route['template'])) { $response->getView()->setTemplate($className, $route['template']); } if (isset($route['after'])) { $callNext = $route['after']; } } // global var routing should probably only be for controllers and methods if (isset($route['global']) && isset($app->wg->{$route}['global'])) { if (isset($route['controller'])) { $response->setControllerName($route['controller']); } if (isset($route['method'])) { $response->setMethodName($route['method']); } if (isset($route['after'])) { $callNext = $route['after']; } } return $callNext; }
/** * @param WikiaApp $app * @param SpecialCssModel $model * @param integer $articleId * * @return boolean */ private static function shouldRedirect($app, $model, $title) { $result = false; // currently special:css cannot handle undo mode if ($app->wg->Request->getInt('undo') > 0 || $app->wg->Request->getInt('undoafter') > 0) { return $result; } if ($app->wg->EnableSpecialCssExt) { $specialCss = new SpecialCssController(); /** @noinspection PhpUndefinedVariableInspection * SpecialCssModel::$suppoertedSkins is defined -- lint has issues with it */ $result = $model->isWikiaCssTitle($title) && $app->checkSkin($model::$supportedSkins) && $specialCss->userCanExecute($app->wg->User); } return $result; }