Merge "jquery.ui.datepicker: Add translations in de-AT and de-CH"
[lhc/web/wiklou.git] / includes / specials / SpecialLog.php
index a164c1e..7132207 100644 (file)
@@ -49,6 +49,7 @@ class SpecialLog extends SpecialPage {
                $opts->add( 'offset', '' );
                $opts->add( 'dir', '' );
                $opts->add( 'offender', '' );
+               $opts->add( 'subtype', '' );
 
                // Set values
                $opts->fetchValuesFromRequest( $this->getRequest() );
@@ -76,19 +77,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 +123,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 +148,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 ) )
                ) {
@@ -167,6 +168,26 @@ class SpecialLog extends SpecialPage {
                        null,
                        LogEventsList::USE_CHECKBOXES
                );
+
+               $action = '';
+               // Allow to filter the log by actions
+               $type = $opts->getValue( 'type' );
+               if ( $type !== '' ) {
+                       $actions = $this->getConfig()->get( 'ActionFilteredLogs' );
+                       if ( isset( $actions[$type] ) ) {
+                               // log type can be filtered by actions
+                               $loglist->setAllowedActions( array_keys( $actions[$type] ) );
+                               $action = $opts->getValue( 'subtype' );
+                               if ( $action !== '' && isset( $actions[$type][$action] ) ) {
+                                       // add condition to query
+                                       $extraConds['log_action'] = $actions[$type][$action];
+                               } else {
+                                       // no action or invalid action
+                                       $action = '';
+                               }
+                       }
+               }
+
                $pager = new LogPager(
                        $loglist,
                        $opts->getValue( 'type' ),
@@ -195,7 +216,8 @@ class SpecialLog extends SpecialPage {
                        $pager->getYear(),
                        $pager->getMonth(),
                        $pager->getFilterParams(),
-                       $opts->getValue( 'tagfilter' )
+                       $opts->getValue( 'tagfilter' ),
+                       $action
                );
 
                # Insert list
@@ -228,7 +250,7 @@ class SpecialLog extends SpecialPage {
                # 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( 'action', 'historysubmit' ) . "\n";
                $s .= Html::hidden( 'type', 'logging' ) . "\n";
@@ -237,53 +259,29 @@ class SpecialLog extends SpecialPage {
                if ( $canRevDelete ) {
                        $buttons .= Html::element(
                                'button',
-                               array(
+                               [
                                        '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',
-                               array(
+                               [
                                        'type' => 'submit',
                                        'name' => 'editchangetags',
                                        'value' => '1',
                                        'class' => "editchangetags-log-submit mw-log-editchangetags-button"
-                               ),
+                               ],
                                $this->msg( 'log-edit-tags' )->text()
                        ) . "\n";
                }
 
-               // Select: All, None, Invert
-               $links = array();
-               $links[] = Html::element(
-                       'a', array( 'href' => '#', 'class' => 'mw-checkbox-all' ),
-                       $this->msg( 'checkbox-all' )->text()
-               );
-               $links[] = Html::element(
-                       'a', array( 'href' => '#', 'class' => 'mw-checkbox-none' ),
-                       $this->msg( 'checkbox-none' )->text()
-               );
-               $links[] = Html::element(
-                       'a', array( 'href' => '#', 'class' => 'mw-checkbox-invert' ),
-                       $this->msg( 'checkbox-invert' )->text()
-               );
-
-               $buttons .= Html::rawElement( 'p',
-                       array(
-                               'class' => "mw-checkbox-toggle-controls"
-                       ),
-                       $this->msg( 'checkbox-select' )
-                               ->rawParams( $this->getLanguage()->commaList( $links ) )->escaped()
-               );
-
-               $this->getOutput()->addModules( 'mediawiki.checkboxtoggle' );
-               $this->getOutput()->addModuleStyles( 'mediawiki.checkboxtoggle.styles' );
+               $buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML();
 
                $s .= $buttons . $formcontents . $buttons;
                $s .= Html::closeElement( 'form' );