Index: trunk/phase3/includes/Html.php |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | * Returns an HTML element in a string. The major advantage here over |
107 | 107 | * manually typing out the HTML is that it will escape all attribute |
108 | 108 | * values. If you're hardcoding all the attributes, or there are none, you |
109 | | - * should probably type out the string yourself. |
| 109 | + * should probably just type out the html element yourself. |
110 | 110 | * |
111 | 111 | * This is quite similar to Xml::tags(), but it implements some useful |
112 | 112 | * HTML-specific logic. For instance, there is no $allowShortTag |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | * |
117 | 117 | * @param $element string The element's name, e.g., 'a' |
118 | 118 | * @param $attribs array Associative array of attributes, e.g., array( |
119 | | - * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for |
| 119 | + * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for |
120 | 120 | * further documentation. |
121 | 121 | * @param $contents string The raw HTML contents of the element: *not* |
122 | 122 | * escaped! |
— | — | @@ -358,6 +358,26 @@ |
359 | 359 | * For instance, it will omit quotation marks if $wgWellFormedXml is false, |
360 | 360 | * and will treat boolean attributes specially. |
361 | 361 | * |
| 362 | + * Attributes that should contain space-separated lists (such as 'class') array |
| 363 | + * values are allowed as well, which will automagically be normalized |
| 364 | + * and converted to a space-separated string. In addition to a numerical |
| 365 | + * array, the attribute value may also be an associative array. See the |
| 366 | + * example below for how that works. |
| 367 | + * @example Numerical array |
| 368 | + * <code> |
| 369 | + * Html::element( 'em', array( |
| 370 | + * 'class' => array( 'foo', 'bar' ) |
| 371 | + * ) ); |
| 372 | + * // gives '<em class="foo bar"></em>' |
| 373 | + * </code> |
| 374 | + * @example Associative array |
| 375 | + * <code> |
| 376 | + * Html::element( 'em', array( |
| 377 | + * 'class' => array( 'foo', 'bar', 'foo' => false, 'quux' => true ) |
| 378 | + * ) ); |
| 379 | + * // gives '<em class="bar quux"></em>' |
| 380 | + * </code> |
| 381 | + * |
362 | 382 | * @param $attribs array Associative array of attributes, e.g., array( |
363 | 383 | * 'href' => 'http://www.mediawiki.org/' ). Values will be HTML-escaped. |
364 | 384 | * A value of false means to omit the attribute. For boolean attributes, |