r104172 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104171‎ | r104172 | r104173 >
Date:15:45, 24 November 2011
Author:reedy
Status:ok
Tags:
Comment:
Documentation, explicit member variables

Update $skin-> to Linker::

Removed direct include of ChangeList, it's autoloaded
Modified paths:
  • /trunk/extensions/Oversight/HideRevision_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Oversight/HideRevision_body.php
@@ -3,6 +3,27 @@
44 * Special page handler function for Special:HideRevision
55 */
66 class HideRevisionForm extends SpecialPage {
 7+
 8+ /**
 9+ * @var Title
 10+ */
 11+ protected $mTarget;
 12+
 13+ /**
 14+ * @var bool
 15+ */
 16+ protected $mPopulated;
 17+
 18+ /**
 19+ * @var array
 20+ */
 21+ protected $mRevisions, $mTimestamps;
 22+
 23+ /**
 24+ * @var string
 25+ */
 26+ protected $mReason;
 27+
728 function __construct() {
829 parent::__construct( 'HideRevision', 'hiderevision' );
930 }
@@ -106,6 +127,9 @@
107128 Xml::closeElement( 'form' ) );
108129 }
109130
 131+ /**
 132+ * @return String
 133+ */
110134 function revisionList() {
111135 if( !$this->mRevisions ) {
112136 return '';
@@ -125,9 +149,12 @@
126150 return $this->makeList( $dbr->resultObject( $result ) );
127151 }
128152
 153+ /**
 154+ * @param $resultSet ResultWrapper
 155+ * @return String
 156+ */
129157 function makeList( $resultSet ) {
130 - global $IP, $wgUser;
131 - require_once( "$IP/includes/ChangesList.php" );
 158+ global $wgUser;
132159 $changes = ChangesList::newFromUser( $wgUser );
133160
134161 $out = $changes->beginRecentChangesList();
@@ -142,6 +169,9 @@
143170 return $out;
144171 }
145172
 173+ /**
 174+ * @return string
 175+ */
146176 function archiveList() {
147177 if( !$this->mTarget || !$this->mTimestamps ) {
148178 return '';
@@ -182,6 +212,9 @@
183213 return $this->makeList( $dbr->resultObject( $result ) );
184214 }
185215
 216+ /**
 217+ * @return string
 218+ */
186219 function revisionFields() {
187220 $out = '';
188221 foreach( $this->mRevisions as $id ) {
@@ -216,10 +249,11 @@
217250
218251 /**
219252 * Go kill the revisions and return status information.
220 - * @param $dbw database
 253+ * @param $dbw DatabaseBase
221254 * @return array of wikitext strings with success/failure messages
222255 */
223256 function hideRevisions( $dbw ) {
 257+ $success = array();
224258 // Live revisions
225259 foreach( $this->mRevisions as $id ) {
226260 $success[] = wfMsgHTML( 'hiderevision-status', $id,
@@ -238,6 +272,8 @@
239273
240274 /**
241275 * Actually go in the database and kill things.
 276+ * @param $dbw DatabaseBase
 277+ * @param $id
242278 * @return message key string for success or failure message
243279 */
244280 function hideRevision( $dbw, $id ) {
@@ -294,6 +330,11 @@
295331 return 'hiderevision-success';
296332 }
297333
 334+ /**
 335+ * @param $dbw DatabaseBase
 336+ * @param $timestamp
 337+ * @return string
 338+ */
298339 function hideArchivedRevision( $dbw, $timestamp ) {
299340 $archive = new PageArchive( $this->mTarget );
300341 $rev = $archive->getRevision( $timestamp );
@@ -318,6 +359,12 @@
319360 return 'hiderevision-success';
320361 }
321362
 363+ /**
 364+ * @param $dbw DatabaseBase
 365+ * @param $title Title
 366+ * @param $rev Revision
 367+ * @return bool
 368+ */
322369 function insertRevision( $dbw, $title, $rev ) {
323370 global $wgUser;
324371 return $dbw->insert( 'hidden',
@@ -408,6 +455,11 @@
409456 }
410457 }
411458
 459+ /**
 460+ * @param $db DatabaseBase
 461+ * @param $condition
 462+ * @return ResultWrapper
 463+ */
412464 function getRevisions( $db, $condition ) {
413465 return $db->select(
414466 array( 'hidden', 'user' ),
@@ -420,6 +472,9 @@
421473 'ORDER BY' => 'hidden_on_timestamp DESC' ) );
422474 }
423475
 476+ /**
 477+ * @return array
 478+ */
424479 public function getSelectFields() {
425480 return array( 'hidden_page as page_id',
426481 'hidden_namespace as page_namespace',
@@ -458,30 +513,36 @@
459514 );
460515 }
461516
 517+ /**
 518+ * @param $row
 519+ * @return string
 520+ */
462521 function listRow( $row ) {
463 - global $wgUser, $wgLang;
464 - $skin = $wgUser->getSkin();
 522+ global $wgLang;
465523 $self = $this->getTitle();
466524 $userPage = Title::makeTitle( NS_USER, $row->user_name );
467525 $victim = Title::makeTitle( $row->page_namespace, $row->page_title );
468526 return "<li>(" .
469 - $skin->makeKnownLinkObj( $self, wfMsgHTML( 'oversight-view' ),
 527+ Linker::makeKnownLinkObj( $self, wfMsgHTML( 'oversight-view' ),
470528 'revision=' . $row->rev_id ) .
471529 ") " .
472530 "(" .
473 - $skin->makeKnownLinkObj( $self, wfMsgHTML( 'diff' ),
 531+ Linker::makeKnownLinkObj( $self, wfMsgHTML( 'diff' ),
474532 'revision=' . $row->rev_id . '&diff=1') .
475533 ") " .
476534 $wgLang->timeanddate( wfTimestamp( TS_MW, $row->hidden_on_timestamp ) ) .
477535 " " .
478 - $skin->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ) .
 536+ Linker::makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ) .
479537 " " .
480 - wfMsgHTML( 'oversight-log-hiderev', $skin->makeLinkObj( $victim ) ) .
 538+ wfMsgHTML( 'oversight-log-hiderev', Linker::makeLinkObj( $victim ) ) .
481539 " " .
482 - $skin->commentBlock( $row->hidden_reason ) .
 540+ Linker::commentBlock( $row->hidden_reason ) .
483541 "</li>\n";
484542 }
485543
 544+ /**
 545+ * @param $revision array
 546+ */
486547 function showRevision( $revision ) {
487548 global $wgOut;
488549
@@ -514,9 +575,12 @@
515576 "</div>" );
516577 }
517578 }
518 - $dbr->freeResult( $result );
519579 }
520580
 581+ /**
 582+ * @param $row
 583+ * @return String
 584+ */
521585 function revisionInfo( $row ) {
522586 global $wgUser;
523587 $changes = ChangesList::newFromUser( $wgUser );
@@ -528,6 +592,10 @@
529593 return $out;
530594 }
531595
 596+ /**
 597+ * @param $revision REvision
 598+ * @return mixed
 599+ */
532600 function showDiff( $revision ){
533601 global $wgOut;
534602
@@ -584,7 +652,6 @@
585653 "</table>" .
586654 "</div>\n" );
587655 }
588 - $dbr->freeResult( $result );
589656 }
590657 }
591658
@@ -594,6 +661,13 @@
595662 class HiddenRevisionsPager extends ReverseChronologicalPager {
596663 public $mForm, $mConds, $namespace, $dbKey, $uid;
597664
 665+ /**
 666+ * @param $form
 667+ * @param $conds array
 668+ * @param $title Title|null
 669+ * @param $user User|null
 670+ * @param offender string
 671+ */
598672 function __construct( $form, $conds = array(), $title = null, $user = null, $offender = '' ) {
599673 $this->mForm = $form;
600674 $this->mConds = $conds;
@@ -610,10 +684,17 @@
611685 parent::__construct();
612686 }
613687
 688+ /**
 689+ * @param $row
 690+ * @return mixed
 691+ */
614692 function formatRow( $row ) {
615693 return $this->mForm->listRow( $row );
616694 }
617695
 696+ /**
 697+ * @return array
 698+ */
618699 function getQueryInfo() {
619700 $conds = $this->mConds;
620701 $conds[] = 'hidden_by_user = user_id';
@@ -636,10 +717,16 @@
637718 );
638719 }
639720
 721+ /**
 722+ * @return string
 723+ */
640724 function getIndexField() {
641725 return 'hidden_on_timestamp';
642726 }
643727
 728+ /**
 729+ * @return string
 730+ */
644731 function getStartBody() {
645732 wfProfileIn( __METHOD__ );
646733 # Do a link batch query
@@ -652,6 +739,9 @@
653740 return '<ul>';
654741 }
655742
 743+ /**
 744+ * @return string
 745+ */
656746 function getEndBody() {
657747 return '</ul>';
658748 }

Status & tagging log