r83644 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83643‎ | r83644 | r83645 >
Date:10:31, 10 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on gmaps 3 input
Modified paths:
  • /branches/SemanticMaps0.8/SM_Settings.php (modified) (history)
  • /branches/SemanticMaps0.8/SemanticMaps.i18n.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/forminputs/SM_FormInput.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js (modified) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/SM_Settings.php
@@ -66,6 +66,8 @@
6767
6868 # Forms
6969
 70+ $smgFIMulti = true;
 71+
7072 # Integer or string. The default width and height of maps in forms created by using Semantic Forms.
7173 # These values only be used when the user does not provide them.
7274 $smgFIWidth = 665;
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3.php
@@ -24,7 +24,7 @@
2525 }
2626
2727 $wgResourceModules['ext.sm.fi.googlemaps3'] = array(
28 - 'dependencies' => array( 'ext.maps.googlemaps3' ),
 28+ 'dependencies' => array( 'ext.maps.googlemaps3', 'jquery.ui.resizable', 'jquery.ui.button', 'jquery.ui.dialog' ),
2929 'localBasePath' => dirname( __FILE__ ),
3030 'remoteBasePath' => $smgScriptPath . '/includes/services/GoogleMaps3',
3131 'group' => 'ext.semanticmaps',
@@ -32,6 +32,10 @@
3333 'jquery.googlemapsinput.js',
3434 'ext.sm.googlemapsinput.js'
3535 ),
 36+ 'messages' => array(
 37+ 'semanticmaps-forminput-remove',
 38+ 'semanticmaps-forminput-add',
 39+ )
