r24733 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24732‎ | r24733 | r24734 >
Date:16:24, 11 August 2007
Author:robchurch
Status:old
Tags:
Comment:
(bug 10872) Fall back to sane defaults when generating protection selector labels for custom restriction levels
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/ProtectionForm.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1202,6 +1202,7 @@
12031203 'protect-locked-access',
12041204 'protect-cascadeon',
12051205 'protect-default',
 1206+ 'protect-fallback',
12061207 'protect-level-autoconfirmed',
12071208 'protect-level-sysop',
12081209 'protect-summary-cascade',
Index: trunk/phase3/includes/ProtectionForm.php
@@ -278,22 +278,28 @@
279279
280280 $out = wfOpenElement( 'select', $attribs );
281281 foreach( $wgRestrictionLevels as $key ) {
282 - $out .= $this->buildOption( $key, $selected );
 282+ $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected );
283283 }
284284 $out .= "</select>\n";
285285 return $out;
286286 }
287287
288 - function buildOption( $key, $selected ) {
289 - $text = ( $key == '' )
290 - ? wfMsg( 'protect-default' )
291 - : wfMsg( "protect-level-$key" );
292 - $selectedAttrib = ($selected == $key)
293 - ? array( 'selected' => 'selected' )
294 - : array();
295 - return wfElement( 'option',
296 - array( 'value' => $key ) + $selectedAttrib,
297 - $text );
 288+ /**
 289+ * Prepare the label for a protection selector option
 290+ *
 291+ * @param string $permission Permission required
 292+ * @return string
 293+ */
 294+ private function getOptionLabel( $permission ) {
 295+ if( $permission == '' ) {
 296+ return wfMsg( 'protect-default' );
 297+ } else {
 298+ $key = "protect-level-{$permission}";
 299+ $msg = wfMsg( $key );
 300+ if( wfEmptyMsg( $key, $msg ) )
 301+ $msg = wfMsg( 'protect-fallback', $permission );
 302+ return $msg;
 303+ }
298304 }
299305
300306 function buildReasonInput() {
@@ -376,6 +382,5 @@
377383 'type' => 'protect' ) ) ) );
378384 $logViewer->showList( $out );
379385 }
380 -}
381386
382 -
 387+}
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1861,6 +1861,7 @@
18621862 Here are the current settings for the page <strong>$1</strong>:',
18631863 '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.",
18641864 'protect-default' => '(default)',
 1865+'protect-fallback' => 'Require "$1" permission',
18651866 'protect-level-autoconfirmed' => 'Block unregistered users',
18661867 'protect-level-sysop' => 'Sysops only',
18671868 'protect-summary-cascade' => 'cascading',
Index: trunk/phase3/RELEASE-NOTES
@@ -170,6 +170,8 @@
171171 * (bug 10859) Introduce 'UserGetImplicitGroups' hook; see docs/hooks.txt for
172172 more information
173173 * (bug 10832) Include user information when viewing a deleted revision
 174+* (bug 10872) Fall back to sane defaults when generating protection selector
 175+ labels for custom restriction levels
174176
175177 == Bugfixes since 1.10 ==
176178

Follow-up revisions

RevisionCommit summaryAuthorDate
r24755Merged revisions 24694-24754 via svnmerge from...david19:48, 13 August 2007

Status & tagging log