Merge "Follow up change Icc8dc4ae: add new message keys to maintenance scripts"
[lhc/web/wiklou.git] / includes / specials / SpecialRevisiondelete.php
index d307e09..d089c73 100644 (file)
@@ -134,7 +134,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                // $this->ids = array_map( 'intval', $this->ids );
                $this->ids = array_unique( array_filter( $this->ids ) );
 
-               if ( $request->getVal( 'action' ) == 'historysubmit' ) {
+               if ( $request->getVal( 'action' ) == 'historysubmit' || $request->getVal( 'action' ) == 'revisiondelete' ) {
                        // For show/hide form submission from history page
                        // Since we are access through index.php?title=XXX&action=historysubmit
                        // getFullTitle() will contain the target title and not our title
@@ -201,12 +201,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
                $qc = $this->getLogQueryCond();
                # Show relevant lines from the deletion log
-               $output->addHTML( "<h2>" . htmlspecialchars( LogPage::getName( 'delete' ) ) . "</h2>\n" );
+               $output->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
                LogEventsList::showLogExtract( $output, 'delete',
                        $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) );
                # Show relevant lines from the suppression log
                if( $user->isAllowed( 'suppressionlog' ) ) {
-                       $output->addHTML( "<h2>" . htmlspecialchars( LogPage::getName( 'suppress' ) ) . "</h2>\n" );
+                       $output->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
                        LogEventsList::showLogExtract( $output, 'suppress',
                                $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) );
                }
@@ -221,7 +221,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $links = array();
                        $links[] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Log' ),
-                               wfMsgHtml( 'viewpagelogs' ),
+                               $this->msg( 'viewpagelogs' )->escaped(),
                                array(),
                                array( 'page' => $this->targetObj->getPrefixedText() )
                        );
@@ -229,7 +229,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                # Give a link to the page history
                                $links[] = Linker::linkKnown(
                                        $this->targetObj,
-                                       wfMsgHtml( 'pagehist' ),
+                                       $this->msg( 'pagehist' )->escaped(),
                                        array(),
                                        array( 'action' => 'history' )
                                );
@@ -238,7 +238,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                        $undelete = SpecialPage::getTitleFor( 'Undelete' );
                                        $links[] = Linker::linkKnown(
                                                $undelete,
-                                               wfMsgHtml( 'deletedhist' ),
+                                               $this->msg( 'deletedhist' )->escaped(),
                                                array(),
                                                array( 'target' => $this->targetObj->getPrefixedDBkey() )
                                        );
@@ -251,6 +251,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
        /**
         * Get the condition used for fetching log snippets
+        * @return array
         */
        protected function getLogQueryCond() {
                $conds = array();
@@ -275,7 +276,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $this->getOutput()->addWikiMsg( 'revdelete-no-file' );
                        return;
                }
-               if( !$oimage->userCan( File::DELETED_FILE, $this->getUser() ) ) {
+               $user = $this->getUser();
+               if( !$oimage->userCan( File::DELETED_FILE, $user ) ) {
                        if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
                                $this->getOutput()->permissionRequired( 'suppressrevision' );
                        } else {
@@ -283,21 +285,22 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        }
                        return;
                }
-               if ( !$this->getUser()->matchEditToken( $this->token, $archiveName ) ) {
+               if ( !$user->matchEditToken( $this->token, $archiveName ) ) {
+                       $lang = $this->getLanguage();
                        $this->getOutput()->addWikiMsg( 'revdelete-show-file-confirm',
                                $this->targetObj->getText(),
-                               $this->getLanguage()->date( $oimage->getTimestamp() ),
-                               $this->getLanguage()->time( $oimage->getTimestamp() ) );
+                               $lang->userDate( $oimage->getTimestamp(), $user ),
+                               $lang->userTime( $oimage->getTimestamp(), $user ) );
                        $this->getOutput()->addHTML(
                                Xml::openElement( 'form', array(
                                        'method' => 'POST',
                                        'action' => $this->getTitle()->getLocalUrl(
-                                               'target=' . urlencode( $oimage->getName() ) .
+                                               'target=' . urlencode( $this->targetObj->getPrefixedDBkey() ) .
                                                '&file=' . urlencode( $archiveName ) .
-                                               '&token=' . urlencode( $this->getUser()->getEditToken( $archiveName ) ) )
+                                               '&token=' . urlencode( $user->getEditToken( $archiveName ) ) )
                                        )
                                ) .
-                               Xml::submitButton( wfMsg( 'revdelete-show-file-submit' ) ) .
+                               Xml::submitButton( $this->msg( 'revdelete-show-file-submit' )->text() ) .
                                '</form>'
                        );
                        return;
@@ -313,7 +316,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
                $key = $oimage->getStorageKey();
                $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key;
