diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
commit | d9022f63880ce039446fba8364f68e656b7bf4cb (patch) | |
tree | 16b40fbf17bf7c9ee6f4ead25b16dd192378050a /includes/revisiondelete | |
parent | 27cf83d177256813e2e802241085fce5dd0f3fb9 (diff) |
Update to MediaWiki 1.19.0
Diffstat (limited to 'includes/revisiondelete')
-rw-r--r-- | includes/revisiondelete/RevisionDelete.php | 74 | ||||
-rw-r--r-- | includes/revisiondelete/RevisionDeleteAbstracts.php | 4 | ||||
-rw-r--r-- | includes/revisiondelete/RevisionDeleter.php | 88 |
3 files changed, 60 insertions, 106 deletions
diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index b329fc4b..6cee6246 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -25,14 +25,18 @@ class RevDel_RevisionList extends RevDel_List { */ public function doQuery( $db ) { $ids = array_map( 'intval', $this->ids ); - $live = $db->select( array('revision','page'), '*', + $live = $db->select( + array( 'revision', 'page', 'user' ), + array_merge( Revision::selectFields(), Revision::selectUserFields() ), array( 'rev_page' => $this->title->getArticleID(), 'rev_id' => $ids, - 'rev_page = page_id' ), __METHOD__, - array( 'ORDER BY' => 'rev_id DESC' ) + array( 'ORDER BY' => 'rev_id DESC' ), + array( + 'page' => Revision::pageJoinCond(), + 'user' => Revision::userJoinCond() ) ); if ( $live->numRows() >= count( $ids ) ) { @@ -128,19 +132,19 @@ class RevDel_RevisionItem extends RevDel_Item { } public function getAuthorNameField() { - return 'rev_user_text'; + return 'user_name'; // see Revision::selectUserFields() } public function canView() { - return $this->revision->userCan( Revision::DELETED_RESTRICTED ); + return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->list->getUser() ); } public function canViewContent() { - return $this->revision->userCan( Revision::DELETED_TEXT ); + return $this->revision->userCan( Revision::DELETED_TEXT, $this->list->getUser() ); } public function getBits() { - return $this->revision->mDeleted; + return $this->revision->getVisibility(); } public function setBits( $bits ) { @@ -189,7 +193,7 @@ class RevDel_RevisionItem extends RevDel_Item { * Overridden by RevDel_ArchiveItem. */ protected function getRevisionLink() { - $date = $this->list->getLang()->timeanddate( $this->revision->getTimestamp(), true ); + $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true ); if ( $this->isDeleted() && !$this->canViewContent() ) { return $date; } @@ -336,7 +340,7 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem { protected function getRevisionLink() { $undelete = SpecialPage::getTitleFor( 'Undelete' ); - $date = $this->list->getLang()->timeanddate( $this->revision->getTimestamp(), true ); + $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true ); if ( $this->isDeleted() && !$this->canViewContent() ) { return $date; } @@ -509,11 +513,11 @@ class RevDel_FileItem extends RevDel_Item { } public function canView() { - return $this->file->userCan( File::DELETED_RESTRICTED ); + return $this->file->userCan( File::DELETED_RESTRICTED, $this->list->getUser() ); } public function canViewContent() { - return $this->file->userCan( File::DELETED_FILE ); + return $this->file->userCan( File::DELETED_FILE, $this->list->getUser() ); } public function getBits() { @@ -567,7 +571,7 @@ class RevDel_FileItem extends RevDel_Item { * Overridden by RevDel_ArchivedFileItem. */ protected function getLink() { - $date = $this->list->getLang()->timeanddate( $this->file->getTimestamp(), true ); + $date = $this->list->getLanguage()->timeanddate( $this->file->getTimestamp(), true ); if ( $this->isDeleted() ) { # Hidden files... if ( !$this->canViewContent() ) { @@ -580,7 +584,7 @@ class RevDel_FileItem extends RevDel_Item { array( 'target' => $this->list->title->getPrefixedText(), 'file' => $this->file->getArchiveName(), - 'token' => $this->list->getUser()->editToken( + 'token' => $this->list->getUser()->getEditToken( $this->file->getArchiveName() ) ) ); @@ -596,7 +600,7 @@ class RevDel_FileItem extends RevDel_Item { * @return string HTML */ protected function getUserTools() { - if( $this->file->userCan( Revision::DELETED_USER ) ) { + if( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) { $link = Linker::userLink( $this->file->user, $this->file->user_text ) . Linker::userToolLinks( $this->file->user, $this->file->user_text ); } else { @@ -615,7 +619,7 @@ class RevDel_FileItem extends RevDel_Item { * @return string HTML */ protected function getComment() { - if( $this->file->userCan( File::DELETED_COMMENT ) ) { + if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) { $block = Linker::commentBlock( $this->file->description ); } else { $block = ' ' . wfMsgHtml( 'rev-deleted-comment' ); @@ -630,11 +634,11 @@ class RevDel_FileItem extends RevDel_Item { $data = wfMsg( 'widthheight', - $this->list->getLang()->formatNum( $this->file->getWidth() ), - $this->list->getLang()->formatNum( $this->file->getHeight() ) + $this->list->getLanguage()->formatNum( $this->file->getWidth() ), + $this->list->getLanguage()->formatNum( $this->file->getHeight() ) ) . ' (' . - wfMsgExt( 'nbytes', 'parsemag', $this->list->getLang()->formatNum( $this->file->getSize() ) ) . + wfMsgExt( 'nbytes', 'parsemag', $this->list->getLanguage()->formatNum( $this->file->getSize() ) ) . ')'; return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' . @@ -718,7 +722,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem { } protected function getLink() { - $date = $this->list->getLang()->timeanddate( $this->file->getTimestamp(), true ); + $date = $this->list->getLanguage()->timeanddate( $this->file->getTimestamp(), true ); $undelete = SpecialPage::getTitleFor( 'Undelete' ); $key = $this->file->getKey(); # Hidden files... @@ -729,7 +733,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem { array( 'target' => $this->list->title->getPrefixedText(), 'file' => $key, - 'token' => $this->list->getUser()->editToken( $key ) + 'token' => $this->list->getUser()->getEditToken( $key ) ) ); } @@ -807,7 +811,7 @@ class RevDel_LogItem extends RevDel_Item { } public function canView() { - return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED ); + return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() ); } public function canViewContent() { @@ -843,9 +847,10 @@ class RevDel_LogItem extends RevDel_Item { } public function getHTML() { - $date = htmlspecialchars( $this->list->getLang()->timeanddate( $this->row->log_timestamp ) ); - $paramArray = LogPage::extractParams( $this->row->log_params ); + $date = htmlspecialchars( $this->list->getLanguage()->timeanddate( $this->row->log_timestamp ) ); $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title ); + $formatter = LogFormatter::newFromRow( $this->row ); + $formatter->setAudience( LogFormatter::FOR_THIS_USER ); // Log link for this page $loglink = Linker::link( @@ -854,27 +859,14 @@ class RevDel_LogItem extends RevDel_Item { array(), array( 'page' => $title->getPrefixedText() ) ); - // Action text - if( !$this->canView() ) { - $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; - } else { - $skin = $this->list->getUser()->getSkin(); - $action = LogPage::actionText( $this->row->log_type, $this->row->log_action, - $title, $skin, $paramArray, true, true ); - if( $this->row->log_deleted & LogPage::DELETED_ACTION ) - $action = '<span class="history-deleted">' . $action . '</span>'; - } - // User links - $userLink = Linker::userLink( $this->row->log_user, - User::WhoIs( $this->row->log_user ) ); - if( LogEventsList::isDeleted($this->row,LogPage::DELETED_USER) ) { - $userLink = '<span class="history-deleted">' . $userLink . '</span>'; - } + // User links and action text + $action = $formatter->getActionText(); // Comment - $comment = $this->list->getLang()->getDirMark() . Linker::commentBlock( $this->row->log_comment ); + $comment = $this->list->getLanguage()->getDirMark() . Linker::commentBlock( $this->row->log_comment ); if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) { $comment = '<span class="history-deleted">' . $comment . '</span>'; } - return "<li>($loglink) $date $userLink $action $comment</li>"; + + return "<li>($loglink) $date $action $comment</li>"; } } diff --git a/includes/revisiondelete/RevisionDeleteAbstracts.php b/includes/revisiondelete/RevisionDeleteAbstracts.php index 73af1e5f..dc7af194 100644 --- a/includes/revisiondelete/RevisionDeleteAbstracts.php +++ b/includes/revisiondelete/RevisionDeleteAbstracts.php @@ -6,7 +6,7 @@ * relevant rows, to return RevDel_Item subclasses wrapping them, and * to wrap bulk update operations. */ -abstract class RevDel_List extends Rev_List { +abstract class RevDel_List extends RevisionListBase { function __construct( IContextSource $context, Title $title, array $ids ) { parent::__construct( $context, $title ); $this->ids = $ids; @@ -242,7 +242,7 @@ abstract class RevDel_List extends Rev_List { /** * Abstract base class for deletable items */ -abstract class RevDel_Item extends Rev_Item { +abstract class RevDel_Item extends RevisionItemBase { /** * Returns true if the item is "current", and the operation to set the given * bits can't be executed for that reason diff --git a/includes/revisiondelete/RevisionDeleter.php b/includes/revisiondelete/RevisionDeleter.php index bde586c5..59a9fa82 100644 --- a/includes/revisiondelete/RevisionDeleter.php +++ b/includes/revisiondelete/RevisionDeleter.php @@ -28,18 +28,24 @@ class RevisionDeleter { } /** - * Gets an array of message keys describing the changes made to the visibility - * of the revision. If the resulting array is $arr, then $arr[0] will contain an - * array of strings describing the items that were hidden, $arr[2] will contain - * an array of strings describing the items that were unhidden, and $arr[3] will - * contain an array with a single string, which can be one of "applied - * restrictions to sysops", "removed restrictions from sysops", or null. + * Gets an array of message keys describing the changes made to the + * visibility of the revision. + * + * If the resulting array is $arr, then $arr[0] will contain an array of + * keys describing the items that were hidden, $arr[1] will contain + * an array of keys describing the items that were unhidden, and $arr[2] + * will contain an array with a single message key, which can be one of + * "revdelete-restricted", "revdelete-unrestricted" indicating (un)suppression + * or null to indicate nothing in particular. + * You can turn the keys in $arr[0] and $arr[1] into message keys by + * appending -hid and and -unhid to the keys respectively. * * @param $n Integer: the new bitfield. * @param $o Integer: the old bitfield. * @return An array as described above. + * @since 1.19 public */ - protected static function getChanges( $n, $o ) { + public static function getChanges( $n, $o ) { $diff = $n ^ $o; $ret = array( 0 => array(), 1 => array(), 2 => array() ); // Build bitfield changes in language @@ -59,51 +65,11 @@ class RevisionDeleter { return $ret; } - /** - * Gets a log message to describe the given revision visibility change. This - * message will be of the form "[hid {content, edit summary, username}]; - * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment". - * - * @param $count Integer: The number of effected revisions. - * @param $nbitfield Integer: The new bitfield for the revision. - * @param $obitfield Integer: The old bitfield for the revision. - * @param $language Language object to use - * @param $isForLog Boolean + /** Get DB field name for URL param... + * Future code for other things may also track + * other types of revision-specific changes. + * @return string One of log_id/rev_id/fa_id/ar_timestamp/oi_archive_name */ - public static function getLogMessage( $count, $nbitfield, $obitfield, $language, $isForLog = false ) { - $changes = self::getChanges( $nbitfield, $obitfield ); - array_walk( $changes, array( __CLASS__, 'expandMessageArray' ), $language ); - - $changesText = array(); - - if( count( $changes[0] ) ) { - $changesText[] = wfMsgExt( 'revdelete-hid', array( 'parsemag', 'language' => $language ), $language->commaList( $changes[0] ) ); - } - if( count( $changes[1] ) ) { - $changesText[] = wfMsgExt( 'revdelete-unhid', array( 'parsemag', 'language' => $language ), $language->commaList( $changes[1] ) ); - } - - $s = $language->semicolonList( $changesText ); - if( count( $changes[2] ) ) { - $s .= $s ? ' (' . $changes[2][0] . ')' : ' ' . $changes[2][0]; - } - - $msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message'; - return wfMsgExt( $msg, array( 'parsemag', 'language' => $language ), $s, $language->formatNum($count) ); - } - - private static function expandMessageArray( &$msg, $key, $language ) { - if ( is_array ( $msg ) ) { - array_walk( $msg, array( __CLASS__, 'expandMessageArray' ), $language ); - } else { - $msg = wfMsgExt( $msg, array( 'parsemag', 'language' => $language ) ); - } - } - - // Get DB field name for URL param... - // Future code for other things may also track - // other types of revision-specific changes. - // @returns string One of log_id/rev_id/fa_id/ar_timestamp/oi_archive_name public static function getRelationType( $typeName ) { if ( isset( SpecialRevisionDelete::$deprecatedTypeMap[$typeName] ) ) { $typeName = SpecialRevisionDelete::$deprecatedTypeMap[$typeName]; @@ -147,16 +113,15 @@ class RevisionDeleter { * * @param $title Title * @param $paramArray Array - * @param $skin Skin * @param $messages * @return String */ - public static function getLogLinks( $title, $paramArray, $skin, $messages ) { + public static function getLogLinks( $title, $paramArray, $messages ) { global $wgLang; if ( count( $paramArray ) >= 2 ) { // Different revision types use different URL params... - $originalKey = $key = $paramArray[0]; + $key = $paramArray[0]; // $paramArray[1] is a CSV of the IDs $Ids = explode( ',', $paramArray[1] ); @@ -166,19 +131,18 @@ class RevisionDeleter { if ( count( $Ids ) == 1 ) { // Live revision diffs... if ( in_array( $key, array( 'oldid', 'revision' ) ) ) { - $revert[] = $skin->link( + $revert[] = Linker::linkKnown( $title, $messages['diff'], array(), array( 'diff' => intval( $Ids[0] ), 'unhide' => 1 - ), - array( 'known', 'noclasses' ) + ) ); // Deleted revision diffs... } elseif ( in_array( $key, array( 'artimestamp','archive' ) ) ) { - $revert[] = $skin->link( + $revert[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Undelete' ), $messages['diff'], array(), @@ -186,14 +150,13 @@ class RevisionDeleter { 'target' => $title->getPrefixedDBKey(), 'diff' => 'prev', 'timestamp' => $Ids[0] - ), - array( 'known', 'noclasses' ) + ) ); } } // View/modify link... - $revert[] = $skin->link( + $revert[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Revisiondelete' ), $messages['revdel-restore'], array(), @@ -201,8 +164,7 @@ class RevisionDeleter { 'target' => $title->getPrefixedText(), 'type' => $key, 'ids' => implode(',', $Ids), - ), - array( 'known', 'noclasses' ) + ) ); // Pipe links |