本文整理汇总了PHP中MWNamespace::getContentNamespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::getContentNamespaces方法的具体用法?PHP MWNamespace::getContentNamespaces怎么用?PHP MWNamespace::getContentNamespaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::getContentNamespaces方法的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: getQueryInfo
function getQueryInfo()
{
$dbr = wfGetDB(DB_SLAVE);
$dMsgText = wfMsgForContent('disambiguationspage');
$linkBatch = new LinkBatch();
# If the text can be treated as a title, use it verbatim.
# Otherwise, pull the titles from the links table
$dp = Title::newFromText($dMsgText);
if ($dp) {
if ($dp->getNamespace() != NS_TEMPLATE) {
# @todo FIXME: We assume the disambiguation message is a template but
# the page can potentially be from another namespace :/
wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
}
$linkBatch->addObj($dp);
} else {
# Get all the templates linked from the Mediawiki:Disambiguationspage
$disPageObj = Title::makeTitleSafe(NS_MEDIAWIKI, 'disambiguationspage');
$res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), __METHOD__);
foreach ($res as $row) {
$linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
}
}
$set = $linkBatch->constructSet('tl', $dbr);
if ($set === false) {
# We must always return a valid SQL query, but this way
# the DB will always quickly return an empty result
$set = 'FALSE';
wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
}
// @todo FIXME: What are pagelinks and p2 doing here?
return array('tables' => array('templatelinks', 'p1' => 'page', 'pagelinks', 'p2' => 'page'), 'fields' => array('p1.page_namespace AS namespace', 'p1.page_title AS title', 'pl_from AS value'), 'conds' => array($set, 'p1.page_id = tl_from', 'pl_namespace = p1.page_namespace', 'pl_title = p1.page_title', 'p2.page_id = pl_from', 'p2.page_namespace' => MWNamespace::getContentNamespaces()));
}
示例4: getOrderFields
function getOrderFields()
{
// For some crazy reason ordering by a constant
// causes a filesort
if ($this->requestedNamespace === false && count(MWNamespace::getContentNamespaces()) > 1) {
return array('page_namespace', 'page_title');
}
return array('page_title');
}
示例5: getQueryInfo
function getQueryInfo()
{
$query = array('tables' => array('page', 'langlinks'), 'fields' => array('namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_title'), 'conds' => array('ll_title IS NULL', 'page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0), 'join_conds' => array('langlinks' => array('LEFT JOIN', 'll_from = page_id')));
if ($this->prefix) {
$dbr = wfGetDB(DB_SLAVE);
$query['conds'][] = 'page_title ' . $dbr->buildLike($this->prefix, $dbr->anyString());
}
return $query;
}
示例6: getOrderFields
function getOrderFields()
{
// For some crazy reason ordering by a constant
// causes a filesort in MySQL 5
if (count(MWNamespace::getContentNamespaces()) > 1) {
return array('page_namespace', 'page_title');
} else {
return array('page_title');
}
}
示例7: getQueryInfo
public function getQueryInfo()
{
$tables = array('page');
$conds = array('page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0);
$joinConds = array();
$options = array('USE INDEX' => array('page' => 'page_redirect_namespace_len'));
// Allow extensions to modify the query
Hooks::run('ShortPagesQuery', array(&$tables, &$conds, &$joinConds, &$options));
return array('tables' => $tables, 'fields' => array('namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_len'), 'conds' => $conds, 'join_conds' => $joinConds, 'options' => $options);
}
示例8: getQueryInfo
public function getQueryInfo()
{
$tables = ['page'];
$conds = ['page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0];
$joinConds = [];
$options = ['USE INDEX' => ['page' => 'page_redirect_namespace_len']];
// Allow extensions to modify the query
Hooks::run('ShortPagesQuery', [&$tables, &$conds, &$joinConds, &$options]);
return ['tables' => $tables, 'fields' => ['namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_len'], 'conds' => $conds, 'join_conds' => $joinConds, 'options' => $options];
}
示例9: getQueryInfo
/**
* Note: Getting page_namespace only works if $this->isCached() is false
*/
function getQueryInfo()
{
return array('tables' => array('page', 'pagelinks'), 'fields' => array("'Withoutimages' as type", 'page_namespace as namespace', 'page_title as title', 'count(*) as value'), 'options' => array('GROUP BY' => 'page_title, page_namespace'), 'join_conds' => array('pagelinks' => array('JOIN', 'page_title = pl_title AND page_namespace = pl_namespace')), 'conds' => array('pl_from > 0', 'page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0, '(
(
SELECT i1.il_to
FROM imagelinks i1
WHERE 20 > ANY (
SELECT count(*)
FROM imagelinks i2
WHERE i1.il_to = i2.il_to
) AND i1.il_from = page_id
LIMIT 1
) IS NULL
)'));
}
示例10: getQueryInfo
function getQueryInfo()
{
return array('tables' => array('langlinks', 'page'), 'fields' => array('namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'COUNT(*)'), 'conds' => array('page_namespace' => MWNamespace::getContentNamespaces()), 'options' => array('HAVING' => 'COUNT(*) > 1', 'GROUP BY' => array('page_namespace', 'page_title')), 'join_conds' => array('page' => array('LEFT JOIN', 'page_id = ll_from')));
}
示例11: canUseNoindex
/**
* Whether the magic words __INDEX__ and __NOINDEX__ function for this page.
*
* @return bool
*/
public function canUseNoindex()
{
global $wgExemptFromUserRobotsControl;
$bannedNamespaces = is_null($wgExemptFromUserRobotsControl) ? MWNamespace::getContentNamespaces() : $wgExemptFromUserRobotsControl;
return !in_array($this->mNamespace, $bannedNamespaces);
}
示例12: testGetContentNamespaces
/**
* @covers MWNamespace::getContentNamespaces
*/
public function testGetContentNamespaces()
{
global $wgContentNamespaces;
$this->assertEquals(array(NS_MAIN), MWNamespace::getContentNamespaces(), '$wgContentNamespaces is an array with only NS_MAIN by default');
# test !is_array( $wgcontentNamespaces )
$wgContentNamespaces = '';
$this->assertEquals(array(NS_MAIN), MWNamespace::getContentNamespaces());
$wgContentNamespaces = false;
$this->assertEquals(array(NS_MAIN), MWNamespace::getContentNamespaces());
$wgContentNamespaces = null;
$this->assertEquals(array(NS_MAIN), MWNamespace::getContentNamespaces());
$wgContentNamespaces = 5;
$this->assertEquals(array(NS_MAIN), MWNamespace::getContentNamespaces());
# test $wgContentNamespaces === array()
$wgContentNamespaces = array();
$this->assertEquals(array(NS_MAIN), MWNamespace::getContentNamespaces());
# test !in_array( NS_MAIN, $wgContentNamespaces )
$wgContentNamespaces = array(NS_USER, NS_CATEGORY);
$this->assertEquals(array(NS_MAIN, NS_USER, NS_CATEGORY), MWNamespace::getContentNamespaces(), 'NS_MAIN is forced in $wgContentNamespaces even if unwanted');
# test other cases, return $wgcontentNamespaces as is
$wgContentNamespaces = array(NS_MAIN);
$this->assertEquals(array(NS_MAIN), MWNamespace::getContentNamespaces());
$wgContentNamespaces = array(NS_MAIN, NS_USER, NS_CATEGORY);
$this->assertEquals(array(NS_MAIN, NS_USER, NS_CATEGORY), MWNamespace::getContentNamespaces());
}
示例13: articles
/**
* Count pages in article space(s)
* @return Integer
*/
public function articles()
{
global $wgArticleCountMethod;
$tables = array('page');
$conds = array('page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0);
if ($wgArticleCountMethod == 'link') {
$tables[] = 'pagelinks';
$conds[] = 'pl_from=page_id';
} elseif ($wgArticleCountMethod == 'comma') {
// To make a correct check for this, we would need, for each page,
// to load the text, maybe uncompress it, maybe decode it and then
// check if there's one comma.
// But one thing we are sure is that if the page is empty, it can't
// contain a comma :)
$conds[] = 'page_len > 0';
}
$this->mArticles = $this->db->selectField($tables, 'COUNT(DISTINCT page_id)', $conds, __METHOD__);
return $this->mArticles;
}
示例14: getQueryInfo
function getQueryInfo()
{
return array('tables' => array('page'), 'fields' => array('page_namespace AS namespace', 'page_title AS title', 'page_counter AS value'), 'conds' => array('page_is_redirect' => 0, 'page_namespace' => MWNamespace::getContentNamespaces()));
}
示例15: getQueryInfo
function getQueryInfo()
{
return array('tables' => array('page', 'revision'), 'fields' => array('namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'rev_timestamp'), 'conds' => array('page_namespace' => MWNamespace::getContentNamespaces(), 'page_is_redirect' => 0, 'page_latest=rev_id'));
}