Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsQP.php |
— | — | @@ -14,8 +14,6 @@ |
15 | 15 | |
16 | 16 | final class SMYahooMapsQP extends SMMapPrinter { |
17 | 17 | |
18 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME; |
19 | | - |
20 | 18 | /** |
21 | 19 | * @see SMMapPrinter::setQueryPrinterSettings() |
22 | 20 | */ |
Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -15,8 +15,6 @@ |
16 | 16 | |
17 | 17 | final class SMYahooMapsFormInput extends SMFormInput { |
18 | 18 | |
19 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME; |
20 | | - |
21 | 19 | protected $specificParameters = array(); |
22 | 20 | |
23 | 21 | /** |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersQP.php |
— | — | @@ -15,8 +15,6 @@ |
16 | 16 | |
17 | 17 | final class SMOpenLayersQP extends SMMapPrinter { |
18 | 18 | |
19 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME; |
20 | | - |
21 | 19 | /** |
22 | 20 | * @see SMMapPrinter::setQueryPrinterSettings() |
23 | 21 | * |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php |
— | — | @@ -15,8 +15,6 @@ |
16 | 16 | |
17 | 17 | final class SMOpenLayersFormInput extends SMFormInput { |
18 | 18 | |
19 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME; |
20 | | - |
21 | 19 | protected $specificParameters = array(); |
22 | 20 | |
23 | 21 | /** |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsQP.php |
— | — | @@ -16,8 +16,6 @@ |
17 | 17 | |
18 | 18 | final class SMGoogleMapsQP extends SMMapPrinter { |
19 | 19 | |
20 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
21 | | - |
22 | 20 | protected $specificParameters; |
23 | 21 | |
24 | 22 | /** |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php |
— | — | @@ -17,8 +17,6 @@ |
18 | 18 | |
19 | 19 | final class SMGoogleMapsFormInput extends SMFormInput { |
20 | 20 | |
21 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
22 | | - |
23 | 21 | protected $specificParameters = array(); |
24 | 22 | |
25 | 23 | /** |
Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | // Only initialize the extension when all dependencies are present. |
38 | 38 | if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) { |
39 | | - define( 'SM_VERSION', '0.6.3 a3' ); |
| 39 | + define( 'SM_VERSION', '0.6.3 a4' ); |
40 | 40 | |
41 | 41 | $smgScriptPath = ( isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps'; |
42 | 42 | $smgDir = dirname( __FILE__ ) . '/'; |
Index: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | */ |
27 | 27 | protected abstract function addFormDependencies(); |
28 | 28 | |
| 29 | + protected $mService; |
| 30 | + |
29 | 31 | /** |
30 | 32 | * @var string |
31 | 33 | */ |
— | — | @@ -43,6 +45,10 @@ |
44 | 46 | |
45 | 47 | private $coordinates; |
46 | 48 | |
| 49 | + public function __construct( MapsMappingService $service ) { |
| 50 | + $this->mService = $service; |
| 51 | + } |
| 52 | + |
47 | 53 | /** |
48 | 54 | * Validates and corrects the provided map properties, and the sets them as class fields. |
49 | 55 | * |
— | — | @@ -61,7 +67,7 @@ |
62 | 68 | * and finally by the specific parameters (the ones specific to a service-feature combination). |
63 | 69 | */ |
64 | 70 | $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), SMFormInputs::$parameters ); |
65 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] ); |
| 71 | + $parameterInfo = array_merge_recursive( $parameterInfo, $this->mService->getParameterInfo() ); |
66 | 72 | $parameterInfo = array_merge_recursive( $parameterInfo, $this->specificParameters ); |
67 | 73 | |
68 | 74 | $manager = new ValidatorManager(); |
— | — | @@ -258,8 +264,6 @@ |
259 | 265 | * Returns html for an html input field with a default value that will automatically dissapear when |
260 | 266 | * the user clicks in it, and reappers when the focus on the field is lost and it's still empty. |
261 | 267 | * |
262 | | - * @author Jeroen De Dauw |
263 | | - * |
264 | 268 | * @param string $id |
265 | 269 | * @param string $value |
266 | 270 | * @param string $args |
— | — | @@ -269,4 +273,4 @@ |
270 | 274 | private static function getDynamicInput( $id, $value, $args = '' ) { |
271 | 275 | return '<input id="' . $id . '" ' . $args . ' value="' . $value . '" onfocus="if (this.value==\'' . $value . '\') {this.value=\'\';}" onblur="if (this.value==\'\') {this.value=\'' . $value . '\';}" />'; |
272 | 276 | } |
273 | | -} |
| 277 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInputs.php |
— | — | @@ -34,21 +34,21 @@ |
35 | 35 | |
36 | 36 | self::initializeParams(); |
37 | 37 | |
38 | | - foreach ( $egMapsServices as $serviceName => $serviceData ) { |
39 | | - // Check if the service has a form input |
40 | | - $hasFI = array_key_exists( 'fi', $serviceData['features'] ); |
| 38 | + foreach ( $egMapsServices as $service ) { |
| 39 | + // Check if the service has a form input. |
| 40 | + $FIClass = $service->getFeature( 'fi' ); |
41 | 41 | |
42 | 42 | // If the service has no FI, skipt it and continue with the next one. |
43 | | - if ( !$hasFI ) continue; |
| 43 | + if ( $FIClass === false ) continue; |
44 | 44 | |
45 | 45 | // At least one form input will be enabled when this point is reached. |
46 | 46 | $hasFormInputs = true; |
47 | 47 | |
48 | 48 | // Add the result form input type for the service name. |
49 | | - self::initFormHook( $serviceName, $serviceName ); |
| 49 | + self::initFormHook( $service->getName(), $service->getName() ); |
50 | 50 | |
51 | 51 | // Loop through the service alliases, and add them as form input types. |
52 | | - foreach ( $serviceData['aliases'] as $alias ) self::initFormHook( $alias, $serviceName ); |
| 52 | + foreach ( $service->getAliases() as $alias ) self::initFormHook( $alias, $service->getName() ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Add the 'map' form input type if there are mapping services that have FI's loaded. |
— | — | @@ -121,16 +121,18 @@ |
122 | 122 | |
123 | 123 | // Get the service name from the field_args, and set it to null if it doesn't exist. |
124 | 124 | if ( array_key_exists( 'service_name', $field_args ) ) { |
125 | | - $service_name = $field_args['service_name']; |
| 125 | + $serviceName = $field_args['service_name']; |
126 | 126 | } |
127 | 127 | else { |
128 | | - $service_name = null; |
| 128 | + $serviceName = null; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Ensure the service is valid and create a new instance of the handling form input class. |
132 | | - $service_name = MapsMapper::getValidService( $service_name, 'fi' ); |
133 | | - $formInput = new $egMapsServices[$service_name]['features']['fi'](); |
| 132 | + $serviceName = MapsMapper::getValidService( $serviceName, 'fi' ); |
| 133 | + $FIClass = $egMapsServices[$serviceName]->getFeature( 'fi' ); |
134 | 134 | |
| 135 | + $formInput = new $FIClass( $egMapsServices[$serviceName] ); |
| 136 | + |
135 | 137 | // Get and return the form input HTML from the hook corresponding with the provided service. |
136 | 138 | return $formInput->formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ); |
137 | 139 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_QueryPrinters.php |
— | — | @@ -34,18 +34,18 @@ |
35 | 35 | |
36 | 36 | $hasQueryPrinters = false; |
37 | 37 | |
38 | | - foreach ( $egMapsServices as $serviceName => $serviceData ) { |
| 38 | + foreach ( $egMapsServices as $service ) { |
39 | 39 | // Check if the service has a query printer. |
40 | | - $hasQP = array_key_exists( 'qp', $serviceData['features'] ); |
| 40 | + $QPClass = $service->getFeature( 'qp' ); |
41 | 41 | |
42 | 42 | // If the service has no QP, skipt it and continue with the next one. |
43 | | - if ( !$hasQP ) continue; |
| 43 | + if ( $QPClass === false ) continue; |
44 | 44 | |
45 | 45 | // At least one query printer will be enabled when this point is reached. |
46 | 46 | $hasQueryPrinters = true; |
47 | 47 | |
48 | 48 | // Initiate the format. |
49 | | - self::initFormat( $serviceName, $serviceData['features']['qp'], $serviceData['aliases'] ); |
| 49 | + self::initFormat( $service->getName(), $QPClass, $service->getAliases() ); |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Add the 'map' result format if there are mapping services that have QP's loaded. |
Index: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_MapPrinter.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | */ |
45 | 45 | protected abstract function addSpecificMapHTML( Parser $parser ); |
46 | 46 | |
47 | | - public $serviceName; |
| 47 | + protected $mService; |
48 | 48 | |
49 | 49 | protected $mLocations = array(); |
50 | 50 | |
— | — | @@ -60,6 +60,10 @@ |
61 | 61 | protected $featureParameters = array(); |
62 | 62 | protected $specificParameters = array(); |
63 | 63 | |
| 64 | + public function __construct( $format, $inline, /* MapsMappingService */ $service = null ) { |
| 65 | + $this->mService = $service; |
| 66 | + } |
| 67 | + |
64 | 68 | /** |
65 | 69 | * Builds up and returns the HTML for the map, with the queried coordinate data on it. |
66 | 70 | * |
— | — | @@ -115,7 +119,7 @@ |
116 | 120 | * and finally by the specific parameters (the ones specific to a service-feature combination). |
117 | 121 | */ |
118 | 122 | $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), $this->featureParameters ); |
119 | | - $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] ); |
| 123 | + $parameterInfo = array_merge_recursive( $parameterInfo, $this->mService->getParameterInfo() ); |
120 | 124 | $parameterInfo = array_merge_recursive( $parameterInfo, $this->specificParameters ); |
121 | 125 | |
122 | 126 | $manager = new ValidatorManager(); |
— | — | @@ -135,7 +139,6 @@ |
136 | 140 | * Sets the map properties as class fields. |
137 | 141 | * |
138 | 142 | * @param array $mapProperties |
139 | | - * @param string $className |
140 | 143 | */ |
141 | 144 | private function setMapProperties( array $mapProperties ) { |
142 | 145 | foreach ( $mapProperties as $paramName => $paramValue ) { |
— | — | @@ -149,7 +152,7 @@ |
150 | 153 | } |
151 | 154 | |
152 | 155 | public final function getResult( $results, $params, $outputmode ) { |
153 | | - // Skip checks, results with 0 entries are normal |
| 156 | + // Skip checks, results with 0 entries are normal. |
154 | 157 | $this->readParameters( $params, $outputmode ); |
155 | 158 | |
156 | 159 | return $this->getResultText( $results, SMW_OUTPUT_HTML ); |
— | — | @@ -166,9 +169,9 @@ |
167 | 170 | * and add the location data, title, label and icon to the m_locations array. |
168 | 171 | * |
169 | 172 | * @param unknown_type $outputmode |
170 | | - * @param unknown_type $row The record you want to add data from |
| 173 | + * @param array $row The record you want to add data from |
171 | 174 | */ |
172 | | - private function addResultRow( $outputmode, $row ) { |
| 175 | + private function addResultRow( $outputmode, array $row ) { |
173 | 176 | global $wgUser, $smgUseSpatialExtensions; |
174 | 177 | |
175 | 178 | $skin = $wgUser->getSkin(); |
— | — | @@ -182,11 +185,11 @@ |
183 | 186 | $coords = array(); |
184 | 187 | $label = array(); |
185 | 188 | |
186 | | - // Loop throught all fields of the record |
| 189 | + // Loop throught all fields of the record. |
187 | 190 | foreach ( $row as $i => $field ) { |
188 | 191 | $pr = $field->getPrintRequest(); |
189 | 192 | |
190 | | - // Loop throught all the parts of the field value |
| 193 | + // Loop throught all the parts of the field value. |
191 | 194 | while ( ( $object = $field->getNextObject() ) !== false ) { |
192 | 195 | if ( $object->getTypeID() == '_wpg' && $i == 0 ) { |
193 | 196 | if ( $this->showtitle ) $title = $object->getLongText( $outputmode, $skin ); |
— | — | @@ -248,12 +251,13 @@ |
249 | 252 | } |
250 | 253 | |
251 | 254 | /** |
252 | | - * Get the icon for a row |
| 255 | + * Get the icon for a row. |
253 | 256 | * |
254 | | - * @param unknown_type $row |
255 | | - * @return unknown |
| 257 | + * @param array $row |
| 258 | + * |
| 259 | + * @return string |
256 | 260 | */ |
257 | | - private function getLocationIcon( $row ) { |
| 261 | + private function getLocationIcon( array $row ) { |
258 | 262 | $icon = ''; |
259 | 263 | $legend_labels = array(); |
260 | 264 | |
— | — | @@ -287,7 +291,6 @@ |
288 | 292 | |
289 | 293 | /** |
290 | 294 | * Sets the zoom level to the provided value, or when not set, to the default. |
291 | | - * |
292 | 295 | */ |
293 | 296 | private function setZoom() { |
294 | 297 | if ( strlen( $this->zoom ) < 1 ) { |
— | — | @@ -303,7 +306,6 @@ |
304 | 307 | /** |
305 | 308 | * Sets the $centre_lat and $centre_lon fields. |
306 | 309 | * Note: this needs to be done AFTRE the maker coordinates are set. |
307 | | - * |
308 | 310 | */ |
309 | 311 | private function setCentre() { |
310 | 312 | // If a centre value is set, use it. |
— | — | @@ -357,4 +359,4 @@ |
358 | 360 | return $params; |
359 | 361 | } |
360 | 362 | |
361 | | -} |
| 363 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/Features/QueryPrinters/SM_Mapper.php |
— | — | @@ -24,9 +24,10 @@ |
25 | 25 | // Note: if this is allowed, then the getParameters should only return the base parameters. |
26 | 26 | if ( $format == 'map' ) $format = $egMapsDefaultServices['qp']; |
27 | 27 | |
28 | | - $service = MapsMapper::getValidService( $format, 'qp' ); |
| 28 | + $service = $egMapsServices[MapsMapper::getValidService( $format, 'qp' )]; |
| 29 | + $QPClass = $service->getFeature( 'qp' ); |
29 | 30 | |
30 | | - $this->queryPrinter = new $egMapsServices[$service]['features']['qp']( $format, $inline ); |
| 31 | + $this->queryPrinter = new $QPClass( $format, $inline, $service ); |
31 | 32 | } |
32 | 33 | |
33 | 34 | public static function getAliases() { |
— | — | @@ -61,4 +62,4 @@ |
62 | 63 | return $this->queryPrinter->getMimeType( $res ); |
63 | 64 | } |
64 | 65 | |
65 | | -} |
| 66 | +} |
\ No newline at end of file |