r24531 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24530‎ | r24531 | r24532 >
Date:21:25, 1 August 2007
Author:daniel
Status:old
Tags:
Comment:
normalize gadget names, allow spaces
Modified paths:
  • /trunk/extensions/Gadgets/Gadgets.php (modified) (history)
  • /trunk/extensions/Gadgets/README (modified) (history)

Diff [purge]

Index: trunk/extensions/Gadgets/Gadgets.php
@@ -53,6 +53,8 @@
5454 }
5555
5656 function wfLoadGadgetsStructured() {
 57+ global $wgContLang, $wgCapitalLinks;
 58+
5759 static $gadgets = NULL;
5860
5961 if ( $gadgets !== NULL ) return $gadgets;
@@ -74,8 +76,13 @@
7577 if ( preg_match( '/^==+ *([^*:\s|]+?)\s*==+\s*$/', $line, $m ) ) {
7678 $section = $m[1];
7779 }
78 - else if ( preg_match( '/^\*+ *(\w[-\w\d]*)((\|[^|]*)+)\s*$/', $line, $m ) ) {
79 - $name = $m[1];
 80+ else if ( preg_match( '/^\*+ *([a-zA-Z](?:[-_:.\w\d ]*[a-zA-Z0-9])?)\s*((\|[^|]*)+)\s*$/', $line, $m ) ) {
 81+ //NOTE: the gadget name is used as part of the name of a form field,
 82+ // and must follow the rules defined in http://www.w3.org/TR/html4/types.html#type-cdata
 83+ // Also, title-normalization applies.
 84+ $name = str_replace(' ', '_', $m[1]);
 85+ if ( $wgCapitalLinks ) $name = $wgContLang->ucfirst( $name );
 86+
8087 $code = preg_split( '/\s*\|\s*/', $m[2], -1, PREG_SPLIT_NO_EMPTY );
8188
8289 if ( $code ) {
Index: trunk/extensions/Gadgets/README
@@ -40,7 +40,9 @@
4141 and references a system message (MediaWiki:Mygadget in the example)
4242 that contains a short descriptiopn of the gadget, using wiki syntax.
4343 Note that the internal name must start with a ASCII letter, and must
44 -contain only ASCII letter and numbers.
 44+contain only ASCII letter and numbers, hyphens ("-"), underscores ("_"),
 45+colons (":"), and periods (".") (spaces are also allowed but converted to
 46+underscored ("_"), like for page titles).
4547
4648 The remaining fields on the line refer to the JavaScript or CSS code that
4749 makes up the gadget, contained in system messages (MediaWiki:Mygadget.js

Status & tagging log