Special:ProtectedPages: Use MultiSelectField instead of checks
authorPrateek Saxena <prtksxna@gmail.com>
Thu, 5 Apr 2018 05:38:06 +0000 (11:08 +0530)
committerPrateek Saxena <prtksxna@gmail.com>
Fri, 6 Apr 2018 05:22:37 +0000 (10:52 +0530)
Bug: T117722
Change-Id: I89193ab9d595a8f4749d9e871917e71a4f8f925c

includes/specials/SpecialProtectedpages.php
languages/i18n/en.json
languages/i18n/qqq.json

index d693b99..84779ea 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
+               $size, $filters
        ) {
                $formDescriptor = [
                        'namespace' => [
@@ -106,23 +106,16 @@ 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,
index 9036396..a5dbb9d 100644 (file)
        "deadendpages-summary": "",
        "deadendpagestext": "The following pages do not link to other pages in {{SITENAME}}.",
        "protectedpages": "Protected pages",
+       "protectedpages-filters": "Filters:",
        "protectedpages-indef": "Indefinite protections only",
        "protectedpages-summary": "This page lists existing pages that are currently protected. For a list of titles that are protected from creation, see [[{{#special:ProtectedTitles}}|{{int:protectedtitles}}]].",
        "protectedpages-cascade": "Cascading protections only",
index 703b49f..73b3101 100644 (file)
        "deadendpages-summary": "{{notranslate}}\nThe summary displayed at the top of [[Special:Deadendpages]]. [[mw:Manual:Interface/Special pages summary|mw manual]].",
        "deadendpagestext": "Introductory text for [[Special:DeadendPages]]",
        "protectedpages": "{{doc-special|ProtectedPages}}",
+       "protectedpages-filters": "Title in [[Special:ProtectedPages]]",
        "protectedpages-indef": "Option in [[Special:ProtectedPages]]",
        "protectedpages-summary": "Summary of [[Special:ProtectedPages]].\n\nSee also:\n* {{msg-mw|Protectedtitles-summary}}",
        "protectedpages-cascade": "Option in [[Special:ProtectedPages]]",