本文整理匯總了PHP中MWNamespace::getCanonicalNamespaces方法的典型用法代碼示例。如果您正苦於以下問題:PHP MWNamespace::getCanonicalNamespaces方法的具體用法?PHP MWNamespace::getCanonicalNamespaces怎麽用?PHP MWNamespace::getCanonicalNamespaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::getCanonicalNamespaces方法的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: tearDown
public function tearDown()
{
global $wgContLang;
// Reset namespace cache
MWNamespace::getCanonicalNamespaces(true);
$wgContLang->resetNamespaces();
parent::tearDown();
}
示例5: checkAll
/**
* @todo Document
* @param $fix Boolean: whether or not to fix broken entries
* @param $suffix String: suffix to append to renamed articles
*
* @return bool
*/
private function checkAll($fix, $suffix = '')
{
global $wgContLang, $wgNamespaceAliases, $wgCapitalLinks;
$spaces = array();
// List interwikis first, so they'll be overridden
// by any conflicting local namespaces.
foreach ($this->getInterwikiList() as $prefix) {
$name = $wgContLang->ucfirst($prefix);
$spaces[$name] = 0;
}
// Now pull in all canonical and alias namespaces...
foreach (MWNamespace::getCanonicalNamespaces() as $ns => $name) {
// This includes $wgExtraNamespaces
if ($name !== '') {
$spaces[$name] = $ns;
}
}
foreach ($wgContLang->getNamespaces() as $ns => $name) {
if ($name !== '') {
$spaces[$name] = $ns;
}
}
foreach ($wgNamespaceAliases as $name => $ns) {
$spaces[$name] = $ns;
}
foreach ($wgContLang->getNamespaceAliases() as $name => $ns) {
$spaces[$name] = $ns;
}
// We'll need to check for lowercase keys as well,
// since we're doing case-sensitive searches in the db.
foreach ($spaces as $name => $ns) {
$moreNames = array();
$moreNames[] = $wgContLang->uc($name);
$moreNames[] = $wgContLang->ucfirst($wgContLang->lc($name));
$moreNames[] = $wgContLang->ucwords($name);
$moreNames[] = $wgContLang->ucwords($wgContLang->lc($name));
$moreNames[] = $wgContLang->ucwordbreaks($name);
$moreNames[] = $wgContLang->ucwordbreaks($wgContLang->lc($name));
if (!$wgCapitalLinks) {
foreach ($moreNames as $altName) {
$moreNames[] = $wgContLang->lcfirst($altName);
}
$moreNames[] = $wgContLang->lcfirst($name);
}
foreach (array_unique($moreNames) as $altName) {
if ($altName !== $name) {
$spaces[$altName] = $ns;
}
}
}
ksort($spaces);
asort($spaces);
$ok = true;
foreach ($spaces as $name => $ns) {
$ok = $this->checkNamespace($ns, $name, $fix, $suffix) && $ok;
}
return $ok;
}
示例6: tearDown
function tearDown()
{
global $wgContLang;
MWNamespace::getCanonicalNamespaces(true);
# reset namespace cache
$wgContLang->resetNamespaces();
# reset namespace cache
parent::tearDown();
}
示例7: tearDown
protected function tearDown()
{
global $wgContLang;
// Reset namespace cache
MWNamespace::getCanonicalNamespaces(true);
$wgContLang->resetNamespaces();
// And LinkCache
MediaWikiServices::getInstance()->resetServiceForTesting('LinkCache');
parent::tearDown();
}
示例8: tearDown
protected function tearDown()
{
global $wgContLang;
// Reset namespace cache
MWNamespace::getCanonicalNamespaces(true);
$wgContLang->resetNamespaces();
// And LinkCache
LinkCache::destroySingleton();
parent::tearDown();
}
示例9: iaclfCanonicalNsText
function iaclfCanonicalNsText($index)
{
static $ns;
if (!$ns) {
$ns = MWNamespace::getCanonicalNamespaces();
foreach ($ns as &$v) {
$v = str_replace('_', ' ', $v);
}
$ns[0] = 'Main';
}
return isset($ns[$index]) ? $ns[$index] : NULL;
}
示例10: teardown
public function teardown()
{
global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
unset($wgExtraNamespaces[12312]);
unset($wgExtraNamespaces[12313]);
unset($wgNamespaceContentModels[12312]);
unset($wgContentHandlers["testing"]);
MWNamespace::getCanonicalNamespaces(true);
# reset namespace cache
$wgContLang->resetNamespaces();
# reset namespace cache
parent::teardown();
}
示例11: tearDown
protected function tearDown()
{
global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
parent::tearDown();
unset($wgExtraNamespaces[12312]);
unset($wgExtraNamespaces[12313]);
unset($wgNamespaceContentModels[12312]);
unset($wgContentHandlers['DUMMY']);
MWNamespace::getCanonicalNamespaces(true);
# reset namespace cache
$wgContLang->resetNamespaces();
# reset namespace cache
}
示例12: setUp
protected function setUp()
{
global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
parent::setUp();
$this->setMwGlobals(['wgExtraNamespaces' => $wgExtraNamespaces, 'wgNamespaceContentModels' => $wgNamespaceContentModels, 'wgContentHandlers' => $wgContentHandlers, 'wgContLang' => $wgContLang]);
$wgExtraNamespaces[12312] = 'Dummy';
$wgExtraNamespaces[12313] = 'Dummy_talk';
$wgNamespaceContentModels[12312] = "testing";
$wgContentHandlers["testing"] = 'DummyContentHandlerForTesting';
MWNamespace::getCanonicalNamespaces(true);
# reset namespace cache
$wgContLang->resetNamespaces();
# reset namespace cache
}
示例13: setUp
protected function setUp()
{
parent::setUp();
if (!$this->isWikitextNS(NS_MAIN)) {
$this->markTestSkipped('Main namespace does not support wikitext.');
}
// Avoid special pages from extensions interferring with the tests
$this->setMwGlobals(['wgSpecialPages' => [], 'wgHooks' => [], 'wgExtraNamespaces' => [self::NS_NONCAP => 'NonCap'], 'wgCapitalLinkOverrides' => [self::NS_NONCAP => false]]);
$this->originalHandlers = TestingAccessWrapper::newFromClass('Hooks')->handlers;
TestingAccessWrapper::newFromClass('Hooks')->handlers = [];
// Clear caches so that our new namespace appears
MWNamespace::getCanonicalNamespaces(true);
Language::factory('en')->resetNamespaces();
SpecialPageFactory::resetList();
}
示例14: onBeforePageDisplay
/**
* @param OutputPage $oOut
* @param Skin $oSkin
* @return boolean
*/
public function onBeforePageDisplay(&$oOut, &$oSkin)
{
$oTitle = $oSkin->getTitle();
$aNamespaces = MWNamespace::getCanonicalNamespaces();
$iCurrentNs = $oTitle->getNamespace();
if ($oTitle->isTalkPage()) {
$iCurrentNs--;
}
if (!isset($aNamespaces[$iCurrentNs])) {
return true;
}
$oStyleSheetTitle = Title::newFromText($aNamespaces[$iCurrentNs] . '_css', NS_MEDIAWIKI);
if ($oStyleSheetTitle->exists()) {
$oOut->addStyle($oStyleSheetTitle->getLocalUrl(array('action' => 'raw', 'ctype' => 'text/css')));
}
return true;
}
示例15: getNamespaceName
public static function getNamespaceName($title)
{
$page_ns = MWNamespace::getCanonicalNamespaces();
$page_ns = $page_ns[$title->getNamespace()];
// NS text
if ($page_ns == "") {
$page_ns = "Main";
}
return $page_ns;
}