Merge "Revert "Adding sanity check to Title::isRedirect().""
[lhc/web/wiklou.git] / includes / revisiondelete / RevisionDelete.php
index 0ba6675..c63fcf7 100644 (file)
@@ -1,4 +1,26 @@
 <?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
  *
@@ -191,9 +213,11 @@ 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->getLang()->timeanddate( $this->revision->getTimestamp(), true );
+               $date = $this->list->getLanguage()->userTimeAndDate(
+                       $this->revision->getTimestamp(), $this->list->getUser() );
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $date;
                }
@@ -211,15 +235,16 @@ 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(
                                        $this->list->title,
-                                       wfMsgHtml('diff'),
+                                       $this->list->msg( 'diff' )->escaped(),
                                        array(),
                                        array(
                                                'diff' => $this->revision->getId(),
@@ -235,14 +260,14 @@ class RevDel_RevisionItem extends RevDel_Item {
        }
 
        public function getHTML() {
-               $difflink = $this->getDiffLink();
+               $difflink = wfMessage( 'parentheses' )->rawParams( $this->getDiffLink() );
                $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 +323,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() {
@@ -340,7 +365,8 @@ 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()->userTimeAndDate(
+                       $this->revision->getTimestamp(), $this->list->getUser() );
                if ( $this->isDeleted() && !$this->canViewContent() ) {
                        return $date;
                }
@@ -353,10 +379,10 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem {
 
        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( $undelete, $this->list->msg( 'diff' )->escaped(), array(),
                        array(
                                'target' => $this->list->title->getPrefixedText(),
                                'diff' => 'prev',
@@ -375,7 +401,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,9 +595,11 @@ class RevDel_FileItem extends RevDel_Item {
        /**
         * Get the link to the file.
         * Overridden by RevDel_ArchivedFileItem.
+        * @return string
         */
        protected function getLink() {
-               $date = $this->list->getLang()->timeanddate( $this->file->getTimestamp(), true  );
+               $date = $this->list->getLanguage()->userTimeAndDate(
+                       $this->file->getTimestamp(), $this->list->getUser() );
                if ( $this->isDeleted() ) {
                        # Hidden files...
                        if ( !$this->canViewContent() ) {
@@ -604,7 +632,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 +650,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 +660,9 @@ class RevDel_FileItem extends RevDel_Item {
 
        public function getHTML() {
                $data =
-                       wfMsg(
-                               'widthheight',
-                               $this->list->getLang()->formatNum( $this->file->getWidth() ),
-                               $this->list->getLang()->formatNum( $this->file->getHeight() )
-                       ) .
-                       ' (' .
-                       wfMsgExt( 'nbytes', 'parsemag', $this->list->getLang()->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,7 +745,8 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem {
        }
 
        protected function getLink() {
-               $date = $this->list->getLang()->timeanddate( $this->file->getTimestamp(), true  );
+               $date = $this->list->getLanguage()->userTimeAndDate(
+                       $this->file->getTimestamp(), $this->list->getUser() );
                $undelete = SpecialPage::getTitleFor( 'Undelete' );
                $key = $this->file->getKey();
                # Hidden files...
@@ -847,38 +871,29 @@ 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()->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() )
                );
-               // 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>';
-               }
+               $loglink = wfMessage( 'parentheses' )->rawParams( $loglink );
+               // 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>";
        }
 }