From a8538c7d58ac75955329ffbbca5ff81aba7bd50e Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 19 Oct 2011 14:52:26 +0000 Subject: [PATCH] Don't reinvent the wheel in LegacyTemplate::pageStats(), just use them items from SkinTemplate --- includes/SkinLegacy.php | 52 +++++------------------------------------ 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/includes/SkinLegacy.php b/includes/SkinLegacy.php index 1d043ed9cb..53273fb5b7 100644 --- a/includes/SkinLegacy.php +++ b/includes/SkinLegacy.php @@ -183,56 +183,16 @@ class LegacyTemplate extends BaseTemplate { } function pageStats() { - global $wgOut, $wgLang, $wgRequest, $wgUser; - global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers; + $ret = array(); + $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' ); - if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) { - return ''; - } - - $title = $this->getSkin()->getTitle(); - - if ( !$wgOut->isArticle() || !$title->exists() ) { - return ''; - } - - $article = new Article( $title, 0 ); - - $s = ''; - - if ( !$wgDisableCounters ) { - $count = $wgLang->formatNum( $article->getCount() ); - - if ( $count ) { - $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count ); + foreach( $items as $item ) { + if ( $this->data[$item] !== false ) { + $ret[] = $this->data[$item]; } } - if ( $wgMaxCredits != 0 ) { - $s .= ' ' . Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ); - } else { - $s .= $this->data['lastmod']; - } - - if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) { - $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( - 'watchlist', - array( 'COUNT(*) AS n' ), - array( - 'wl_title' => $dbr->strencode( $title->getDBkey() ), - 'wl_namespace' => $title->getNamespace() - ), - __METHOD__ - ); - $x = $dbr->fetchObject( $res ); - - $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview', - array( 'parseinline' ), $wgLang->formatNum( $x->n ) - ); - } - - return $s . ' ' . $this->getSkin()->getCopyright(); + return implode( ' ', $ret ); } function topLinks() { -- 2.20.1