fix typo in comment
[lhc/web/wiklou.git] / includes / specials / SpecialRevisiondelete.php
index 212c1fd..cb2447d 100644 (file)
@@ -38,9 +38,6 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        /** The RevDel_List object, storing the list of items to be deleted/undeleted */
        var $list;
 
-       /** New bitfield value, used for form display post-submit */
-       var $newBits;
-
        /**
         * Assorted information about each type, needed by the special page.
         * TODO Move some of this to the list class
@@ -170,11 +167,13 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $qc = $this->getLogQueryCond();
                # Show relevant lines from the deletion log
                $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
-               LogEventsList::showLogExtract( $wgOut, 'delete', $this->targetObj->getPrefixedText(), '', 25, $qc );
+               LogEventsList::showLogExtract( $wgOut, 'delete',
+                       $this->targetObj->getPrefixedText(), '', 25, $qc );
                # Show relevant lines from the suppression log
                if( $wgUser->isAllowed( 'suppressionlog' ) ) {
                        $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
-                       LogEventsList::showLogExtract( $wgOut, 'suppress', $this->targetObj->getPrefixedText(), '', 25, $qc );
+                       LogEventsList::showLogExtract( $wgOut, 'suppress',
+                               $this->targetObj->getPrefixedText(), '', 25, $qc );
                }
        }
 
@@ -182,24 +181,36 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
         * Show some useful links in the subtitle
         */
        protected function showConvenienceLinks() {
-               global $wgOut, $wgUser;
+               global $wgOut, $wgUser, $wgLang;
                # Give a link to the logs/hist for this page
                if( $this->targetObj ) {
                        $links = array();
                        $logtitle = SpecialPage::getTitleFor( 'Log' );
-                       $links[] = $this->skin->makeKnownLinkObj( $logtitle, wfMsgHtml( 'viewpagelogs' ),
-                               wfArrayToCGI( array( 'page' => $this->targetObj->getPrefixedUrl() ) ) );
+                       $links[] = $this->skin->linkKnown(
+                               $logtitle,
+                               wfMsgHtml( 'viewpagelogs' ),
+                               array(),
+                               array( 'page' => $this->targetObj->getPrefixedText() )
+                       );
                        # Give a link to the page history
-                       $links[] = $this->skin->makeKnownLinkObj( $this->targetObj, wfMsgHtml( 'pagehist' ),
-                               wfArrayToCGI( array( 'action' => 'history' ) ) );
+                       $links[] = $this->skin->linkKnown(
+                               $this->targetObj,
+                               wfMsgHtml( 'pagehist' ),
+                               array(),
+                               array( 'action' => 'history' )
+                       );
                        # Link to deleted edits
                        if( $wgUser->isAllowed('undelete') ) {
                                $undelete = SpecialPage::getTitleFor( 'Undelete' );
-                               $links[] = $this->skin->makeKnownLinkObj( $undelete, wfMsgHtml( 'deletedhist' ),
-                                       wfArrayToCGI( array( 'target' => $this->targetObj->getPrefixedDBkey() ) ) );
+                               $links[] = $this->skin->linkKnown(
+                                       $undelete,
+                                       wfMsgHtml( 'deletedhist' ),
+                                       array(),
+                                       array( 'target' => $this->targetObj->getPrefixedDBkey() )
+                               );
                        }
                        # Logs themselves don't have histories or archived revisions
-                       $wgOut->setSubtitle( '<p>'.implode($links,' / ').'</p>' );
+                       $wgOut->setSubtitle( '<p>' . $wgLang->pipeList( $links ) . '</p>' );
                }
        }
 
@@ -293,7 +304,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                if ( $this->typeName == 'logging' ) {
                        $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->ids) ) );
                } else {
-                       $wgOut->addWikiMsg( 'revdelete-selected', $this->targetObj->getPrefixedText(), count( $this->ids ) );
+                       $wgOut->addWikiMsg( 'revdelete-selected',
+                               $this->targetObj->getPrefixedText(), count( $this->ids ) );
                }
 
                $bitfields = 0;
@@ -322,10 +334,6 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
                        return;
                }
-
-               if ( !is_null( $this->newBits ) ) {
-                       $bitfields = $this->newBits;
-               }
                
                $wgOut->addHTML( "</ul>" );
                // Explanation text
