r83815 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83814‎ | r83815 | r83816 >
Date:10:43, 13 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
some work on the new form inputs
Modified paths:
  • /branches/SemanticMaps0.8/SemanticMaps.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/forminputs/SM_FormInput.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3FormInput.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/ext.sm.googlemapsinput.js (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/OpenLayers/SM_OpenLayers.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/OpenLayers/SM_OpenLayersFormInput.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/OpenLayers/ext.sm.openlayersinput.js (added) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/ext.sm.googlemapsinput.js
@@ -9,8 +9,22 @@
1010 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
1111 */
1212
 13+function buildInputValue( locations ) {
 14+ var dms = [];
 15+
 16+ for ( i in locations ) {
 17+ dms.push( locationToDMS( locations[i].lat, locations[i].lon ) );
 18+ }
 19+
 20+ return dms.join( '; ' );
 21+}
 22+
 23+function locationToDMS ( lat, lon ) { // TODO: i18n
 24+ return Math.abs( lat ) + '° ' + ( lat < 0 ? 'S' : 'N' ) + ', ' + Math.abs( lon ) + '° ' + ( lon < 0 ? 'W' : 'E' );
 25+}
 26+
1327 jQuery(document).ready(function() {
14 - if ( true ) {
 28+ if ( false ) {
1529 for ( i in window.maps.googlemaps3_forminputs ) {
1630 jQuery( '#' + i + '_forminput' ).googlemapsinput( i, window.maps.googlemaps3_forminputs[i] );
1731 }
@@ -18,8 +32,11 @@
1933 else {
2034 alert( mediaWiki.msg( 'maps-googlemaps3-incompatbrowser' ) );
2135
22 - for ( i in window.maps.googlemaps3 ) {
23 - jQuery( '#' + i + '_forminput' ).text( mediaWiki.msg( 'maps-load-failed' ) );
 36+ for ( i in window.maps.googlemaps3_forminputs ) {
 37+ jQuery( '#' + i + '_forminput' )
 38+ .html( $( '<input />' )
 39+ .attr( { 'name': i, 'value': buildInputValue( window.maps.googlemaps3_forminputs[i].locations ) } )
 40+ );
2441 }
2542 }
2643 });
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js
@@ -9,7 +9,6 @@
1010 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
1111 */
1212
13 -
1413 (function( $ ){ $.fn.googlemapsinput = function( mapDivId, options ) {
1514 var MAPFILES_URL = "http://maps.gstatic.com/intl/en_us/mapfiles/";
1615
@@ -29,7 +28,7 @@
3029 this.html(
3130 $( '<div />' ).css( {
3231 'display': 'none'
33 - } ).append( $( '<input />' ).attr( { 'type': 'text', 'name': options.inputname, 'id': mapDivId + '_values' } ) )
 32+ } ).append( append( $( '<input />' ).attr( { 'type': 'text', 'name': options.inputname, 'id': mapDivId + '_values' } ) )
3433 );
3534
3635 updateInputValue( buildInputValue( options.locations ) );
@@ -298,9 +297,7 @@
299298 $( "#" + mapDivId + '_addbutton_' + i ).button().click( onRemoveButtonClick );
300299 }
301300
302 - function locationToDMS ( lat, lon ) { // TODO: i18n
303 - return Math.abs( lat ) + '° ' + ( lat < 0 ? 'S' : 'N' ) + ', ' + Math.abs( lon ) + '° ' + ( lon < 0 ? 'W' : 'E' );
304 - }
 301+
305302
306303 function updateInput() {
307304 var locations = [];
@@ -314,16 +311,6 @@
315312 $( '#' + mapDivId + '_values' ).text( value );
316313 }
317314
318 - function buildInputValue( locations ) {
319 - var dms = [];
320 -
321 - for ( i in locations ) {
322 - dms.push( locationToDMS( locations[i].lat, locations[i].lon ) );
323 - }
324 -
325 - return dms.join( '; ' );
326 - }
327 -
328315 return this;
329316
330317 }; })( jQuery );
\ No newline at end of file
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3FormInput.php
@@ -12,25 +12,6 @@
1313 class SMGoogleMaps3FormInput extends SMFormInput {
1414
1515 /**
16 - * @see SMFormInput::getInputHTML
17 - *
18 - * @since 0.8
19 - *
20 - * @param array $params
21 - * @param Parser $parser
22 - * @param string $mapName
23 - *
24 - * @return string
25 - */
26 - protected function getInputHTML( array $params, Parser $parser, $mapName ) {
27 - $html = '';
28 -
29 - $html .= parent::getInputHTML( $params, $parser, $mapName );
30 -
31 - return $html;
32 - }
33 -
34 - /**
3516 * @see SMFormInput::getResourceModules
3617 *
3718 * @since 0.8
Index: branches/SemanticMaps0.8/includes/services/OpenLayers/SM_OpenLayers.php
@@ -20,6 +20,22 @@
2121 die( 'Not an entry point.' );
2222 }
2323
 24+$wgResourceModules['ext.sm.fi.openlayers'] = array(
 25+ 'dependencies' => array( 'ext.maps.openlayers', 'jquery.ui.button', 'jquery.ui.dialog' ),
 26+ 'localBasePath' => dirname( __FILE__ ),
 27+ 'remoteBasePath' => $smgScriptPath . '/includes/services/OpenLayers',
 28+ 'group' => 'ext.semanticmaps',
 29+ 'scripts' => array(
 30+ 'jquery.openlayersinput.js',
 31+ 'ext.sm.openlayersinput.js'
 32+ ),
 33+ 'messages' => array(
 34+ 'semanticmaps-forminput-remove',
 35+ 'semanticmaps-forminput-add',
 36+ 'semanticmaps-forminput-locations'
 37+ )
 38+);
 39+
2440 $wgHooks['MappingServiceLoad'][] = 'smfInitOpenLayers';
2541
2642 function smfInitOpenLayers() {
Index: branches/SemanticMaps0.8/includes/services/OpenLayers/ext.sm.openlayersinput.js
@@ -0,0 +1,25 @@
 2+/**
 3+ * JavasSript for the Google Maps v3 form input in the Semantic Maps extension.
 4+ * @see http://www.mediawiki.org/wiki/Extension:Semantic_Maps
 5+ *
 6+ * @since 0.8
 7+ * @ingroup SemanticMaps
 8+ *
 9+ * @licence GNU GPL v3
 10+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
 11+ */
 12+
 13+jQuery(document).ready(function() {
 14+ if ( true ) {
 15+ for ( i in window.maps.openlayers_forminputs ) {
 16+ jQuery( '#' + i + '_forminput' ).openlayersinput( i, window.maps.openlayers_forminputs[i] );
 17+ }
 18+ }
 19+ else {
 20+ alert( mediaWiki.msg( 'maps-openlayers-incompatbrowser' ) );
 21+
 22+ for ( i in window.maps.openlayers_forminputs ) {
 23+ jQuery( '#' + i + '_forminput' ).text( mediaWiki.msg( 'maps-load-failed' ) );
 24+ }
 25+ }
 26+});
Property changes on: branches/SemanticMaps0.8/includes/services/OpenLayers/ext.sm.openlayersinput.js
___________________________________________________________________
Added: svn:eol-style
127 + native
Index: branches/SemanticMaps0.8/includes/services/OpenLayers/SM_OpenLayersFormInput.php
@@ -11,28 +11,14 @@
1212 class SMOpenLayersFormInput extends SMFormInput {
1313
1414 /**
15 - * @see MapsMapFeature::addFormDependencies()
 15+ * @see SMFormInput::getResourceModules
 16+ *
 17+ * @since 0.8
 18+ *
 19+ * @return array of string
1620 */
17 - protected function addFormDependencies() {
18 - global $wgOut;
19 - global $smgScriptPath, $smgStyleVersion;
20 -
21 - $this->service->addDependency( Html::linkedScript( "$smgScriptPath/includes/services/OpenLayers/SM_OpenLayersForms.js?$smgStyleVersion" ) );
22 - $this->service->addDependencies( $wgOut );
23 - }
 21+ protected function getResourceModules() {
 22+ return array_merge( parent::getResourceModules(), array( 'ext.sm.fi.openlayers' ) );
 23+ }
2424
25 - /**
26 - * @see MapsMapFeature::addSpecificMapHTML
27 - */
28 - public function addSpecificMapHTML() {
29 - return Html::element(
30 - 'div',
31 - array(
32 - 'id' => $this->service->getMapId( false ),
33 - 'style' => "width: $this->width; height: $this->height; background-color: #cccccc; overflow: hidden;",
34 - ),
35 - wfMsg( 'maps-loading-map' )
36 - );
37 - }
38 -
3925 }
Index: branches/SemanticMaps0.8/includes/forminputs/SM_FormInput.php
@@ -152,6 +152,7 @@
153153 'div',
154154 array(
155155 'id' => $mapName . '_forminput',
 156+ 'style' => 'display: inline'
156157 ),
157158 wfMsg( 'semanticmaps-loading-forminput' )
158159 );
Index: branches/SemanticMaps0.8/SemanticMaps.php
@@ -41,69 +41,66 @@
4242 die( '<b>Error:</b> You need to have <a href="http://semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Semantic Maps">Semantic Maps</a>.<br />' );
4343 }
4444
45 -// Only initialize the extension when all dependencies are present.
46 -if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) {
47 - define( 'SM_VERSION', '0.8 alpha' );
 45+define( 'SM_VERSION', '0.8 alpha' );
4846
49 - $smgScriptPath = ( $wgExtensionAssetsPath === false ? '/extensions' : $wgExtensionAssetsPath ) . '/SemanticMaps';
50 - $smgDir = dirname( __FILE__ ) . '/';
 47+$smgScriptPath = ( $wgExtensionAssetsPath === false ? '/extensions' : $wgExtensionAssetsPath ) . '/SemanticMaps';
 48+$smgDir = dirname( __FILE__ ) . '/';
5149
52 - $smgStyleVersion = $wgStyleVersion . '-' . SM_VERSION;
 50+$smgStyleVersion = $wgStyleVersion . '-' . SM_VERSION;
5351
54 - // Include the settings file.
55 - require_once 'SM_Settings.php';
 52+// Include the settings file.
 53+require_once 'SM_Settings.php';
5654
57 - # (named) Array of String. This array contains the available features for Maps.
58 - # Commenting out the inclusion of any feature will make Maps completely ignore it, and so improve performance.
59 -
60 - # Query printers
61 - include_once $smgDir . 'includes/queryprinters/SM_QueryPrinters.php';
62 - # Form imputs
63 - include_once $smgDir . 'includes/forminputs/SM_FormInputs.php';
 55+# (named) Array of String. This array contains the available features for Maps.
 56+# Commenting out the inclusion of any feature will make Maps completely ignore it, and so improve performance.
6457
65 - # Include the mapping services that should be loaded into Semantic Maps.
66 - # Commenting or removing a mapping service will cause Semantic Maps to completely ignore it, and so improve performance.
67 -
68 - # Google Maps API v2
69 - include_once $smgDir . 'includes/services/GoogleMaps/SM_GoogleMaps.php';
70 - # Google Maps API v3
71 - include_once $smgDir . 'includes/services/GoogleMaps3/SM_GoogleMaps3.php';
72 - # OpenLayers API
73 - include_once $smgDir . 'includes/services/OpenLayers/SM_OpenLayers.php';
74 - # Yahoo! Maps API
75 - include_once $smgDir . 'includes/services/YahooMaps/SM_YahooMaps.php';
76 -
77 - $wgExtensionFunctions[] = 'smfSetup';
 58+ # Query printers
 59+ include_once $smgDir . 'includes/queryprinters/SM_QueryPrinters.php';
 60+ # Form imputs
 61+ include_once $smgDir . 'includes/forminputs/SM_FormInputs.php';
7862
79 - $wgExtensionMessagesFiles['SemanticMaps'] = $smgDir . 'SemanticMaps.i18n.php';
 63+# Include the mapping services that should be loaded into Semantic Maps.
 64+# Commenting or removing a mapping service will cause Semantic Maps to completely ignore it, and so improve performance.
8065
81 - $incDir = dirname( __FILE__ ) . '/includes/';
82 -
83 - // Data values
84 - $wgAutoloadClasses['SMGeoCoordsValue'] = $incDir . 'SM_GeoCoordsValue.php';
85 -
86 - // Value descriptions
87 - $wgAutoloadClasses['SMGeoCoordsValueDescription'] = $incDir . 'SM_GeoCoordsValueDescription.php';
88 - $wgAutoloadClasses['SMAreaValueDescription'] = $incDir . 'SM_AreaValueDescription.php';
89 -
90 - $wgAutoloadClasses['SemanticMapsHooks'] = dirname( __FILE__ ) . '/SemanticMaps.hooks.php';
91 -
92 - // Hook for initializing the Geographical Coordinate type.
93 - $wgHooks['smwInitDatatypes'][] = 'SMGeoCoordsValue::initGeoCoordsType';
94 -
95 - // Hook for initializing the field types needed by Geographical Coordinates.
96 - $wgHooks['SMWCustomSQLStoreFieldType'][] = 'SMGeoCoordsValue::initGeoCoordsFieldTypes';
97 -
98 - // Hook for defining a table to store geographical coordinates in.
99 - $wgHooks['SMWPropertyTables'][] = 'SMGeoCoordsValue::initGeoCoordsTable';
100 -
101 - // Hook for defining the default query printer for queries that ask for geographical coordinates.
102 - $wgHooks['SMWResultFormat'][] = 'SMGeoCoordsValue::addGeoCoordsDefaultFormat';
103 -
104 - // Hook for adding a Semantic Maps links to the Admin Links extension.
105 - $wgHooks['AdminLinks'][] = 'SemanticMapsHooks::addToAdminLinks';
106 -}
 66+ # Google Maps API v2
 67+ include_once $smgDir . 'includes/services/GoogleMaps/SM_GoogleMaps.php';
 68+ # Google Maps API v3
 69+ include_once $smgDir . 'includes/services/GoogleMaps3/SM_GoogleMaps3.php';
 70+ # OpenLayers API
 71+ include_once $smgDir . 'includes/services/OpenLayers/SM_OpenLayers.php';
 72+ # Yahoo! Maps API
 73+ include_once $smgDir . 'includes/services/YahooMaps/SM_YahooMaps.php';
