(bug 10872) Fall back to sane defaults when generating protection selector labels...
authorRob Church <robchurch@users.mediawiki.org>
Sat, 11 Aug 2007 16:24:01 +0000 (16:24 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 11 Aug 2007 16:24:01 +0000 (16:24 +0000)
RELEASE-NOTES
includes/ProtectionForm.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index db72cc3..cd1d4f1 100644 (file)
@@ -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 ==
 
index c85cc30..c249ec1 100644 (file)
@@ -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 .= "</select>\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
index 247c201..584b8d6 100644 (file)
@@ -1861,6 +1861,7 @@ Here are the current settings for the page <strong>$1</strong>:',
 Here are the current settings for the page <strong>$1</strong>:',
 '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',
index 627a232..5d284c8 100644 (file)
@@ -1202,6 +1202,7 @@ $wgMessageStructure = array(
                'protect-locked-access',
                'protect-cascadeon',
                'protect-default',
+               'protect-fallback',
                'protect-level-autoconfirmed',
                'protect-level-sysop',
                'protect-summary-cascade',