From 6198592553fca99c19d2afec2766359ed7579d89 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet Date: Sun, 19 Oct 2008 04:11:02 +0000 Subject: [PATCH] (bug 13701) {{NUMBEROFVIEWS}} magic word to show number of total views. --- RELEASE-NOTES | 1 + includes/MagicWord.php | 2 ++ includes/parser/CoreParserFunctions.php | 3 +++ includes/parser/Parser.php | 2 ++ includes/parser/Parser_OldPP.php | 3 +++ includes/specials/SpecialDisambiguations.php | 2 +- languages/messages/MessagesEn.php | 1 + 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ce12fadeaf..08902a927c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -275,6 +275,7 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 15717) Set $separatorTransformTable for language 'eu' * (bug 15605) Enabled $datePreferences for language 'hr'. Added standard date preferences. +* (bug 13701) {{NUMBEROFVIEWS}} magic word to show number of total views. === API changes in 1.14 === diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 594b2f443d..5b5b77f0ff 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -103,6 +103,7 @@ class MagicWord { 'contentlanguage', 'pagesinnamespace', 'numberofadmins', + 'numberofviews', 'defaultsort', 'pagesincategory', 'index', @@ -146,6 +147,7 @@ class MagicWord { 'localtimestamp' => 3600, 'pagesinnamespace' => 3600, 'numberofadmins' => 3600, + 'numberofviews' => 3600, 'numberingroup' => 3600, ); diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index c49654467d..e5fb65e79e 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -215,6 +215,9 @@ class CoreParserFunctions { static function numberofedits( $parser, $raw = null ) { return self::formatRaw( SiteStats::edits(), $raw ); } + static function numberofviews( $parser, $raw = null ) { + return self::formatRaw( SiteStats::views(), $raw ); + } static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) { return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw ); } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 7b2f2317d9..0d3d5179b1 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2587,6 +2587,8 @@ class Parser return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::numberingroup('sysop') ); case 'numberofedits': return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::edits() ); + case 'numberofviews': + return $this->mVarCache[$index] = $wgContLang->formatNum( SiteStats::views() ); case 'currenttimestamp': return $this->mVarCache[$index] = wfTimestamp( TS_MW, $ts ); case 'localtimestamp': diff --git a/includes/parser/Parser_OldPP.php b/includes/parser/Parser_OldPP.php index 177b98901b..907bba8c09 100644 --- a/includes/parser/Parser_OldPP.php +++ b/includes/parser/Parser_OldPP.php @@ -121,6 +121,7 @@ class Parser_OldPP $this->setFunctionHook( 'numberoffiles', array( 'CoreParserFunctions', 'numberoffiles' ), SFH_NO_HASH ); $this->setFunctionHook( 'numberofadmins', array( 'CoreParserFunctions', 'numberofadmins' ), SFH_NO_HASH ); $this->setFunctionHook( 'numberofedits', array( 'CoreParserFunctions', 'numberofedits' ), SFH_NO_HASH ); + $this->setFunctionHook( 'numberofviews', array( 'CoreParserFunctions', 'numberofviews' ), SFH_NO_HASH ); $this->setFunctionHook( 'language', array( 'CoreParserFunctions', 'language' ), SFH_NO_HASH ); $this->setFunctionHook( 'padleft', array( 'CoreParserFunctions', 'padleft' ), SFH_NO_HASH ); $this->setFunctionHook( 'padright', array( 'CoreParserFunctions', 'padright' ), SFH_NO_HASH ); @@ -2565,6 +2566,8 @@ class Parser_OldPP return $varCache[$index] = $wgContLang->formatNum( SiteStats::numberingroup('sysop') ); case 'numberofedits': return $varCache[$index] = $wgContLang->formatNum( SiteStats::edits() ); + case 'numberofviews': + return $varCache[$index] = $wgContLang->formatNum( SiteStats::views() ); case 'currenttimestamp': return $varCache[$index] = wfTimestampNow(); case 'localtimestamp': diff --git a/includes/specials/SpecialDisambiguations.php b/includes/specials/SpecialDisambiguations.php index a29111c474..0a728b6860 100644 --- a/includes/specials/SpecialDisambiguations.php +++ b/includes/specials/SpecialDisambiguations.php @@ -84,7 +84,7 @@ class DisambiguationsPage extends PageQueryPage { function formatResult( $skin, $result ) { global $wgContLang; - $title = Title::newFromId( $result->value ); + $title = Title::newFromID( $result->value ); $dp = Title::makeTitle( $result->namespace, $result->title ); $from = $skin->link( $title ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 5bf4a1c509..6a49a0752c 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -247,6 +247,7 @@ $magicWords = array( 'numberoffiles' => array( 1, 'NUMBEROFFILES' ), 'numberofusers' => array( 1, 'NUMBEROFUSERS' ), 'numberofedits' => array( 1, 'NUMBEROFEDITS' ), + 'numberofviews' => array( 1, 'NUMBEROFVIEWS' ), 'pagename' => array( 1, 'PAGENAME' ), 'pagenamee' => array( 1, 'PAGENAMEE' ), 'namespace' => array( 1, 'NAMESPACE' ), -- 2.20.1