From a54fc5b9743709f67a82fa66c80990c03270d7d8 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 11 Aug 2007 16:24:01 +0000 Subject: [PATCH] (bug 10872) Fall back to sane defaults when generating protection selector labels for custom restriction levels --- RELEASE-NOTES | 2 ++ includes/ProtectionForm.php | 31 ++++++++++++++++++------------- languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index db72cc3cd3..cd1d4f17b0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -170,6 +170,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 10859) Introduce 'UserGetImplicitGroups' hook; see docs/hooks.txt for more information * (bug 10832) Include user information when viewing a deleted revision +* (bug 10872) Fall back to sane defaults when generating protection selector + labels for custom restriction levels == Bugfixes since 1.10 == diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index c85cc30458..c249ec1291 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -278,22 +278,28 @@ class ProtectionForm { $out = wfOpenElement( 'select', $attribs ); foreach( $wgRestrictionLevels as $key ) { - $out .= $this->buildOption( $key, $selected ); + $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected ); } $out .= "\n"; return $out; } - function buildOption( $key, $selected ) { - $text = ( $key == '' ) - ? wfMsg( 'protect-default' ) - : wfMsg( "protect-level-$key" ); - $selectedAttrib = ($selected == $key) - ? array( 'selected' => 'selected' ) - : array(); - return wfElement( 'option', - array( 'value' => $key ) + $selectedAttrib, - $text ); + /** + * Prepare the label for a protection selector option + * + * @param string $permission Permission required + * @return string + */ + private function getOptionLabel( $permission ) { + if( $permission == '' ) { + return wfMsg( 'protect-default' ); + } else { + $key = "protect-level-{$permission}"; + $msg = wfMsg( $key ); + if( wfEmptyMsg( $key, $msg ) ) + $msg = wfMsg( 'protect-fallback', $permission ); + return $msg; + } } function buildReasonInput() { @@ -376,6 +382,5 @@ class ProtectionForm { 'type' => 'protect' ) ) ) ); $logViewer->showList( $out ); } -} - +} \ No newline at end of file diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 247c201017..584b8d627a 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1861,6 +1861,7 @@ Here are the current settings for the page $1:', Here are the current settings for the page $1:', 'protect-cascadeon' => "This page is currently protected because it is included in the following {{PLURAL:$1|page, which has|pages, which have}} cascading protection turned on. You can change this page's protection level, but it will not affect the cascading protection.", 'protect-default' => '(default)', +'protect-fallback' => 'Require "$1" permission', 'protect-level-autoconfirmed' => 'Block unregistered users', 'protect-level-sysop' => 'Sysops only', 'protect-summary-cascade' => 'cascading', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 627a2328f5..5d284c80ae 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1202,6 +1202,7 @@ $wgMessageStructure = array( 'protect-locked-access', 'protect-cascadeon', 'protect-default', + 'protect-fallback', 'protect-level-autoconfirmed', 'protect-level-sysop', 'protect-summary-cascade', -- 2.20.1