r64317 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64316‎ | r64317 | r64318 >
Date:22:17, 28 March 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6 - Follow up to r64299 - Changed output of the maps to match the changes made in Maps for Google Maps and OpenLayers
Modified paths:
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php
@@ -45,7 +45,7 @@
4646 * @see SMMapPrinter::addSpecificMapHTML()
4747 *
4848 */
49 - protected function addSpecificMapHTML() {
 49+ protected function addSpecificMapHTML( Parser $parser ) {
5050 global $wgJsMimeType;
5151
5252 $markerItems = array();
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php
@@ -67,7 +67,7 @@
6868 * @see MapsMapFeature::addSpecificMapHTML()
6969 *
7070 */
71 - protected function addSpecificMapHTML() {
 71+ protected function addSpecificMapHTML( Parser $parser ) {
7272 global $wgJsMimeType;
7373
7474 $this->output .= "
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php
@@ -45,15 +45,12 @@
4646 * @see SMMapPrinter::addSpecificMapHTML()
4747 *
4848 */
49 - protected function addSpecificMapHTML() {
50 - global $wgJsMimeType;
51 -
52 - $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
53 -
 49+ protected function addSpecificMapHTML( Parser $parser ) {
 50+ // TODO: refactor up like done in maps with display point
5451 $markerItems = array();
5552
5653 foreach ( $this->m_locations as $location ) {
57 - // Create a string containing the marker JS
 54+ // Create a string containing the marker JS .
5855 list( $lat, $lon, $title, $label, $icon ) = $location;
5956
6057 $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
@@ -61,15 +58,35 @@
6259
6360 $markersString = implode( ',', $markerItems );
6461
65 - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
66 - <script type='$wgJsMimeType'> /*<![CDATA[*/
67 - addOnloadHook(
68 - function() {
69 - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$this->controls], [$markersString], $this->height);
70 - }
71 - );
72 - /*]]>*/ </script>";
 62+ $this->output .= Html::element(
 63+ 'div',
 64+ array(
 65+ 'id' => $this->mapName,
 66+ 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
 67+ ),
 68+ wfMsg('maps-loading-map')
 69+ );
 70+
 71+ $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
 72+
 73+ $parser->getOutput()->addHeadItem(
 74+ Html::inlineScript( <<<EOT
 75+addOnloadHook(
 76+ function() {
 77+ initOpenLayer(
 78+ '$this->mapName',
 79+ $this->centre_lat,
 80+ $this->centre_lon,
 81+ $this->zoom,
 82+ [$layerItems],
 83+ [$this->controls],
 84+ [$markersString]
 85+ );
7386 }
 87+);
 88+EOT
 89+ ) );
 90+ }
7491
7592 /**
7693 * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list.
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php
@@ -66,22 +66,43 @@
6767 * @see MapsMapFeature::addSpecificMapHTML()
6868 *
6969 */
70 - protected function addSpecificMapHTML() {
71 - global $wgJsMimeType;
 70+ protected function addSpecificMapHTML( Parser $parser ) {
 71+ $this->output .= Html::element(
 72+ 'div',
 73+ array(
 74+ 'id' => $this->mapName,
 75+ 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
 76+ ),
 77+ wfMsg('maps-loading-map')
 78+ );
7279
7380 $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
7481
75 - $this->output .= "
76 - <div id='" . $this->mapName . "' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
 82+ $parser->getOutput()->addHeadItem(
 83+ Html::inlineScript( <<<EOT
 84+addOnloadHook(
 85+ function() {
 86+ makeFormInputOpenLayer(
 87+ '$this->mapName',
 88+ '$this->coordsFieldName',
 89+ $this->centre_lat,
 90+ $this->centre_lon,
 91+ $this->zoom,
 92+ $this->marker_lat,
 93+ $this->marker_lon,
 94+ [$layerItems],
 95+ [$this->controls],
 96+ );
 97+ }
 98+);
 99+EOT
 100+ ) );
77101
78 - <script type='$wgJsMimeType'>/*<![CDATA[*/
79 - addOnloadHook(function() {makeFormInputOpenLayer('" . $this->mapName . "', '" . $this->coordsFieldName . "', " . $this->centre_lat . ", " . $this->centre_lon . ", " . $this->zoom . ", " . $this->marker_lat . ", " . $this->marker_lon . ", [$layerItems], [$this->controls], $this->height);});
80 - /*]]>*/</script>";
81102 }
82103
83104 /**
84105 * @see SMFormInput::manageGeocoding()
85 - *
 106+ * TODO: find a geocoding service that can be used here
86107 */
87108 protected function manageGeocoding() {
88109 $this->enableGeocoding = false;
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMQP.php
@@ -45,7 +45,7 @@
4646 * @see SMMapPrinter::addSpecificMapHTML()
4747 *
4848 */
49 - protected function addSpecificMapHTML() {
 49+ protected function addSpecificMapHTML( Parser $parser ) {
5050 global $wgJsMimeType;
5151
5252 $markerItems = array();
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php
@@ -68,7 +68,7 @@
6969 * @see MapsMapFeature::addSpecificMapHTML()
7070 *
7171 */
72 - protected function addSpecificMapHTML() {
 72+ protected function addSpecificMapHTML( Parser $parser ) {
7373 global $wgJsMimeType;
7474
7575 $this->output .= <<<EOT
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -35,7 +35,7 @@
3636
3737 // Only initialize the extension when all dependencies are present.
3838 if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) {
39 - define( 'SM_VERSION', '0.6 a4' );
 39+ define( 'SM_VERSION', '0.6 a5' );
4040
4141 $smgScriptPath = ( isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps';
4242 $smgDir = dirname( __FILE__ ) . '/';
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php
@@ -1,7 +1,7 @@
22 <?php
33
44 /**
5 - * Abstract class that provides the common functionallity for all map query printers
 5+ * File holding abstract class SMMapPrinter.
66 *
77 * @file SM_MapPrinter.php
88 * @ingroup SemanticMaps
@@ -15,16 +15,23 @@
1616 die( 'Not an entry point.' );
1717 }
1818
 19+/**
 20+ * Abstract class that provides the common functionallity for all map query printers.
 21+ *
 22+ * @ingroup SemanticMaps
 23+ *
 24+ * @author Jeroen De Dauw
 25+ * @author Robert Buzink
 26+ * @author Yaron Koren
 27+ *
 28+ * TODO:
 29+ * This class is borrowing an awefull lot code from MapsMapFeature, which
 30+ * ideally should be inherited. Since SMWResultPrinter already gets inherited,
 31+ * this is not possible. Finding a better solution to this code redundancy
 32+ * would be nice, cause now changes to MapsMapFeature need to be copied here.
 33+ */
1934 abstract class SMMapPrinter extends SMWResultPrinter {
2035
21 - /*
22 - * TODO:
23 - * This class is borrowing an awefull lot code from MapsMapFeature, which
24 - * ideally should be inherited. Since SMWResultPrinter already gets inherited,
25 - * this is not possible. Finding a better solution to this code redundancy
26 - * would be nice, cause now changes to MapsMapFeature need to be copied here.
27 - */
28 -
2936 /**
3037 * Sets the map service specific element name
3138 */
@@ -38,7 +45,7 @@
3946 /**
4047 * Gets the query result
4148 */
42 - protected abstract function addSpecificMapHTML();
 49+ protected abstract function addSpecificMapHTML( Parser $parser );
4350
4451 public $serviceName;
4552
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php
@@ -63,47 +63,53 @@
6464 * @see SMMapPrinter::getQueryResult()
6565 *
6666 */
67 - protected function addSpecificMapHTML() {
68 - global $wgJsMimeType;
69 -
70 - $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
 67+ protected function addSpecificMapHTML( Parser $parser ) {
 68+ MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
7169
 70+ // TODO: refactor up like done in maps with display point
7271 $markerItems = array();
7372
7473 foreach ( $this->m_locations as $location ) {
7574 list( $lat, $lon, $title, $label, $icon ) = $location;
76 -
7775 $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
7876 }
7977
80 - // Create a string containing the marker JS
 78+ // Create a string containing the marker JS.
8179 $markersString = implode( ',', $markerItems );
8280
83 - $this->output .= <<<EOT
84 -<div id="$this->mapName"></div>
85 -<script type="$wgJsMimeType"> /*<![CDATA[*/
 81+ $this->output .= Html::element(
 82+ 'div',
 83+ array(
 84+ 'id' => $this->mapName,
 85+ 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;",
 86+ ),
 87+ wfMsg('maps-loading-map')
 88+ );
 89+
 90+ $parser->getOutput()->addHeadItem(
 91+ Html::inlineScript( <<<EOT
8692 addOnloadHook(
8793 function() {
88 - initializeGoogleMap('$this->mapName',
89 - {
90 - width: $this->width,
91 - height: $this->height,
92 - lat: $this->centre_lat,
93 - lon: $this->centre_lon,
94 - zoom: $this->zoom,
95 - type: $this->type,
96 - types: [$this->types],
97 - controls: [$this->controls],
98 - scrollWheelZoom: $this->autozoom
99 - },
100 - [$markersString]
101 - );
 94+ initializeGoogleMap('$this->mapName',
 95+ {
 96+ width: $this->width,
 97+ height: $this->height,
 98+ lat: $this->centre_lat,
 99+ lon: $this->centre_lon,
 100+ zoom: $this->zoom,
 101+ type: $this->type,
 102+ types: [$this->types],
 103+ controls: [$this->controls],
 104+ scrollWheelZoom: $this->autozoom
 105+ },
 106+ [$markersString]
 107+ );
102108 }
103109 );
104 -/*]]>*/ </script>
105 -EOT;
106 -
107 - $this->output .= $onloadFunctions;
 110+EOT
 111+ ) );
 112+
 113+
108114 }
109115
110116 /**
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php
@@ -69,7 +69,7 @@
7070 * @see MapsMapFeature::addSpecificFormInputHTML()
7171 *
7272 */
73 - protected function addSpecificMapHTML() {
 73+ protected function addSpecificMapHTML( Parser $parser ) {
7474 global $wgJsMimeType;
7575
7676 // Remove the overlays control in case it's present.

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r64299Changes for 0.6...jeroendedauw19:09, 28 March 2010

Status & tagging log