Merge "Deprecating: Consolidating `progressive` & `constructive` buttons"
[lhc/web/wiklou.git] / includes / specials / SpecialLog.php
index 88184f9..d4c7c6a 100644 (file)
@@ -76,19 +76,19 @@ class SpecialLog extends SpecialPage {
                }
 
                # Handle type-specific inputs
-               $qc = array();
+               $qc = [];
                if ( $opts->getValue( 'type' ) == 'suppress' ) {
                        $offender = User::newFromName( $opts->getValue( 'offender' ), false );
                        if ( $offender && $offender->getId() > 0 ) {
-                               $qc = array( 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() );
+                               $qc = [ 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() ];
                        } elseif ( $offender && IP::isIPAddress( $offender->getName() ) ) {
-                               $qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() );
+                               $qc = [ 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() ];
                        }
                } else {
                        // Allow extensions to add relations to their search types
                        Hooks::run(
                                'SpecialLogAddLogSearchRelations',
-                               array( $opts->getValue( 'type' ), $this->getRequest(), &$qc )
+                               [ $opts->getValue( 'type' ), $this->getRequest(), &$qc ]
                        );
                }
 
@@ -122,13 +122,13 @@ class SpecialLog extends SpecialPage {
                if ( $types !== null ) {
                        return $types;
                }
-               $types = array(
+               $types = [
                        'block',
                        'newusers',
                        'rights',
-               );
+               ];
 
-               Hooks::run( 'GetLogTypesOnUser', array( &$types ) );
+               Hooks::run( 'GetLogTypesOnUser', [ &$types ] );
                return $types;
        }
 
@@ -147,7 +147,7 @@ class SpecialLog extends SpecialPage {
        private function parseParams( FormOptions $opts, $par ) {
                # Get parameters
                $parms = explode( '/', ( $par = ( $par !== null ) ? $par : '' ) );
-               $symsForAll = array( '*', 'all' );
+               $symsForAll = [ '*', 'all' ];
                if ( $parms[0] != '' &&
                        ( in_array( $par, $this->getConfig()->get( 'LogTypes' ) ) || in_array( $par, $symsForAll ) )
                ) {
@@ -165,7 +165,7 @@ class SpecialLog extends SpecialPage {
                $loglist = new LogEventsList(
                        $this->getContext(),
                        null,
-                       LogEventsList::USE_REVDEL_CHECKBOXES
+                       LogEventsList::USE_CHECKBOXES
                );
                $pager = new LogPager(
                        $loglist,
@@ -203,7 +203,7 @@ class SpecialLog extends SpecialPage {
                if ( $logBody ) {
                        $this->getOutput()->addHTML(
                                $pager->getNavigationBar() .
-                                       $this->getRevisionButton(
+                                       $this->getActionButtons(
                                                $loglist->beginLogEventsList() .
                                                        $logBody .
                                                        $loglist->endLogEventsList()
@@ -215,30 +215,53 @@ class SpecialLog extends SpecialPage {
                }
        }
 
-       private function getRevisionButton( $formcontents ) {
-               # If the user doesn't have the ability to delete log entries,
-               # don't bother showing them the button.
-               if ( !$this->getUser()->isAllowedAll( 'deletedhistory', 'deletelogentry' ) ) {
+       private function getActionButtons( $formcontents ) {
+               $user = $this->getUser();
+               $canRevDelete = $user->isAllowedAll( 'deletedhistory', 'deletelogentry' );
+               $showTagEditUI = ChangeTags::showTagEditingUI( $user );
+               # If the user doesn't have the ability to delete log entries nor edit tags,
+               # don't bother showing them the button(s).
+               if ( !$canRevDelete && !$showTagEditUI ) {
                        return $formcontents;
                }
 
-               # Show button to hide log entries
+               # Show button to hide log entries and/or edit change tags
                $s = Html::openElement(
                        'form',
-                       array( 'action' => wfScript(), 'id' => 'mw-log-deleterevision-submit' )
+                       [ 'action' => wfScript(), 'id' => 'mw-log-deleterevision-submit' ]
                ) . "\n";
-               $s .= Html::hidden( 'title', SpecialPage::getTitleFor( 'Revisiondelete' ) ) . "\n";
-               $s .= Html::hidden( 'target', SpecialPage::getTitleFor( 'Log' ) ) . "\n";
+               $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
                $s .= Html::hidden( 'type', 'logging' ) . "\n";
-               $button = Html::element(
-                       'button',
-                       array(
-                               'type' => 'submit',
-                               'class' => "deleterevision-log-submit mw-log-deleterevision-button"
-                       ),
-                       $this->msg( 'showhideselectedlogentries' )->text()
-               ) . "\n";
-               $s .= $button . $formcontents . $button;
+
+               $buttons = '';
+               if ( $canRevDelete ) {
+                       $buttons .= Html::element(
+                               'button',
+                               [
+                                       'type' => 'submit',
+                                       'name' => 'revisiondelete',
+                                       'value' => '1',
+                                       'class' => "deleterevision-log-submit mw-log-deleterevision-button"
+                               ],
+                               $this->msg( 'showhideselectedlogentries' )->text()
+                       ) . "\n";
+               }
+               if ( $showTagEditUI ) {
+                       $buttons .= Html::element(
+                               'button',
+                               [
+                                       'type' => 'submit',
+                                       'name' => 'editchangetags',
+                                       'value' => '1',
+                                       'class' => "editchangetags-log-submit mw-log-editchangetags-button"
+                               ],
+                               $this->msg( 'log-edit-tags' )->text()
+                       ) . "\n";
+               }
+
+               $buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML();
+
+               $s .= $buttons . $formcontents . $buttons;
                $s .= Html::closeElement( 'form' );
 
                return $s;