r59682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59681‎ | r59682 | r59683 >
Date:21:22, 2 December 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified paths:
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSM.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php (added) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFunctions.js (added) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMQP.php (added) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php
@@ -3,7 +3,7 @@
44 /**
55 * A query printer for maps using the Open Layers API
66 *
7 - * @file SM_OpenLayers.php
 7+ * @file SM_OpenLayersQP.php
88 * @ingroup SMOpenLayers
99 *
1010 * @author Jeroen De Dauw
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFunctions.js
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSM.php
@@ -20,5 +20,5 @@
2121 die( 'Not an entry point.' );
2222 }
2323
24 -// $egMapsServices['osm']['qp'] = array('class' => 'SMOSMQP', 'file' => 'SemanticMaps/OpenStreetMap/SM_OSMQP.php', 'local' => false);
 24+$egMapsServices['osm']['qp'] = array('class' => 'SMOSMQP', 'file' => 'SemanticMaps/OpenStreetMap/SM_OSMQP.php', 'local' => false);
2525 // $egMapsServices['osm']['fi'] = array('class' => 'SMOSMFormInput', 'file' => 'SemanticMaps/OpenStreetMap/SM_OSMFormInput.php', 'local' => false);
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMQP.php
@@ -0,0 +1,95 @@
 2+<?php
 3+
 4+/**
 5+ * A query printer for maps using the Open Layers API optimized for OSM
 6+ *
 7+ * @file SM_OSMQP.php
 8+ * @ingroup SMOSM
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class SMOSMQP extends SMMapPrinter {
 18+
 19+ public $serviceName = MapsOSM::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see SMMapPrinter::setQueryPrinterSettings()
 23+ *
 24+ */
 25+ protected function setQueryPrinterSettings() {
 26+ global $egMapsOSMZoom, $egMapsOSMPrefix;
 27+
 28+ $this->elementNamePrefix = $egMapsOSMPrefix;
 29+ $this->defaultZoom = $egMapsOSMZoom;
 30+
 31+ $this->spesificParameters = array(
 32+ 'zoom' => array(
 33+ 'default' => '',
 34+ )
 35+ );
 36+ }
 37+
 38+ /**
 39+ * @see SMMapPrinter::doMapServiceLoad()
 40+ *
 41+ */
 42+ protected function doMapServiceLoad() {
 43+ global $egOSMMapsOnThisPage;
 44+
 45+ MapsOSM::addOSMDependencies($this->output);
 46+ $egOSMMapsOnThisPage++;
 47+
 48+ $this->elementNr = $egOSMMapsOnThisPage;
 49+ }
 50+
 51+ /**
 52+ * @see SMMapPrinter::addSpecificMapHTML()
 53+ *
 54+ */
 55+ protected function addSpecificMapHTML() {
 56+ global $wgJsMimeType;
 57+
 58+ $markerItems = array();
 59+
 60+ foreach ($this->m_locations as $location) {
 61+ // Create a string containing the marker JS
 62+ list($lat, $lon, $title, $label, $icon) = $location;
 63+
 64+ $title = str_replace("'", "\'", $title);
 65+ $label = str_replace("'", "\'", $label);
 66+
 67+ $markerItems[] = "getOSMMarkerData($lon, $lat, '$title', '$label', '$icon')";
 68+ }
 69+
 70+ $markersString = implode(',', $markerItems);
 71+
 72+ $controlItems = MapsMapper::createJSItemsString(explode(',', $this->controls));
 73+
 74+ $this->output .= <<<EOT
 75+ <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', {
 76+ mode: 'osm-wm',
 77+ layer: 'osm-like',
 78+ locale: '$this->lang',
 79+ lat: $this->centre_lat,
 80+ lon: $this->centre_lon,
 81+ zoom: $this->zoom,
 82+ width: $this->width,
 83+ height: $this->height,
 84+ markers: [$markersString],
 85+ controls: [$controlItems]
 86+ });</script>
 87+
 88+ <!-- map div -->
 89+ <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
 90+ <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
 91+ <!-- /map div -->
 92+ </div>
 93+EOT;
 94+ }
 95+
 96+}
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php
@@ -0,0 +1,106 @@
 2+<?php
 3+
 4+/**
 5+ * Form input hook that adds an OSM map format to Semantic Forms
 6+ *
 7+ * @file SM_OSMFormInput.php
 8+ * @ingroup SMOSM
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class SMOSMFormInput extends SMFormInput {
 18+
 19+ public $serviceName = MapsOSM::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsMapFeature::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsOSMZoom, $egMapsOSMPrefix;
 27+
 28+ $this->elementNamePrefix = $egMapsOSMPrefix;
 29+ $this->showAddresFunction = 'showOSMAddress';
 30+
 31+ $this->earthZoom = 1;
 32+
 33+ $this->defaultZoom = $egMapsOSMZoom;
 34+ }
 35+
 36+ /**
 37+ * @see MapsMapFeature::addFormDependencies()
 38+ *
 39+ */
 40+ protected function addFormDependencies() {
 41+ global $wgJsMimeType;
 42+ global $smgScriptPath, $smgOSMFormsOnThisPage, $smgStyleVersion;
 43+
 44+ MapsOSM::addOLDependencies($this->output);
 45+
 46+ if (empty($smgOSMFormsOnThisPage)) {
 47+ $smgOSMFormsOnThisPage = 0;
 48+ $this->output .= "<script type='$wgJsMimeType' src='$smgScriptPath/OpenStreetMap/SM_OSMFunctions.js?$smgStyleVersion'></script>";
 49+ }
 50+ }
 51+
 52+ /**
 53+ * @see MapsMapFeature::doMapServiceLoad()
 54+ *
 55+ */
 56+ protected function doMapServiceLoad() {
 57+ global $egOSMMapsOnThisPage, $smgOSMFormsOnThisPage;
 58+
 59+ self::addFormDependencies();
 60+
 61+ $egOSMMapsOnThisPage++;
 62+ $smgOSMFormsOnThisPage++;
 63+
 64+ $this->elementNr = $egOSMMapsOnThisPage;
 65+ }
 66+
 67+ /**
 68+ * @see MapsMapFeature::addSpecificMapHTML()
 69+ *
 70+ */
 71+ protected function addSpecificMapHTML() {
 72+ global $wgJsMimeType;
 73+
 74+ $controlItems = MapsMapper::createJSItemsString(explode(',', $this->controls));
 75+
 76+ $this->output .= <<<EOT
 77+ addOnloadHook(makeOSMFormInput(
 78+ '$this->mapName',
 79+ '$this->coordsFieldName',
 80+ {
 81+ mode: 'osm-wm',
 82+ layer: 'osm-like',
 83+ locale: '$this->lang',
 84+ lat: $this->centre_lat,
 85+ lon: $this->centre_lon,
 86+ zoom: $this->zoom,
 87+ width: $this->width,
 88+ height: $this->height,
 89+ controls: [$controlItems]
 90+ }
 91+ ));
 92+
 93+ <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
 94+ <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
 95+ </div>
 96+EOT;
 97+ }
 98+
 99+ /**
 100+ * @see SMFormInput::manageGeocoding()
 101+ *
 102+ */
 103+ protected function manageGeocoding() {
 104+ $this->enableGeocoding = false;
 105+ }
 106+
 107+}
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -23,7 +23,7 @@
2424 die( 'Not an entry point.' );
2525 }
2626
27 -define('SM_VERSION', '0.5 a12');
 27+define('SM_VERSION', '0.5 a13');
