/** * @author Inez Korczynski <*****@*****.**> */ public function initPage(&$out) { wfDebugLog('lyricsminimal', '##### SkinLyricsMinimal initPage #####'); wfProfileIn(__METHOD__); global $wgHooks, $wgCityId, $wgCat; SkinTemplate::initPage($out); $this->skinname = 'lyricsminimal'; $this->stylename = 'lyricsminimal'; $this->template = 'LyricsMinimalTemplate'; // Get category information (id, name, url) $cats = wfGetBreadCrumb(); $idx = count($cats)-2; if(isset($cats[$idx])) { $wgCat = $cats[$idx]; wfDebugLog('lyricsminimal', 'There is category info'); } else { $wgCat = array('id' => -1); wfDebugLog('lyricsminimal', 'No category info'); } // Function addVariables will be called to populate all needed data to render skin $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array(&$this, 'addVariables'); wfProfileOut(__METHOD__); }
/** * @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; }