Index: branches/RL2/extensions/Gadgets/Gadgets.hooks.php |
— | — | @@ -281,7 +281,6 @@ |
282 | 282 | $encCategory = bin2hex( $category ); |
283 | 283 | foreach ( $gadgets as $gadget ) { |
284 | 284 | $id = $gadget->getId(); |
285 | | - $sectionCat = $category === '' ? '' : "/gadgetcategory-$encRepoSource-$encCategory"; |
286 | 285 | if ( $repo->isLocal() ) { |
287 | 286 | // For local gadgets we have all the information |
288 | 287 | $title = htmlspecialchars( $gadget->getTitleMessage() ); |
— | — | @@ -292,6 +291,7 @@ |
293 | 292 | } else { |
294 | 293 | $text = wfMessage( 'gadgets-preference-description' )->rawParams( $title, $description )->parse(); |
295 | 294 | } |
| 295 | + $sectionCat = $category === '' ? '' : "/gadgetcategorylocal-$encRepoSource-$encCategory"; |
296 | 296 | $preferences["gadget-$id"] = array( |
297 | 297 | 'type' => 'toggle', |
298 | 298 | 'label' => $text, |
— | — | @@ -300,6 +300,7 @@ |
301 | 301 | 'name' => 'gadgetpref-' . bin2hex( $id ), |
302 | 302 | ); |
303 | 303 | } else { |
| 304 | + $sectionCat = $category === '' ? '' : "/gadgetcategory-$encRepoSource-$encCategory"; |
304 | 305 | $preferences["gadget-$id"] = array( |
305 | 306 | 'type' => 'toggle', |
306 | 307 | 'label' => htmlspecialchars( $id ), // will be changed by JS |
— | — | @@ -319,12 +320,19 @@ |
320 | 321 | |
321 | 322 | public static function preferencesGetLegend( $form, $key, &$legend ) { |
322 | 323 | $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 | + } |
329 | 337 | } |
330 | 338 | return true; |
331 | 339 | } |