/**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
 public static function onResourceLoaderGetConfigVarsWithContext(&$vars, $context)
 {
     global $wgUseAjax;
     $skin = $context->getSkin();
     if ($skin == 'monobook' || $skin == 'uncyclopedia') {
         if (!empty($wgUseAjax)) {
             $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
         }
     }
     return true;
 }
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgResourceLoaderMaxQueryLength;
     // Pre-process information
     $separatorTransTable = $wgContLang->separatorTransformTable();
     $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
     $compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
     $digitTransTable = $wgContLang->digitTransformTable();
     $digitTransTable = $digitTransTable ? $digitTransTable : array();
     $compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
     $mainPage = Title::newMainPage();
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $wgContLang->getNamespaceIds(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength);
     if ($wgContLang->hasVariants()) {
         $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
     }
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
Esempio n. 4
0
 /**
  * Make a <script> tag containing global variables
  * @param array $data Associative array containing one element:
  *     skinname => the skin name
  * The odd calling convention is for backwards compatibility
  */
 static function makeGlobalVariablesScript($data)
 {
     global $wgScript, $wgStylePath, $wgUser;
     global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
     global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
     global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
     global $wgUseAjax, $wgAjaxWatch;
     global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
     global $wgRestrictionTypes, $wgLivePreview;
     global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
     $ns = $wgTitle->getNamespace();
     $nsname = isset($wgCanonicalNamespaceNames[$ns]) ? $wgCanonicalNamespaceNames[$ns] : $wgTitle->getNsText();
     $separatorTransTable = $wgContLang->separatorTransformTable();
     $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
     $compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
     $digitTransTable = $wgContLang->digitTransformTable();
     $digitTransTable = $digitTransTable ? $digitTransTable : array();
     $compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
     $vars = array('skin' => $data['skinname'], 'stylepath' => $wgStylePath, 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias($wgTitle->getDBkey()), 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText('action', 'view'), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(), 'wgUserGroups' => $wgUser->isAnon() ? NULL : $wgUser->getEffectiveGroups(), 'wgUserLanguage' => $wgLang->getCode(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, 'wgCurRevisionId' => isset($wgArticle) ? $wgArticle->getLatest() : 0, 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable);
     if ($wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption('disablesuggest', false)) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
         $vars['wgDBname'] = $wgDBname;
         $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($wgUser);
         $vars['wgMWSuggestMessages'] = array(wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
     }
     foreach ($wgRestrictionTypes as $type) {
         $vars['wgRestriction' . ucfirst($type)] = $wgTitle->getRestrictions($type);
     }
     if ($wgLivePreview && $wgUser->getOption('uselivepreview')) {
         $vars['wgLivepreviewMessageLoading'] = wfMsg('livepreview-loading');
         $vars['wgLivepreviewMessageReady'] = wfMsg('livepreview-ready');
         $vars['wgLivepreviewMessageFailed'] = wfMsg('livepreview-failed');
         $vars['wgLivepreviewMessageError'] = wfMsg('livepreview-error');
     }
     if ($wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn()) {
         $msgs = (object) array();
         foreach (array('watch', 'unwatch', 'watching', 'unwatching') as $msgName) {
             $msgs->{$msgName . 'Msg'} = wfMsg($msgName);
         }
         $vars['wgAjaxWatch'] = $msgs;
     }
     wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
     return self::makeVariablesScript($vars);
 }
Esempio n. 5
0
 /**
  * Make a <script> tag containing global variables
  * @param $skinName string Name of the skin
  * The odd calling convention is for backwards compatibility
  * @TODO @FIXME Make this not depend on $wgTitle!
  */
 static function makeGlobalVariablesScript($skinName)
 {
     if (is_array($skinName)) {
         # Weird back-compat stuff.
         $skinName = $skinName['skinname'];
     }
     global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension;
     global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
     global $wgOut, $wgArticle;
     global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
     global $wgUseAjax, $wgAjaxWatch;
     global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
     global $wgRestrictionTypes;
     global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
     global $wgSitename;
     $ns = $wgTitle->getNamespace();
     $nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $wgTitle->getNsText();
     $separatorTransTable = $wgContLang->separatorTransformTable();
     $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
     $compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
     $digitTransTable = $wgContLang->digitTransformTable();
     $digitTransTable = $digitTransTable ? $digitTransTable : array();
     $compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
     $mainPage = Title::newFromText(wfMsgForContent('mainpage'));
     $vars = array('skin' => $skinName, 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ? SpecialPage::resolveAlias($wgTitle->getDBkey()) : false, 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText('action', 'view'), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(), 'wgUserGroups' => $wgUser->isAnon() ? null : $wgUser->getEffectiveGroups(), 'wgUserLanguage' => $wgLang->getCode(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, 'wgCurRevisionId' => isset($wgArticle) ? $wgArticle->getLatest() : 0, 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $wgContLang->getNamespaceIds(), 'wgSiteName' => $wgSitename, 'wgCategories' => $wgOut->getCategories());
     if ($wgContLang->hasVariants()) {
         $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
     }
     // if on upload page output the extension list & js_upload
     if (SpecialPage::resolveAlias($wgTitle->getDBkey()) == 'Upload') {
         global $wgFileExtensions, $wgAjaxUploadInterface;
         $vars['wgFileExtensions'] = $wgFileExtensions;
     }
     if ($wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption('disablesuggest', false)) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
         $vars['wgDBname'] = $wgDBname;
         $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($wgUser);
         $vars['wgMWSuggestMessages'] = array(wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
     }
     foreach ($wgRestrictionTypes as $type) {
         $vars['wgRestriction' . ucfirst($type)] = $wgTitle->getRestrictions($type);
     }
     if ($wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn()) {
         $msgs = (object) array();
         foreach (array('watch', 'unwatch', 'watching', 'unwatching', 'tooltip-ca-watch', 'tooltip-ca-unwatch') as $msgName) {
             $msgs->{$msgName . 'Msg'} = wfMsg($msgName);
         }
         $vars['wgAjaxWatch'] = $msgs;
     }
     // Allow extensions to add their custom variables to the global JS variables
     wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
     return self::makeVariablesScript($vars);
 }