r102858 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102857‎ | r102858 | r102859 >
Date:11:39, 12 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
[RL2] Fix regression in r101364: fieldset legends for local categories will not be i18ned by JS, so they need to be treated differently.
Modified paths:
  • /branches/RL2/extensions/Gadgets/Gadgets.hooks.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.hooks.php
@@ -281,7 +281,6 @@
282282 $encCategory = bin2hex( $category );
283283 foreach ( $gadgets as $gadget ) {
284284 $id = $gadget->getId();
285 - $sectionCat = $category === '' ? '' : "/gadgetcategory-$encRepoSource-$encCategory";
286285 if ( $repo->isLocal() ) {
287286 // For local gadgets we have all the information
288287 $title = htmlspecialchars( $gadget->getTitleMessage() );
@@ -292,6 +291,7 @@
293292 } else {
294293 $text = wfMessage( 'gadgets-preference-description' )->rawParams( $title, $description )->parse();
295294 }
 295+ $sectionCat = $category === '' ? '' : "/gadgetcategorylocal-$encRepoSource-$encCategory";
296296 $preferences["gadget-$id"] = array(
297297 'type' => 'toggle',
298298 'label' => $text,
@@ -300,6 +300,7 @@
301301 'name' => 'gadgetpref-' . bin2hex( $id ),
302302 );
303303 } else {
 304+ $sectionCat = $category === '' ? '' : "/gadgetcategory-$encRepoSource-$encCategory";
304305 $preferences["gadget-$id"] = array(
305306 'type' => 'toggle',
306307 'label' => htmlspecialchars( $id ), // will be changed by JS
@@ -319,12 +320,19 @@
320321
321322 public static function preferencesGetLegend( $form, $key, &$legend ) {
322323 $matches = null;
323 - if ( preg_match( '/^(gadgetrepo|gadgetcategory-[A-Za-z0-9]*)-([A-Za-z0-9]*)$/', $key, $matches ) ) {
324 - // Decode the category ID
325 - $catID = pack( "H*", $matches[2] ); // PHP doesn't have hex2bin() yet
326 - // Just display the ID itself (with ucfirst applied)
327 - // This will be changed to a properly i18ned string by JS
328 - $legend = $form->getLang()->ucfirst( $catID );
 324+ if ( preg_match( '/^(?:gadgetrepo|gadgetcategory(local)?-[A-Za-z0-9]*)-([A-Za-z0-9]*)$/', $key, $matches ) ) {
 325+ // Decode the category or repo ID
 326+ $id = pack( "H*", $matches[2] ); // PHP doesn't have hex2bin() yet
 327+ if ( $matches[1] !== null ) {
 328+ // This is a local category ID
 329+ // We have access to the message, so display it
 330+ $legend = LocalGadgetRepo::singleton()->getCategoryTitle( $id, $form->getLang() );
 331+ } else {
 332+ // This is a repository ID or a foreign category ID
 333+ // Just display the ID itself (with ucfirst applied)
 334+ // This will be changed to a properly i18ned string by JS
 335+ $legend = $form->getLang()->ucfirst( $id );
 336+ }
329337 }
330338 return true;
331339 }

Sign-offs

UserFlagDate
Nikerabbitinspected15:02, 24 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101364[RL2] Use fieldsets instead of divs and h1's for sectioning the gadget prefer...catrope16:45, 31 October 2011

Status & tagging log