From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/specials/SpecialDeletedContributions.php | 179 +++++++++++++--------- 1 file changed, 107 insertions(+), 72 deletions(-) (limited to 'includes/specials/SpecialDeletedContributions.php') diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index e374979e..9b9888ad 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -27,13 +27,20 @@ */ class DeletedContribsPager extends IndexPager { public $mDefaultDirection = true; - var $messages, $target; - var $namespace = '', $mDb; + public $messages; + public $target; + public $namespace = ''; + public $mDb; + + /** + * @var string Navigation bar with paging links. + */ + protected $mNavigationBar; function __construct( IContextSource $context, $target, $namespace = false ) { parent::__construct( $context ); $msgs = array( 'deletionlog', 'undeleteviewlink', 'diff' ); - foreach( $msgs as $msg ) { + foreach ( $msgs as $msg ) { $this->messages[$msg] = $this->msg( $msg )->escaped(); } $this->target = $target; @@ -44,6 +51,7 @@ class DeletedContribsPager extends IndexPager { function getDefaultQuery() { $query = parent::getDefaultQuery(); $query['target'] = $this->target; + return $query; } @@ -52,17 +60,18 @@ class DeletedContribsPager extends IndexPager { $conds = array_merge( $userCond, $this->getNamespaceCond() ); $user = $this->getUser(); // Paranoia: avoid brute force searches (bug 17792) - if( !$user->isAllowed( 'deletedhistory' ) ) { + if ( !$user->isAllowed( 'deletedhistory' ) ) { $conds[] = $this->mDb->bitAnd( 'ar_deleted', Revision::DELETED_USER ) . ' = 0'; - } elseif( !$user->isAllowed( 'suppressrevision' ) ) { + } elseif ( !$user->isAllowed( 'suppressrevision' ) ) { $conds[] = $this->mDb->bitAnd( 'ar_deleted', Revision::SUPPRESSED_USER ) . ' != ' . Revision::SUPPRESSED_USER; } + return array( 'tables' => array( 'archive' ), 'fields' => array( - 'ar_rev_id', 'ar_namespace', 'ar_title', 'ar_timestamp', 'ar_comment', 'ar_minor_edit', - 'ar_user', 'ar_user_text', 'ar_deleted' + 'ar_rev_id', 'ar_namespace', 'ar_title', 'ar_timestamp', 'ar_comment', + 'ar_minor_edit', 'ar_user', 'ar_user_text', 'ar_deleted' ), 'conds' => $conds, 'options' => array( 'USE INDEX' => $index ) @@ -107,8 +116,17 @@ class DeletedContribsPager extends IndexPager { $lang = $this->getLanguage(); $limits = $lang->pipeList( $limitLinks ); - $this->mNavigationBar = "(" . $lang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ) . ") " . - $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'], $pagingLinks['next'], $limits )->escaped(); + $firstLast = $lang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ); + $firstLast = $this->msg( 'parentheses' )->rawParams( $firstLast )->escaped(); + $prevNext = $this->msg( 'viewprevnext' ) + ->rawParams( + $pagingLinks['prev'], + $pagingLinks['next'], + $limits + )->escaped(); + $separator = $this->msg( 'word-separator' )->escaped(); + $this->mNavigationBar = $firstLast . $separator . $prevNext; + return $this->mNavigationBar; } @@ -138,15 +156,15 @@ class DeletedContribsPager extends IndexPager { $page = Title::makeTitle( $row->ar_namespace, $row->ar_title ); $rev = new Revision( array( - 'title' => $page, - 'id' => $row->ar_rev_id, - 'comment' => $row->ar_comment, - 'user' => $row->ar_user, - 'user_text' => $row->ar_user_text, - 'timestamp' => $row->ar_timestamp, - 'minor_edit' => $row->ar_minor_edit, - 'deleted' => $row->ar_deleted, - ) ); + 'title' => $page, + 'id' => $row->ar_rev_id, + 'comment' => $row->ar_comment, + 'user' => $row->ar_user, + 'user_text' => $row->ar_user_text, + 'timestamp' => $row->ar_timestamp, + 'minor_edit' => $row->ar_minor_edit, + 'deleted' => $row->ar_deleted, + ) ); $undelete = SpecialPage::getTitleFor( 'Undelete' ); @@ -168,7 +186,7 @@ class DeletedContribsPager extends IndexPager { $user = $this->getUser(); - if( $user->isAllowed( 'deletedtext' ) ) { + if ( $user->isAllowed( 'deletedtext' ) ) { $last = Linker::linkKnown( $undelete, $this->messages['diff'], @@ -184,9 +202,10 @@ class DeletedContribsPager extends IndexPager { } $comment = Linker::revComment( $rev ); - $date = htmlspecialchars( $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $user ) ); + $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $user ); + $date = htmlspecialchars( $date ); - if( !$user->isAllowed( 'undelete' ) || !$rev->userCan( Revision::DELETED_TEXT, $user ) ) { + if ( !$user->isAllowed( 'undelete' ) || !$rev->userCan( Revision::DELETED_TEXT, $user ) ) { $link = $date; // unusable link } else { $link = Linker::linkKnown( @@ -200,7 +219,7 @@ class DeletedContribsPager extends IndexPager { ); } // Style deleted items - if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { + if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) { $link = '' . $link . ''; } @@ -210,7 +229,7 @@ class DeletedContribsPager extends IndexPager { array( 'class' => 'mw-changeslist-title' ) ); - if( $rev->isMinor() ) { + if ( $rev->isMinor() ) { $mflag = ChangesList::flag( 'minor' ); } else { $mflag = ''; @@ -218,7 +237,9 @@ class DeletedContribsPager extends IndexPager { // Revision delete link $del = Linker::getRevDeleteLink( $user, $rev, $page ); - if ( $del ) $del .= ' '; + if ( $del ) { + $del .= ' '; + } $tools = Html::rawElement( 'span', @@ -231,13 +252,14 @@ class DeletedContribsPager extends IndexPager { $ret = "{$del}{$link} {$tools} {$separator} {$mflag} {$pagelink} {$comment}"; # Denote if username is redacted for this edit - if( $rev->isDeleted( Revision::DELETED_USER ) ) { + if ( $rev->isDeleted( Revision::DELETED_USER ) ) { $ret .= " " . $this->msg( 'rev-deleted-user-contribs' )->escaped() . ""; } $ret = Html::rawElement( 'li', array(), $ret ) . "\n"; wfProfileOut( __METHOD__ ); + return $ret; } @@ -254,7 +276,7 @@ class DeletedContribsPager extends IndexPager { class DeletedContributionsPage extends SpecialPage { function __construct() { parent::__construct( 'DeletedContributions', 'deletedhistory', - /*listed*/ true, /*function*/ false, /*file*/ false ); + /*listed*/true, /*function*/false, /*file*/false ); } /** @@ -265,6 +287,7 @@ class DeletedContributionsPage extends SpecialPage { */ function execute( $par ) { global $wgQueryPageDefaultLimit; + $this->setHeaders(); $this->outputHeader(); @@ -272,6 +295,7 @@ class DeletedContributionsPage extends SpecialPage { if ( !$this->userCanExecute( $user ) ) { $this->displayRestrictionError(); + return; } @@ -289,6 +313,7 @@ class DeletedContributionsPage extends SpecialPage { if ( !strlen( $target ) ) { $out->addHTML( $this->getForm( '' ) ); + return; } @@ -298,6 +323,7 @@ class DeletedContributionsPage extends SpecialPage { $userObj = User::newFromName( $target, false ); if ( !$userObj ) { $out->addHTML( $this->getForm( '' ) ); + return; } $this->getSkin()->setRelevantUser( $userObj ); @@ -316,28 +342,33 @@ class DeletedContributionsPage extends SpecialPage { $pager = new DeletedContribsPager( $this->getContext(), $target, $options['namespace'] ); if ( !$pager->getNumRows() ) { $out->addWikiMsg( 'nocontribs' ); + return; } # Show a message about slave lag, if applicable $lag = wfGetLB()->safeGetLag( $pager->getDatabase() ); - if( $lag > 0 ) + if ( $lag > 0 ) { $out->showLagWarning( $lag ); + } $out->addHTML( '

' . $pager->getNavigationBar() . '

' . - $pager->getBody() . - '

' . $pager->getNavigationBar() . '

' ); + $pager->getBody() . + '

' . $pager->getNavigationBar() . '

' ); # If there were contributions, and it was a valid user or IP, show # the appropriate "footer" message - WHOIS tools, etc. - if( $target != 'newbies' ) { - $message = IP::isIPAddress( $target ) - ? 'sp-contributions-footer-anon' - : 'sp-contributions-footer'; - - if( !$this->msg( $message )->isDisabled() ) { - $out->wrapWikiMsg( "", array( $message, $target ) ); + if ( $target != 'newbies' ) { + $message = IP::isIPAddress( $target ) ? + 'sp-contributions-footer-anon' : + 'sp-contributions-footer'; + + if ( !$this->msg( $message )->isDisabled() ) { + $out->wrapWikiMsg( + "", + array( $message, $target ) + ); } } } @@ -358,11 +389,12 @@ class DeletedContributionsPage extends SpecialPage { $nt = $userObj->getUserPage(); $id = $userObj->getID(); $talk = $nt->getTalkPage(); - if( $talk ) { + if ( $talk ) { # Talk page link $tools[] = Linker::link( $talk, $this->msg( 'sp-contributions-talk' )->escaped() ); - if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { - if( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links + if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { + # Block / Change block / Unblock links + if ( $this->getUser()->isAllowed( 'block' ) ) { if ( $userObj->isBlocked() ) { $tools[] = Linker::linkKnown( # Change block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), @@ -377,8 +409,8 @@ class DeletedContributionsPage extends SpecialPage { 'ip' => $nt->getDBkey() ) ); - } - else { # User is not blocked + } else { + # User is not blocked $tools[] = Linker::linkKnown( # Block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), $this->msg( 'blocklink' )->escaped() @@ -419,7 +451,7 @@ class DeletedContributionsPage extends SpecialPage { # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext( $this->getContext() ); - if( $userrightsPage->userCanChangeRights( $userObj ) ) { + if ( $userrightsPage->userCanChangeRights( $userObj ) ) { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ), $this->msg( 'sp-contributions-userrights' )->escaped() @@ -432,7 +464,8 @@ class DeletedContributionsPage extends SpecialPage { // Show a note if the user is blocked and display the last block log entry. if ( $userObj->isBlocked() ) { - $out = $this->getOutput(); // LogEventsList::showLogExtract() wants the first parameter by ref + // LogEventsList::showLogExtract() wants the first parameter by ref + $out = $this->getOutput(); LogEventsList::showLogExtract( $out, 'block', @@ -451,16 +484,7 @@ class DeletedContributionsPage extends SpecialPage { } } - // Old message 'contribsub' had one parameter, but that doesn't work for - // languages that want to put the "for" bit right after $user but before - // $links. If 'contribsub' is around, use it for reverse compatibility, - // otherwise use 'contribsub2'. - $oldMsg = $this->msg( 'contribsub' ); - if ( $oldMsg->exists() ) { - return $oldMsg->rawParams( "$user ($links)" ); - } else { - return $this->msg( 'contribsub2' )->rawParams( $user, $links ); - } + return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() ); } /** @@ -499,27 +523,38 @@ class DeletedContributionsPage extends SpecialPage { $f .= "\t" . Html::hidden( $name, $value ) . "\n"; } - $f .= Xml::openElement( 'fieldset' ) . - Xml::element( 'legend', array(), $this->msg( 'sp-contributions-search' )->text() ) . - Xml::tags( 'label', array( 'for' => 'target' ), $this->msg( 'sp-contributions-username' )->parse() ) . ' ' . - Html::input( 'target', $options['target'], 'text', array( + $f .= Xml::openElement( 'fieldset' ); + $f .= Xml::element( 'legend', array(), $this->msg( 'sp-contributions-search' )->text() ); + $f .= Xml::tags( + 'label', + array( 'for' => 'target' ), + $this->msg( 'sp-contributions-username' )->parse() + ) . ' '; + $f .= Html::input( + 'target', + $options['target'], + 'text', + array( 'size' => '20', 'required' => '' - ) + ( $options['target'] ? array() : array( 'autofocus' ) ) ) . ' '. - Html::namespaceSelector( - array( - 'selected' => $options['namespace'], - 'all' => '', - 'label' => $this->msg( 'namespace' )->text() - ), array( - 'name' => 'namespace', - 'id' => 'namespace', - 'class' => 'namespaceselector', - ) - ) . ' ' . - Xml::submitButton( $this->msg( 'sp-contributions-submit' )->text() ) . - Xml::closeElement( 'fieldset' ) . - Xml::closeElement( 'form' ); + ) + ( $options['target'] ? array() : array( 'autofocus' ) ) + ) . ' '; + $f .= Html::namespaceSelector( + array( + 'selected' => $options['namespace'], + 'all' => '', + 'label' => $this->msg( 'namespace' )->text() + ), + array( + 'name' => 'namespace', + 'id' => 'namespace', + 'class' => 'namespaceselector', + ) + ) . ' '; + $f .= Xml::submitButton( $this->msg( 'sp-contributions-submit' )->text() ); + $f .= Xml::closeElement( 'fieldset' ); + $f .= Xml::closeElement( 'form' ); + return $f; } -- cgit v1.2.3-54-g00ecf