From 9ac031495981e12435e83a96243d66aa4c1e4962 Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Thu, 2 Jan 2014 13:45:44 -0500 Subject: [PATCH] Allow hiding redirects in Special:ProtectedPages Add a checkbox to hide redirects in Special:ProtectedPages. Bug: 19233 Change-Id: If1753eddc834f55c301a6e78e0802ee9d94a24b2 --- includes/specials/SpecialProtectedpages.php | 44 +++++++++++++++------ languages/messages/MessagesEn.php | 1 + languages/messages/MessagesQqq.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index db3be12eec..214fbd9fd3 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -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 { "
" . $this->getExpiryCheck( $indefOnly ) . " \n" . $this->getCascadeCheck( $cascadeOnly ) . " \n" . + $this->getRedirectCheck( $noRedirect ) . " \n" . "
" . $this->getSizeLimit( $sizetype, $size ) . " \n" . "" . @@ -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 ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 13284acb19..16808c5f5f 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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 diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 9c1b9f16bf..91c6c29e89 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -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.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index ded36ccbcc..a89131085f 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1809,6 +1809,7 @@ $wgMessageStructure = array( 'protectedpages-indef', 'protectedpages-summary', 'protectedpages-cascade', + 'protectedpages-noredirect', 'protectedpagesempty', 'protectedtitles', 'protectedtitles-summary', -- 2.20.1