本文整理汇总了PHP中MWNamespace::isCapitalized方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::isCapitalized方法的具体用法?PHP MWNamespace::isCapitalized怎么用?PHP MWNamespace::isCapitalized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::isCapitalized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfigSettings
/**
* @param ResourceLoaderContext $context
* @return array
*/
protected function getConfigSettings($context)
{
$hash = $context->getHash();
if (isset($this->configVars[$hash])) {
return $this->configVars[$hash];
}
global $wgContLang;
$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;
}
}
$conf = $this->getConfig();
// Build list of variables
$vars = array('wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => '.php', 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgExtraSignatureNamespaces' => $conf->get('ExtraSignatureNamespaces'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get('ForeignUploadTargets'), 'wgEnableUploads' => $conf->get('EnableUploads'));
Hooks::run('ResourceLoaderGetConfigVars', array(&$vars));
$this->configVars[$hash] = $vars;
return $this->configVars[$hash];
}
示例2: getConfig
/**
* @param ResourceLoaderContext $context
* @return array
*/
protected function getConfig($context)
{
$hash = $context->getHash();
if (isset($this->configVars[$hash])) {
return $this->configVars[$hash];
}
global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion, $wgSearchType;
$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, 'wgSearchType' => $wgSearchType, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values(array_unique($wgFileExtensions)), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion, 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled);
wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
$this->configVars[$hash] = $vars;
return $this->configVars[$hash];
}
示例3: getConfig
/**
* @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;
}
示例4: titleString
public static function titleString( $title ) {
$namespace = $title->getNsText();
if ( $namespace != '' ) {
$namespace .= ':';
}
if ( MWNamespace::isCapitalized( $title->getNamespace() ) ) {
global $wgContLang;
return $namespace . $wgContLang->ucfirst( $title->getText() );
} else {
return $namespace . $title->getText();
}
}
示例5: execute
public function execute()
{
$this->user = User::newSystemUser('Conversion script', ['steal' => true]);
$this->namespace = intval($this->getOption('namespace', 0));
if (MWNamespace::isCapitalized($this->namespace)) {
$this->output("Will be moving pages to first letter capitalized titles");
$callback = 'processRowToUppercase';
} else {
$this->output("Will be moving pages to first letter lowercase titles");
$callback = 'processRowToLowercase';
}
$this->dryrun = $this->hasOption('dry-run');
$this->runTable(['table' => 'page', 'conds' => ['page_namespace' => $this->namespace], 'index' => 'page_id', 'callback' => $callback]);
}
示例6: register
function register()
{
global $wgContLang, $wgNamespaceAliases, $wgNonincludableNamespaces;
$lib = array('loadSiteStats' => array($this, 'loadSiteStats'), 'getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'));
$info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion());
if (!self::$namespacesCache) {
$namespaces = array();
$namespacesByName = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$canonical = MWNamespace::getCanonicalName($ns);
$namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !($wgNonincludableNamespaces && in_array($ns, $wgNonincludableNamespaces)), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'aliases' => array());
if ($ns >= NS_MAIN) {
$namespaces[$ns]['subject'] = MWNamespace::getSubject($ns);
$namespaces[$ns]['talk'] = MWNamespace::getTalk($ns);
$namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns);
} else {
$namespaces[$ns]['subject'] = $ns;
}
$namespacesByName[strtr($title, ' ', '_')] = $ns;
if ($canonical) {
$namespacesByName[$canonical] = $ns;
}
}
$aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases());
foreach ($aliases as $title => $ns) {
if (!isset($namespacesByName[$title])) {
$ct = count($namespaces[$ns]['aliases']);
$namespaces[$ns]['aliases'][$ct + 1] = $title;
$namespacesByName[$title] = $ns;
}
}
$namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->text();
self::$namespacesCache = $namespaces;
}
$info['namespaces'] = self::$namespacesCache;
if (self::$siteStatsLoaded) {
$stats = $this->loadSiteStats();
$info['stats'] = $stats[0];
}
$this->getEngine()->registerInterface('mw.site.lua', $lib, $info);
}
示例7: register
function register()
{
global $wgContLang, $wgNamespaceAliases, $wgDisableCounters;
$lib = array('getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'), 'interwikiMap' => array($this, 'interwikiMap'));
$info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion());
if (!self::$namespacesCache || self::$namespacesCacheLang !== $wgContLang->getCode()) {
$namespaces = array();
$namespacesByName = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$canonical = MWNamespace::getCanonicalName($ns);
$namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !MWNamespace::isNonincludable($ns), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'defaultContentModel' => MWNamespace::getNamespaceContentModel($ns), 'aliases' => array());
if ($ns >= NS_MAIN) {
$namespaces[$ns]['subject'] = MWNamespace::getSubject($ns);
$namespaces[$ns]['talk'] = MWNamespace::getTalk($ns);
$namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns);
} else {
$namespaces[$ns]['subject'] = $ns;
}
$namespacesByName[strtr($title, ' ', '_')] = $ns;
if ($canonical) {
$namespacesByName[$canonical] = $ns;
}
}
$aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases());
foreach ($aliases as $title => $ns) {
if (!isset($namespacesByName[$title]) && isset($namespaces[$ns])) {
$ct = count($namespaces[$ns]['aliases']);
$namespaces[$ns]['aliases'][$ct + 1] = $title;
$namespacesByName[$title] = $ns;
}
}
$namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->inContentLanguage()->text();
self::$namespacesCache = $namespaces;
self::$namespacesCacheLang = $wgContLang->getCode();
}
$info['namespaces'] = self::$namespacesCache;
$info['stats'] = array('pages' => (int) SiteStats::pages(), 'articles' => (int) SiteStats::articles(), 'files' => (int) SiteStats::images(), 'edits' => (int) SiteStats::edits(), 'views' => $wgDisableCounters ? null : (int) SiteStats::views(), 'users' => (int) SiteStats::users(), 'activeUsers' => (int) SiteStats::activeUsers(), 'admins' => (int) SiteStats::numberingroup('sysop'));
return $this->getEngine()->registerInterface('mw.site.lua', $lib, $info);
}
示例8: addUploadJS
/**
* Add upload JS to the OutputPage
*/
protected function addUploadJS()
{
$config = $this->getConfig();
$useAjaxDestCheck = $config->get('UseAjax') && $config->get('AjaxUploadDestCheck');
$useAjaxLicensePreview = $config->get('UseAjax') && $config->get('AjaxLicensePreview') && $config->get('EnableAPI');
$this->mMaxUploadSize['*'] = UploadBase::getMaxUploadSize();
$scriptVars = array('wgAjaxUploadDestCheck' => $useAjaxDestCheck, 'wgAjaxLicensePreview' => $useAjaxLicensePreview, 'wgUploadAutoFill' => !$this->mForReUpload && $this->mDestFile === '', 'wgUploadSourceIds' => $this->mSourceIds, 'wgCheckFileExtensions' => $config->get('CheckFileExtensions'), 'wgStrictFileExtensions' => $config->get('StrictFileExtensions'), 'wgFileExtensions' => array_values(array_unique($config->get('FileExtensions'))), 'wgCapitalizeUploads' => MWNamespace::isCapitalized(NS_FILE), 'wgMaxUploadSize' => $this->mMaxUploadSize, 'wgFileCanRotate' => SpecialUpload::rotationEnabled());
$out = $this->getOutput();
$out->addJsConfigVars($scriptVars);
$out->addModules(array('mediawiki.action.edit', 'mediawiki.special.upload'));
}
示例9: addUploadJS
/**
* Add upload JS to the OutputPage
*/
protected function addUploadJS()
{
global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI, $wgStrictFileExtensions;
$useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
$useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
$this->mMaxUploadSize['*'] = UploadBase::getMaxUploadSize();
$scriptVars = array('wgAjaxUploadDestCheck' => $useAjaxDestCheck, 'wgAjaxLicensePreview' => $useAjaxLicensePreview, 'wgUploadAutoFill' => !$this->mForReUpload && $this->mDestFile === '', 'wgUploadSourceIds' => $this->mSourceIds, 'wgStrictFileExtensions' => $wgStrictFileExtensions, 'wgCapitalizeUploads' => MWNamespace::isCapitalized(NS_FILE), 'wgMaxUploadSize' => $this->mMaxUploadSize);
$out = $this->getOutput();
$out->addJsConfigVars($scriptVars);
$out->addModules(array('mediawiki.action.edit', 'mediawiki.legacy.upload', 'mediawiki.special.upload'));
}
示例10: getNameFromTitle
/**
* Get the name of an image from its title object
*
* @param $title Title
*/
public function getNameFromTitle(Title $title)
{
global $wgContLang;
if ($this->initialCapital != MWNamespace::isCapitalized(NS_FILE)) {
$name = $title->getUserCaseDBKey();
if ($this->initialCapital) {
$name = $wgContLang->ucfirst($name);
}
} else {
$name = $title->getDBkey();
}
return $name;
}
示例11: testIsCapitalizedHardcodedAssertions
/**
* Some namespaces are always capitalized per code definition
* in MWNamespace::$alwaysCapitalizedNamespaces
*/
public function testIsCapitalizedHardcodedAssertions()
{
// NS_MEDIA and NS_FILE are treated the same
$this->assertEquals(MWNamespace::isCapitalized(NS_MEDIA), MWNamespace::isCapitalized(NS_FILE), 'NS_MEDIA and NS_FILE have same capitalization rendering');
// Boths are capitalized by default
$this->assertIsCapitalized(NS_MEDIA);
$this->assertIsCapitalized(NS_FILE);
// Always capitalized namespaces
// @see MWNamespace::$alwaysCapitalizedNamespaces
$this->assertIsCapitalized(NS_SPECIAL);
$this->assertIsCapitalized(NS_USER);
$this->assertIsCapitalized(NS_MEDIAWIKI);
}
示例12: appendNamespaces
protected function appendNamespaces($property)
{
global $wgContLang;
$data = array(ApiResult::META_TYPE => 'assoc');
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$data[$ns] = array('id' => intval($ns), 'case' => MWNamespace::isCapitalized($ns) ? 'first-letter' : 'case-sensitive');
ApiResult::setContentValue($data[$ns], 'name', $title);
$canonical = MWNamespace::getCanonicalName($ns);
$data[$ns]['subpages'] = MWNamespace::hasSubpages($ns);
if ($canonical) {
$data[$ns]['canonical'] = strtr($canonical, '_', ' ');
}
$data[$ns]['content'] = MWNamespace::isContent($ns);
$data[$ns]['nonincludable'] = MWNamespace::isNonincludable($ns);
$contentmodel = MWNamespace::getNamespaceContentModel($ns);
if ($contentmodel) {
$data[$ns]['defaultcontentmodel'] = $contentmodel;
}
}
ApiResult::setIndexedTagName($data, 'ns');
return $this->getResult()->addValue('query', $property, $data);
}
示例13: capitalize
/**
* Capitalize a text string for a title if it belongs to a namespace that capitalizes
*
* @param string $text Containing title to capitalize
* @param int $ns Namespace index, defaults to NS_MAIN
* @return string Containing capitalized title
*/
public static function capitalize($text, $ns = NS_MAIN)
{
global $wgContLang;
if (MWNamespace::isCapitalized($ns)) {
return $wgContLang->ucfirst($text);
} else {
return $text;
}
}
示例14: testIsCapitalizedWithWgCapitalLinkOverrides
/**
* Counter part for MWNamespace::testIsCapitalizedWithWgCapitalLinks() now
* testing the $wgCapitalLinkOverrides global.
*
* @todo split groups of assertions in autonomous testing functions
*/
public function testIsCapitalizedWithWgCapitalLinkOverrides()
{
global $wgCapitalLinkOverrides;
// Save the global to easily reset to MediaWiki default settings
$savedGlobal = $wgCapitalLinkOverrides;
// Test default settings
$this->assertTrue(MWNamespace::isCapitalized(NS_PROJECT));
$this->assertTrue(MWNamespace::isCapitalized(NS_PROJECT_TALK));
// hardcoded namespaces (see above function) are capitalized:
$this->assertTrue(MWNamespace::isCapitalized(NS_SPECIAL));
$this->assertTrue(MWNamespace::isCapitalized(NS_USER));
$this->assertTrue(MWNamespace::isCapitalized(NS_MEDIAWIKI));
// Hardcoded namespaces remains capitalized
$wgCapitalLinkOverrides[NS_SPECIAL] = false;
$wgCapitalLinkOverrides[NS_USER] = false;
$wgCapitalLinkOverrides[NS_MEDIAWIKI] = false;
$this->assertTrue(MWNamespace::isCapitalized(NS_SPECIAL));
$this->assertTrue(MWNamespace::isCapitalized(NS_USER));
$this->assertTrue(MWNamespace::isCapitalized(NS_MEDIAWIKI));
$wgCapitalLinkOverrides = $savedGlobal;
$wgCapitalLinkOverrides[NS_PROJECT] = false;
$this->assertFalse(MWNamespace::isCapitalized(NS_PROJECT));
$wgCapitalLinkOverrides[NS_PROJECT] = true;
$this->assertTrue(MWNamespace::isCapitalized(NS_PROJECT));
unset($wgCapitalLinkOverrides[NS_PROJECT]);
$this->assertTrue(MWNamespace::isCapitalized(NS_PROJECT));
// reset global state:
$wgCapitalLinkOverrides = $savedGlobal;
}
示例15: getConfig
/**
* @param $context ResourceLoaderContext
* @return array
*/
protected function getConfig( $context ) {
global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
$wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
$wgVariantArticlePath, $wgActionPaths, $wgVersion,
$wgEnableAPI, $wgEnableWriteAPI, $wgDBname,
$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,
// Force object to avoid "empty" associative array from
// becoming [] instead of {} in JS (bug 34604)
'wgActionPaths' => (object)$wgActionPaths,
'wgServer' => $wgServer,
'wgUserLanguage' => $context->getLanguage(),
'wgContentLanguage' => $wgContLang->getCode(),
'wgVersion' => $wgVersion,
'wgEnableAPI' => $wgEnableAPI,
'wgEnableWriteAPI' => $wgEnableWriteAPI,
'wgMainPageTitle' => $mainPage->getPrefixedText(),
'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
'wgNamespaceIds' => $namespaceIds,
'wgSiteName' => $wgSitename,
'wgFileExtensions' => array_values( array_unique( $wgFileExtensions ) ),
'wgDBname' => $wgDBname,
// This sucks, it is only needed on Special:Upload, but I could
// not find a way to add vars only for a certain module
'wgFileCanRotate' => BitmapHandler::canRotate(),
'wgAvailableSkins' => Skin::getSkinNames(),
'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
// MediaWiki sets cookies to have this prefix by default
'wgCookiePrefix' => $wgCookiePrefix,
'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
);
wfRunHooks( 'ResourceLoaderGetConfigVars', array( &$vars ) );
return $vars;
}