* A new magic word, {{NUMBEROFFILES}}, returns the number of rows in the
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sun, 26 Jun 2005 03:23:24 +0000 (03:23 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sun, 26 Jun 2005 03:23:24 +0000 (03:23 +0000)
  image table

RELEASE-NOTES
includes/MagicWord.php
includes/Parser.php
languages/Language.php

index 585996f..0892f35 100644 (file)
@@ -300,6 +300,7 @@ Various bugfixes, small features, and a few experimental things:
 * (bug 1120) Updated the Czech translation
 * A new magic word, {{SCRIPTPATH}}, returns $wgScriptPath
 * A new magic word, {{SERVERNAME}}, returns $wgServerName
+* A new magic word, {{NUMBEROFFILES}}, returns the number of rows in the image table
 * Special:Imagelist displays titles with " " instead of "_"
 * Less gratuitous munging of content sample in delete summary
 * badaccess/badaccesstext to supercede sysop*, developer* messages
index 3abb026..0fbe370 100644 (file)
@@ -54,6 +54,7 @@ define('MAG_CURRENTDOW',              39);
 define('MAG_REVISIONID',               40);
 define('MAG_SCRIPTPATH',               41);
 define('MAG_SERVERNAME',               42);
+define('MAG_NUMBEROFFILES',            43);
 
 $wgVariableIDs = array(
        MAG_CURRENTMONTH,
@@ -65,6 +66,7 @@ $wgVariableIDs = array(
        MAG_CURRENTYEAR,
        MAG_CURRENTTIME,
        MAG_NUMBEROFARTICLES,
+       MAG_NUMBEROFFILES,
        MAG_SITENAME,
        MAG_SERVER,
        MAG_SERVERNAME,
index f63ca03..ebed5d5 100644 (file)
@@ -1885,6 +1885,8 @@ class Parser
                                return $varCache[$index] = $wgContLang->formatNum( date('w') );
                        case MAG_NUMBEROFARTICLES:
                                return $varCache[$index] = $wgContLang->formatNum( wfNumberOfArticles() );
+                       case MAG_NUMBEROFFILES:
+                               return $varCache[$index] = $wgContLang->formatNum( wfNumberOfFiles() );
                        case MAG_SITENAME:
                                return $wgSitename;
                        case MAG_SERVER:
@@ -3381,6 +3383,20 @@ function wfNumberOfArticles() {
        return $wgNumberOfArticles;
 }
 
+/**
+ * Return the number of files
+ */
+function wfNumberOfFiles() {
+       $fname = 'Parser::wfNumberOfFiles';
+       
+       wfProfileIn( $fname );
+       $dbr =& wfGetDB( DB_SLAVE );
+       $res = $dbr->selectField('image', 'COUNT(*)', array(), $fname );
+       wfProfileOut( $fname );
+       
+       return $res;
+}
+
 /**
  * Get various statistics from the database
  * @private
index eac2e56..cc994e9 100644 (file)
@@ -208,6 +208,7 @@ $wgLanguageNamesEn =& $wgLanguageNames;
        MAG_CURRENTYEAR          => array( 1,    'CURRENTYEAR'            ),
        MAG_CURRENTTIME          => array( 1,    'CURRENTTIME'            ),
        MAG_NUMBEROFARTICLES     => array( 1,    'NUMBEROFARTICLES'       ),
+       MAG_NUMBEROFFILES        => array( 1,    'NUMBEROFFILES'          ),
        MAG_PAGENAME             => array( 1,    'PAGENAME'               ),
        MAG_PAGENAMEE            => array( 1,    'PAGENAMEE'              ),
        MAG_NAMESPACE            => array( 1,    'NAMESPACE'              ),