2828
2929 $smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps';
3030 $smgIP = $IP . '/extensions/SemanticMaps';
@@ -37,8 +37,8 @@
3838
3939 $wgHooks['AdminLinks'][] = 'smfAddToAdminLinks';
4040
41 -$wgAutoloadClasses['SMGeoCoordsValue'] = $smgIP . '/SM_GeoCoordsValue.php';
42 -$wgHooks['smwInitDatatypes'][] = 'smfInitGeoCoordsType';
 41+//$wgAutoloadClasses['SMGeoCoordsValue'] = $smgIP . '/SM_GeoCoordsValue.php';
 42+//$wgHooks['smwInitDatatypes'][] = 'smfInitGeoCoordsType';
4343
4444 $wgExtensionMessagesFiles['SemanticMaps'] = $smgIP . '/SemanticMaps.i18n.php';
4545
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php
@@ -48,14 +48,19 @@
4949 }
5050
5151 private static function initializeParams() {
52 - global $egMapsDefaultService;
 52+ global $egMapsDefaultService, $egMapsDefaultCentre;
5353
5454 self::$parameters = array(
5555 'format' => array(
5656 'aliases' => array(),
5757 'criteria' => array(),
5858 'default' => $egMapsDefaultService
59 - ),
 59+ ),
 60+ 'centre' => array(
 61+ 'aliases' => array('center'),
 62+ 'criteria' => array(),
 63+ 'default' => $egMapsDefaultCentre
 64+ ),
6065 );
6166 }
6267
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php
@@ -66,6 +66,7 @@
6767 *
6868 * @param unknown_type $res
6969 * @param unknown_type $outputmode
 70+ *
7071 * @return array
7172 */
7273 public final function getResultText($res, $outputmode) {
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php
@@ -34,7 +34,12 @@
3535 $this->spesificParameters = array(
3636 'zoom' => array(
3737 'default' => '',
38 - )
 38+ ),
 39+ 'overlays' => array(
 40+ 'aliases' => array(),
 41+ 'criteria' => array(),
 42+ 'default' => ''
 43+ ),
3944 );
4045 }
4146

Status & tagging log