From 4a789ab18b0d3ed37a1652521dc9ade929a3c8b5 Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Wed, 18 Jun 2014 17:50:48 +0300 Subject: [PATCH] Coding style tweaks & removed one unused variable from the setup file. Change-Id: Ia523e2e9cbf374a5feb357290218ebb276652664 --- Editcount.php | 6 ++++-- Editcount_body.php | 36 +++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Editcount.php b/Editcount.php index d665ae1..873c2d7 100644 --- a/Editcount.php +++ b/Editcount.php @@ -1,5 +1,4 @@ __FILE__, 'name' => 'Editcount', @@ -21,7 +24,6 @@ $wgExtensionCredits['specialpage'][] = array( 'url' => 'https://www.mediawiki.org/wiki/Extension:Editcount', ); -$dir = dirname(__FILE__) . '/'; $wgMessagesDirs['Editcount'] = __DIR__ . '/i18n'; $wgExtensionMessagesFiles['Editcount'] = __DIR__ . '/Editcount.i18n.php'; $wgExtensionMessagesFiles['EditcountAliases'] = __DIR__ . '/Editcount.alias.php'; diff --git a/Editcount_body.php b/Editcount_body.php index 5e53033..d388801 100644 --- a/Editcount_body.php +++ b/Editcount_body.php @@ -1,5 +1,4 @@ formatNum( $user->getEditCount() ); - } else { - $out = ""; + $out = ''; } } else { $out = $wgContLang->formatNum( $this->editsInNs( $uid, $namespace ) ); @@ -63,8 +63,9 @@ class Editcount extends IncludableSpecialPage { @list( $user, $namespace ) = explode( '/', $par, 2 ); // str*cmp sucks - if ( isset( $namespace ) ) + if ( isset( $namespace ) ) { $namespace = $wgContLang->getNsIndex( $namespace ); + } return array( $user, $namespace ); } @@ -79,8 +80,9 @@ class Editcount extends IncludableSpecialPage { */ function getTotal( $nscount ) { $total = 0; - foreach ( array_values( $nscount ) as $i ) + foreach ( array_values( $nscount ) as $i ) { $total += $i; + } return $total; } @@ -97,7 +99,7 @@ class Editcount extends IncludableSpecialPage { $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( array( 'user', 'revision', 'page' ), - array( 'page_namespace', 'COUNT(*) as count' ), + array( 'page_namespace', 'COUNT(*) AS count' ), array( 'user_id' => $uid, 'rev_user = user_id', @@ -107,7 +109,7 @@ class Editcount extends IncludableSpecialPage { array( 'GROUP BY' => 'page_namespace' ) ); - while( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $nscount[$row->page_namespace] = $row->count; } @@ -125,7 +127,7 @@ class Editcount extends IncludableSpecialPage { $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->selectField( array( 'user', 'revision', 'page' ), - array( 'COUNT(*) as count' ), + array( 'COUNT(*) AS count' ), array( 'user_id' => $uid, 'page_namespace' => $ns, @@ -165,7 +167,7 @@ class EditcountHTML extends Editcount { $this->setHeaders(); - $action = htmlspecialchars( $this->getPageTitle()->getLocalUrl() ); + $action = htmlspecialchars( $this->getPageTitle()->getLocalURL() ); $user = $this->msg( 'editcount_username' )->escaped(); $submit = $this->msg( 'editcount_submit' )->escaped(); $out = " @@ -185,9 +187,9 @@ class EditcountHTML extends Editcount {   "; } - $out .=" + $out .= ' - "; + '; $this->getOutput()->addHTML( $out ); } @@ -211,12 +213,12 @@ class EditcountHTML extends Editcount { "; - foreach ($this->nscount as $ns => $edits) { + foreach ( $this->nscount as $ns => $edits ) { $fedits = $lang->formatNum( $edits ); - $fns = $ns == NS_MAIN ? $this->msg( 'blanknamespace' ) : $lang->getFormattedNsText( $ns ); + $fns = ( $ns == NS_MAIN ) ? $this->msg( 'blanknamespace' ) : $lang->getFormattedNsText( $ns ); $percent = wfPercent( $edits / $this->total * 100 ); $fpercent = $lang->formatNum( $percent ); - $ret .=" + $ret .= " $fns $fedits @@ -224,8 +226,8 @@ class EditcountHTML extends Editcount { "; } - $ret .= " - "; + $ret .= ' + '; return $ret; }