r106422 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106421‎ | r106422 | r106423 >
Date:10:58, 16 December 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Stylize
Modified paths:
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Namespace.php
@@ -36,7 +36,7 @@
3737 * @return true
3838 */
3939 private static function isMethodValidFor( $index, $method ) {
40 - if( $index < NS_MAIN ) {
 40+ if ( $index < NS_MAIN ) {
4141 throw new MWException( "$method does not make any sense for given namespace $index" );
4242 }
4343 return true;
@@ -50,7 +50,7 @@
5151 */
5252 public static function isMovable( $index ) {
5353 global $wgAllowImageMoving;
54 - return !( $index < NS_MAIN || ($index == NS_FILE && !$wgAllowImageMoving) || $index == NS_CATEGORY );
 54+ return !( $index < NS_MAIN || ( $index == NS_FILE && !$wgAllowImageMoving ) || $index == NS_CATEGORY );
5555 }
5656
5757 /**
@@ -106,7 +106,7 @@
107107 */
108108 public static function getSubject( $index ) {
109109 # Handle special namespaces
110 - if( $index < NS_MAIN ) {
 110+ if ( $index < NS_MAIN ) {
111111 return $index;
112112 }
113113
@@ -126,9 +126,9 @@
127127 public static function getAssociated( $index ) {
128128 self::isMethodValidFor( $index, __METHOD__ );
129129
130 - if( self::isSubject( $index ) ) {
 130+ if ( self::isSubject( $index ) ) {
131131 return self::getTalk( $index );
132 - } elseif( self::isTalk( $index ) ) {
 132+ } elseif ( self::isTalk( $index ) ) {
133133 return self::getSubject( $index );
134134 } else {
135135 return null;
@@ -209,7 +209,7 @@
210210 */
211211 public static function getCanonicalName( $index ) {
212212 $nslist = self::getCanonicalNamespaces();
213 - if( isset( $nslist[$index] ) ) {
 213+ if ( isset( $nslist[$index] ) ) {
214214 return $nslist[$index];
215215 } else {
216216 return false;
@@ -228,7 +228,7 @@
229229 if ( $xNamespaces === false ) {
230230 $xNamespaces = array();
231231 foreach ( self::getCanonicalNamespaces() as $i => $text ) {
232 - $xNamespaces[strtolower($text)] = $i;
 232+ $xNamespaces[strtolower( $text )] = $i;
233233 }
234234 }
235235 if ( array_key_exists( $name, $xNamespaces ) ) {
@@ -306,7 +306,7 @@
307307 */
308308 public static function getContentNamespaces() {
309309 global $wgContentNamespaces;
310 - if( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === array() ) {
 310+ if ( !is_array( $wgContentNamespaces ) || $wgContentNamespaces === array() ) {
311311 return NS_MAIN;
312312 } elseif ( !in_array( NS_MAIN, $wgContentNamespaces ) ) {
313313 // always force NS_MAIN to be part of array (to match the algorithm used by isContent)
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -44,17 +44,17 @@
4545 $this->opts = array();
4646 $request = $this->getRequest();
4747
48 - if( $par == 'newbies' ) {
 48+ if ( $par == 'newbies' ) {
4949 $target = 'newbies';
5050 $this->opts['contribs'] = 'newbie';
51 - } elseif( $par !== null ) {
 51+ } elseif ( $par !== null ) {
5252 $target = $par;
5353 } else {
5454 $target = $request->getVal( 'target' );
5555 }
5656
5757 // check for radiobox
58 - if( $request->getVal( 'contribs' ) == 'newbie' ) {
 58+ if ( $request->getVal( 'contribs' ) == 'newbie' ) {
5959 $target = 'newbies';
6060 $this->opts['contribs'] = 'newbie';
6161 } else {
@@ -63,36 +63,36 @@
6464
6565 $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' );
6666
67 - if( !strlen( $target ) ) {
 67+ if ( !strlen( $target ) ) {
6868 $out->addHTML( $this->getForm() );
6969 return;
7070 }
7171
7272 $user = $this->getUser();
7373
74 - $this->opts['limit'] = $request->getInt( 'limit', $user->getOption('rclimit') );
 74+ $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
7575 $this->opts['target'] = $target;
7676 $this->opts['topOnly'] = $request->getBool( 'topOnly' );
7777
7878 $userObj = User::newFromName( $target, false );
79 - if( !$userObj ) {
 79+ if ( !$userObj ) {
8080 $out->addHTML( $this->getForm() );
8181 return;
8282 }
8383 $nt = $userObj->getUserPage();
8484 $id = $userObj->getID();
8585
86 - if( $this->opts['contribs'] != 'newbie' ) {
 86+ if ( $this->opts['contribs'] != 'newbie' ) {
8787 $target = $nt->getText();
8888 $out->addSubtitle( $this->contributionsSub( $userObj ) );
8989 $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ), $target ) ) );
9090 $this->getSkin()->setRelevantUser( $userObj );
9191 } else {
92 - $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub') );
 92+ $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
9393 $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
9494 }
9595
96 - if( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
 96+ if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
9797 $this->opts['namespace'] = intval( $ns );
9898 } else {
9999 $this->opts['namespace'] = '';
@@ -106,13 +106,13 @@
107107
108108 // Allows reverts to have the bot flag in recent changes. It is just here to
109109 // be passed in the form at the top of the page
110 - if( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
 110+ if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
111111 $this->opts['bot'] = '1';
112112 }
113113
114114 $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev';
115115 # Offset overrides year/month selection
116 - if( $skip ) {
 116+ if ( $skip ) {
117117 $this->opts['year'] = '';
118118 $this->opts['month'] = '';
119119 } else {
@@ -121,7 +121,7 @@
122122 }
123123
124124 $feedType = $request->getVal( 'feed' );
125 - if( $feedType ) {
 125+ if ( $feedType ) {
126126 // Maintain some level of backwards compatability
127127 // If people request feeds using the old parameters, redirect to API
128128 $apiParams = array(
@@ -172,12 +172,12 @@
173173 'nsInvert' => $this->opts['nsInvert'],
174174 'associated' => $this->opts['associated'],
175175 ) );
176 - if( !$pager->getNumRows() ) {
 176+ if ( !$pager->getNumRows() ) {
177177 $out->addWikiMsg( 'nocontribs', $target );
178178 } else {
179179 # Show a message about slave lag, if applicable
180180 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
181 - if( $lag > 0 )
 181+ if ( $lag > 0 )
182182 $out->showLagWarning( $lag );
183183
184184 $out->addHTML(
@@ -189,7 +189,7 @@
190190 $out->preventClickjacking( $pager->getPreventClickjacking() );
191191
192192 # Show the appropriate "footer" message - WHOIS tools, etc.
193 - if( $this->opts['contribs'] != 'newbie' ) {
 193+ if ( $this->opts['contribs'] != 'newbie' ) {
194194 $message = 'sp-contributions-footer';
195195 if ( IP::isIPAddress( $target ) ) {
196196 $message = 'sp-contributions-footer-anon';
@@ -200,7 +200,7 @@
201201 }
202202 }
203203
204 - if( !wfMessage( $message, $target )->isDisabled() ) {
 204+ if ( !wfMessage( $message, $target )->isDisabled() ) {
205205 $out->wrapWikiMsg(
206206 "<div class='mw-contributions-footer'>\n$1\n</div>",
207207 array( $message, $target ) );
@@ -223,7 +223,7 @@
224224 }
225225 $nt = $userObj->getUserPage();
226226 $talk = $userObj->getTalkPage();
227 - if( $talk ) {
 227+ if ( $talk ) {
228228 $tools = self::getUserLinks( $nt, $talk, $userObj, $this->getUser() );
229229 $links = $this->getLanguage()->pipeList( $tools );
230230
@@ -276,8 +276,8 @@
277277
278278 $tools[] = Linker::link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) );
279279
280 - if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
281 - if( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
 280+ if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
 281+ if ( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
282282 if ( $target->isBlocked() ) {
283283 $tools[] = Linker::linkKnown( # Change block link
284284 SpecialPage::getTitleFor( 'Block', $username ),
@@ -317,7 +317,7 @@
318318 );
319319
320320 # Add link to deleted user contributions for priviledged users
321 - if( $subject->isAllowed( 'deletedhistory' ) ) {
 321+ if ( $subject->isAllowed( 'deletedhistory' ) ) {
322322 $tools[] = Linker::linkKnown(
323323 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
324324 wfMsgHtml( 'sp-contributions-deleted' )
@@ -327,7 +327,7 @@
328328 # Add a link to change user rights for privileged users
329329 $userrightsPage = new UserrightsPage();
330330 $userrightsPage->getContext()->setUser( $subject );
331 - if( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
 331+ if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
332332 $tools[] = Linker::linkKnown(
333333 SpecialPage::getTitleFor( 'Userrights', $username ),
334334 wfMsgHtml( 'sp-contributions-userrights' )
@@ -346,45 +346,45 @@
347347 global $wgScript;
348348
349349 $this->opts['title'] = $this->getTitle()->getPrefixedText();
350 - if( !isset( $this->opts['target'] ) ) {
 350+ if ( !isset( $this->opts['target'] ) ) {
351351 $this->opts['target'] = '';
352352 } else {
353353 $this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] );
354354 }
355355
356 - if( !isset( $this->opts['namespace'] ) ) {
 356+ if ( !isset( $this->opts['namespace'] ) ) {
357357 $this->opts['namespace'] = '';
358358 }
359359
360 - if( !isset( $this->opts['nsInvert'] ) ) {
 360+ if ( !isset( $this->opts['nsInvert'] ) ) {
361361 $this->opts['nsInvert'] = '';
362362 }
363363
364 - if( !isset( $this->opts['associated'] ) ) {
 364+ if ( !isset( $this->opts['associated'] ) ) {
365365 $this->opts['associated'] = false;
366366 }
367367
368 - if( !isset( $this->opts['contribs'] ) ) {
 368+ if ( !isset( $this->opts['contribs'] ) ) {
369369 $this->opts['contribs'] = 'user';
370370 }
371371
372 - if( !isset( $this->opts['year'] ) ) {
 372+ if ( !isset( $this->opts['year'] ) ) {
373373 $this->opts['year'] = '';
374374 }
375375
376 - if( !isset( $this->opts['month'] ) ) {
 376+ if ( !isset( $this->opts['month'] ) ) {
377377 $this->opts['month'] = '';
378378 }
379379
380 - if( $this->opts['contribs'] == 'newbie' ) {
 380+ if ( $this->opts['contribs'] == 'newbie' ) {
381381 $this->opts['target'] = '';
382382 }
383383
384 - if( !isset( $this->opts['tagfilter'] ) ) {
 384+ if ( !isset( $this->opts['tagfilter'] ) ) {
385385 $this->opts['tagfilter'] = '';
386386 }
387387
388 - if( !isset( $this->opts['topOnly'] ) ) {
 388+ if ( !isset( $this->opts['topOnly'] ) ) {
389389 $this->opts['topOnly'] = false;
390390 }
391391
@@ -393,7 +393,7 @@
394394 # Add hidden params for tracking except for parameters in $skipParameters
395395 $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' );
396396 foreach ( $this->opts as $name => $value ) {
397 - if( in_array( $name, $skipParameters ) ) {
 397+ if ( in_array( $name, $skipParameters ) ) {
398398 continue;
399399 }
400400 $form .= "\t" . Html::hidden( $name, $value ) . "\n";
@@ -401,7 +401,7 @@
402402
403403 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] );
404404
405 - if ($tagFilter) {
 405+ if ( $tagFilter ) {
406406 $filterSelection =
407407 Xml::tags( 'td', array( 'class' => 'mw-label' ), array_shift( $tagFilter ) ) .
408408 Xml::tags( 'td', array( 'class' => 'mw-input' ), implode( '&#160', $tagFilter ) );
@@ -448,7 +448,7 @@
449449 Xml::namespaceSelector( $this->opts['namespace'], '' ) . '&#160;' .
450450 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
451451 Xml::checkLabel(
452 - wfMsg('invert'),
 452+ wfMsg( 'invert' ),
453453 'nsInvert',
454454 'nsInvert',
455455 $this->opts['nsInvert'],
@@ -457,7 +457,7 @@
458458 ) .
459459 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
460460 Xml::checkLabel(
461 - wfMsg('namespace_association'),
 461+ wfMsg( 'namespace_association' ),
462462 'associated',
463463 'associated',
464464 $this->opts['associated'],
@@ -522,7 +522,7 @@
523523 if ( $explain->exists() ) {
524524 $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
525525 }
526 - $form .= Xml::closeElement('fieldset' ) .
 526+ $form .= Xml::closeElement( 'fieldset' ) .
527527 Xml::closeElement( 'form' );
528528 return $form;
529529 }
@@ -543,7 +543,7 @@
544544
545545 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
546546
547 - foreach( $msgs as $msg ) {
 547+ foreach ( $msgs as $msg ) {
548548 $this->messages[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
549549 }
550550
@@ -577,10 +577,10 @@
578578 $conds = array_merge( $userCond, $this->getNamespaceCond() );
579579
580580 // Paranoia: avoid brute force searches (bug 17342)
581 - if( !$user->isAllowed( 'deletedhistory' ) ) {
582 - $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
583 - } elseif( !$user->isAllowed( 'suppressrevision' ) ) {
584 - $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
 581+ if ( !$user->isAllowed( 'deletedhistory' ) ) {
 582+ $conds[] = $this->mDb->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0';
 583+ } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
 584+ $conds[] = $this->mDb->bitAnd( 'rev_deleted', Revision::SUPPRESSED_USER ) .
585585 ' != ' . Revision::SUPPRESSED_USER;
586586 }
587587
@@ -619,10 +619,10 @@
620620 $condition = array();
621621 $join_conds = array();
622622 $tables = array( 'revision', 'page', 'user' );
623 - if( $this->contribs == 'newbie' ) {
 623+ if ( $this->contribs == 'newbie' ) {
624624 $tables[] = 'user_groups';
625625 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
626 - $condition[] = 'rev_user >' . (int)($max - $max / 100);
 626+ $condition[] = 'rev_user >' . (int)( $max - $max / 100 );
627627 $condition[] = 'ug_group IS NULL';
628628 $index = 'user_timestamp';
629629 # @todo FIXME: Other groups may have 'bot' rights
@@ -636,22 +636,22 @@
637637 $index = 'user_timestamp';
638638 }
639639 }
640 - if( $this->deletedOnly ) {
 640+ if ( $this->deletedOnly ) {
641641 $condition[] = "rev_deleted != '0'";
642642 }
643 - if( $this->topOnly ) {
 643+ if ( $this->topOnly ) {
644644 $condition[] = "rev_id = page_latest";
645645 }
646646 return array( $tables, $index, $condition, $join_conds );
647647 }
648648
649649 function getNamespaceCond() {
650 - if( $this->namespace !== '' ) {
 650+ if ( $this->namespace !== '' ) {
651651 $selectedNS = $this->mDb->addQuotes( $this->namespace );
652652 $eq_op = $this->nsInvert ? '!=' : '=';
653653 $bool_op = $this->nsInvert ? 'AND' : 'OR';
654654
655 - if( !$this->associated ) {
 655+ if ( !$this->associated ) {
656656 return array( "page_namespace $eq_op $selectedNS" );
657657 } else {
658658 $associatedNS = $this->mDb->addQuotes (
@@ -709,7 +709,7 @@
710710 array( 'rev_id', 'rev_len' ),
711711 array( 'rev_id' => $revIds ),
712712 __METHOD__ );
713 - foreach( $res as $row ) {
 713+ foreach ( $res as $row ) {
714714 $revLens[$row->rev_id] = $row->rev_len;
715715 }
716716 wfProfileOut( __METHOD__ );
@@ -749,19 +749,19 @@
750750 );
751751 # Mark current revisions
752752 $topmarktext = '';
753 - if( $row->rev_id == $row->page_latest ) {
 753+ if ( $row->rev_id == $row->page_latest ) {
754754 $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
755755 # Add rollback link
756 - if( !$row->page_is_new && $page->quickUserCan( 'rollback' )
 756+ if ( !$row->page_is_new && $page->quickUserCan( 'rollback' )
757757 && $page->quickUserCan( 'edit' ) )
758758 {
759759 $this->preventClickjacking();
760 - $topmarktext .= ' '.Linker::generateRollback( $rev );
 760+ $topmarktext .= ' ' . Linker::generateRollback( $rev );
761761 }
762762 }
763763 $user = $this->getUser();
764764 # Is there a visible previous revision?
765 - if( $rev->userCan( Revision::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) {
 765+ if ( $rev->userCan( Revision::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) {
766766 $difftext = Linker::linkKnown(
767767 $page,
768768 $this->messages['diff'],
@@ -790,23 +790,23 @@
791791
792792 $comment = $this->getLanguage()->getDirMark() . Linker::revComment( $rev, false, true );
793793 $date = $this->getLanguage()->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
794 - if( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
 794+ if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
795795 $d = Linker::linkKnown(
796796 $page,
797 - htmlspecialchars($date),
 797+ htmlspecialchars( $date ),
798798 array(),
799799 array( 'oldid' => intval( $row->rev_id ) )
800800 );
801801 } else {
802802 $d = htmlspecialchars( $date );
803803 }
804 - if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
 804+ if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
805805 $d = '<span class="history-deleted">' . $d . '</span>';
806806 }
807807
808808 # Show user names for /newbies as there may be different users.
809809 # Note that we already excluded rows with hidden user names.
810 - if( $this->contribs == 'newbie' ) {
 810+ if ( $this->contribs == 'newbie' ) {
811811 $userlink = ' . . ' . Linker::userLink( $rev->getUser(), $rev->getUserText() );
812812 $userlink .= ' ' . wfMsg( 'parentheses',
813813 Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) ) . ' ';
@@ -814,13 +814,13 @@
815815 $userlink = '';
816816 }
817817
818 - if( $rev->getParentId() === 0 ) {
 818+ if ( $rev->getParentId() === 0 ) {
819819 $nflag = ChangesList::flag( 'newpage' );
820820 } else {
821821 $nflag = '';
822822 }
823823
824 - if( $rev->isMinor() ) {
 824+ if ( $rev->isMinor() ) {
825825 $mflag = ChangesList::flag( 'minor' );
826826 } else {
827827 $mflag = '';
@@ -828,8 +828,8 @@
829829
830830 // Don't show useless link to people who cannot hide revisions
831831 $canHide = $user->isAllowed( 'deleterevision' );
832 - if( $canHide || ($rev->getVisibility() && $user->isAllowed('deletedhistory')) ) {
833 - if( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
 832+ if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
 833+ if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
834834 $del = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
835835 } else {
836836 $query = array(
@@ -849,12 +849,12 @@
850850 $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
851851
852852 # Denote if username is redacted for this edit
853 - if( $rev->isDeleted( Revision::DELETED_USER ) ) {
854 - $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";
 853+ if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
 854+ $ret .= " <strong>" . wfMsgHtml( 'rev-deleted-user-contribs' ) . "</strong>";
855855 }
856856
857857 # Tags, if any.
858 - list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
 858+ list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
859859 $classes = array_merge( $classes, $newClasses );
860860 $ret .= " $tagSummary";
861861

Status & tagging log