r100229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100228‎ | r100229 | r100230 >
Date:14:52, 19 October 2011
Author:ialex
Status:ok
Tags:
Comment:
Don't reinvent the wheel in LegacyTemplate::pageStats(), just use them items from SkinTemplate
Modified paths:
  • /trunk/phase3/includes/SkinLegacy.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinLegacy.php
@@ -183,56 +183,16 @@
184184 }
185185
186186 function pageStats() {
187 - global $wgOut, $wgLang, $wgRequest, $wgUser;
188 - global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
 187+ $ret = array();
 188+ $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
189189
190 - if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) {
191 - return '';
192 - }
193 -
194 - $title = $this->getSkin()->getTitle();
195 -
196 - if ( !$wgOut->isArticle() || !$title->exists() ) {
197 - return '';
198 - }
199 -
200 - $article = new Article( $title, 0 );
201 -
202 - $s = '';
203 -
204 - if ( !$wgDisableCounters ) {
205 - $count = $wgLang->formatNum( $article->getCount() );
206 -
207 - if ( $count ) {
208 - $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
 190+ foreach( $items as $item ) {
 191+ if ( $this->data[$item] !== false ) {
 192+ $ret[] = $this->data[$item];
209193 }
210194 }
211195
212 - if ( $wgMaxCredits != 0 ) {
213 - $s .= ' ' . Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
214 - } else {
215 - $s .= $this->data['lastmod'];
216 - }
217 -
218 - if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
219 - $dbr = wfGetDB( DB_SLAVE );
220 - $res = $dbr->select(
221 - 'watchlist',
222 - array( 'COUNT(*) AS n' ),
223 - array(
224 - 'wl_title' => $dbr->strencode( $title->getDBkey() ),
225 - 'wl_namespace' => $title->getNamespace()
226 - ),
227 - __METHOD__
228 - );
229 - $x = $dbr->fetchObject( $res );
230 -
231 - $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
232 - array( 'parseinline' ), $wgLang->formatNum( $x->n )
233 - );
234 - }
235 -
236 - return $s . ' ' . $this->getSkin()->getCopyright();
 196+ return implode( ' ', $ret );
237197 }
238198
239199 function topLinks() {

Status & tagging log