/** * @param array $vars JS variables to be added at the bottom of the page * @param OutputPage $out * @return bool return true - it's a hook */ function wfMakeGlobalVariablesScript(array &$vars, OutputPage $out) { wfProfileIn(__METHOD__); global $wgMemc, $wgEnableAjaxLogin, $wgPrivateTracker, $wgExtensionsPath, $wgArticle, $wgStyleVersion, $wgSitename, $wgDisableAnonymousEditing, $wgGroupPermissions, $wgBlankImgUrl, $wgCookieDomain, $wgCookiePath, $wgResourceBasePath; $skin = $out->getSkin(); $title = $out->getTitle(); // MW1.19 - ResourceLoaderStartUpModule class adds more variables $cats = wfGetBreadCrumb(); $idx = count($cats) - 2; if (isset($cats[$idx])) { $vars['wgCatId'] = $cats[$idx]['id']; $vars['wgParentCatId'] = $cats[$idx]['parentId']; } else { $vars['wgCatId'] = 0; $vars['wgParentCatId'] = 0; } $skinName = get_class($skin); if (is_array($wgEnableAjaxLogin) && in_array($skinName, $wgEnableAjaxLogin)) { $vars['wgEnableAjaxLogin'] = true; } $vars['wgBlankImgUrl'] = $wgBlankImgUrl; if (!empty($wgPrivateTracker)) { $vars['wgPrivateTracker'] = true; } // TODO: load it on-demand using JSMessages if ($vars['wgIsArticle'] == false && !empty($vars['wgEnableAjaxLogin'])) { $vars['ajaxLogin1'] = wfMsg('ajaxLogin1'); $vars['ajaxLogin2'] = wfMsg('ajaxLogin2'); } // TODO: use wgMainPageTitle instead? $vars['wgMainpage'] = wfMsgForContent('mainpage'); if (Wikia::isMainPage()) { $vars['wgIsMainpage'] = true; } if (Wikia::isContentNamespace()) { $vars['wgIsContentNamespace'] = true; } $vars['wgStyleVersion'] = isset($wgStyleVersion) ? $wgStyleVersion : ''; // TODO: is this one really needed? if (isset($skin->themename)) { $vars['themename'] = $skin->themename; } $vars['wgExtensionsPath'] = $wgExtensionsPath; $vars['wgResourceBasePath'] = $wgResourceBasePath; $vars['wgSitename'] = $wgSitename; // Set the JavaScript variable which is used by AJAX request to make data caching possible - Inez $vars['wgMWrevId'] = $wgMemc->get(wfMemcKey('wgMWrevId')); // macbre: get revision ID of current article if (($title->isContentPage() || $title->isTalkPage()) && !is_null($wgArticle)) { $vars['wgRevisionId'] = !empty($wgArticle->mRevision) ? $wgArticle->mRevision->getId() : intval($wgArticle->mLatest); } // is anon editing disabled? if ($wgDisableAnonymousEditing || $wgGroupPermissions['user']['edit'] === false) { $vars['wgDisableAnonymousEditing'] = true; } // moved from Interstitial.php $vars['wgCookieDomain'] = $wgCookieDomain; $vars['wgCookiePath'] = $wgCookiePath; wfProfileOut(__METHOD__); return true; }
/** * Checks if flags should be displayed on a page * @return bool */ public function shouldDisplayFlags() { global $wgTitle; return $wgTitle->exists() && \Wikia::isContentNamespace(); }
/** * MW1.19 - ResourceLoaderStartUpModule class adds more variables * @param array $vars JS variables to be added at the bottom of the page * @param OutputPage $out * @return bool return true - it's a hook */ function wfMakeGlobalVariablesScript(array &$vars, OutputPage $out) { wfProfileIn(__METHOD__); global $wgMemc, $wgPrivateTracker, $wgExtensionsPath, $wgArticle, $wgSitename, $wgDisableAnonymousEditing, $wgCityId, $wgGroupPermissions, $wgBlankImgUrl, $wgCookieDomain, $wgCookiePath, $wgResourceBasePath; $skin = $out->getSkin(); $title = $out->getTitle(); // FIXME: This needs to be converted to getVerticalId when the data is available (PLATFORM-267) $hubService = WikiFactoryHub::getInstance(); $catId = $hubService->getCategoryId($wgCityId); if (isset($catId)) { $vars['wgCatId'] = $catId; } else { $vars['wgCatId'] = 0; } $vars['wgBlankImgUrl'] = $wgBlankImgUrl; if (!empty($wgPrivateTracker)) { $vars['wgPrivateTracker'] = true; } // TODO: use wgMainPageTitle instead? $vars['wgMainpage'] = wfMsgForContent('mainpage'); if (Wikia::isMainPage()) { $vars['wgIsMainpage'] = true; } if (Wikia::isContentNamespace()) { $vars['wgIsContentNamespace'] = true; } // TODO: is this one really needed? if (isset($skin->themename)) { $vars['themename'] = $skin->themename; } $vars['wgExtensionsPath'] = $wgExtensionsPath; $vars['wgResourceBasePath'] = $wgResourceBasePath; $vars['wgSitename'] = $wgSitename; // Set the JavaScript variable which is used by AJAX request to make data caching possible - Inez $vars['wgMWrevId'] = $wgMemc->get(wfMemcKey('wgMWrevId')); // macbre: get revision ID of current article if (($title->isContentPage() || $title->isTalkPage()) && !is_null($wgArticle)) { $vars['wgRevisionId'] = !empty($wgArticle->mRevision) ? $wgArticle->mRevision->getId() : intval($wgArticle->mLatest); } // is anon editing disabled? if ($wgDisableAnonymousEditing || $wgGroupPermissions['user']['edit'] === false) { $vars['wgDisableAnonymousEditing'] = true; } // moved from Interstitial.php $vars['wgCookieDomain'] = $wgCookieDomain; $vars['wgCookiePath'] = $wgCookiePath; wfProfileOut(__METHOD__); return true; }