Fix function name case
[lhc/web/wiklou.git] / includes / logging / LogEventsList.php
index 039161a..0cf584b 100644 (file)
@@ -40,6 +40,11 @@ class LogEventsList extends ContextSource {
         */
        protected $showTagEditUI;
 
+       /**
+        * @var array
+        */
+       protected $allowedActions = null;
+
        /**
         * Constructor.
         * The first two parameters used to be $skin and $out, but now only a context
@@ -74,9 +79,10 @@ class LogEventsList extends ContextSource {
         * @param int $month Month
         * @param array $filter
         * @param string $tagFilter Tag to select by default
+        * @param string $action
         */
        public function showOptions( $types = [], $user = '', $page = '', $pattern = '', $year = 0,
-               $month = 0, $filter = null, $tagFilter = ''
+               $month = 0, $filter = null, $tagFilter = '', $action = null
        ) {
                global $wgScript, $wgMiserMode;
 
@@ -113,6 +119,11 @@ class LogEventsList extends ContextSource {
                        $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) );
                }
 
+               // Action filter
+               if ( $action !== null ) {
+                       $html .= Xml::tags( 'p', null, $this->getActionSelector( $types, $action ) );
+               }
+
                // Submit button
                $html .= Xml::submitButton( $this->msg( 'logeventslist-submit' )->text() );
 
@@ -287,6 +298,41 @@ class LogEventsList extends ContextSource {
                return '';
        }
 
+       /**
+        * Drop down menu for selection of actions that can be used to filter the log
+        * @param array $types
+        * @param string $action
+        * @return string
+        * @since 1.27
+        */
+       private function getActionSelector( $types, $action ) {
+               if ( $this->allowedActions === null || !count( $this->allowedActions ) ) {
+                       return '';
+               }
+               $html = '';
+               $html .= Xml::label( wfMessage( 'log-action-filter-' . $types[0] )->text(),
+                       'action-filter-' .$types[0] ) . "\n";
+               $select = new XmlSelect( 'subtype' );
+               $select->addOption( wfMessage( 'log-action-filter-all' )->text(), '' );
+               foreach ( $this->allowedActions as $value ) {
+                       $msgKey = 'log-action-filter-' . $types[0] . '-' . $value;
+                       $select->addOption( wfMessage( $msgKey )->text(), $value );
+               }
+               $select->setDefault( $action );
+               $html .= $select->getHTML();
+               return $html;
+       }
+
+       /**
+        * Sets the action types allowed for log filtering
+        * To one action type may correspond several log_actions
+        * @param array $actions
+        * @since 1.27
+        */
+       public function setAllowedActions( $actions ) {
+               $this->allowedActions = $actions;
+       }
+
        /**
         * @return string
         */
@@ -507,6 +553,7 @@ class LogEventsList extends ContextSource {
         * - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
         * - useRequestParams boolean Set true to use Pager-related parameters in the WebRequest
         * - useMaster boolean Use master DB
+        * - extraUrlParams array|bool Additional url parameters for "full log" link (if it is shown)
         * @return int Number of total log items (not limited by $lim)
         */
        public static function showLogExtract(
@@ -521,6 +568,7 @@ class LogEventsList extends ContextSource {
                        'flags' => 0,
                        'useRequestParams' => false,
                        'useMaster' => false,
+                       'extraUrlParams' => false,
                ];
                # The + operator appends elements of remaining keys from the right
                # handed array to the left handed, whereas duplicated keys are NOT overwritten.
@@ -532,6 +580,8 @@ class LogEventsList extends ContextSource {
                $msgKey = $param['msgKey'];
                $wrap = $param['wrap'];
                $flags = $param['flags'];
+               $extraUrlParams = $param['extraUrlParams'];
+
                $useRequestParams = $param['useRequestParams'];
                if ( !is_array( $msgKey ) ) {
                        $msgKey = [ $msgKey ];
@@ -618,7 +668,11 @@ class LogEventsList extends ContextSource {
                                $urlParam['type'] = $types[0];
                        }
 
-                       $s .= Linker::link(
+                       if ( $extraUrlParams !== false ) {
+                               $urlParam = array_merge( $urlParam, $extraUrlParams );
+                       }
+
+                       $s .= Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Log' ),
                                $context->msg( 'log-fulllog' )->escaped(),
                                [],