-               StreamFile::stream( $path );
+               $repo->streamFile( $path );
        }
 
        /**
@@ -376,22 +379,23 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $out = Xml::openElement( 'form', array( 'method' => 'post',
                                        'action' => $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) ),
                                        'id' => 'mw-revdel-form-revisions' ) ) .
-                               Xml::fieldset( wfMsg( 'revdelete-legend' ) ) .
+                               Xml::fieldset( $this->msg( 'revdelete-legend' )->text() ) .
                                $this->buildCheckBoxes() .
                                Xml::openElement( 'table' ) .
                                "<tr>\n" .
                                        '<td class="mw-label">' .
-                                               Xml::label( wfMsg( 'revdelete-log' ), 'wpRevDeleteReasonList' ) .
+                                               Xml::label( $this->msg( 'revdelete-log' )->text(), 'wpRevDeleteReasonList' ) .
                                        '</td>' .
                                        '<td class="mw-input">' .
                                                Xml::listDropDown( 'wpRevDeleteReasonList',
-                                                       wfMsgForContent( 'revdelete-reason-dropdown' ),
-                                                       wfMsgForContent( 'revdelete-reasonotherlist' ), '', 'wpReasonDropDown', 1
+                                                       $this->msg( 'revdelete-reason-dropdown' )->inContentLanguage()->text(),
+                                                       $this->msg( 'revdelete-reasonotherlist' )->inContentLanguage()->text(),
+                                                       '', 'wpReasonDropDown', 1
                                                ) .
                                        '</td>' .
                                "</tr><tr>\n" .
                                        '<td class="mw-label">' .
-                                               Xml::label( wfMsg( 'revdelete-otherreason' ), 'wpReason' ) .
+                                               Xml::label( $this->msg( 'revdelete-otherreason' )->text(), 'wpReason' ) .
                                        '</td>' .
                                        '<td class="mw-input">' .
                                                Xml::input( 'wpReason', 60, $this->otherReason, array( 'id' => 'wpReason', 'maxlength' => 100 ) ) .
@@ -399,7 +403,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                "</tr><tr>\n" .
                                        '<td></td>' .
                                        '<td class="mw-submit">' .
-                                               Xml::submitButton( wfMsgExt('revdelete-submit','parsemag',$numRevisions),
+                                               Xml::submitButton( $this->msg( 'revdelete-submit', $numRevisions )->text(),
                                                        array( 'name' => 'wpSubmit' ) ) .
                                        '</td>' .
                                "</tr>\n" .
@@ -419,7 +423,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                $title = Title::makeTitle( NS_MEDIAWIKI, 'revdelete-reason-dropdown' );
                                $link = Linker::link(
                                        $title,
-                                       wfMsgHtml( 'revdelete-edit-reasonlist' ),
+                                       $this->msg( 'revdelete-edit-reasonlist' )->escaped(),
                                        array(),
                                        array( 'action' => 'edit' )
                                );
@@ -458,7 +462,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        }
                        foreach( $this->checks as $item ) {
                                list( $message, $name, $field ) = $item;
-                               $innerHTML = Xml::checkLabel( wfMsg($message), $name, $name, $bitfield & $field );
+                               $innerHTML = Xml::checkLabel( $this->msg( $message )->text(), $name, $name, $bitfield & $field );
                                if( $field == Revision::DELETED_RESTRICTED )
                                        $innerHTML = "<b>$innerHTML</b>";
                                $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
@@ -467,9 +471,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                // Otherwise, use tri-state radios
                } else {
                        $html .= '<tr>';
-                       $html .= '<th class="mw-revdel-checkbox">'.wfMsgHtml('revdelete-radio-same').'</th>';
-                       $html .= '<th class="mw-revdel-checkbox">'.wfMsgHtml('revdelete-radio-unset').'</th>';
-                       $html .= '<th class="mw-revdel-checkbox">'.wfMsgHtml('revdelete-radio-set').'</th>';
+                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
                        $html .= "<th></th></tr>\n";
                        foreach( $this->checks as $item ) {
                                list( $message, $name, $field ) = $item;
@@ -482,7 +486,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                $line = '<td class="mw-revdel-checkbox">' . Xml::radio( $name, -1, $selected == -1 ) . '</td>';
                                $line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 0, $selected == 0 ) . '</td>';
                                $line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 1, $selected == 1 ) . '</td>';
-                               $label = wfMsgHtml($message);
+                               $label = $this->msg( $message )->escaped();
                                if( $field == Revision::DELETED_RESTRICTED ) {
                                        $label = "<b>$label</b>";
                                }
@@ -497,6 +501,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
        /**
         * UI entry point for form submission.
+        * @return bool
         */
        protected function submit() {
                # Check edit token on submission
@@ -510,7 +515,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $comment = $listReason;
                if( $comment != 'other' && $this->otherReason != '' ) {
                        // Entry from drop down menu + additional comment
-                       $comment .= wfMsgForContent( 'colon-separator' ) . $this->otherReason;
+                       $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->otherReason;
                } elseif( $comment == 'other' ) {
                        $comment = $this->otherReason;
                }
@@ -592,6 +597,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
        /**
         * Do the write operations. Simple wrapper for RevDel_*List::setVisibility().
+        * @return
         */
        protected function save( $bitfield, $reason, $title ) {
                return $this->getList()->setVisibility(