Index: trunk/extensions/Maps/includes/Maps_Layer.php |
— | — | @@ -126,7 +126,8 @@ |
127 | 127 | $params['type'] = new Parameter( 'type' ); |
128 | 128 | $params['type']->addCriteria( New CriterionInArray( array_keys( self::$types ) ) ); |
129 | 129 | |
130 | | - $params[] = new Parameter( 'label' ); |
| 130 | + $params['label'] = new Parameter( 'label' ); |
| 131 | + $params['label']->lowerCaseValue = false; |
131 | 132 | |
132 | 133 | $params[] = new Parameter( 'lowerbound', Parameter::TYPE_FLOAT ); |
133 | 134 | $params[] = new Parameter( 'upperbound', Parameter::TYPE_FLOAT ); |
— | — | @@ -188,9 +189,9 @@ |
189 | 190 | */ |
190 | 191 | public function getJavaScriptDefinition() { |
191 | 192 | foreach ( $this->properties as $name => $value ) { |
192 | | - ${ $name } = Xml::encodeJsVar( $value ); |
| 193 | + ${ $name } = MapsMapper::encodeJsVar( $value ); |
193 | 194 | } |
194 | | - |
| 195 | + |
195 | 196 | $class = self::$types[$this->getType()]['class']; |
196 | 197 | |
197 | 198 | $options = array(); |
Index: trunk/extensions/Maps/includes/services/OpenLayers/Maps_ParamOLLayers.php |
— | — | @@ -36,6 +36,7 @@ |
37 | 37 | |
38 | 38 | foreach ( $parameter->getValue() as $layerOrGroup ) { |
39 | 39 | $lcLayerOrGroup = strtolower( $layerOrGroup ); |
| 40 | + |
40 | 41 | // Layer groups. Loop over all items and add them when not present yet. |
41 | 42 | if ( array_key_exists( $lcLayerOrGroup, $egMapsOLLayerGroups ) ) { |
42 | 43 | foreach ( $egMapsOLLayerGroups[$lcLayerOrGroup] as $layerName ) { |
Index: trunk/extensions/Maps/includes/Maps_Mapper.php |
— | — | @@ -63,6 +63,56 @@ |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
| 67 | + * Encode a variable of unknown type to JavaScript. |
| 68 | + * Arrays are converted to JS arrays, objects are converted to JS associative |
| 69 | + * arrays (objects). So cast your PHP associative arrays to objects before |
| 70 | + * passing them to here. |
| 71 | + * |
| 72 | + * This is a copy of |
| 73 | + * @see Xml::encodeJsVar |
| 74 | + * which fixes incorrect behaviour with floats. |
| 75 | + * |
| 76 | + * @since 0.7.1 |
| 77 | + * |
| 78 | + * @param mixed $value |
| 79 | + */ |
| 80 | + public static function encodeJsVar( $value ) { |
| 81 | + if ( is_bool( $value ) ) { |
| 82 | + $s = $value ? 'true' : 'false'; |
| 83 | + } elseif ( is_null( $value ) ) { |
| 84 | + $s = 'null'; |
| 85 | + } elseif ( is_int( $value ) || is_float( $value ) ) { |
| 86 | + $s = $value; |
| 87 | + } elseif ( is_array( $value ) && // Make sure it's not associative. |
| 88 | + array_keys($value) === range( 0, count($value) - 1 ) || |
| 89 | + count($value) == 0 |
| 90 | + ) { |
| 91 | + $s = '['; |
| 92 | + foreach ( $value as $elt ) { |
| 93 | + if ( $s != '[' ) { |
| 94 | + $s .= ', '; |
| 95 | + } |
| 96 | + $s .= self::encodeJsVar( $elt ); |
| 97 | + } |
| 98 | + $s .= ']'; |
| 99 | + } elseif ( is_object( $value ) || is_array( $value ) ) { |
| 100 | + // Objects and associative arrays |
| 101 | + $s = '{'; |
| 102 | + foreach ( (array)$value as $name => $elt ) { |
| 103 | + if ( $s != '{' ) { |
| 104 | + $s .= ', '; |
| 105 | + } |
| 106 | + $s .= '"' . Xml::escapeJsString( $name ) . '": ' . |
| 107 | + self::encodeJsVar( $elt ); |
| 108 | + } |
| 109 | + $s .= '}'; |
| 110 | + } else { |
| 111 | + $s = '"' . Xml::escapeJsString( $value ) . '"'; |
| 112 | + } |
| 113 | + return $s; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
67 | 117 | * This function returns the definitions for the parameters used by every map feature. |
68 | 118 | * |
69 | 119 | * @return array |