@@ -336,7 +344,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
                $wgOut->addHTML(
                        Xml::openElement( 'form', array( 'method' => 'post',
-                               'action' => $this->getTitle()->getLocalUrl( 'action=submit' ), 
+                               'action' => $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) ), 
                                'id' => 'mw-revdel-form-revisions' ) ) .
                        Xml::openElement( 'fieldset' ) .
                        Xml::element( 'legend', null,  wfMsg( 'revdelete-legend' ) ) .
@@ -366,8 +374,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        }
        
        /**
-       * @param int $bitfields, aggregate bitfield of all the bitfields
-       * @returns string HTML
+       * @param $bitfields Interger: aggregate bitfield of all the bitfields
+       * @return String: HTML
        */
        protected function buildCheckBoxes( $bitfields ) {
                $html = '';
@@ -384,7 +392,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
        /**
         * UI entry point for form submission.
-        * @param WebRequest $request
+        * @param $request WebRequest
         */
        protected function submit( $request ) {
                global $wgUser, $wgOut;
@@ -419,6 +427,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                global $wgOut;
                $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
                $wgOut->wrapWikiMsg( '<span class="success">$1</span>', $this->typeInfo['success'] );
+               $this->list->reloadFromMaster();
                $this->showForm();
        }
 
@@ -434,8 +443,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
        /**
         * Put together a rev_deleted bitfield from the submitted checkboxes
-        * @param WebRequest $request
-        * @return int
+        * @param $request WebRequest
+        * @return Integer
         */
        protected function extractBitfield( $request ) {
                $bitfield = 0;
@@ -456,7 +465,6 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                if( $bitfield == Revision::DELETED_RESTRICTED ) {
                        return Status::newFatal( 'revdelete-only-restricted' );
                }
-               $this->newBits = $bitfield;
                return $this->getList()->setVisibility( array(
                        'value' => $bitfield,
                        'comment' => $reason ) );
@@ -472,11 +480,12 @@ class RevisionDeleter {
         * Checks for a change in the bitfield for a certain option and updates the
         * provided array accordingly.
         *
-        * @param String $desc Description to add to the array if the option was
+        * @param $desc String: description to add to the array if the option was
         * enabled / disabled.
-        * @param int $field The bitmask describing the single option.
-        * @param int $diff The xor of the old and new bitfields.
-        * @param array $arr The array to update.
+        * @param $field Integer: the bitmask describing the single option.
+        * @param $diff Integer: the xor of the old and new bitfields.
+        * @param $new Integer: the new bitfield 
+        * @param $arr Array: the array to update.
         */
        protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
                if( $diff & $field ) {
@@ -492,8 +501,8 @@ class RevisionDeleter {
         * a single string, which can be one of "applied restrictions to sysops",
         * "removed restrictions from sysops", or null.
         *
-        * @param int $n The new bitfield.
-        * @param int $o The old bitfield.
+        * @param $n Integer: the new bitfield.
+        * @param $o Integer: the old bitfield.
         * @return An array as described above.
         */
        protected static function getChanges( $n, $o ) {
@@ -521,10 +530,10 @@ class RevisionDeleter {
         * message will be of the form "[hid {content, edit summary, username}];
         * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
         *
-        * @param int $count The number of effected revisions.
-        * @param int $nbitfield The new bitfield for the revision.
-        * @param int $obitfield The old bitfield for the revision.
-        * @param bool $isForLog
+        * @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 $isForLog Boolean
         */
        public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false ) {
                global $wgLang;
@@ -643,7 +652,7 @@ abstract class RevDel_List {
                                $opType = 'modify';
                        }
 
-                       if ( $item->isCurrent() && $opType == 'hide' ) {
+                       if ( $item->isHideCurrentOp( $newBits ) ) {
                                // Cannot hide current version text
                                $status->error( 'revdelete-hide-current', $item->formatDate(), $item->formatTime() );
                                $status->failCount++;
@@ -708,6 +717,15 @@ abstract class RevDel_List {
                return $status;
        }
 
+       /**
+        * Reload the list data from the master DB. This can be done after setVisibility()
+        * to allow $item->getHTML() to show the new data.
+        */
+       function reloadFromMaster() {
+               $dbw = wfGetDB( DB_MASTER );
+               $this->res = $this->doQuery( $dbw );
+       }
+
        /**
         * Record a log entry on the action
         * @param $params Associative array of parameters:
@@ -733,7 +751,8 @@ abstract class RevDel_List {
                $logParams = $this->getLogParams( $params );
                // Actually add the deletion log entry
                $log = new LogPage( $logType );
-               $logid = $log->addEntry( $this->getLogAction(), $params['title'], $params['comment'], $logParams );
+               $logid = $log->addEntry( $this->getLogAction(), $params['title'],
+                       $params['comment'], $logParams );
                // Allow for easy searching of deletion log items for revision/log items
                $log->addRelations( $field, $params['ids'], $logid );
        }
@@ -884,7 +903,7 @@ abstract class RevDel_Item {
        }
 
        /**
-        * Get the date, formatted with $wgLang
+        * Get the time, formatted with $wgLang
         */
        public function formatTime() {
                global $wgLang;
@@ -900,10 +919,11 @@ abstract class RevDel_Item {
        }
 
        /** 
-        * Returns true if the item is "current" and can't be deleted for that reason
+        * Returns true if the item is "current", and the operation to set the given
+        * bits can't be executed for that reason
         * STUB
         */
-       public function isCurrent() {
+       public function isHideCurrentOp( $newBits ) {
                return false;
        }
 
@@ -1030,7 +1050,8 @@ class RevDel_RevisionItem extends RevDel_Item {
                        ),
                        array(
                                'rc_this_oldid' => $this->revision->getId(), // condition
-                               'rc_timestamp' => $dbw->timestamp( $this->revision->getTimestamp() ), // non-unique index
+                               // non-unique timestamp index
+                               'rc_timestamp' => $dbw->timestamp( $this->revision->getTimestamp() ),
                        ),
                        __METHOD__
                );
@@ -1041,8 +1062,9 @@ class RevDel_RevisionItem extends RevDel_Item {
                return $this->revision->isDeleted( Revision::DELETED_TEXT );
        }
 
-       public function isCurrent() {
-               return $this->list->getCurrent() == $this->getId();
+       public function isHideCurrentOp( $newBits ) {
+               return ( $newBits & Revision::DELETED_TEXT ) 
+                       && $this->list->getCurrent() == $this->getId();
        }
 
        /**
@@ -1055,8 +1077,15 @@ class RevDel_RevisionItem extends RevDel_Item {
                if ( $this->isDeleted() && !$this->canView() ) {
                        return $date;
                }
-               return $this->special->skin->makeLinkObj( $this->list->title, $date, 
-                       'oldid='.$this->revision->getId() . '&unhide=1' );
+               return $this->special->skin->link(
+                       $this->list->title,
+                       $date, 
+                       array(),
+                       array(
+                               'oldid' => $this->revision->getId(),
+                               'unhide' => 1
+                       )
+               );
        }
 
        /**
@@ -1068,10 +1097,19 @@ class RevDel_RevisionItem extends RevDel_Item {
                        return wfMsgHtml('diff');
                } else {
                        return 
-                               $this->special->skin->makeKnownLinkObj
+                               $this->special->skin->link
                                        $this->list->title, 
                                        wfMsgHtml('diff'),
-                                       'diff=' . $this->revision->getId() . '&oldid=prev&unhide=1' 
+                                       array(),
+                                       array(
+                                               'diff' => $this->revision->getId(),
+                                               'oldid' => 'prev',
+                                               'unhide' => 1
+                                       ),
+                                       array(
+                                               'known',
+                                               'noclasses'
+                                       )
                                );
                }
        }
@@ -1544,8 +1582,12 @@ class RevDel_LogItem extends RevDel_Item {
                $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
 
                $logtitle = SpecialPage::getTitleFor( 'Log' );
-               $loglink = $this->special->skin->link( $logtitle, wfMsgHtml( 'log' ), array(),
-                       array( 'page' => $title->getPrefixedUrl() ) );
+               $loglink = $this->special->skin->link(
+                       $logtitle,
+                       wfMsgHtml( 'log' ),
+                       array(),
+                       array( 'page' => $title->getPrefixedText() )
+               );
                // Action text
                if( !$this->canView() ) {
                        $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';