themselves. Some minor tweaks to the actual message content.
* Introduce $wgContentNamespaces which allows for articles to exist in namespaces other
than the main namespace, and still be counted as valid content in the site statistics.
+* (bug 5932) Introduce {{PAGESINNAMESPACE}} magic word
== Compatibility ==
'MAG_DIRECTIONMARK',
'MAG_LANGUAGE',
'MAG_CONTENTLANGUAGE',
+ 'MAG_PAGESINNAMESPACE',
);
if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
MAG_DIRECTIONMARK,
MAG_LANGUAGE,
MAG_CONTENTLANGUAGE,
+ MAG_PAGESINNAMESPACE,
);
if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
}
}
}
+
+ # PAGESINNAMESPACE
+ if( !$found ) {
+ $mwPagesInNs =& MagicWord::get( MAG_PAGESINNAMESPACE );
+ if( $mwPagesInNs->matchStartAndRemove( $part1 ) ) {
+ $found = true;
+ $count = wfPagesInNs( intval( $part1 ) );
+ $mwRawSuffix =& MagicWord::get( MAG_RAWSUFFIX );
+ if( isset( $args[0] ) && $mwRawSuffix->match( $args[0] ) ) {
+ $text = $linestart . $count;
+ } else {
+ $text = $linestart . $wgContLang->formatNum( $count );
+ }
+ }
+ }
# #LANGUAGE:
if( !$found ) {
return (int)$count;
}
+/**
+ * Count the number of pages in a particular namespace
+ *
+ * @param $ns Namespace
+ * @return integer
+ */
+function wfPagesInNs( $ns ) {
+ static $pageCount = array();
+ wfProfileIn( 'wfPagesInNs' );
+ if( !isset( $pageCount[$ns] ) ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $pageCount[$ns] = $dbr->selectField( 'page', 'COUNT(*)', array( 'page_namespace' => $ns ), 'wfPagesInNs' );
+ }
+ wfProfileOut( 'wfPagesInNs' );
+ return (int)$pageCount[$ns];
+}
+
/**
* Get various statistics from the database
* @private
MAG_DIRECTIONMARK => array( 1, 'DIRECTIONMARK', 'DIRMARK' ),
MAG_LANGUAGE => array( 0, '#LANGUAGE:' ),
MAG_CONTENTLANGUAGE => array( 1, 'CONTENTLANGUAGE', 'CONTENTLANG' ),
+ MAG_PAGESINNAMESPACE => array( 1, 'PAGESINNAMESPACE:', 'PAGESINNS:' ),
);
if (!$wgCachedMessageArrays) {