r54492 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54491‎ | r54492 | r54493 >
Date:22:34, 5 August 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Refactoring for 0.3
Modified paths:
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayers.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SM_FormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMaps.php
@@ -14,6 +14,8 @@
1515
1616 final class SMYahooMaps extends SMMapPrinter {
1717
 18+ public $serviceName = MapsYahooMaps::SERVICE_NAME;
 19+
1820 public function getName() {
1921 wfLoadExtensionMessages('SemanticMaps');
2022 return wfMsg('sm_yahoomaps_printername');
@@ -41,6 +43,8 @@
4244 $egYahooMapsOnThisPage++;
4345
4446 $this->elementNr = $egYahooMapsOnThisPage;
 47+
 48+ $this->defaultParams = MapsYahooMaps::getDefaultParams();
4549 }
4650
4751 /**
@@ -56,6 +60,8 @@
5761 MapsUtils::makePxValue($this->width);
5862 MapsUtils::makePxValue($this->height);
5963
 64+ $this->autozoom = MapsYahooMaps::getAutozoomJSValue($this->autozoom);
 65+
6066 $markerItems = array();
6167
6268 foreach ($this->m_locations as $location) {
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php
@@ -14,6 +14,8 @@
1515 }
1616
1717 final class SMYahooMapsFormInput extends SMFormInput {
 18+
 19+ public $serviceName = MapsYahooMaps::SERVICE_NAME;
1820
1921 /**
2022 * @see MapsMapFeature::setMapSettings()
@@ -25,8 +27,10 @@
2628 $this->elementNamePrefix = $egMapsYahooMapsPrefix;
2729 $this->showAddresFunction = 'showYAddress';
2830
29 - $this->earthZoom = 17;
30 - $this->defaultZoom = $egMapsYahooMapsZoom;
 31+ $this->earthZoom = 17;
 32+
 33+ $this->defaultParams = MapsYahooMaps::getDefaultParams();
 34+ $this->defaultZoom = $egMapsYahooMapsZoom;
3135 }
3236
3337 /**
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayers.php
@@ -15,6 +15,8 @@
1616
1717 final class SMOpenLayers extends SMMapPrinter {
1818
 19+ public $serviceName = MapsOpenLayers::SERVICE_NAME;
 20+
1921 public function getName() {
2022 wfLoadExtensionMessages('SemanticMaps');
2123 return wfMsg('sm_openlayers_printername');
@@ -29,6 +31,8 @@
3032
3133 $this->elementNamePrefix = $egMapsOpenLayersPrefix;
3234 $this->defaultZoom = $egMapsOpenLayersZoom;
 35+
 36+ $this->defaultParams = MapsOpenLayers::getDefaultParams();
3337 }
3438
3539 /**
@@ -52,6 +56,8 @@
5357 global $wgJsMimeType;
5458
5559 $controlItems = MapsOpenLayers::createControlsString($this->controls);
 60+
 61+ MapsMapper::enforceArrayValues($this->layers);
5662 $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies($this->output, $this->layers);
5763
5864 MapsUtils::makePxValue($this->width);
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php
@@ -15,6 +15,8 @@
1616
1717 final class SMOpenLayersFormInput extends SMFormInput {
1818
 19+ public $serviceName = MapsOpenLayers::SERVICE_NAME;
 20+
1921 /**
2022 * @see MapsMapFeature::setMapSettings()
2123 *
@@ -26,7 +28,9 @@
2729 $this->showAddresFunction = 'showOLAddress';
2830
2931 $this->earthZoom = 1;
30 - $this->defaultZoom = $egMapsOpenLayersZoom;
 32+
 33+ $this->defaultParams = MapsOpenLayers::getDefaultParams();
 34+ $this->defaultZoom = $egMapsOpenLayersZoom;
3135 }
3236
3337 /**
Index: trunk/extensions/SemanticMaps/SM_MapPrinter.php
@@ -32,6 +32,10 @@
3333 */
3434 protected abstract function addSpecificMapHTML();
3535
 36+ public $serviceName;
 37+
 38+ protected $defaultParams = array();
 39+
3640 protected $m_locations = array();
3741
3842 protected $defaultZoom;
@@ -57,16 +61,14 @@
5862 public final function getResultText($res, $outputmode) {
5963 $this->formatResultData($res, $outputmode);
6064
61 - $this->manageMapProperties();
62 -
6365 $this->setQueryPrinterSettings();
6466
 67+ $this->manageMapProperties($this->m_params, 'SMMapPrinter');
 68+
6569 $this->doMapServiceLoad();
6670
67 - $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr;
 71+ $this->setMapName();
6872
69 - $this->autozoom = ($this->autozoom == 'no' || $this->autozoom == 'off') ? 'false' : 'true';
70 -
7173 $this->setZoom();
7274
7375 $this->setCentre();
@@ -166,16 +168,21 @@
167169 return $icon;
168170 }
169171
170 - private function manageMapProperties() {
171 - $this->m_params = MapsMapper::setDefaultParValues($this->m_params, true);
 172+ private function manageMapProperties($mapProperties, $className) {
 173+ global $egMapsServices;
172174
 175+ $mapProperties = MapsMapper::getValidParams($mapProperties, $egMapsServices[$this->serviceName]['parameters']);
 176+ $mapProperties = MapsMapper::setDefaultParValues($mapProperties, $this->defaultParams);
 177+
173178 // Go through the array with map parameters and create new variables
174179 // with the name of the key and value of the item if they don't exist on class level yet.
175 - foreach($this->m_params as $paramName => $paramValue) {
176 - if (!property_exists('SMMapPrinter', $paramName)) {
 180+ foreach($mapProperties as $paramName => $paramValue) {
 181+ if (!property_exists($className, $paramName)) {
177182 $this->{$paramName} = $paramValue;
178183 }
179184 }
 185+
 186+ MapsMapper::enforceArrayValues($this->controls);
180187 }
181188
182189 /**
@@ -208,4 +215,12 @@
209216 }
210217 }
211218
 219+ /**
 220+ * Sets the $mapName field, using the $elementNamePrefix and $elementNr.
 221+ *
 222+ */
 223+ protected function setMapName() {
 224+ $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr;
 225+ }
 226+
212227 }
Index: trunk/extensions/SemanticMaps/SM_FormInput.php
@@ -90,18 +90,15 @@
9191 }
9292
9393 /**
94 - * Sets the zoom so the whole map is visible in case there is no maker yet,
95 - * and sets it to the default when there is a marker but no zoom parameter.
96 - *
97 - * @param unknown_type $defaultZoom The mapping service's default zoom level
98 - * @param unknown_type $earthZoom The mapping service's earth-level zoom (on which the complete map is visible)
 94+ * Sets the zoom so the whole map is visible in case there is no maker yet,
 95+ * and sets it to the default when there is a marker but no zoom parameter.
9996 */
10097 private function setZoom() {
101 - if (empty($this->coordinates)) {
102 - $this->zoom = $this->earthZoom;
103 - } else if (strlen($this->zoom) < 1) {
104 - $this->zoom = $this->defaultZoom;
105 - }
 98+ if (empty($this->coordinates)) {
 99+ $this->zoom = $this->earthZoom;
 100+ } else if (strlen($this->zoom) < 1) {
 101+ $this->zoom = $this->defaultZoom;
 102+ }
106103 }
107104
108105 /**
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMaps.php
@@ -16,6 +16,8 @@
1717
1818 final class SMGoogleMaps extends SMMapPrinter {
1919
 20+ public $serviceName = MapsGoogleMaps::SERVICE_NAME;
 21+
2022 public function getName() {
2123 wfLoadExtensionMessages('SemanticMaps');
2224 return wfMsg('sm_googlemaps_printername');
@@ -31,6 +33,8 @@
3234 $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
3335
3436 $this->defaultZoom = $egMapsGoogleMapsZoom;
 37+
 38+ $this->defaultParams = MapsGoogleMaps::getDefaultParams();
3539 }
3640
3741 /**
@@ -58,12 +62,14 @@
5963 global $wgJsMimeType;
6064
6165 $enableEarth = MapsGoogleMaps::getEarthValue($this->earth);
62 - $this->earth = MapsGoogleMaps::getJSEarthValue($enableEarth);
 66+ $this->earth = MapsMapper::getJSBoolValue($enableEarth);
6367
6468 // Get the Google Maps names for the control and map types
6569 $this->type = MapsGoogleMaps::getGMapType($this->type, $enableEarth);
6670 $control = MapsGoogleMaps::getGControlType($this->controls);
6771
 72+ $this->autozoom = MapsGoogleMaps::getAutozoomJSValue($this->autozoom);
 73+
6874 $markerItems = array();
6975
7076 foreach ($this->m_locations as $location) {
@@ -71,7 +77,7 @@
7278 list($lat, $lon, $title, $label, $icon) = $location;
7379 $title = str_replace("'", "\'", $title);
7480 $label = str_replace("'", "\'", $label);
75 - $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label')";
 81+ $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '')";
7682 }
7783
7884 $markersString = implode(',', $markerItems);
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php
@@ -17,6 +17,8 @@
1818
1919 final class SMGoogleMapsFormInput extends SMFormInput {
2020
 21+ public $serviceName = MapsGoogleMaps::SERVICE_NAME;
 22+
2123 /**
2224 * @see MapsMapFeature::setMapSettings()
2325 *
@@ -28,7 +30,9 @@
2931 $this->showAddresFunction = 'showGAddress';
3032
3133 $this->earthZoom = 1;
32 - $this->defaultZoom = $egMapsGoogleMapsZoom;
 34+
 35+ $this->defaultParams = MapsGoogleMaps::getDefaultParams();
 36+ $this->defaultZoom = $egMapsGoogleMapsZoom;
3337 }
3438
3539

Status & tagging log