X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Factions%2Fpagers%2FHistoryPager.php;h=14f76bc37f6a7ca536fd092e403845b7d68376b9;hb=1d286560d2cd4f2adf6138f62a8dfcfad5991c14;hp=c9c1b51a9929f794d7fc91e0f635be3615a72eac;hpb=af7ae6c804be8629fe2305e3a088f03e1af2fa9b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/pagers/HistoryPager.php b/includes/actions/pagers/HistoryPager.php index c9c1b51a99..14f76bc37f 100644 --- a/includes/actions/pagers/HistoryPager.php +++ b/includes/actions/pagers/HistoryPager.php @@ -22,6 +22,7 @@ */ use MediaWiki\MediaWikiServices; +use MediaWiki\Revision\RevisionRecord; /** * @ingroup Pager @@ -123,7 +124,6 @@ class HistoryPager extends ReverseChronologicalPager { */ function formatRow( $row ) { if ( $this->lastRow ) { - $latest = ( $this->counter == 1 && $this->mIsFirst ); $firstInList = $this->counter == 1; $this->counter++; @@ -131,8 +131,7 @@ class HistoryPager extends ReverseChronologicalPager { ? $this->getTitle()->getNotificationTimestamp( $this->getUser() ) : false; - $s = $this->historyLine( - $this->lastRow, $row, $notifTimestamp, $latest, $firstInList ); + $s = $this->historyLine( $this->lastRow, $row, $notifTimestamp, false, $firstInList ); } else { $s = ''; } @@ -173,6 +172,7 @@ class HistoryPager extends ReverseChronologicalPager { * @return string HTML output */ protected function getStartBody() { + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); $this->lastRow = false; $this->counter = 1; $this->oldIdChecked = 0; @@ -185,34 +185,40 @@ class HistoryPager extends ReverseChronologicalPager { $s .= Html::hidden( 'type', 'revision' ) . "\n"; // Button container stored in $this->buttons for re-use in getEndBody() - $this->buttons = Html::openElement( 'div', [ 'class' => 'mw-history-compareselectedversions' ] ); - $className = 'historysubmit mw-history-compareselectedversions-button'; - $attrs = [ 'class' => $className ] - + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' ); - $this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(), - $attrs - ) . "\n"; - - $user = $this->getUser(); - $actionButtons = ''; - if ( $user->isAllowed( 'deleterevision' ) ) { - $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' ); - } - if ( $this->showTagEditUI ) { - $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' ); - } - if ( $actionButtons ) { - $this->buttons .= Xml::tags( 'div', [ 'class' => - 'mw-history-revisionactions' ], $actionButtons ); - } + $this->buttons = ''; + if ( $this->getNumRows() > 0 ) { + $this->buttons .= Html::openElement( + 'div', [ 'class' => 'mw-history-compareselectedversions' ] ); + $className = 'historysubmit mw-history-compareselectedversions-button'; + $attrs = [ 'class' => $className ] + + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' ); + $this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(), + $attrs + ) . "\n"; + + $user = $this->getUser(); + $actionButtons = ''; + if ( $permissionManager->userHasRight( $user, 'deleterevision' ) ) { + $actionButtons .= $this->getRevisionButton( + 'revisiondelete', 'showhideselectedversions' ); + } + if ( $this->showTagEditUI ) { + $actionButtons .= $this->getRevisionButton( + 'editchangetags', 'history-edit-tags' ); + } + if ( $actionButtons ) { + $this->buttons .= Xml::tags( 'div', [ 'class' => + 'mw-history-revisionactions' ], $actionButtons ); + } - if ( $user->isAllowed( 'deleterevision' ) || $this->showTagEditUI ) { - $this->buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML(); - } + if ( $permissionManager->userHasRight( $user, 'deleterevision' ) || $this->showTagEditUI ) { + $this->buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML(); + } - $this->buttons .= ''; + $this->buttons .= ''; - $s .= $this->buttons; + $s .= $this->buttons; + } $s .= '