Index: branches/SemanticMaps0.8/SM_Settings.php |
— | — | @@ -66,6 +66,8 @@ |
67 | 67 | |
68 | 68 | # Forms |
69 | 69 | |
| 70 | + $smgFIMulti = true; |
| 71 | + |
70 | 72 | # Integer or string. The default width and height of maps in forms created by using Semantic Forms. |
71 | 73 | # These values only be used when the user does not provide them. |
72 | 74 | $smgFIWidth = 665; |
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | } |
26 | 26 | |
27 | 27 | $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' ), |
29 | 29 | 'localBasePath' => dirname( __FILE__ ), |
30 | 30 | 'remoteBasePath' => $smgScriptPath . '/includes/services/GoogleMaps3', |
31 | 31 | 'group' => 'ext.semanticmaps', |
— | — | @@ -32,6 +32,10 @@ |
33 | 33 | 'jquery.googlemapsinput.js', |
34 | 34 | 'ext.sm.googlemapsinput.js' |
35 | 35 | ), |
| 36 | + 'messages' => array( |
| 37 | + 'semanticmaps-forminput-remove', |
| 38 | + 'semanticmaps-forminput-add', |
| 39 | + ) |
36 | 40 | ); |
37 | 41 | |
38 | 42 | $wgHooks['MappingServiceLoad'][] = 'smfInitGoogleMaps3'; |
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js |
— | — | @@ -10,19 +10,74 @@ |
11 | 11 | */ |
12 | 12 | |
13 | 13 | (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 | + ); |
15 | 19 | |
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( |
17 | 49 | $( '<div />' ) |
18 | 50 | .attr( { |
19 | 51 | 'id': mapDivId, |
20 | 52 | 'width': options.width, |
21 | 53 | 'height': options.height |
22 | | - } ) |
| 54 | + } ) |
23 | 55 | ); |
| 56 | + */ |
24 | 57 | |
25 | | - //$('#' + mapDivId).googlemaps( options ) |
| 58 | + $( "button", ".mapinput" ).button(); |
26 | 59 | |
| 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 | + |
27 | 82 | return this; |
28 | 83 | |
29 | 84 | }; })( jQuery ); |
\ No newline at end of file |
Index: branches/SemanticMaps0.8/includes/forminputs/SM_FormInput.php |
— | — | @@ -19,6 +19,15 @@ |
20 | 20 | protected $service; |
21 | 21 | |
22 | 22 | /** |
| 23 | + * A character to separate multiple locations with. |
| 24 | + * |
| 25 | + * @since 0.8 |
| 26 | + * |
| 27 | + * @var char |
| 28 | + */ |
| 29 | + const SEPARATOR = ';'; |
| 30 | + |
| 31 | + /** |
23 | 32 | * Constructor. |
24 | 33 | * |
25 | 34 | * @since 0.8 |
— | — | @@ -37,12 +46,18 @@ |
38 | 47 | * @return array |
39 | 48 | */ |
40 | 49 | protected function getParameterInfo() { |
| 50 | + global $smgFIMulti; |
| 51 | + |
41 | 52 | $params = MapsMapper::getCommonParameters(); |
42 | 53 | $this->service->addParameterInfo( $params ); |
43 | 54 | |
44 | 55 | $params['zoom']->setDefault( false ); |
45 | 56 | $params['zoom']->setDoManipulationOfDefault( false ); |
46 | 57 | |
| 58 | + $params['multi'] = new Parameter( 'multi', Parameter::TYPE_BOOLEAN ); |
| 59 | + $params['multi']->setDefault( $smgFIMulti ); |
| 60 | + $params['multi']->setDoManipulationOfDefault( false ); |
| 61 | + |
47 | 62 | $params['centre'] = new Parameter( 'centre' ); |
48 | 63 | $params['centre']->setDefault( false ); |
49 | 64 | $params['centre']->addAliases( 'center' ); |
— | — | @@ -56,6 +71,12 @@ |
57 | 72 | $params['icon']->setDefault( '' ); |
58 | 73 | $params['icon']->addCriteria( New CriterionNotEmpty() ); |
59 | 74 | |
| 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 | + |
60 | 81 | return $params; |
61 | 82 | } |
62 | 83 | |
— | — | @@ -78,7 +99,9 @@ |
79 | 100 | if ( !is_array( $value ) && !is_object( $value ) ) { |
80 | 101 | $parameters[$key] = $value; |
81 | 102 | } |
82 | | - } |
| 103 | + } |
| 104 | + |
| 105 | + $parameters['locations'] = '1,1;42,42';//$coordinates; |
83 | 106 | |
84 | 107 | $validator = new Validator( wfMsg( 'maps_' . $this->service->getName() ), false ); |
85 | 108 | $validator->setParameters( $parameters, $this->getParameterInfo() ); |
— | — | @@ -92,6 +115,8 @@ |
93 | 116 | $params = $validator->getParameterValues(); |
94 | 117 | $mapName = $this->service->getMapId(); |
95 | 118 | |
| 119 | + $params['inputname'] = $input_name; |
| 120 | + |
96 | 121 | $output = $this->getInputHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName ); |
97 | 122 | |
98 | 123 | $this->service->addResourceModules( $this->getResourceModules() ); |
Index: branches/SemanticMaps0.8/SemanticMaps.i18n.php |
— | — | @@ -28,7 +28,10 @@ |
29 | 29 | // Forms |
30 | 30 | 'semanticmaps_lookupcoordinates' => 'Look up coordinates', |
31 | 31 | 'semanticmaps_enteraddresshere' => 'Enter address here', |
| 32 | + 'semanticmaps-loading-forminput' => 'Loading map form input...', |
32 | 33 | 'semanticmaps_notfound' => 'not found', |
| 34 | + 'semanticmaps-forminput-remove' => 'Remove', |
| 35 | + 'semanticmaps-forminput-add' => 'Add', |
33 | 36 | |
34 | 37 | // Parameter descriptions |
35 | 38 | 'semanticmaps_paramdesc_format' => 'The mapping service used to generate the map', |