r74888 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74887‎ | r74888 | r74889 >
Date:09:54, 17 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7.1 - follow up to r74885
Modified paths:
  • /trunk/extensions/Maps/includes/Maps_Layer.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/includes/Maps_Layer.php
@@ -22,19 +22,6 @@
2323 protected static $types = array(
2424 'image' => array(
2525 '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 - )
3926 )
4027 );
4128
@@ -81,6 +68,9 @@
8269 */
8370 public function __construct( array $properties ) {
8471 $this->properties = $properties;
 72+
 73+ // TODO
 74+ $this->properties['source'] = MapsMapper::getImageUrl( $this->properties['source'] );
8575 }
8676
8777 /**
@@ -136,19 +126,22 @@
137127 protected function getParameterDefinitions() {
138128 $params = array();
139129
 130+ $params['type'] = new Parameter( 'type' );
 131+ $params['type']->addCriteria( New CriterionInArray( array_keys( self::$types ) ) );
 132+
140133 $params[] = new Parameter( 'label' );
141134
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 );
148141
149142 $params[] = new Parameter( 'zoomlevels', Parameter::TYPE_INTEGER, false );
150143
151144 $params['source'] = new Parameter( 'source' );
152 - //$params['source']->addCriteria();
 145+ //$params['source']->addCriteria(); // TODO
153146 //$params['source']->addManipulations();
154147
155148 return $params;
@@ -168,6 +161,8 @@
169162 if ( $validator->hasFatalError() !== false ) {
170163 $this->errors = $validator->getErrors();
171164 }
 165+
 166+ $this->properties = $validator->getParameterValues();
172167 }
173168
174169 /**
@@ -195,22 +190,16 @@
196191 * @return string
197192 */
198193 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+ }
208197
209198 $class = self::$types[$this->getType()]['class'];
210199
211200 $options = array();
212201
213202 if ( array_key_exists( 'zoomlevels', $this->properties ) ) {
214 - $options['numZoomLevels'] = (int)$this->properties['zoomlevels'];
 203+ $options['numZoomLevels'] = $zoomlevels;
215204 }
216205
217206 $options = Xml::encodeJsVar( (object)$options );
@@ -219,7 +208,7 @@
220209 new $class(
221210 $label,
222211 $source,
223 - new OpenLayers.Bounds($leftBound, $lowerBound, $rightBound, $upperBound),
 212+ new OpenLayers.Bounds($leftbound, $lowerbound, $rightbound, $upperbound),
224213 new OpenLayers.Size($width, $height),
225214 {$options}
226215 )

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74885Changes for 0.7.1 - improvements to layer validationjeroendedauw09:27, 17 October 2010

Status & tagging log