本文整理匯總了PHP中MWNamespace::isContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP MWNamespace::isContent方法的具體用法?PHP MWNamespace::isContent怎麽用?PHP MWNamespace::isContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::isContent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: PlusoHeader
public static function PlusoHeader(&$article, &$outputDone, &$pcache)
{
global $wgOut, $wgPlusoUserID, $wgPlusoHeader, $wgPlusoMain, $wgPlusoBackgroundHeader, $wgPlusoThemeHeader, $wgPlusoServicesHeader;
# Check if page is in content namespace and the setting to enable/disable article header tooblar either on the main page or at all
if (!MWNamespace::isContent($article->getTitle()->getNamespace()) || !$wgPlusoHeader || $article->getTitle()->equals(Title::newMainPage()) && !$wgPlusoMain) {
return true;
}
/* Output Pluso header in <h1> */
$wgOut->addHTML('
<script type="text/javascript">
(function() {
if (window.pluso)if (typeof window.pluso.start == "function") return;
if (window.ifpluso==undefined) { window.ifpluso = 1;
var d = document, s = d.createElement("script"), g = "getElementsByTagName";
s.type = "text/javascript"; s.charset="UTF-8"; s.async = true;
s.src = ("https:" == window.location.protocol ? "https" : "http") + "://share.pluso.ru/pluso-like.js";
var h=d[g]("body")[0];
h.appendChild(s);
}
})();
jQuery(document).ready(function() {
var title = jQuery("#firstHeading").html();
jQuery("#firstHeading").html(title + \'<div data-user="' . $wgPlusoUserID . '" class="pluso" style="float: right;right: 10px;" data-background="' . $wgPlusoBackgroundHeader . '" data-options="medium,round,line,horizontal,counter,theme=' . $wgPlusoThemeHeader . '" data-services="' . $wgPlusoServicesHeader . '"></div>\');
});</script>');
return true;
}
示例2: viewHook
/**
* Article::view() hook
*
* @param Article $article
* @return bool
*/
public static function viewHook($article)
{
global $wgOut;
$title = $article->getTitle();
if (MWNamespace::isContent($title->getNamespace())) {
$wgOut->addHTML(self::buildLinks($title));
$wgOut->addHeadItem('backandforth', self::buildHeadItem());
}
return true;
}
示例3: 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);
}
示例4: 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);
}
示例5: AddThisHeader
/**
* Function for article header toolbar
*
* @param $article Article
* @param $outputDone
* @param $pcache
* @return bool|bool
*/
public static function AddThisHeader(&$article, &$outputDone, &$pcache)
{
global $wgOut, $wgAddThispubid, $wgAddThis, $wgAddThisHeader, $wgAddThisMain, $wgAddThisHServ, $wgAddThisBackground, $wgAddThisBorder;
# Check if page is in content namespace and the setting to enable/disable article header tooblar either on the main page or at all
if (!MWNamespace::isContent($article->getTitle()->getNamespace()) || !$wgAddThisHeader || $article->getTitle()->equals(Title::newMainPage()) && !$wgAddThisMain) {
return true;
}
# Localisation for "Share"
$share = wfMessage('addthis')->escaped();
# Output AddThis widget
$wgOut->addHTML('<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style" id="addthistoolbar" style="background:' . $wgAddThisBackground . '; border-color:' . $wgAddThisBorder . ';">
<a href="//www.addthis.com/bookmark.php?v=250&pubid=' . $wgAddThispubid . '" class="addthis_button_compact"> ' . $share . '</a><span class="addthis_separator"> </span>');
$wgOut->addHTML(self::makeLinks($wgAddThisHServ));
$wgOut->addHTML('</div>
<script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js#pubid=' . $wgAddThispubid . '"></script>');
# Output AddThis Address Bar Sharing script, if enabled
if ($wgAddThis['addressbarsharing']) {
$wgOut->addHTML('<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>');
}
return true;
}
示例6: isContentPage
/**
* Is this Title in a namespace which contains content?
* In other words, is this a content page, for the purposes of calculating
* statistics, etc?
*
* @return bool
*/
public function isContentPage()
{
return MWNamespace::isContent($this->getNamespace());
}
示例7: appendNamespaces
protected function appendNamespaces($property)
{
global $wgContLang;
$data = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$data[$ns] = array('id' => intval($ns), 'case' => MWNamespace::isCapitalized($ns) ? 'first-letter' : 'case-sensitive');
ApiResult::setContent($data[$ns], $title);
$canonical = MWNamespace::getCanonicalName($ns);
if (MWNamespace::hasSubpages($ns)) {
$data[$ns]['subpages'] = '';
}
if ($canonical) {
$data[$ns]['canonical'] = strtr($canonical, '_', ' ');
}
if (MWNamespace::isContent($ns)) {
$data[$ns]['content'] = '';
}
}
$this->getResult()->setIndexedTagName($data, 'ns');
return $this->getResult()->addValue('query', $property, $data);
}
示例8: 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);
}
示例9: replaceLinkHolders
/**
* Replace <!--LINK--> link placeholders with actual links, in the buffer
* Placeholders created in Skin::makeLinkObj()
* Returns an array of links found, indexed by PDBK:
* 0 - broken
* 1 - normal link
* 2 - stub
* $options is a bit field, RLH_FOR_UPDATE to select for update
*/
function replaceLinkHolders(&$text, $options = 0)
{
global $wgUser;
global $wgContLang;
$fname = 'Parser::replaceLinkHolders';
wfProfileIn($fname);
$pdbks = array();
$colours = array();
$sk = $this->mOptions->getSkin();
$linkCache = LinkCache::singleton();
if (!empty($this->mLinkHolders['namespaces'])) {
wfProfileIn($fname . '-check');
$dbr = wfGetDB(DB_SLAVE);
$page = $dbr->tableName('page');
$threshold = $wgUser->getOption('stubthreshold');
# Sort by namespace
asort($this->mLinkHolders['namespaces']);
# Generate query
$query = false;
$current = null;
foreach ($this->mLinkHolders['namespaces'] as $key => $ns) {
# Make title object
$title = $this->mLinkHolders['titles'][$key];
# Skip invalid entries.
# Result will be ugly, but prevents crash.
if (is_null($title)) {
continue;
}
$pdbk = $pdbks[$key] = $title->getPrefixedDBkey();
# Check if it's a static known link, e.g. interwiki
if ($title->isAlwaysKnown()) {
$colours[$pdbk] = 1;
} elseif (($id = $linkCache->getGoodLinkID($pdbk)) != 0) {
$colours[$pdbk] = 1;
$this->mOutput->addLink($title, $id);
} elseif ($linkCache->isBadLink($pdbk)) {
$colours[$pdbk] = 0;
} elseif ($title->getNamespace() == NS_SPECIAL && !SpecialPage::exists($pdbk)) {
$colours[$pdbk] = 0;
} else {
# Not in the link cache, add it to the query
if (!isset($current)) {
$current = $ns;
$query = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect";
$query .= " FROM {$page} WHERE (page_namespace={$ns} AND page_title IN(";
} elseif ($current != $ns) {
$current = $ns;
$query .= ")) OR (page_namespace={$ns} AND page_title IN(";
} else {
$query .= ', ';
}
$query .= $dbr->addQuotes($this->mLinkHolders['dbkeys'][$key]);
}
}
if ($query) {
$query .= '))';
if ($options & RLH_FOR_UPDATE) {
$query .= ' FOR UPDATE';
}
$res = $dbr->query($query, $fname);
# Fetch data and form into an associative array
# non-existent = broken
# 1 = known
# 2 = stub
while ($s = $dbr->fetchObject($res)) {
$title = Title::makeTitle($s->page_namespace, $s->page_title);
$pdbk = $title->getPrefixedDBkey();
$linkCache->addGoodLinkObj($s->page_id, $title, $s->page_len, $s->page_is_redirect);
$this->mOutput->addLink($title, $s->page_id);
$colours[$pdbk] = $threshold == 0 || ($s->page_len >= $threshold || $s->page_is_redirect || !MWNamespace::isContent($s->page_namespace)) ? 1 : 2;
}
}
wfProfileOut($fname . '-check');
# Do a second query for different language variants of links and categories
if ($wgContLang->hasVariants()) {
$linkBatch = new LinkBatch();
$variantMap = array();
// maps $pdbkey_Variant => $keys (of link holders)
$categoryMap = array();
// maps $category_variant => $category (dbkeys)
$varCategories = array();
// category replacements oldDBkey => newDBkey
$categories = $this->mOutput->getCategoryLinks();
// Add variants of links to link batch
foreach ($this->mLinkHolders['namespaces'] as $key => $ns) {
$title = $this->mLinkHolders['titles'][$key];
if (is_null($title)) {
continue;
}
$pdbk = $title->getPrefixedDBkey();
$titleText = $title->getText();
//.........這裏部分代碼省略.........
示例10: getLinkColour
/**
* Return the CSS colour of a known link
*
* @param mixed $s
* @param integer $threshold user defined threshold
* @return string CSS class
*/
function getLinkColour($s, $threshold)
{
if ($s === false) {
return '';
}
$colour = '';
if (!empty($s->page_is_redirect)) {
# Page is a redirect
$colour = 'mw-redirect';
} elseif ($threshold > 0 && $s->page_len < $threshold && MWNamespace::isContent($s->page_namespace)) {
# Page is a stub
$colour = 'stub';
}
return $colour;
}
示例11: getLinkColour
/**
* Return the CSS colour of a known link
*
* @param Title $t
* @param integer $threshold user defined threshold
* @return string CSS class
*/
function getLinkColour($t, $threshold)
{
$colour = '';
if ($t->isRedirect()) {
# Page is a redirect
$colour = 'mw-redirect';
} elseif ($threshold > 0 && $t->exists() && $t->getLength() < $threshold && MWNamespace::isContent($t->getNamespace())) {
# Page is a stub
$colour = 'stub';
}
return $colour;
}
示例12: TweetANewEditMade
/**
* Function for tweeting edited articles
*
* @param $article Article
* @param $user User
* @param $text string
* @param $summary string
* @param $minoredit bool
* @param $watchthis
* @param $sectionanchor
* @param $flags
* @param $revision
* @param $status
* @param $baseRevId
* @return bool
*/
public static function TweetANewEditMade( &$article, &$user, $text, $summary, $minoredit, $watchthis,
$sectionanchor, &$flags, $revision, &$status, $baseRevId ) {
global $wgTweetANewTweet, $wgTweetANewText, $wgRequest;
# Check if $wgTweetANewTweet['Edit'] is enabled or the Tweet checkbox was selected on the edit page
if ( $wgRequest->getCheck( 'wpTweetANewEdit' ) || $wgTweetANewTweet['Edit'] ) {
# Unless the tweet checkbox is selected, only proceeds if page is outside content namespace
# and if a minor edit, checks $wgTweetANewTweet['SkipMinor']
# Also prevents new articles from processing as TweetANewNewArticle function is used instead
if ( ( !MWNamespace::isContent( $article->getTitle()->getNamespace() )
|| ( $minoredit !== 0 && $wgTweetANewTweet['SkipMinor'] )
&& !$wgRequest->getCheck( 'wpTweetANewEdit' ) )
|| $article->estimateRevisionCount() == 1
) {
return true;
}
# Determine the time and date of last modification - exit if newer than $wgTweetANewTweet['LessMinutesOld']
# ToDo - there must be a cleaner way of doing this
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'revision',
array( 'rev_timestamp' ),
array( 'rev_page' => $article->getId() ),
__METHOD__,
array( 'ORDER BY' => 'rev_id DESC', 'LIMIT' => '2' )
);
$edittime = array();
foreach ( $res as $row ) {
$edittime[] = $row->rev_timestamp;
}
$edittimenow = mktime( substr( $edittime[0], 8, 2 ), substr( $edittime[0], 10, 2 ),
substr( $edittime[0], 12 ), substr( $edittime[0], 4, 2 ), substr( $edittime[0], 6, 2 ),
substr( $edittime[0], 0, 4 )
);
$edittimelast = mktime( substr( $edittime[1], 8, 2 ), substr( $edittime[1], 10, 2 ),
substr( $edittime[1], 12 ), substr( $edittime[1], 4, 2 ), substr( $edittime[1], 6, 2 ),
substr( $edittime[1], 0, 4 )
);
$edittimediv = $edittimenow - $edittimelast;
if ( $edittimediv < ( $wgTweetANewTweet['LessMinutesOld'] * 60 ) ) {
return true;
}
# Generate final url
$finalurl = self::makeFinalUrl(
$article->getTitle()->getFullURL()
);
# Generate $author based on $wgTweetANewText['RealName']
if ( $wgTweetANewText['RealName'] ) {
$author = $user->getRealName();
} else {
$author = $user->getName();
}
$tweet_text = '';
# Add prefix indication that edit is minor if enabled by $wgTweetANewText['Minor']
if ( $minoredit !== 0 && $wgTweetANewText['Minor'] ) {
$tweet_text = wfMsg( 'tweetanew-minoredit' );
# Add a space after the indicator if $wgTweetANewText['MinorSpace'] is true
if ( $minoredit !== 0 && $wgTweetANewText['MinorSpace'] ) {
$tweet_text .= ' ';
}
}
# Generate a random tweet texts based if $wgTweetANewText['EditRandom'] is true
if ( $wgTweetANewText['EditRandom'] ) {
# Setup switcher using max number set by $wgTweetANewText['EditRandomMax']
$switcher = rand( 1, $wgTweetANewText['EditRandomMax'] );
# Parse random text
$tweet_text .= wfMsg( 'tweetanew-edit' . $switcher,
array( $article->getTitle()->getText(), $finalurl )
);
} else {
# Use default tweet message format
$tweet_body = wfMsg( 'tweetanew-editdefault',
array( $article->getTitle()->getText(), $finalurl )
);
$tweet_text .= $tweet_body;
}
# Add author info if $wgTweetANewText['EditAuthor'] is true
if ( $wgTweetANewText['EditAuthor'] ) {
//.........這裏部分代碼省略.........
示例13: onLinksUpdateAfterInsert
/**
* Handler for LinksUpdateAfterInsert hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/LinksUpdateAfterInsert
* @param $linksUpdate LinksUpdate
* @param $table string
* @param $insertions array
* @return bool
*/
public static function onLinksUpdateAfterInsert($linksUpdate, $table, $insertions)
{
global $wgRequest, $wgUser;
// Rollback or undo should not trigger link notification
// @Todo Implement a better solution so it doesn't depend on the checking of
// a specific set of request variables
if ($wgRequest->getVal('wpUndidRevision') || $wgRequest->getVal('action') == 'rollback') {
return true;
}
// Handle only
// 1. inserts to pagelinks table &&
// 2. content namespace pages &&
// 3. non-transcluding pages &&
// 4. non-redirect pages
if ($table !== 'pagelinks' || !MWNamespace::isContent($linksUpdate->mTitle->getNamespace()) || !$linksUpdate->mRecursive || $linksUpdate->mTitle->isRedirect()) {
return true;
}
// link notification is boundless as you can include infinite number of links in a page
// db insert is expensive, limit it to a reasonable amount, we can increase this limit
// once the storage is on Redis
$max = 10;
// Only create notifications for links to content namespace pages
// @Todo - use one big insert instead of individual insert inside foreach loop
foreach ($insertions as $key => $page) {
if (MWNamespace::isContent($page['pl_namespace'])) {
$title = Title::makeTitle($page['pl_namespace'], $page['pl_title']);
if ($title->isRedirect()) {
continue;
}
EchoEvent::create(array('type' => 'page-linked', 'title' => $title, 'agent' => $wgUser, 'extra' => array('link-from-page-id' => $linksUpdate->mTitle->getArticleId())));
$max--;
}
if ($max < 0) {
break;
}
}
return true;
}
示例14: getLinkColour
/**
* Return the CSS colour of a known link
*
* @since 1.16.3
* @param LinkTarget $t
* @param int $threshold User defined threshold
* @return string CSS class
*/
public static function getLinkColour(LinkTarget $t, $threshold)
{
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
// Make sure the target is in the cache
$id = $linkCache->addLinkObj($t);
if ($id == 0) {
// Doesn't exist
return '';
}
if ($linkCache->getGoodLinkFieldObj($t, 'redirect')) {
# Page is a redirect
return 'mw-redirect';
} elseif ($threshold > 0 && MWNamespace::isContent($t->getNamespace()) && $linkCache->getGoodLinkFieldObj($t, 'length') < $threshold) {
# Page is a stub
return 'stub';
}
return '';
}
示例15: testIsContentWithAdditionsInWgContentNamespaces
/**
* Similar to testIsContent() but alters the $wgContentNamespaces
* global variable.
*/
public function testIsContentWithAdditionsInWgContentNamespaces()
{
// NS_MAIN is a content namespace per DefaultSettings.php
// and per function definition.
$this->assertTrue(MWNamespace::isContent(NS_MAIN));
// Tests that user defined namespace #252 is not content:
$this->assertFalse(MWNamespace::isContent(252));
# @todo FIXME: Is global saving really required for PHPUnit?
// Bless namespace # 252 as a content namespace
global $wgContentNamespaces;
$savedGlobal = $wgContentNamespaces;
$wgContentNamespaces[] = 252;
$this->assertTrue(MWNamespace::isContent(252));
// Makes sure NS_MAIN was not impacted
$this->assertTrue(MWNamespace::isContent(NS_MAIN));
// Restore global
$wgContentNamespaces = $savedGlobal;
// Verify namespaces after global restauration
$this->assertTrue(MWNamespace::isContent(NS_MAIN));
$this->assertFalse(MWNamespace::isContent(252));
}