diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
commit | 63601400e476c6cf43d985f3e7b9864681695ed4 (patch) | |
tree | f7846203a952e38aaf66989d0a4702779f549962 /includes/revisiondelete/RevisionDelete.php | |
parent | 8ff01378c9e0207f9169b81966a51def645b6a51 (diff) |
Update to MediaWiki 1.20.2
this update includes:
* adjusted Arch Linux skin
* updated FluxBBAuthPlugin
* patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'includes/revisiondelete/RevisionDelete.php')
-rw-r--r-- | includes/revisiondelete/RevisionDelete.php | 152 |
1 files changed, 94 insertions, 58 deletions
diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index 6cee6246..6ceadff4 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -1,5 +1,27 @@ <?php /** + * Base implementations for deletable items. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup RevisionDelete + */ + +/** * List for revision table items * * This will check both the 'revision' table for live revisions and the @@ -191,13 +213,16 @@ class RevDel_RevisionItem extends RevDel_Item { /** * Get the HTML link to the revision text. * Overridden by RevDel_ArchiveItem. + * @return string */ protected function getRevisionLink() { - $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true ); + $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( + $this->revision->getTimestamp(), $this->list->getUser() ) ); + if ( $this->isDeleted() && !$this->canViewContent() ) { return $date; } - return Linker::link( + return Linker::linkKnown( $this->list->title, $date, array(), @@ -211,38 +236,36 @@ class RevDel_RevisionItem extends RevDel_Item { /** * Get the HTML link to the diff. * Overridden by RevDel_ArchiveItem + * @return string */ protected function getDiffLink() { if ( $this->isDeleted() && !$this->canViewContent() ) { - return wfMsgHtml('diff'); + return $this->list->msg( 'diff' )->escaped(); } else { return - Linker::link( + Linker::linkKnown( $this->list->title, - wfMsgHtml('diff'), + $this->list->msg( 'diff' )->escaped(), array(), array( 'diff' => $this->revision->getId(), 'oldid' => 'prev', 'unhide' => 1 - ), - array( - 'known', - 'noclasses' ) ); } } public function getHTML() { - $difflink = $this->getDiffLink(); + $difflink = $this->list->msg( 'parentheses' ) + ->rawParams( $this->getDiffLink() )->escaped(); $revlink = $this->getRevisionLink(); $userlink = Linker::revUserLink( $this->revision ); $comment = Linker::revComment( $this->revision ); if ( $this->isDeleted() ) { $revlink = "<span class=\"history-deleted\">$revlink</span>"; } - return "<li>($difflink) $revlink $userlink $comment</li>"; + return "<li>$difflink $revlink $userlink $comment</li>"; } } @@ -298,7 +321,7 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem { public function __construct( $list, $row ) { RevDel_Item::__construct( $list, $row ); $this->revision = Revision::newFromArchiveRow( $row, - array( 'page' => $this->list->title->getArticleId() ) ); + array( 'page' => $this->list->title->getArticleID() ) ); } public function getIdField() { @@ -339,29 +362,39 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem { } protected function getRevisionLink() { - $undelete = SpecialPage::getTitleFor( 'Undelete' ); - $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true ); + $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( + $this->revision->getTimestamp(), $this->list->getUser() ) ); + if ( $this->isDeleted() && !$this->canViewContent() ) { return $date; } - return Linker::link( $undelete, $date, array(), + + return Linker::link( + SpecialPage::getTitleFor( 'Undelete' ), + $date, + array(), array( 'target' => $this->list->title->getPrefixedText(), 'timestamp' => $this->revision->getTimestamp() - ) ); + ) + ); } protected function getDiffLink() { if ( $this->isDeleted() && !$this->canViewContent() ) { - return wfMsgHtml( 'diff' ); + return $this->list->msg( 'diff' )->escaped(); } - $undelete = SpecialPage::getTitleFor( 'Undelete' ); - return Linker::link( $undelete, wfMsgHtml('diff'), array(), + + return Linker::link( + SpecialPage::getTitleFor( 'Undelete' ), + $this->list->msg( 'diff' )->escaped(), + array(), array( 'target' => $this->list->title->getPrefixedText(), 'diff' => 'prev', 'timestamp' => $this->revision->getTimestamp() - ) ); + ) + ); } } @@ -375,7 +408,7 @@ class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem { RevDel_Item::__construct( $list, $row ); $this->revision = Revision::newFromArchiveRow( $row, - array( 'page' => $this->list->title->getArticleId() ) ); + array( 'page' => $this->list->title->getArticleID() ) ); } public function getIdField() { @@ -569,31 +602,34 @@ class RevDel_FileItem extends RevDel_Item { /** * Get the link to the file. * Overridden by RevDel_ArchivedFileItem. + * @return string */ protected function getLink() { - $date = $this->list->getLanguage()->timeanddate( $this->file->getTimestamp(), true ); - if ( $this->isDeleted() ) { - # Hidden files... - if ( !$this->canViewContent() ) { - $link = $date; - } else { - $revdelete = SpecialPage::getTitleFor( 'Revisiondelete' ); - $link = Linker::link( - $revdelete, - $date, array(), - array( - 'target' => $this->list->title->getPrefixedText(), - 'file' => $this->file->getArchiveName(), - 'token' => $this->list->getUser()->getEditToken( - $this->file->getArchiveName() ) - ) - ); - } - return '<span class="history-deleted">' . $link . '</span>'; - } else { + $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( + $this->file->getTimestamp(), $this->list->getUser() ) ); + + if ( !$this->isDeleted() ) { # Regular files... - return Xml::element( 'a', array( 'href' => $this->file->getUrl() ), $date ); + return Html::rawElement( 'a', array( 'href' => $this->file->getUrl() ), $date ); } + + # Hidden files... + if ( !$this->canViewContent() ) { + $link = $date; + } else { + $link = Linker::link( + SpecialPage::getTitleFor( 'Revisiondelete' ), + $date, + array(), + array( + 'target' => $this->list->title->getPrefixedText(), + 'file' => $this->file->getArchiveName(), + 'token' => $this->list->getUser()->getEditToken( + $this->file->getArchiveName() ) + ) + ); + } + return '<span class="history-deleted">' . $link . '</span>'; } /** * Generate a user tool link cluster if the current user is allowed to view it @@ -604,7 +640,7 @@ class RevDel_FileItem extends RevDel_Item { $link = Linker::userLink( $this->file->user, $this->file->user_text ) . Linker::userToolLinks( $this->file->user, $this->file->user_text ); } else { - $link = wfMsgHtml( 'rev-deleted-user' ); + $link = $this->list->msg( 'rev-deleted-user' )->escaped(); } if( $this->file->isDeleted( Revision::DELETED_USER ) ) { return '<span class="history-deleted">' . $link . '</span>'; @@ -622,7 +658,7 @@ class RevDel_FileItem extends RevDel_Item { if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) { $block = Linker::commentBlock( $this->file->description ); } else { - $block = ' ' . wfMsgHtml( 'rev-deleted-comment' ); + $block = ' ' . $this->list->msg( 'rev-deleted-comment' )->escaped(); } if( $this->file->isDeleted( File::DELETED_COMMENT ) ) { return "<span class=\"history-deleted\">$block</span>"; @@ -632,14 +668,9 @@ class RevDel_FileItem extends RevDel_Item { public function getHTML() { $data = - wfMsg( - 'widthheight', - $this->list->getLanguage()->formatNum( $this->file->getWidth() ), - $this->list->getLanguage()->formatNum( $this->file->getHeight() ) - ) . - ' (' . - wfMsgExt( 'nbytes', 'parsemag', $this->list->getLanguage()->formatNum( $this->file->getSize() ) ) . - ')'; + $this->list->msg( 'widthheight' )->numParams( + $this->file->getWidth(), $this->file->getHeight() )->text() . + ' (' . $this->list->msg( 'nbytes' )->numParams( $this->file->getSize() )->text() . ')'; return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' . $data . ' ' . $this->getComment(). '</li>'; @@ -722,13 +753,15 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem { } protected function getLink() { - $date = $this->list->getLanguage()->timeanddate( $this->file->getTimestamp(), true ); - $undelete = SpecialPage::getTitleFor( 'Undelete' ); - $key = $this->file->getKey(); + $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( + $this->file->getTimestamp(), $this->list->getUser() ) ); + # Hidden files... if( !$this->canViewContent() ) { $link = $date; } else { + $undelete = SpecialPage::getTitleFor( 'Undelete' ); + $key = $this->file->getKey(); $link = Linker::link( $undelete, $date, array(), array( 'target' => $this->list->title->getPrefixedText(), @@ -847,18 +880,21 @@ class RevDel_LogItem extends RevDel_Item { } public function getHTML() { - $date = htmlspecialchars( $this->list->getLanguage()->timeanddate( $this->row->log_timestamp ) ); + $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( + $this->row->log_timestamp, $this->list->getUser() ) ); $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title ); $formatter = LogFormatter::newFromRow( $this->row ); + $formatter->setContext( $this->list->getContext() ); $formatter->setAudience( LogFormatter::FOR_THIS_USER ); // Log link for this page $loglink = Linker::link( SpecialPage::getTitleFor( 'Log' ), - wfMsgHtml( 'log' ), + $this->list->msg( 'log' )->escaped(), array(), array( 'page' => $title->getPrefixedText() ) ); + $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped(); // User links and action text $action = $formatter->getActionText(); // Comment @@ -867,6 +903,6 @@ class RevDel_LogItem extends RevDel_Item { $comment = '<span class="history-deleted">' . $comment . '</span>'; } - return "<li>($loglink) $date $action $comment</li>"; + return "<li>$loglink $date $action $comment</li>"; } } |