Merge "Use {{int:}} on MediaWiki:Blockedtext and MediaWiki:Autoblockedtext"
[lhc/web/wiklou.git] / includes / specials / SpecialProtectedpages.php
index ac34996..26f4da5 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,17 +88,16 @@ 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
+               $size, $filters
        ) {
                $formDescriptor = [
                        'namespace' => [
-                               'class' => 'HTMLSelectNamespace',
+                               'class' => HTMLSelectNamespace::class,
                                'name' => 'namespace',
                                'id' => 'namespace',
                                'cssclass' => 'namespaceselector',
@@ -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' => HTMLSizeFilterField::class,
                                'name' => 'size',
                        ]
                ];
-               $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() );
+               $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
                $htmlForm
                        ->setMethod( 'get' )
                        ->setWrapperLegendMsg( 'protectedpages' )