Index: trunk/extensions/Maps/includes/Maps_Layer.php |
— | — | @@ -22,19 +22,6 @@ |
23 | 23 | protected static $types = array( |
24 | 24 | 'image' => array( |
25 | 25 | 'class' => 'OpenLayers.Layer.Image', |
26 | | - 'required' => array( |
27 | | - 'label', |
28 | | - 'source', |
29 | | - 'lowerbound', |
30 | | - 'upperbound', |
31 | | - 'leftbound', |
32 | | - 'rightbound', |
33 | | - 'width', |
34 | | - 'height' |
35 | | - ), |
36 | | - 'optional' => array( |
37 | | - 'zoomlevels' |
38 | | - ) |
39 | 26 | ) |
40 | 27 | ); |
41 | 28 | |
— | — | @@ -81,6 +68,9 @@ |
82 | 69 | */ |
83 | 70 | public function __construct( array $properties ) { |
84 | 71 | $this->properties = $properties; |
| 72 | + |
| 73 | + // TODO |
| 74 | + $this->properties['source'] = MapsMapper::getImageUrl( $this->properties['source'] ); |
85 | 75 | } |
86 | 76 | |
87 | 77 | /** |
— | — | @@ -136,19 +126,22 @@ |
137 | 127 | protected function getParameterDefinitions() { |
138 | 128 | $params = array(); |
139 | 129 | |
| 130 | + $params['type'] = new Parameter( 'type' ); |
| 131 | + $params['type']->addCriteria( New CriterionInArray( array_keys( self::$types ) ) ); |
| 132 | + |
140 | 133 | $params[] = new Parameter( 'label' ); |
141 | 134 | |
142 | | - $params[] = new Parameter( 'lowerbound', Parameter::TYPE_INTEGER ); |
143 | | - $params[] = new Parameter( 'upperbound', Parameter::TYPE_INTEGER ); |
144 | | - $params[] = new Parameter( 'leftbound', Parameter::TYPE_INTEGER ); |
145 | | - $params[] = new Parameter( 'rightbound', Parameter::TYPE_INTEGER ); |
146 | | - $params[] = new Parameter( 'width', Parameter::TYPE_INTEGER ); |
147 | | - $params[] = new Parameter( 'height', Parameter::TYPE_INTEGER ); |
| 135 | + $params[] = new Parameter( 'lowerbound', Parameter::TYPE_FLOAT ); |
| 136 | + $params[] = new Parameter( 'upperbound', Parameter::TYPE_FLOAT ); |
| 137 | + $params[] = new Parameter( 'leftbound', Parameter::TYPE_FLOAT ); |
| 138 | + $params[] = new Parameter( 'rightbound', Parameter::TYPE_FLOAT ); |
| 139 | + $params[] = new Parameter( 'width', Parameter::TYPE_FLOAT ); |
| 140 | + $params[] = new Parameter( 'height', Parameter::TYPE_FLOAT ); |
148 | 141 | |
149 | 142 | $params[] = new Parameter( 'zoomlevels', Parameter::TYPE_INTEGER, false ); |
150 | 143 | |
151 | 144 | $params['source'] = new Parameter( 'source' ); |
152 | | - //$params['source']->addCriteria(); |
| 145 | + //$params['source']->addCriteria(); // TODO |
153 | 146 | //$params['source']->addManipulations(); |
154 | 147 | |
155 | 148 | return $params; |
— | — | @@ -168,6 +161,8 @@ |
169 | 162 | if ( $validator->hasFatalError() !== false ) { |
170 | 163 | $this->errors = $validator->getErrors(); |
171 | 164 | } |
| 165 | + |
| 166 | + $this->properties = $validator->getParameterValues(); |
172 | 167 | } |
173 | 168 | |
174 | 169 | /** |
— | — | @@ -195,22 +190,16 @@ |
196 | 191 | * @return string |
197 | 192 | */ |
198 | 193 | public function getJavaScriptDefinition() { |
199 | | - // Note: this is currently hardcoded for layers of type image. |
200 | | - $label = Xml::encodeJsVar( $this->properties['label'] ); |
201 | | - $source = Xml::encodeJsVar( MapsMapper::getImageUrl( $this->properties['source'] ) ); |
202 | | - $lowerBound = Xml::encodeJsVar( (int)$this->properties['lowerbound'] ); |
203 | | - $upperBound = Xml::encodeJsVar( (int)$this->properties['upperbound'] ); |
204 | | - $leftBound = Xml::encodeJsVar( (int)$this->properties['leftbound'] ); |
205 | | - $rightBound = Xml::encodeJsVar( (int)$this->properties['rightbound'] ); |
206 | | - $width = Xml::encodeJsVar( (int)$this->properties['width'] ); |
207 | | - $height = Xml::encodeJsVar( (int)$this->properties['height'] ); |
| 194 | + foreach ( $this->properties as $name => $value ) { |
| 195 | + ${ $name } = Xml::encodeJsVar( $value ); |
| 196 | + } |
208 | 197 | |
209 | 198 | $class = self::$types[$this->getType()]['class']; |
210 | 199 | |
211 | 200 | $options = array(); |
212 | 201 | |
213 | 202 | if ( array_key_exists( 'zoomlevels', $this->properties ) ) { |
214 | | - $options['numZoomLevels'] = (int)$this->properties['zoomlevels']; |
| 203 | + $options['numZoomLevels'] = $zoomlevels; |
215 | 204 | } |
216 | 205 | |
217 | 206 | $options = Xml::encodeJsVar( (object)$options ); |
— | — | @@ -219,7 +208,7 @@ |
220 | 209 | new $class( |
221 | 210 | $label, |
222 | 211 | $source, |
223 | | - new OpenLayers.Bounds($leftBound, $lowerBound, $rightBound, $upperBound), |
| 212 | + new OpenLayers.Bounds($leftbound, $lowerbound, $rightbound, $upperbound), |
224 | 213 | new OpenLayers.Size($width, $height), |
225 | 214 | {$options} |
226 | 215 | ) |