Index: trunk/extensions/Oversight/HideRevision_body.php |
— | — | @@ -3,6 +3,27 @@ |
4 | 4 | * Special page handler function for Special:HideRevision |
5 | 5 | */ |
6 | 6 | 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 | + |
7 | 28 | function __construct() { |
8 | 29 | parent::__construct( 'HideRevision', 'hiderevision' ); |
9 | 30 | } |
— | — | @@ -106,6 +127,9 @@ |
107 | 128 | Xml::closeElement( 'form' ) ); |
108 | 129 | } |
109 | 130 | |
| 131 | + /** |
| 132 | + * @return String |
| 133 | + */ |
110 | 134 | function revisionList() { |
111 | 135 | if( !$this->mRevisions ) { |
112 | 136 | return ''; |
— | — | @@ -125,9 +149,12 @@ |
126 | 150 | return $this->makeList( $dbr->resultObject( $result ) ); |
127 | 151 | } |
128 | 152 | |
| 153 | + /** |
| 154 | + * @param $resultSet ResultWrapper |
| 155 | + * @return String |
| 156 | + */ |
129 | 157 | function makeList( $resultSet ) { |
130 | | - global $IP, $wgUser; |
131 | | - require_once( "$IP/includes/ChangesList.php" ); |
| 158 | + global $wgUser; |
132 | 159 | $changes = ChangesList::newFromUser( $wgUser ); |
133 | 160 | |
134 | 161 | $out = $changes->beginRecentChangesList(); |
— | — | @@ -142,6 +169,9 @@ |
143 | 170 | return $out; |
144 | 171 | } |
145 | 172 | |
| 173 | + /** |
| 174 | + * @return string |
| 175 | + */ |
146 | 176 | function archiveList() { |
147 | 177 | if( !$this->mTarget || !$this->mTimestamps ) { |
148 | 178 | return ''; |
— | — | @@ -182,6 +212,9 @@ |
183 | 213 | return $this->makeList( $dbr->resultObject( $result ) ); |
184 | 214 | } |
185 | 215 | |
| 216 | + /** |
| 217 | + * @return string |
| 218 | + */ |
186 | 219 | function revisionFields() { |
187 | 220 | $out = ''; |
188 | 221 | foreach( $this->mRevisions as $id ) { |
— | — | @@ -216,10 +249,11 @@ |
217 | 250 | |
218 | 251 | /** |
219 | 252 | * Go kill the revisions and return status information. |
220 | | - * @param $dbw database |
| 253 | + * @param $dbw DatabaseBase |
221 | 254 | * @return array of wikitext strings with success/failure messages |
222 | 255 | */ |
223 | 256 | function hideRevisions( $dbw ) { |
| 257 | + $success = array(); |
224 | 258 | // Live revisions |
225 | 259 | foreach( $this->mRevisions as $id ) { |
226 | 260 | $success[] = wfMsgHTML( 'hiderevision-status', $id, |
— | — | @@ -238,6 +272,8 @@ |
239 | 273 | |
240 | 274 | /** |
241 | 275 | * Actually go in the database and kill things. |
| 276 | + * @param $dbw DatabaseBase |
| 277 | + * @param $id |
242 | 278 | * @return message key string for success or failure message |
243 | 279 | */ |
244 | 280 | function hideRevision( $dbw, $id ) { |
— | — | @@ -294,6 +330,11 @@ |
295 | 331 | return 'hiderevision-success'; |
296 | 332 | } |
297 | 333 | |
| 334 | + /** |
| 335 | + * @param $dbw DatabaseBase |
| 336 | + * @param $timestamp |
| 337 | + * @return string |
| 338 | + */ |
298 | 339 | function hideArchivedRevision( $dbw, $timestamp ) { |
299 | 340 | $archive = new PageArchive( $this->mTarget ); |
300 | 341 | $rev = $archive->getRevision( $timestamp ); |
— | — | @@ -318,6 +359,12 @@ |
319 | 360 | return 'hiderevision-success'; |
320 | 361 | } |
321 | 362 | |
| 363 | + /** |
| 364 | + * @param $dbw DatabaseBase |
| 365 | + * @param $title Title |
| 366 | + * @param $rev Revision |
| 367 | + * @return bool |
| 368 | + */ |
322 | 369 | function insertRevision( $dbw, $title, $rev ) { |
323 | 370 | global $wgUser; |
324 | 371 | return $dbw->insert( 'hidden', |
— | — | @@ -408,6 +455,11 @@ |
409 | 456 | } |
410 | 457 | } |
411 | 458 | |
| 459 | + /** |
| 460 | + * @param $db DatabaseBase |
| 461 | + * @param $condition |
| 462 | + * @return ResultWrapper |
| 463 | + */ |
412 | 464 | function getRevisions( $db, $condition ) { |
413 | 465 | return $db->select( |
414 | 466 | array( 'hidden', 'user' ), |
— | — | @@ -420,6 +472,9 @@ |
421 | 473 | 'ORDER BY' => 'hidden_on_timestamp DESC' ) ); |
422 | 474 | } |
423 | 475 | |
| 476 | + /** |
| 477 | + * @return array |
| 478 | + */ |
424 | 479 | public function getSelectFields() { |
425 | 480 | return array( 'hidden_page as page_id', |
426 | 481 | 'hidden_namespace as page_namespace', |
— | — | @@ -458,30 +513,36 @@ |
459 | 514 | ); |
460 | 515 | } |
461 | 516 | |
| 517 | + /** |
| 518 | + * @param $row |
| 519 | + * @return string |
| 520 | + */ |
462 | 521 | function listRow( $row ) { |
463 | | - global $wgUser, $wgLang; |
464 | | - $skin = $wgUser->getSkin(); |
| 522 | + global $wgLang; |
465 | 523 | $self = $this->getTitle(); |
466 | 524 | $userPage = Title::makeTitle( NS_USER, $row->user_name ); |
467 | 525 | $victim = Title::makeTitle( $row->page_namespace, $row->page_title ); |
468 | 526 | return "<li>(" . |
469 | | - $skin->makeKnownLinkObj( $self, wfMsgHTML( 'oversight-view' ), |
| 527 | + Linker::makeKnownLinkObj( $self, wfMsgHTML( 'oversight-view' ), |
470 | 528 | 'revision=' . $row->rev_id ) . |
471 | 529 | ") " . |
472 | 530 | "(" . |
473 | | - $skin->makeKnownLinkObj( $self, wfMsgHTML( 'diff' ), |
| 531 | + Linker::makeKnownLinkObj( $self, wfMsgHTML( 'diff' ), |
474 | 532 | 'revision=' . $row->rev_id . '&diff=1') . |
475 | 533 | ") " . |
476 | 534 | $wgLang->timeanddate( wfTimestamp( TS_MW, $row->hidden_on_timestamp ) ) . |
477 | 535 | " " . |
478 | | - $skin->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ) . |
| 536 | + Linker::makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ) . |
479 | 537 | " " . |
480 | | - wfMsgHTML( 'oversight-log-hiderev', $skin->makeLinkObj( $victim ) ) . |
| 538 | + wfMsgHTML( 'oversight-log-hiderev', Linker::makeLinkObj( $victim ) ) . |
481 | 539 | " " . |
482 | | - $skin->commentBlock( $row->hidden_reason ) . |
| 540 | + Linker::commentBlock( $row->hidden_reason ) . |
483 | 541 | "</li>\n"; |
484 | 542 | } |
485 | 543 | |
| 544 | + /** |
| 545 | + * @param $revision array |
| 546 | + */ |
486 | 547 | function showRevision( $revision ) { |
487 | 548 | global $wgOut; |
488 | 549 | |
— | — | @@ -514,9 +575,12 @@ |
515 | 576 | "</div>" ); |
516 | 577 | } |
517 | 578 | } |
518 | | - $dbr->freeResult( $result ); |
519 | 579 | } |
520 | 580 | |
| 581 | + /** |
| 582 | + * @param $row |
| 583 | + * @return String |
| 584 | + */ |
521 | 585 | function revisionInfo( $row ) { |
522 | 586 | global $wgUser; |
523 | 587 | $changes = ChangesList::newFromUser( $wgUser ); |
— | — | @@ -528,6 +592,10 @@ |
529 | 593 | return $out; |
530 | 594 | } |
531 | 595 | |
| 596 | + /** |
| 597 | + * @param $revision REvision |
| 598 | + * @return mixed |
| 599 | + */ |
532 | 600 | function showDiff( $revision ){ |
533 | 601 | global $wgOut; |
534 | 602 | |
— | — | @@ -584,7 +652,6 @@ |
585 | 653 | "</table>" . |
586 | 654 | "</div>\n" ); |
587 | 655 | } |
588 | | - $dbr->freeResult( $result ); |
589 | 656 | } |
590 | 657 | } |
591 | 658 | |
— | — | @@ -594,6 +661,13 @@ |
595 | 662 | class HiddenRevisionsPager extends ReverseChronologicalPager { |
596 | 663 | public $mForm, $mConds, $namespace, $dbKey, $uid; |
597 | 664 | |
| 665 | + /** |
| 666 | + * @param $form |
| 667 | + * @param $conds array |
| 668 | + * @param $title Title|null |
| 669 | + * @param $user User|null |
| 670 | + * @param offender string |
| 671 | + */ |
598 | 672 | function __construct( $form, $conds = array(), $title = null, $user = null, $offender = '' ) { |
599 | 673 | $this->mForm = $form; |
600 | 674 | $this->mConds = $conds; |
— | — | @@ -610,10 +684,17 @@ |
611 | 685 | parent::__construct(); |
612 | 686 | } |
613 | 687 | |
| 688 | + /** |
| 689 | + * @param $row |
| 690 | + * @return mixed |
| 691 | + */ |
614 | 692 | function formatRow( $row ) { |
615 | 693 | return $this->mForm->listRow( $row ); |
616 | 694 | } |
617 | 695 | |
| 696 | + /** |
| 697 | + * @return array |
| 698 | + */ |
618 | 699 | function getQueryInfo() { |
619 | 700 | $conds = $this->mConds; |
620 | 701 | $conds[] = 'hidden_by_user = user_id'; |
— | — | @@ -636,10 +717,16 @@ |
637 | 718 | ); |
638 | 719 | } |
639 | 720 | |
| 721 | + /** |
| 722 | + * @return string |
| 723 | + */ |
640 | 724 | function getIndexField() { |
641 | 725 | return 'hidden_on_timestamp'; |
642 | 726 | } |
643 | 727 | |
| 728 | + /** |
| 729 | + * @return string |
| 730 | + */ |
644 | 731 | function getStartBody() { |
645 | 732 | wfProfileIn( __METHOD__ ); |
646 | 733 | # Do a link batch query |
— | — | @@ -652,6 +739,9 @@ |
653 | 740 | return '<ul>'; |
654 | 741 | } |
655 | 742 | |
| 743 | + /** |
| 744 | + * @return string |
| 745 | + */ |
656 | 746 | function getEndBody() { |
657 | 747 | return '</ul>'; |
658 | 748 | } |