http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96188
Revision: 96188
Author: dantman
Date: 2011-09-03 14:36:58 +0000 (Sat, 03 Sep 2011)
Log Message:
-----------
Expand r96170's support for space separated attributes with support for boolean
keys such as array( 'class' => array( 'selected' => true ) ) to match our
array( 'checked' => false ) support.
As per discussion with Krinkle make sure that in array( 'foo', 'foo' => false,
'foo' ) the 'foo' key is authoritive.
Modified Paths:
--------------
trunk/phase3/includes/Html.php
Modified: trunk/phase3/includes/Html.php
===================================================================
--- trunk/phase3/includes/Html.php 2011-09-03 14:27:01 UTC (rev 96187)
+++ trunk/phase3/includes/Html.php 2011-09-03 14:36:58 UTC (rev 96188)
@@ -432,13 +432,31 @@
// values. Implode/explode to get those into
the main array as well.
if ( is_array( $value ) ) {
// If input wasn't an array, we can
skip this step
- $value = implode( ' ', $value );
+
+ $newValue = array();
+ foreach ( $value as $k => $v ) {
+ if ( is_string( $v ) ) {
+ // String values should
be normal `array( 'foo' )`
+ // Just append them
+ if ( !isset( $value[$v]
) ) {
+ // As a special
case don't set 'foo' if a
+ // separate
'foo' => true/false exists in the array
+ // keys should
be authoritive
+ $newValue[] =
$v;
+ }
+ } elseif ( $v ) {
+ // If the value is
truthy but not a string this is likely
+ // an array( 'foo' =>
true ), falsy values don't add strings
+ $newValue[] = $k;
+ }
+ }
+ $value = implode( ' ', $newValue );
}
$value = explode( ' ', $value );
// Normalize spacing by fixing up cases where
people used
// more than 1 space and/or a trailing/leading
space
- $value = array_diff( $value, array( '', ' ') );
+ $value = array_diff( $value, array( '', ' ' ) );
// Remove duplicates and create the string
$value = implode( ' ', array_unique( $value ) );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs