Introduce PageHistoryPager::doBatchLookups hook.
[lhc/web/wiklou.git] / includes / actions / HistoryAction.php
index 6ee5d2c..83185e4 100644 (file)
@@ -67,8 +67,7 @@ class HistoryAction extends FormlessAction {
        }
 
        /**
-        * Get the Article object we are working on.
-        * @return Page
+        * @return WikiPage|Article|ImagePage|CategoryPage|Page The Article object we are working on.
         */
        public function getArticle() {
                return $this->page;
@@ -102,8 +101,6 @@ class HistoryAction extends FormlessAction {
                        return; // Client cache fresh and headers sent, nothing more to do.
                }
 
-               wfProfileIn( __METHOD__ );
-
                $this->preCacheMessages();
                $config = $this->context->getConfig();
 
@@ -131,7 +128,6 @@ class HistoryAction extends FormlessAction {
                $feedType = $request->getVal( 'feed' );
                if ( $feedType ) {
                        $this->feed( $feedType );
-                       wfProfileOut( __METHOD__ );
 
                        return;
                }
@@ -151,7 +147,6 @@ class HistoryAction extends FormlessAction {
                                        'msgKey' => array( 'moveddeleted-notice' )
                                )
                        );
-                       wfProfileOut( __METHOD__ );
 
                        return;
                }
@@ -215,7 +210,6 @@ class HistoryAction extends FormlessAction {
                );
                $out->preventClickjacking( $pager->getPreventClickjacking() );
 
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -438,8 +432,13 @@ class HistoryPager extends ReverseChronologicalPager {
                        $latest = ( $this->counter == 1 && $this->mIsFirst );
                        $firstInList = $this->counter == 1;
                        $this->counter++;
-                       $s = $this->historyLine( $this->lastRow, $row,
-                               $this->getTitle()->getNotificationTimestamp( $this->getUser() ), $latest, $firstInList );
+
+                       $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
+                               ? $this->getTitle()->getNotificationTimestamp( $this->getUser() )
+                               : false;
+
+                       $s = $this->historyLine(
+                               $this->lastRow, $row, $notifTimestamp, $latest, $firstInList );
                } else {
                        $s = '';
                }
@@ -449,6 +448,10 @@ class HistoryPager extends ReverseChronologicalPager {
        }
 
        function doBatchLookups() {
+               if ( !Hooks::run( 'PageHistoryPager::doBatchLookups', array( $this, $this->mResult ) ) ) {
+                       return;
+               }
+
                # Do a link batch query
                $this->mResult->seek( 0 );
                $batch = new LinkBatch();
@@ -485,6 +488,7 @@ class HistoryPager extends ReverseChronologicalPager {
                        'id' => 'mw-history-compare' ) ) . "\n";
                $s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
                $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
+               $s .= Html::hidden( 'type', 'revision' ) . "\n";
 
                // Button container stored in $this->buttons for re-use in getEndBody()
                $this->buttons = '<div>';
@@ -495,8 +499,17 @@ class HistoryPager extends ReverseChronologicalPager {
                        $attrs
                ) . "\n";
 
-               if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
-                       $this->buttons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
+               $user = $this->getUser();
+               $actionButtons = '';
+               if ( $user->isAllowed( 'deleterevision' ) ) {
+                       $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
+               }
+               if ( $user->isAllowed( 'changetags' ) ) {
+                       $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
+               }
+               if ( $actionButtons ) {
+                       $this->buttons .= Xml::tags( 'div', array( 'class' =>
+                               'mw-history-revisionactions' ), $actionButtons );
                }
                $this->buttons .= '</div>';
 
@@ -538,8 +551,13 @@ class HistoryPager extends ReverseChronologicalPager {
                                $next = $this->mPastTheEndRow;
                        }
                        $this->counter++;
-                       $s = $this->historyLine( $this->lastRow, $next,
-                               $this->getTitle()->getNotificationTimestamp( $this->getUser() ), $latest, $firstInList );
+
+                       $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
+                               ? $this->getTitle()->getNotificationTimestamp( $this->getUser() )
+                               : false;
+
+                       $s = $this->historyLine(
+                               $this->lastRow, $next, $notifTimestamp, $latest, $firstInList );
                } else {
                        $s = '';
                }
@@ -612,11 +630,15 @@ class HistoryPager extends ReverseChronologicalPager {
 
                $del = '';
                $user = $this->getUser();
-               // Show checkboxes for each revision
-               if ( $user->isAllowed( 'deleterevision' ) ) {
+               $canRevDelete = $user->isAllowed( 'deleterevision' );
+               $canModifyTags = $user->isAllowed( 'changetags' );
+               // Show checkboxes for each revision, to allow for revision deletion and
+               // change tags
+               if ( $canRevDelete || $canModifyTags ) {
                        $this->preventClickjacking();
-                       // If revision was hidden from sysops, disable the checkbox
-                       if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
+                       // If revision was hidden from sysops and we don't need the checkbox
+                       // for anything else, disable it
+                       if ( !$canModifyTags && !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
                                $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
                        // Otherwise, enable the checkbox...
                        } else {
@@ -901,4 +923,5 @@ class HistoryPager extends ReverseChronologicalPager {
        function getPreventClickjacking() {
                return $this->preventClickjacking;
        }
+
 }