r89874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89873‎ | r89874 | r89875 >
Date:08:30, 11 June 2011
Author:ialex
Status:ok
Tags:
Comment:
* Made Special:RevisionDelete use the local variables stored in the RequestContext object instead of global ones and removed the $skin member
* Also updated classes in includes/revisiondelete that were using the $skin member of Special:RevisionDelete
* Handle action=revisiondelete (or rather action=historysubmit&revisiondelete=1) with an Action object that sets the RequestContext object of the SpecialPage object, and in this case get the target Title object through the context instead of $wgTitle
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/includes/actions/RevisiondeleteAction.php (added) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDelete.php (modified) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDeleteAbstracts.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/revisiondelete/RevisionDelete.php
@@ -170,12 +170,11 @@
171171 * Overridden by RevDel_ArchiveItem.
172172 */
173173 protected function getRevisionLink() {
174 - global $wgLang;
175 - $date = $wgLang->timeanddate( $this->revision->getTimestamp(), true );
 174+ $date = $this->getLang()->timeanddate( $this->revision->getTimestamp(), true );
176175 if ( $this->isDeleted() && !$this->canViewContent() ) {
177176 return $date;
178177 }
179 - return $this->special->skin->link(
 178+ return Linker::link(
180179 $this->list->title,
181180 $date,
182181 array(),
@@ -195,7 +194,7 @@
196195 return wfMsgHtml('diff');
197196 } else {
198197 return
199 - $this->special->skin->link(
 198+ Linker::link(
200199 $this->list->title,
201200 wfMsgHtml('diff'),
202201 array(),
@@ -215,8 +214,8 @@
216215 public function getHTML() {
217216 $difflink = $this->getDiffLink();
218217 $revlink = $this->getRevisionLink();
219 - $userlink = $this->special->skin->revUserLink( $this->revision );
220 - $comment = $this->special->skin->revComment( $this->revision );
 218+ $userlink = Linker::revUserLink( $this->revision );
 219+ $comment = Linker::revComment( $this->revision );
221220 if ( $this->isDeleted() ) {
222221 $revlink = "<span class=\"history-deleted\">$revlink</span>";
223222 }
@@ -298,13 +297,12 @@
299298 }
300299
301300 protected function getRevisionLink() {
302 - global $wgLang;
303301 $undelete = SpecialPage::getTitleFor( 'Undelete' );
304 - $date = $wgLang->timeanddate( $this->revision->getTimestamp(), true );
 302+ $date = $this->getLang()->timeanddate( $this->revision->getTimestamp(), true );
305303 if ( $this->isDeleted() && !$this->canViewContent() ) {
306304 return $date;
307305 }
308 - return $this->special->skin->link( $undelete, $date, array(),
 306+ return Linker::link( $undelete, $date, array(),
309307 array(
310308 'target' => $this->list->title->getPrefixedText(),
311309 'timestamp' => $this->revision->getTimestamp()
@@ -316,7 +314,7 @@
317315 return wfMsgHtml( 'diff' );
318316 }
319317 $undelete = SpecialPage::getTitleFor( 'Undelete' );
320 - return $this->special->skin->link( $undelete, wfMsgHtml('diff'), array(),
 318+ return Linker::link( $undelete, wfMsgHtml('diff'), array(),
321319 array(
322320 'target' => $this->list->title->getPrefixedText(),
323321 'diff' => 'prev',
@@ -508,20 +506,19 @@
509507 * Overridden by RevDel_ArchivedFileItem.
510508 */
511509 protected function getLink() {
512 - global $wgLang, $wgUser;
513 - $date = $wgLang->timeanddate( $this->file->getTimestamp(), true );
 510+ $date = $this->getLang()->timeanddate( $this->file->getTimestamp(), true );
514511 if ( $this->isDeleted() ) {
515512 # Hidden files...
516513 if ( !$this->canViewContent() ) {
517514 $link = $date;
518515 } else {
519 - $link = $this->special->skin->link(
 516+ $link = Linker::link(
520517 $this->special->getTitle(),
521518 $date, array(),
522519 array(
523520 'target' => $this->list->title->getPrefixedText(),
524521 'file' => $this->file->getArchiveName(),
525 - 'token' => $wgUser->editToken( $this->file->getArchiveName() )
 522+ 'token' => $this->getUser()->editToken( $this->file->getArchiveName() )
526523 )
527524 );
528525 }
@@ -537,8 +534,8 @@
538535 */
539536 protected function getUserTools() {
540537 if( $this->file->userCan( Revision::DELETED_USER ) ) {
541 - $link = $this->special->skin->userLink( $this->file->user, $this->file->user_text ) .
542 - $this->special->skin->userToolLinks( $this->file->user, $this->file->user_text );
 538+ $link = Linker::userLink( $this->file->user, $this->file->user_text ) .
 539+ Linker::userToolLinks( $this->file->user, $this->file->user_text );
543540 } else {
544541 $link = wfMsgHtml( 'rev-deleted-user' );
545542 }
@@ -556,7 +553,7 @@
557554 */
558555 protected function getComment() {
559556 if( $this->file->userCan( File::DELETED_COMMENT ) ) {
560 - $block = $this->special->skin->commentBlock( $this->file->description );
 557+ $block = Linker::commentBlock( $this->file->description );
561558 } else {
562559 $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
563560 }
@@ -567,15 +564,14 @@
568565 }
569566
570567 public function getHTML() {
571 - global $wgLang;
572568 $data =
573569 wfMsg(
574570 'widthheight',
575 - $wgLang->formatNum( $this->file->getWidth() ),
576 - $wgLang->formatNum( $this->file->getHeight() )
 571+ $this->getLang()->formatNum( $this->file->getWidth() ),
 572+ $this->getLang()->formatNum( $this->file->getHeight() )
577573 ) .
578574 ' (' .
579 - wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $this->file->getSize() ) ) .
 575+ wfMsgExt( 'nbytes', 'parsemag', $this->getLang()->formatNum( $this->file->getSize() ) ) .
580576 ')';
581577
582578 return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' .
@@ -641,19 +637,18 @@
642638 }
643639
644640 protected function getLink() {
645 - global $wgLang, $wgUser;
646 - $date = $wgLang->timeanddate( $this->file->getTimestamp(), true );
 641+ $date = $this->getLang()->timeanddate( $this->file->getTimestamp(), true );
647642 $undelete = SpecialPage::getTitleFor( 'Undelete' );
648643 $key = $this->file->getKey();
649644 # Hidden files...
650645 if( !$this->canViewContent() ) {
651646 $link = $date;
652647 } else {
653 - $link = $this->special->skin->link( $undelete, $date, array(),
 648+ $link = Linker::link( $undelete, $date, array(),
654649 array(
655650 'target' => $this->list->title->getPrefixedText(),
656651 'file' => $key,
657 - 'token' => $wgUser->editToken( $key )
 652+ 'token' => $this->getUser()->editToken( $key )
658653 )
659654 );
660655 }
@@ -749,14 +744,12 @@
750745 }
751746
752747 public function getHTML() {
753 - global $wgLang;
754 -
755 - $date = htmlspecialchars( $wgLang->timeanddate( $this->row->log_timestamp ) );
 748+ $date = htmlspecialchars( $this->getLang()->timeanddate( $this->row->log_timestamp ) );
756749 $paramArray = LogPage::extractParams( $this->row->log_params );
757750 $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
758751
759752 // Log link for this page
760 - $loglink = $this->special->skin->link(
 753+ $loglink = Linker::link(
761754 SpecialPage::getTitleFor( 'Log' ),
762755 wfMsgHtml( 'log' ),
763756 array(),
@@ -767,18 +760,18 @@
768761 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
769762 } else {
770763 $action = LogPage::actionText( $this->row->log_type, $this->row->log_action, $title,
771 - $this->special->skin, $paramArray, true, true );
 764+ $this->special->getSkin(), $paramArray, true, true );
772765 if( $this->row->log_deleted & LogPage::DELETED_ACTION )
773766 $action = '<span class="history-deleted">' . $action . '</span>';
774767 }
775768 // User links
776 - $userLink = $this->special->skin->userLink( $this->row->log_user,
 769+ $userLink = Linker::userLink( $this->row->log_user,
777770 User::WhoIs( $this->row->log_user ) );
778771 if( LogEventsList::isDeleted($this->row,LogPage::DELETED_USER) ) {
779772 $userLink = '<span class="history-deleted">' . $userLink . '</span>';
780773 }
781774 // Comment
782 - $comment = $wgLang->getDirMark() . $this->special->skin->commentBlock( $this->row->log_comment );
 775+ $comment = $this->getLang()->getDirMark() . Linker::commentBlock( $this->row->log_comment );
783776 if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) {
784777 $comment = '<span class="history-deleted">' . $comment . '</span>';
785778 }
Index: trunk/phase3/includes/revisiondelete/RevisionDeleteAbstracts.php
@@ -331,6 +331,24 @@
332332 }
333333
334334 /**
 335+ * Get the user doing the action
 336+ *
 337+ * @return User object
 338+ */
 339+ public function getUser() {
 340+ return $this->special->getUser();
 341+ }
 342+
 343+ /**
 344+ * Get the language of the user doing the action
 345+ *
 346+ * @return Language object
 347+ */
 348+ public function getLang() {
 349+ return $this->special->getLang();
 350+ }
 351+
 352+ /**
335353 * Create an item object from a DB result row
336354 * @param $row stdclass
337355 */
@@ -429,6 +447,24 @@
430448 }
431449
432450 /**
 451+ * Get the user doing the action
 452+ *
 453+ * @return User object
 454+ */
 455+ public function getUser() {
 456+ return $this->special->getUser();
 457+ }
 458+
 459+ /**
 460+ * Get the language of the user doing the action
 461+ *
 462+ * @return Language object
 463+ */
 464+ public function getLang() {
 465+ return $this->special->getLang();
 466+ }
 467+
 468+ /**
433469 * Returns true if the current user can view the item
434470 */
435471 abstract public function canView();
Index: trunk/phase3/includes/actions/RevisiondeleteAction.php
@@ -0,0 +1,53 @@
 2+<?php
 3+/**
 4+ * An action that just pass the request to Special:RevisionDelete
 5+ *
 6+ * Copyright © 2011 Alexandre Emsenhuber
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ *
 18+ * You should have received a copy of the GNU General Public License
 19+ * along with this program; if not, write to the Free Software
 20+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 21+ *
 22+ * @file
 23+ * @ingroup Actions
 24+ * @author Alexandre Emsenhuber
 25+ */
 26+
 27+class RevisiondeleteAction extends FormlessAction {
 28+
 29+ public function getName() {
 30+ return 'revisiondelete';
 31+ }
 32+
 33+ public function getRestriction() {
 34+ return null;
 35+ }
 36+
 37+ public function requiresUnblock() {
 38+ return false;
 39+ }
 40+
 41+ public function getDescription() {
 42+ return '';
 43+ }
 44+
 45+ public function onView() {
 46+ return '';
 47+ }
 48+
 49+ public function show() {
 50+ $special = SpecialPageFactory::getPage( 'Revisiondelete' );
 51+ $special->setContext( $this->getContext() );
 52+ $special->execute( '' );
 53+ }
 54+}
Property changes on: trunk/phase3/includes/actions/RevisiondeleteAction.php
___________________________________________________________________
Added: svn:eol-style
155 + native
Index: trunk/phase3/includes/AutoLoader.php
@@ -250,6 +250,7 @@
251251 # includes/actions
252252 'CreditsAction' => 'includes/actions/CreditsAction.php',
253253 'PurgeAction' => 'includes/actions/PurgeAction.php',
 254+ 'RevisiondeleteAction' => 'includes/actions/RevisiondeleteAction.php',
254255 'UnwatchAction' => 'includes/actions/WatchAction.php',
255256 'WatchAction' => 'includes/actions/WatchAction.php',
256257
Index: trunk/phase3/includes/Wiki.php
@@ -465,11 +465,6 @@
466466 $history = new HistoryPage( $article );
467467 $history->history();
468468 break;
469 - case 'revisiondelete':
470 - // For show/hide submission from history page
471 - $special = SpecialPageFactory::getPage( 'Revisiondelete' );
472 - $special->execute( '' );
473 - break;
474469 default:
475470 if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) {
476471 $this->context->output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -5030,6 +5030,7 @@
50315031 */
50325032 $wgActions = array(
50335033 'credits' => true,
 5034+ 'revisiondelete' => true,
50345035 'purge' => true,
50355036 'unwatch' => true,
50365037 'watch' => true,
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -28,9 +28,6 @@
2929 * @ingroup SpecialPage
3030 */
3131 class SpecialRevisionDelete extends UnlistedSpecialPage {
32 - /** Skin object */
33 - var $skin;
34 -
3532 /** True if the submit button was clicked, and the form was posted */
3633 var $submitClicked;
3734
@@ -114,43 +111,46 @@
115112 }
116113
117114 public function execute( $par ) {
118 - global $wgOut, $wgUser, $wgRequest;
119 - if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
120 - $wgOut->permissionRequired( 'deletedhistory' );
 115+ $output = $this->getOutput();
 116+ $user = $this->getUser();
 117+ if( !$user->isAllowed( 'deletedhistory' ) ) {
 118+ $output->permissionRequired( 'deletedhistory' );
121119 return;
122120 } else if( wfReadOnly() ) {
123 - $wgOut->readOnlyPage();
 121+ $output->readOnlyPage();
124122 return;
125123 }
126 - $this->mIsAllowed = $wgUser->isAllowed('deleterevision'); // for changes
127 - $this->skin = $wgUser->getSkin();
 124+ $this->mIsAllowed = $user->isAllowed('deleterevision'); // for changes
128125 $this->setHeaders();
129126 $this->outputHeader();
130 - $this->submitClicked = $wgRequest->wasPosted() && $wgRequest->getBool( 'wpSubmit' );
 127+ $request = $this->getRequest();
 128+ $this->submitClicked = $request->wasPosted() && $request->getBool( 'wpSubmit' );
131129 # Handle our many different possible input types.
132 - $ids = $wgRequest->getVal( 'ids' );
 130+ $ids = $request->getVal( 'ids' );
133131 if ( !is_null( $ids ) ) {
134132 # Allow CSV, for backwards compatibility, or a single ID for show/hide links
135133 $this->ids = explode( ',', $ids );
136134 } else {
137135 # Array input
138 - $this->ids = array_keys( $wgRequest->getArray('ids',array()) );
 136+ $this->ids = array_keys( $request->getArray('ids',array()) );
139137 }
140138 // $this->ids = array_map( 'intval', $this->ids );
141139 $this->ids = array_unique( array_filter( $this->ids ) );
142140
143 - if ( $wgRequest->getVal( 'action' ) == 'historysubmit' ) {
144 - # For show/hide form submission from history page
145 - $this->targetObj = $GLOBALS['wgTitle'];
 141+ if ( $request->getVal( 'action' ) == 'historysubmit' ) {
 142+ // For show/hide form submission from history page
 143+ // Since we are access through index.php?title=XXX&action=historysubmit
 144+ // getFullTitle() will contain the target title and not our title
 145+ $this->targetObj = $this->getFullTitle();
146146 $this->typeName = 'revision';
147147 } else {
148 - $this->typeName = $wgRequest->getVal( 'type' );
149 - $this->targetObj = Title::newFromText( $wgRequest->getText( 'target' ) );
 148+ $this->typeName = $request->getVal( 'type' );
 149+ $this->targetObj = Title::newFromText( $request->getText( 'target' ) );
150150 }
151151
152152 # For reviewing deleted files...
153 - $this->archiveName = $wgRequest->getVal( 'file' );
154 - $this->token = $wgRequest->getVal( 'token' );
 153+ $this->archiveName = $request->getVal( 'file' );
 154+ $this->token = $request->getVal( 'token' );
155155 if ( $this->archiveName && $this->targetObj ) {
156156 $this->tryShowFile( $this->archiveName );
157157 return;
@@ -162,7 +162,7 @@
163163
164164 # No targets?
165165 if( !isset( self::$allowedTypes[$this->typeName] ) || count( $this->ids ) == 0 ) {
166 - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
 166+ $output->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
167167 return;
168168 }
169169 $this->typeInfo = self::$allowedTypes[$this->typeName];
@@ -175,10 +175,10 @@
176176 $this->targetObj = $rev ? $rev->getTitle() : $this->targetObj;
177177 }
178178
179 - $this->otherReason = $wgRequest->getVal( 'wpReason' );
 179+ $this->otherReason = $request->getVal( 'wpReason' );
180180 # We need a target page!
181181 if( is_null($this->targetObj) ) {
182 - $wgOut->addWikiMsg( 'undelete-header' );
 182+ $output->addWikiMsg( 'undelete-header' );
183183 return;
184184 }
185185 # Give a link to the logs/hist for this page
@@ -190,27 +190,27 @@
191191 array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ),
192192 array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER )
193193 );
194 - if( $wgUser->isAllowed('suppressrevision') ) {
 194+ if( $user->isAllowed('suppressrevision') ) {
195195 $this->checks[] = array( 'revdelete-hide-restricted',
196196 'wpHideRestricted', Revision::DELETED_RESTRICTED );
197197 }
198198
199199 # Either submit or create our form
200200 if( $this->mIsAllowed && $this->submitClicked ) {
201 - $this->submit( $wgRequest );
 201+ $this->submit( $request );
202202 } else {
203203 $this->showForm();
204204 }
205205
206206 $qc = $this->getLogQueryCond();
207207 # Show relevant lines from the deletion log
208 - $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
209 - LogEventsList::showLogExtract( $wgOut, 'delete',
 208+ $output->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
 209+ LogEventsList::showLogExtract( $output, 'delete',
210210 $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) );
211211 # Show relevant lines from the suppression log
212 - if( $wgUser->isAllowed( 'suppressionlog' ) ) {
213 - $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
214 - LogEventsList::showLogExtract( $wgOut, 'suppress',
 212+ if( $user->isAllowed( 'suppressionlog' ) ) {
 213+ $output->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
 214+ LogEventsList::showLogExtract( $output, 'suppress',
215215 $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) );
216216 }
217217 }
@@ -219,11 +219,10 @@
220220 * Show some useful links in the subtitle
221221 */
222222 protected function showConvenienceLinks() {
223 - global $wgOut, $wgUser, $wgLang;
224223 # Give a link to the logs/hist for this page
225224 if( $this->targetObj ) {
226225 $links = array();
227 - $links[] = $this->skin->linkKnown(
 226+ $links[] = Linker::linkKnown(
228227 SpecialPage::getTitleFor( 'Log' ),
229228 wfMsgHtml( 'viewpagelogs' ),
230229 array(),
@@ -231,16 +230,16 @@
232231 );
233232 if ( $this->targetObj->getNamespace() != NS_SPECIAL ) {
234233 # Give a link to the page history
235 - $links[] = $this->skin->linkKnown(
 234+ $links[] = Linker::linkKnown(
236235 $this->targetObj,
237236 wfMsgHtml( 'pagehist' ),
238237 array(),
239238 array( 'action' => 'history' )
240239 );
241240 # Link to deleted edits
242 - if( $wgUser->isAllowed('undelete') ) {
 241+ if( $this->getUser()->isAllowed('undelete') ) {
243242 $undelete = SpecialPage::getTitleFor( 'Undelete' );
244 - $links[] = $this->skin->linkKnown(
 243+ $links[] = Linker::linkKnown(
245244 $undelete,
246245 wfMsgHtml( 'deletedhist' ),
247246 array(),
@@ -249,7 +248,7 @@
250249 }
251250 }
252251 # Logs themselves don't have histories or archived revisions
253 - $wgOut->setSubtitle( '<p>' . $wgLang->pipeList( $links ) . '</p>' );
 252+ $this->getOutput()->setSubtitle( '<p>' . $this->getLang()->pipeList( $links ) . '</p>' );
254253 }
255254 }
256255
@@ -271,36 +270,34 @@
272271 * TODO Mostly copied from Special:Undelete. Refactor.
273272 */
274273 protected function tryShowFile( $archiveName ) {
275 - global $wgOut, $wgRequest, $wgUser, $wgLang;
276 -
277274 $repo = RepoGroup::singleton()->getLocalRepo();
278275 $oimage = $repo->newFromArchiveName( $this->targetObj, $archiveName );
279276 $oimage->load();
280277 // Check if user is allowed to see this file
281278 if ( !$oimage->exists() ) {
282 - $wgOut->addWikiMsg( 'revdelete-no-file' );
 279+ $this->getOutput()->addWikiMsg( 'revdelete-no-file' );
283280 return;
284281 }
285282 if( !$oimage->userCan(File::DELETED_FILE) ) {
286283 if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
287 - $wgOut->permissionRequired( 'suppressrevision' );
 284+ $this->getOutput()->permissionRequired( 'suppressrevision' );
288285 } else {
289 - $wgOut->permissionRequired( 'deletedtext' );
 286+ $this->getOutput()->permissionRequired( 'deletedtext' );
290287 }
291288 return;
292289 }
293 - if ( !$wgUser->matchEditToken( $this->token, $archiveName ) ) {
294 - $wgOut->addWikiMsg( 'revdelete-show-file-confirm',
 290+ if ( !$this->getUser()->matchEditToken( $this->token, $archiveName ) ) {
 291+ $this->getOutput()->addWikiMsg( 'revdelete-show-file-confirm',
295292 $this->targetObj->getText(),
296 - $wgLang->date( $oimage->getTimestamp() ),
297 - $wgLang->time( $oimage->getTimestamp() ) );
298 - $wgOut->addHTML(
 293+ $this->getLang()->date( $oimage->getTimestamp() ),
 294+ $this->getLang()->time( $oimage->getTimestamp() ) );
 295+ $this->getOutput()->addHTML(
299296 Xml::openElement( 'form', array(
300297 'method' => 'POST',
301298 'action' => $this->getTitle()->getLocalUrl(
302299 'target=' . urlencode( $oimage->getName() ) .
303300 '&file=' . urlencode( $archiveName ) .
304 - '&token=' . urlencode( $wgUser->editToken( $archiveName ) ) )
 301+ '&token=' . urlencode( $this->getUser()->editToken( $archiveName ) ) )
305302 )
306303 ) .
307304 Xml::submitButton( wfMsg( 'revdelete-show-file-submit' ) ) .
@@ -308,14 +305,14 @@
309306 );
310307 return;
311308 }
312 - $wgOut->disable();
 309+ $this->getOutput()->disable();
313310 # We mustn't allow the output to be Squid cached, otherwise
314311 # if an admin previews a deleted image, and it's cached, then
315312 # a user without appropriate permissions can toddle off and
316313 # nab the image, and Squid will serve it
317 - $wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
318 - $wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
319 - $wgRequest->response()->header( 'Pragma: no-cache' );
 314+ $this->getRequest()->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
 315+ $this->getRequest()->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
 316+ $this->getRequest()->response()->header( 'Pragma: no-cache' );
320317
321318 # Stream the file to the client
322319 global $IP;
@@ -341,17 +338,16 @@
342339 * which will allow the user to choose new visibility settings.
343340 */
344341 protected function showForm() {
345 - global $wgOut, $wgUser, $wgLang;
346342 $UserAllowed = true;
347343
348344 if ( $this->typeName == 'logging' ) {
349 - $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->ids) ) );
 345+ $this->getOutput()->addWikiMsg( 'logdelete-selected', $this->getLang()->formatNum( count($this->ids) ) );
350346 } else {
351 - $wgOut->addWikiMsg( 'revdelete-selected',
 347+ $this->getOutput()->addWikiMsg( 'revdelete-selected',
352348 $this->targetObj->getPrefixedText(), count( $this->ids ) );
353349 }
354350
355 - $wgOut->addHTML( "<ul>" );
 351+ $this->getOutput()->addHTML( "<ul>" );
356352
357353 $numRevisions = 0;
358354 // Live revisions...
@@ -360,21 +356,21 @@
361357 $item = $list->current();
362358 if ( !$item->canView() ) {
363359 if( !$this->submitClicked ) {
364 - $wgOut->permissionRequired( 'suppressrevision' );
 360+ $this->getOutput()->permissionRequired( 'suppressrevision' );
365361 return;
366362 }
367363 $UserAllowed = false;
368364 }
369365 $numRevisions++;
370 - $wgOut->addHTML( $item->getHTML() );
 366+ $this->getOutput()->addHTML( $item->getHTML() );
371367 }
372368
373369 if( !$numRevisions ) {
374 - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
 370+ $this->getOutput()->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
375371 return;
376372 }
377373
378 - $wgOut->addHTML( "</ul>" );
 374+ $this->getOutput()->addHTML( "</ul>" );
379375 // Explanation text
380376 $this->addUsageText();
381377
@@ -414,7 +410,7 @@
415411 '</td>' .
416412 "</tr>\n" .
417413 Xml::closeElement( 'table' ) .
418 - Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
 414+ Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) .
419415 Html::hidden( 'target', $this->targetObj->getPrefixedText() ) .
420416 Html::hidden( 'type', $this->typeName ) .
421417 Html::hidden( 'ids', implode( ',', $this->ids ) ) .
@@ -425,9 +421,9 @@
426422 if( $this->mIsAllowed ) {
427423 $out .= Xml::closeElement( 'form' ) . "\n";
428424 // Show link to edit the dropdown reasons
429 - if( $wgUser->isAllowed( 'editinterface' ) ) {
 425+ if( $this->getUser()->isAllowed( 'editinterface' ) ) {
430426 $title = Title::makeTitle( NS_MEDIAWIKI, 'revdelete-reason-dropdown' );
431 - $link = $wgUser->getSkin()->link(
 427+ $link = Linker::link(
432428 $title,
433429 wfMsgHtml( 'revdelete-edit-reasonlist' ),
434430 array(),
@@ -436,7 +432,7 @@
437433 $out .= Xml::tags( 'p', array( 'class' => 'mw-revdel-editreasons' ), $link ) . "\n";
438434 }
439435 }
440 - $wgOut->addHTML( $out );
 436+ $this->getOutput()->addHTML( $out );
441437 }
442438
443439 /**
@@ -444,13 +440,12 @@
445441 * @todo FIXME: Wikimedia-specific policy text
446442 */
447443 protected function addUsageText() {
448 - global $wgOut, $wgUser;
449 - $wgOut->addWikiMsg( 'revdelete-text' );
450 - if( $wgUser->isAllowed( 'suppressrevision' ) ) {
451 - $wgOut->addWikiMsg( 'revdelete-suppress-text' );
 444+ $this->getOutput()->addWikiMsg( 'revdelete-text' );
 445+ if( $this->getUser()->isAllowed( 'suppressrevision' ) ) {
 446+ $this->getOutput()->addWikiMsg( 'revdelete-suppress-text' );
452447 }
453448 if( $this->mIsAllowed ) {
454 - $wgOut->addWikiMsg( 'revdelete-confirm' );
 449+ $this->getOutput()->addWikiMsg( 'revdelete-confirm' );
455450 }
456451 }
457452
@@ -458,8 +453,6 @@
459454 * @return String: HTML
460455 */
461456 protected function buildCheckBoxes() {
462 - global $wgRequest;
463 -
464457 $html = '<table>';
465458 // If there is just one item, use checkboxes
466459 $list = $this->getList();
@@ -467,7 +460,7 @@
468461 $list->reset();
469462 $bitfield = $list->current()->getBits(); // existing field
470463 if( $this->submitClicked ) {
471 - $bitfield = $this->extractBitfield( $this->extractBitParams($wgRequest), $bitfield );
 464+ $bitfield = $this->extractBitfield( $this->extractBitParams(), $bitfield );
472465 }
473466 foreach( $this->checks as $item ) {
474467 list( $message, $name, $field ) = $item;
@@ -488,7 +481,7 @@
489482 list( $message, $name, $field ) = $item;
490483 // If there are several items, use third state by default...
491484 if( $this->submitClicked ) {
492 - $selected = $wgRequest->getInt( $name, 0 /* unchecked */ );
 485+ $selected = $this->getRequest()->getInt( $name, 0 /* unchecked */ );
493486 } else {
494487 $selected = -1; // use existing field
495488 }
@@ -510,17 +503,15 @@
511504
512505 /**
513506 * UI entry point for form submission.
514 - * @param $request WebRequest
515507 */
516 - protected function submit( $request ) {
517 - global $wgUser, $wgOut;
 508+ protected function submit() {
518509 # Check edit token on submission
519 - if( $this->submitClicked && !$wgUser->matchEditToken( $request->getVal('wpEditToken') ) ) {
520 - $wgOut->addWikiMsg( 'sessionfailure' );
 510+ if( $this->submitClicked && !$this->getUser()->matchEditToken( $this->getRequest()->getVal('wpEditToken') ) ) {
 511+ $this->getOutput()->addWikiMsg( 'sessionfailure' );
521512 return false;
522513 }
523 - $bitParams = $this->extractBitParams( $request );
524 - $listReason = $request->getText( 'wpRevDeleteReasonList', 'other' ); // from dropdown
 514+ $bitParams = $this->extractBitParams();
 515+ $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' ); // from dropdown
525516 $comment = $listReason;
526517 if( $comment != 'other' && $this->otherReason != '' ) {
527518 // Entry from drop down menu + additional comment
@@ -529,8 +520,8 @@
530521 $comment = $this->otherReason;
531522 }
532523 # Can the user set this field?
533 - if( $bitParams[Revision::DELETED_RESTRICTED]==1 && !$wgUser->isAllowed('suppressrevision') ) {
534 - $wgOut->permissionRequired( 'suppressrevision' );
 524+ if( $bitParams[Revision::DELETED_RESTRICTED]==1 && !$this->getUser()->isAllowed('suppressrevision') ) {
 525+ $this->getOutput()->permissionRequired( 'suppressrevision' );
535526 return false;
536527 }
537528 # If the save went through, go to success message...
@@ -549,9 +540,8 @@
550541 * Report that the submit operation succeeded
551542 */
552543 protected function success() {
553 - global $wgOut;
554 - $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
555 - $wgOut->wrapWikiMsg( "<span class=\"success\">\n$1\n</span>", $this->typeInfo['success'] );
 544+ $this->getOutput()->setPagetitle( wfMsg( 'actioncomplete' ) );
 545+ $this->getOutput()->wrapWikiMsg( "<span class=\"success\">\n$1\n</span>", $this->typeInfo['success'] );
556546 $this->list->reloadFromMaster();
557547 $this->showForm();
558548 }
@@ -560,22 +550,21 @@
561551 * Report that the submit operation failed
562552 */
563553 protected function failure( $status ) {
564 - global $wgOut;
565 - $wgOut->setPagetitle( wfMsg( 'actionfailed' ) );
566 - $wgOut->addWikiText( $status->getWikiText( $this->typeInfo['failure'] ) );
 554+ $this->getOutput()->setPagetitle( wfMsg( 'actionfailed' ) );
 555+ $this->getOutput()->addWikiText( $status->getWikiText( $this->typeInfo['failure'] ) );
567556 $this->showForm();
568557 }
569558
570559 /**
571560 * Put together an array that contains -1, 0, or the *_deleted const for each bit
572 - * @param $request WebRequest
 561+ *
573562 * @return array
574563 */
575 - protected function extractBitParams( $request ) {
 564+ protected function extractBitParams() {
576565 $bitfield = array();
577566 foreach( $this->checks as $item ) {
578567 list( /* message */ , $name, $field ) = $item;
579 - $val = $request->getInt( $name, 0 /* unchecked */ );
 568+ $val = $this->getRequest()->getInt( $name, 0 /* unchecked */ );
580569 if( $val < -1 || $val > 1) {
581570 $val = -1; // -1 for existing value
582571 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r89875And I forgot to commit this file in r89874ialex08:40, 11 June 2011

Status & tagging log