r66231 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66230‎ | r66231 | r66232 >
Date:22:24, 11 May 2010
Author:siebrand
Status:ok
Tags:
Comment:
stylize.php, remove trailing whitespace, break a long line
Modified paths:
  • /trunk/phase3/includes/Credits.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Credits.php
@@ -21,30 +21,29 @@
2222 */
2323
2424 class Credits {
25 -
2625 /**
2726 * This is largely cadged from PageHistory::history
2827 * @param $article Article object
2928 */
3029 public static function showPage( Article $article ) {
3130 global $wgOut;
32 -
 31+
3332 wfProfileIn( __METHOD__ );
34 -
 33+
3534 $wgOut->setPageTitle( $article->mTitle->getPrefixedText() );
3635 $wgOut->setSubtitle( wfMsg( 'creditspage' ) );
3736 $wgOut->setArticleFlag( false );
3837 $wgOut->setArticleRelated( true );
3938 $wgOut->setRobotPolicy( 'noindex,nofollow' );
40 -
41 - if( $article->mTitle->getArticleID() == 0 ) {
 39+
 40+ if ( $article->mTitle->getArticleID() == 0 ) {
4241 $s = wfMsg( 'nocredits' );
4342 } else {
4443 $s = self::getCredits( $article, -1 );
4544 }
46 -
 45+
4746 $wgOut->addHTML( $s );
48 -
 47+
4948 wfProfileOut( __METHOD__ );
5049 }
5150
@@ -59,7 +58,7 @@
6059 wfProfileIn( __METHOD__ );
6160 $s = '';
6261
63 - if( isset( $cnt ) && $cnt != 0 ){
 62+ if ( isset( $cnt ) && $cnt != 0 ) {
6463 $s = self::getAuthor( $article );
6564 if ( $cnt > 1 || $cnt < 0 ) {
6665 $s .= ' ' . self::getContributors( $article, $cnt - 1, $showIfMax );
@@ -74,13 +73,13 @@
7574 * Get the last author with the last modification time
7675 * @param $article Article object
7776 */
78 - protected static function getAuthor( Article $article ){
 77+ protected static function getAuthor( Article $article ) {
7978 global $wgLang;
8079
8180 $user = User::newFromId( $article->getUser() );
8281
8382 $timestamp = $article->getTimestamp();
84 - if( $timestamp ){
 83+ if ( $timestamp ) {
8584 $d = $wgLang->date( $article->getTimestamp(), true );
8685 $t = $wgLang->time( $article->getTimestamp(), true );
8786 } else {
@@ -99,62 +98,62 @@
10099 */
101100 protected static function getContributors( Article $article, $cnt, $showIfMax ) {
102101 global $wgLang, $wgHiddenPrefs;
103 -
 102+
104103 $contributors = $article->getContributors();
105 -
 104+
106105 $others_link = false;
107 -
 106+
108107 # Hmm... too many to fit!
109 - if( $cnt > 0 && $contributors->count() > $cnt ){
 108+ if ( $cnt > 0 && $contributors->count() > $cnt ) {
110109 $others_link = self::othersLink( $article );
111 - if( !$showIfMax )
 110+ if ( !$showIfMax )
112111 return wfMsgExt( 'othercontribs', 'parsemag', $others_link, $contributors->count() );
113112 }
114 -
 113+
115114 $real_names = array();
116115 $user_names = array();
117116 $anon_ips = array();
118 -
 117+
119118 # Sift for real versus user names
120 - foreach( $contributors as $user ) {
 119+ foreach ( $contributors as $user ) {
121120 $cnt--;
122 - if( $user->isLoggedIn() ){
 121+ if ( $user->isLoggedIn() ) {
123122 $link = self::link( $user );
124 - if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
 123+ if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
125124 $real_names[] = $link;
126125 else
127126 $user_names[] = $link;
128127 } else {
129128 $anon_ips[] = self::link( $user );
130129 }
131 - if( $cnt == 0 ) break;
 130+ if ( $cnt == 0 ) break;
132131 }
133 -
 132+
134133 if ( count( $real_names ) ) {
135134 $real = $wgLang->listToText( $real_names );
136135 } else {
137136 $real = false;
138137 }
139 -
 138+
140139 # "ThisSite user(s) A, B and C"
141 - if( count( $user_names ) ){
 140+ if ( count( $user_names ) ) {
142141 $user = wfMsgExt( 'siteusers', array( 'parsemag' ),
143142 $wgLang->listToText( $user_names ), count( $user_names ) );
144143 } else {
145144 $user = false;
146145 }
147146
148 - if( count( $anon_ips ) ){
 147+ if ( count( $anon_ips ) ) {
149148 $anon = wfMsgExt( 'anonusers', array( 'parsemag' ),
150149 $wgLang->listToText( $anon_ips ), count( $anon_ips ) );
151150 } else {
152151 $anon = false;
153152 }
154 -
 153+
155154 # This is the big list, all mooshed together. We sift for blank strings
156155 $fulllist = array();
157 - foreach( array( $real, $user, $anon, $others_link ) as $s ){
158 - if( $s ){
 156+ foreach ( array( $real, $user, $anon, $others_link ) as $s ) {
 157+ if ( $s ) {
159158 array_push( $fulllist, $s );
160159 }
161160 }
@@ -163,7 +162,7 @@
164163 $creds = $wgLang->listToText( $fulllist );
165164
166165 # "Based on work by ..."
167 - return strlen( $creds )
 166+ return strlen( $creds )
168167 ? wfMsgExt( 'othercontribs', 'parsemag', $creds, count( $fulllist ) )
169168 : '';
170169 }
@@ -175,7 +174,7 @@
176175 */
177176 protected static function link( User $user ) {
178177 global $wgUser, $wgHiddenPrefs;
179 - if( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() )
 178+ if ( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() )
180179 $real = $user->getRealName();
181180 else
182181 $real = false;
@@ -195,13 +194,13 @@
196195 */
197196 protected static function userLink( User $user ) {
198197 $link = self::link( $user );
199 - if( $user->isAnon() ){
 198+ if ( $user->isAnon() ) {
200199 return wfMsgExt( 'anonuser', array( 'parseinline', 'replaceafter' ), $link );
201200 } else {
202201 global $wgHiddenPrefs;
203 - if( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
 202+ if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() )
204203 return $link;
205 - else
 204+ else
206205 return wfMsgExt( 'siteuser', array( 'parseinline', 'replaceafter' ), $link );
207206 }
208207 }
@@ -214,6 +213,12 @@
215214 protected static function othersLink( Article $article ) {
216215 global $wgUser;
217216 $skin = $wgUser->getSkin();
218 - return $skin->link( $article->getTitle(), wfMsgHtml( 'others' ), array(), array( 'action' => 'credits' ), array( 'known' ) );
 217+ return $skin->link(
 218+ $article->getTitle(),
 219+ wfMsgHtml( 'others' ),
 220+ array(),
 221+ array( 'action' => 'credits' ),
 222+ array( 'known' )
 223+ );
219224 }
220225 }

Status & tagging log