10774
 75+$wgExtensionFunctions[] = 'smfSetup';
 76+
 77+$wgExtensionMessagesFiles['SemanticMaps'] = $smgDir . 'SemanticMaps.i18n.php';
 78+
 79+$incDir = dirname( __FILE__ ) . '/includes/';
 80+
 81+// Data values
 82+$wgAutoloadClasses['SMGeoCoordsValue'] = $incDir . 'SM_GeoCoordsValue.php';
 83+
 84+// Value descriptions
 85+$wgAutoloadClasses['SMGeoCoordsValueDescription'] = $incDir . 'SM_GeoCoordsValueDescription.php';
 86+$wgAutoloadClasses['SMAreaValueDescription'] = $incDir . 'SM_AreaValueDescription.php';
 87+
 88+$wgAutoloadClasses['SemanticMapsHooks'] = dirname( __FILE__ ) . '/SemanticMaps.hooks.php';
 89+
 90+// Hook for initializing the Geographical Coordinate type.
 91+$wgHooks['smwInitDatatypes'][] = 'SMGeoCoordsValue::initGeoCoordsType';
 92+
 93+// Hook for initializing the field types needed by Geographical Coordinates.
 94+$wgHooks['SMWCustomSQLStoreFieldType'][] = 'SMGeoCoordsValue::initGeoCoordsFieldTypes';
 95+
 96+// Hook for defining a table to store geographical coordinates in.
 97+$wgHooks['SMWPropertyTables'][] = 'SMGeoCoordsValue::initGeoCoordsTable';
 98+
 99+// Hook for defining the default query printer for queries that ask for geographical coordinates.
 100+$wgHooks['SMWResultFormat'][] = 'SMGeoCoordsValue::addGeoCoordsDefaultFormat';
 101+
 102+// Hook for adding a Semantic Maps links to the Admin Links extension.
 103+$wgHooks['AdminLinks'][] = 'SemanticMapsHooks::addToAdminLinks';
 104+
108105 /**
109106 * 'Initialization' function for the Semantic Maps extension.
110107 * The only work done here is creating the extension credits for

Status & tagging log