3640 );
3741
3842 $wgHooks['MappingServiceLoad'][] = 'smfInitGoogleMaps3';
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js
@@ -10,19 +10,74 @@
1111 */
1212
1313 (function( $ ){ $.fn.googlemapsinput = function( mapDivId, options ) {
14 - this.text( '' );
 14+ this.html(
 15+ $( '<div />' ).css( {
 16+ 'display': 'none'
 17+ } ).append( $( '<input />' ).attr( { 'type': 'text', 'name': options.inputname, 'id': mapDivId + '_values' } ) )
 18+ );
1519
16 - this.html(
 20+ updateInputValue( buildInputValue( options.locations ) );
 21+
 22+ var table = $( '<table />' ).attr( { 'class' : 'mapinput' } );
 23+
 24+ for ( i in options.locations ) {
 25+ table.append(
 26+ '<tr><td>' +
 27+ locationToDMS( options.locations[i].lat, options.locations[i].lon ) +
 28+ '</td><td>' +
 29+ '<button>' + mediaWiki.msg( 'semanticmaps-forminput-remove' ) + '</button>' +
 30+ '</td></tr>'
 31+ );
 32+ }
 33+
 34+ table.append(
 35+ '<tr><td width="300px">' +
 36+ '<input type="text" class="text ui-widget-content ui-corner-all" />' +
 37+ '</td><td>' +
 38+ '<button>' + mediaWiki.msg( 'semanticmaps-forminput-add' ) + '</button>' +
 39+ '</td></tr>'
 40+
 41+ );
 42+
 43+ this.append(
 44+ table
 45+ );
 46+
 47+ /*
 48+ this.append(
1749 $( '<div />' )
1850 .attr( {
1951 'id': mapDivId,
2052 'width': options.width,
2153 'height': options.height
22 - } )
 54+ } )
2355 );
 56+ */
2457
25 - //$('#' + mapDivId).googlemaps( options )
 58+ $( "button", ".mapinput" ).button();
2659
 60+ //$('#' + mapDivId).googlemaps( options ).resizable();
 61+
 62+ function locationToDMS ( lat, lon ) { // TODO: i18n
 63+ return Math.abs( lat ) + '° ' + ( lat < 0 ? 'S' : 'N' ) + ', ' + Math.abs( lon ) + '° ' + ( lon < 0 ? 'W' : 'E' );
 64+ }
 65+
 66+ function updateInputValue( value ) {
 67+ $( '#' + mapDivId + '_values' ).text( value );
 68+ }
 69+
 70+ function buildInputValue( locations ) {
 71+ var dms = [];
 72+
 73+ for ( i in locations ) {
 74+ dms.push( locationToDMS( locations[i].lat, locations[i].lon ) );
 75+ }
 76+
 77+ return dms.join( '; ' );
 78+ }
 79+
 80+ this.attr( { 'width': options.width, 'height': options.height } );
 81+
2782 return this;
2883
2984 }; })( jQuery );
\ No newline at end of file
Index: branches/SemanticMaps0.8/includes/forminputs/SM_FormInput.php
@@ -19,6 +19,15 @@
2020 protected $service;
2121
2222 /**
 23+ * A character to separate multiple locations with.
 24+ *
 25+ * @since 0.8
 26+ *
 27+ * @var char
 28+ */
 29+ const SEPARATOR = ';';
 30+
 31+ /**
2332 * Constructor.
2433 *
2534 * @since 0.8
@@ -37,12 +46,18 @@
3847 * @return array
3948 */
4049 protected function getParameterInfo() {
 50+ global $smgFIMulti;
 51+
4152 $params = MapsMapper::getCommonParameters();
4253 $this->service->addParameterInfo( $params );
4354
4455 $params['zoom']->setDefault( false );
4556 $params['zoom']->setDoManipulationOfDefault( false );
4657
 58+ $params['multi'] = new Parameter( 'multi', Parameter::TYPE_BOOLEAN );
 59+ $params['multi']->setDefault( $smgFIMulti );
 60+ $params['multi']->setDoManipulationOfDefault( false );
 61+
4762 $params['centre'] = new Parameter( 'centre' );
4863 $params['centre']->setDefault( false );
4964 $params['centre']->addAliases( 'center' );
@@ -56,6 +71,12 @@
5772 $params['icon']->setDefault( '' );
5873 $params['icon']->addCriteria( New CriterionNotEmpty() );
5974
 75+ $params['locations'] = new ListParameter( 'locations', self::SEPARATOR );
 76+ $params['locations']->addCriteria( new CriterionIsLocation() );
 77+ $manipulation = new MapsParamLocation();
 78+ $manipulation->toJSONObj = true;
 79+ $params['locations']->addManipulations( $manipulation );
 80+
6081 return $params;
6182 }
6283
@@ -78,7 +99,9 @@
79100 if ( !is_array( $value ) && !is_object( $value ) ) {
80101 $parameters[$key] = $value;
81102 }
82 - }
 103+ }
 104+
 105+ $parameters['locations'] = '1,1;42,42';//$coordinates;
83106
84107 $validator = new Validator( wfMsg( 'maps_' . $this->service->getName() ), false );
85108 $validator->setParameters( $parameters, $this->getParameterInfo() );
@@ -92,6 +115,8 @@
93116 $params = $validator->getParameterValues();
94117 $mapName = $this->service->getMapId();
95118
 119+ $params['inputname'] = $input_name;
 120+
96121 $output = $this->getInputHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName );
97122
98123 $this->service->addResourceModules( $this->getResourceModules() );
Index: branches/SemanticMaps0.8/SemanticMaps.i18n.php
@@ -28,7 +28,10 @@
2929 // Forms
3030 'semanticmaps_lookupcoordinates' => 'Look up coordinates',
3131 'semanticmaps_enteraddresshere' => 'Enter address here',
 32+ 'semanticmaps-loading-forminput' => 'Loading map form input...',
3233 'semanticmaps_notfound' => 'not found',
 34+ 'semanticmaps-forminput-remove' => 'Remove',
 35+ 'semanticmaps-forminput-add' => 'Add',
3336
3437 // Parameter descriptions
3538 'semanticmaps_paramdesc_format' => 'The mapping service used to generate the map',

Status & tagging log