Allow hiding redirects in Special:ProtectedPages
authorJackmcbarn <jackmcbarn@gmail.com>
Thu, 2 Jan 2014 18:45:44 +0000 (13:45 -0500)
committerJackmcbarn <jackmcbarn@gmail.com>
Thu, 2 Jan 2014 18:52:17 +0000 (13:52 -0500)
Add a checkbox to hide redirects in Special:ProtectedPages.

Bug: 19233
Change-Id: If1753eddc834f55c301a6e78e0802ee9d94a24b2

includes/specials/SpecialProtectedpages.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index db3be12..214fbd9 100644 (file)
@@ -52,6 +52,7 @@ class SpecialProtectedpages extends SpecialPage {
                $ns = $request->getIntOrNull( 'namespace' );
                $indefOnly = $request->getBool( 'indefonly' ) ? 1 : 0;
                $cascadeOnly = $request->getBool( 'cascadeonly' ) ? 1 : 0;
+               $noRedirect = $request->getBool( 'noredirect' ) ? 1 : 0;
 
                $pager = new ProtectedPagesPager(
                        $this,
@@ -62,7 +63,8 @@ class SpecialProtectedpages extends SpecialPage {
                        $sizetype,
                        $size,
                        $indefOnly,
-                       $cascadeOnly
+                       $cascadeOnly,
+                       $noRedirect
                );
 
                $this->getOutput()->addHTML( $this->showOptions(
@@ -72,7 +74,8 @@ class SpecialProtectedpages extends SpecialPage {
                        $sizetype,
                        $size,
                        $indefOnly,
-                       $cascadeOnly
+                       $cascadeOnly,
+                       $noRedirect
                ) );
 
                if ( $pager->getNumRows() ) {
@@ -186,17 +189,18 @@ class SpecialProtectedpages extends SpecialPage {
        }
 
        /**
-        * @param $namespace Integer
-        * @param string $type restriction type
-        * @param string $level restriction level
+        * @param int $namespace
+        * @param string $type Restriction type
+        * @param string $level Restriction level
         * @param string $sizetype "min" or "max"
-        * @param $size Integer
-        * @param $indefOnly Boolean: only indefinie protection
-        * @param $cascadeOnly Boolean: only cascading protection
+        * @param int $size
+        * @param bool $indefOnly Only indefinite protection
+        * @param bool $cascadeOnly Only cascading protection
+        * @param bool $noRedirect Don't show redirects
         * @return String: input form
         */
        protected function showOptions( $namespace, $type = 'edit', $level, $sizetype,
-               $size, $indefOnly, $cascadeOnly
+               $size, $indefOnly, $cascadeOnly, $noRedirect
        ) {
                global $wgScript;
 
@@ -212,6 +216,7 @@ class SpecialProtectedpages extends SpecialPage {
                        "<br /><span style='white-space: nowrap'>" .
                        $this->getExpiryCheck( $indefOnly ) . "&#160;\n" .
                        $this->getCascadeCheck( $cascadeOnly ) . "&#160;\n" .
+                       $this->getRedirectCheck( $noRedirect ) . "&#160;\n" .
                        "</span><br /><span style='white-space: nowrap'>" .
                        $this->getSizeLimit( $sizetype, $size ) . "&#160;\n" .
                        "</span>" .
@@ -269,6 +274,19 @@ class SpecialProtectedpages extends SpecialPage {
                ) . "\n";
        }
 
+       /**
+        * @param bool $noRedirect
+        * @return string Formatted HTML
+        */
+       protected function getRedirectCheck( $noRedirect ) {
+               return Xml::checkLabel(
+                       $this->msg( 'protectedpages-noredirect' )->text(),
+                       'noredirect',
+                       'noredirect',
+                       $noRedirect
+               ) . "\n";
+       }
+
        /**
         * @param string $sizetype "min" or "max"
         * @param mixed $size
@@ -372,10 +390,10 @@ class SpecialProtectedpages extends SpecialPage {
  */
 class ProtectedPagesPager extends AlphabeticPager {
        public $mForm, $mConds;
-       private $type, $level, $namespace, $sizetype, $size, $indefonly;
+       private $type, $level, $namespace, $sizetype, $size, $indefonly, $cascadeonly, $noredirect;
 
        function __construct( $form, $conds = array(), $type, $level, $namespace,
-               $sizetype = '', $size = 0, $indefonly = false, $cascadeonly = false
+               $sizetype = '', $size = 0, $indefonly = false, $cascadeonly = false, $noredirect = false
        ) {
                $this->mForm = $form;
                $this->mConds = $conds;
@@ -386,6 +404,7 @@ class ProtectedPagesPager extends AlphabeticPager {
                $this->size = intval( $size );
                $this->indefonly = (bool)$indefonly;
                $this->cascadeonly = (bool)$cascadeonly;
+               $this->noredirect = (bool)$noredirect;
                parent::__construct( $form->getContext() );
        }
 
@@ -424,6 +443,9 @@ class ProtectedPagesPager extends AlphabeticPager {
                if ( $this->cascadeonly ) {
                        $conds[] = 'pr_cascade = 1';
                }
+               if ( $this->noredirect ) {
+                       $conds[] = 'page_is_redirect = 0';
+               }
 
                if ( $this->level ) {
                        $conds[] = 'pr_level=' . $this->mDb->addQuotes( $this->level );
index 13284ac..16808c5 100644 (file)
@@ -2753,6 +2753,7 @@ It now redirects to [[$2]].',
 'protectedpages-indef'            => 'Indefinite protections only',
 'protectedpages-summary'          => '', # do not translate or duplicate this message to other languages
 'protectedpages-cascade'          => 'Cascading protections only',
+'protectedpages-noredirect'       => 'Hide redirects',
 'protectedpagesempty'             => 'No pages are currently protected with these parameters.',
 'protectedtitles'                 => 'Protected titles',
 'protectedtitles-summary'         => '', # do not translate or duplicate this message to other languages
index 9c1b9f1..91c6c29 100644 (file)
@@ -4943,6 +4943,7 @@ See the following search results:
 'protectedpages' => '{{doc-special|ProtectedPages}}',
 'protectedpages-indef' => 'Option in [[Special:ProtectedPages]]',
 'protectedpages-cascade' => 'Option in [[Special:ProtectedPages]]',
+'protectedpages-noredirect' => 'Option in [[Special:ProtectedPages]]',
 'protectedpagesempty' => 'Used in [[Special:ProtectedPages]], when there are no protected pages with the specified parameters.',
 'protectedtitles' => '{{doc-special|ProtectedTitles}}',
 'protectedtitlesempty' => 'Used on [[Special:ProtectedTitles]]. This text appears if the list of protected titles is empty. See the [[mw:Project:Protected_titles|help page on MediaWiki]] for more information.',
index ded36cc..a891310 100644 (file)
@@ -1809,6 +1809,7 @@ $wgMessageStructure = array(
                'protectedpages-indef',
                'protectedpages-summary',
                'protectedpages-cascade',
+               'protectedpages-noredirect',
                'protectedpagesempty',
                'protectedtitles',
                'protectedtitles-summary',