From: Ævar Arnfjörð Bjarmason Date: Sun, 26 Jun 2005 03:23:24 +0000 (+0000) Subject: * A new magic word, {{NUMBEROFFILES}}, returns the number of rows in the X-Git-Tag: 1.5.0beta1~13 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=76d3a0b5f35755c6d4227058be7fb912cf894708;p=lhc%2Fweb%2Fwiklou.git * A new magic word, {{NUMBEROFFILES}}, returns the number of rows in the image table --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 585996fd32..0892f35932 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 3abb02638e..0fbe370b95 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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, diff --git a/includes/Parser.php b/includes/Parser.php index f63ca03eb6..ebed5d52af 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 diff --git a/languages/Language.php b/languages/Language.php index eac2e5635a..cc994e9f4f 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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' ),