Merge "CSP: In tests, use setMwGlobals() instead of manual set+undo"
[lhc/web/wiklou.git] / includes / specials / SpecialProtectedpages.php
index d693b99..4b1b344 100644 (file)
@@ -45,9 +45,12 @@ class SpecialProtectedpages extends SpecialPage {
                $sizetype = $request->getVal( 'size-mode' );
                $size = $request->getIntOrNull( 'size' );
                $ns = $request->getIntOrNull( 'namespace' );
-               $indefOnly = $request->getBool( 'indefonly' ) ? 1 : 0;
-               $cascadeOnly = $request->getBool( 'cascadeonly' ) ? 1 : 0;
-               $noRedirect = $request->getBool( 'noredirect' ) ? 1 : 0;
+
+               $filters = $request->getArray( 'wpfilters' );
+               $filters = is_null( $filters ) ? [] : $filters;
+               $indefOnly = in_array( 'indefonly', $filters );
+               $cascadeOnly = in_array( 'cascadeonly', $filters );
+               $noRedirect = in_array( 'noredirect', $filters );
 
                $pager = new ProtectedPagesPager(
                        $this,
@@ -69,9 +72,7 @@ class SpecialProtectedpages extends SpecialPage {
                        $level,
                        $sizetype,
                        $size,
-                       $indefOnly,
-                       $cascadeOnly,
-                       $noRedirect
+                       $filters
                ) );
 
                if ( $pager->getNumRows() ) {
@@ -87,13 +88,12 @@ class SpecialProtectedpages extends SpecialPage {
         * @param string $level Restriction level
         * @param string $sizetype "min" or "max"
         * @param int $size
-        * @param bool $indefOnly Only indefinite protection
-        * @param bool $cascadeOnly Only cascading protection
-        * @param bool $noRedirect Don't show redirects
+        * @param array $filters Filters set for the pager: indefOnly,
+        *   cascadeOnly, noRedirect
         * @return string Input form
         */
-       protected function showOptions( $namespace, $type = 'edit', $level, $sizetype,
-               $size, $indefOnly, $cascadeOnly, $noRedirect
+       protected function showOptions( $namespace, $type, $level, $sizetype,
+               $size, $filters
        ) {
                $formDescriptor = [
                        'namespace' => [
@@ -106,30 +106,23 @@ class SpecialProtectedpages extends SpecialPage {
                        ],
                        'typemenu' => $this->getTypeMenu( $type ),
                        'levelmenu' => $this->getLevelMenu( $level ),
-                       'expirycheck' => [
-                               'type' => 'check',
-                               'label' => $this->msg( 'protectedpages-indef' )->text(),
-                               'name' => 'indefonly',
-                               'id' => 'indefonly',
-                       ],
-                       'cascadecheck' => [
-                               'type' => 'check',
-                               'label' => $this->msg( 'protectedpages-cascade' )->text(),
-                               'name' => 'cascadeonly',
-                               'id' => 'cascadeonly',
-                       ],
-                       'redirectcheck' => [
-                               'type' => 'check',
-                               'label' => $this->msg( 'protectedpages-noredirect' )->text(),
-                               'name' => 'noredirect',
-                               'id' => 'noredirect',
+                       'filters' => [
+                               'class' => 'HTMLMultiSelectField',
+                               'label' => $this->msg( 'protectedpages-filters' )->text(),
+                               'flatlist' => true,
+                               'options' => [
+                                       $this->msg( 'protectedpages-indef' )->text() => 'indefonly',
+                                       $this->msg( 'protectedpages-cascade' )->text() => 'cascadeonly',
+                                       $this->msg( 'protectedpages-noredirect' )->text() => 'noredirect',
+                               ],
+                               'default' => $filters,
                        ],
                        'sizelimit' => [
                                'class' => HTMLSizeFilterField::class,
                                'name' => 'size',
                        ]
                ];
-               $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() );
+               $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
                $htmlForm
                        ->setMethod( 'get' )
                        ->setWrapperLegendMsg( 'protectedpages' )