Index: trunk/extensions/SemanticMaps/includes/services/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | global $wgOut; |
50 | 50 | global $smgScriptPath, $smgYahooFormsOnThisPage, $smgStyleVersion; |
51 | 51 | |
52 | | - $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/YahooMaps/SM_YahooMapsForms.js?$smgStyleVersion" ) ); |
| 52 | + $this->service->addDependency( Html::linkedScript( "$smgScriptPath/includes/services/YahooMaps/SM_YahooMapsForms.js?$smgStyleVersion" ) ); |
53 | 53 | $this->service->addDependencies( $wgOut ); |
54 | 54 | } |
55 | 55 | |
— | — | @@ -56,8 +56,6 @@ |
57 | 57 | * @see MapsMapFeature::addSpecificMapHTML |
58 | 58 | */ |
59 | 59 | public function addSpecificMapHTML() { |
60 | | - global $wgOut; |
61 | | - |
62 | 60 | $mapName = $this->service->getMapId( false ); |
63 | 61 | |
64 | 62 | $this->output .= Html::element( |
— | — | @@ -69,9 +67,7 @@ |
70 | 68 | wfMsg( 'maps-loading-map' ) |
71 | 69 | ); |
72 | 70 | |
73 | | - $wgOut->addInlineScript( <<<EOT |
74 | | -addOnloadHook( |
75 | | - function() { |
| 71 | + MapsMapper::addInlineScript( $this->service, <<<EOT |
76 | 72 | makeFormInputYahooMap( |
77 | 73 | "$mapName", |
78 | 74 | "$this->coordsFieldName", |
— | — | @@ -85,8 +81,6 @@ |
86 | 82 | {$this->markerCoords['lat']}, |
87 | 83 | {$this->markerCoords['lon']} |
88 | 84 | ); |
89 | | - } |
90 | | -); |
91 | 85 | EOT |
92 | 86 | ); |
93 | 87 | |
Index: trunk/extensions/SemanticMaps/includes/services/OpenLayers/SM_OpenLayersFormInput.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | global $wgOut; |
40 | 40 | global $smgScriptPath, $smgOLFormsOnThisPage, $smgStyleVersion; |
41 | 41 | |
42 | | - $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/OpenLayers/SM_OpenLayersForms.js?$smgStyleVersion" ) ); |
| 42 | + $this->service->addDependency( Html::linkedScript( "$smgScriptPath/includes/services/OpenLayers/SM_OpenLayersForms.js?$smgStyleVersion" ) ); |
43 | 43 | $this->service->addDependencies( $wgOut ); |
44 | 44 | } |
45 | 45 | |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | * @see MapsMapFeature::addSpecificMapHTML |
48 | 48 | */ |
49 | 49 | public function addSpecificMapHTML() { |
50 | | - global $wgOut, $wgLang; |
| 50 | + global $wgLang; |
51 | 51 | |
52 | 52 | $mapName = $this->service->getMapId( false ); |
53 | 53 | |
— | — | @@ -63,9 +63,7 @@ |
64 | 64 | |
65 | 65 | $langCode = $wgLang->getCode(); |
66 | 66 | |
67 | | - $wgOut->addInlineScript( <<<EOT |
68 | | -addOnloadHook( |
69 | | - function() { |
| 67 | + MapsMapper::addInlineScript( $this->service,<<<EOT |
70 | 68 | makeFormInputOpenLayer( |
71 | 69 | "$mapName", |
72 | 70 | "$this->coordsFieldName", |
— | — | @@ -78,8 +76,6 @@ |
79 | 77 | [$this->controls], |
80 | 78 | "$langCode" |
81 | 79 | ); |
82 | | - } |
83 | | -); |
84 | 80 | EOT |
85 | 81 | ); |
86 | 82 | |
Index: trunk/extensions/SemanticMaps/includes/services/GoogleMaps/SM_GoogleMapsFormInput.php |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | global $wgOut; |
54 | 54 | global $smgScriptPath, $smgGoogleFormsOnThisPage, $smgStyleVersion; |
55 | 55 | |
56 | | - $this->service->addDependency( Html::linkedScript( "$smgScriptPath/Services/GoogleMaps/SM_GoogleMapsForms.js?$smgStyleVersion" ) ); |
| 56 | + $this->service->addDependency( Html::linkedScript( "$smgScriptPath/includes/services/GoogleMaps/SM_GoogleMapsForms.js?$smgStyleVersion" ) ); |
57 | 57 | $this->service->addDependencies( $wgOut ); |
58 | 58 | } |
59 | 59 | |
— | — | @@ -60,8 +60,6 @@ |
61 | 61 | * @see MapsMapFeature::addSpecificFormInputHTML |
62 | 62 | */ |
63 | 63 | public function addSpecificMapHTML() { |
64 | | - global $wgOut; |
65 | | - |
66 | 64 | $mapName = $this->service->getMapId( false ); |
67 | 65 | |
68 | 66 | // Remove the overlays control in case it's present. |
— | — | @@ -79,9 +77,7 @@ |
80 | 78 | wfMsg( 'maps-loading-map' ) |
81 | 79 | ); |
82 | 80 | |
83 | | - $wgOut->addInlineScript( <<<EOT |
84 | | -addOnloadHook( |
85 | | - function() { |
| 81 | + MapsMapper::addInlineScript( $this->service, <<<EOT |
86 | 82 | makeGoogleMapFormInput( |
87 | 83 | "$mapName", |
88 | 84 | "$this->coordsFieldName", |
— | — | @@ -98,8 +94,6 @@ |
99 | 95 | {$this->markerCoords['lat']}, |
100 | 96 | {$this->markerCoords['lon']} |
101 | 97 | ); |
102 | | - } |
103 | | -); |
104 | 98 | EOT |
105 | 99 | ); |
106 | 100 | } |
Index: trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInput.php |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | * |
94 | 94 | * @param array $mapProperties |
95 | 95 | * |
96 | | - * @return boolean Indicates whether the map should be shown or not. |
| 96 | + * @return mixed ValidationError object if there is a fatal error, false othewise |
97 | 97 | */ |
98 | 98 | protected final function setMapProperties( array $mapProperties ) { |
99 | 99 | /* |
— | — | @@ -129,9 +129,9 @@ |
130 | 130 | |
131 | 131 | $validator->validateParameters(); |
132 | 132 | |
133 | | - $showMap = $validator->hasFatalError(); |
| 133 | + $fatalError = $validator->hasFatalError(); |
134 | 134 | |
135 | | - if ( $showMap ) { |
| 135 | + if ( $fatalError === false ) { |
136 | 136 | $parameters = $validator->getParameterValues(); |
137 | 137 | |
138 | 138 | foreach ( $parameters as $paramName => $paramValue ) { |
— | — | @@ -145,26 +145,31 @@ |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | | - return $showMap; |
| 149 | + return $fatalError; |
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * This function is a hook for Semantic Forms, and returns the HTML needed in |
154 | 154 | * the form to handle coordinate data. |
155 | 155 | * |
| 156 | + * TODO: Use function args for sf stuffz |
| 157 | + * |
156 | 158 | * @return array |
157 | | - * |
158 | | - * TODO: Use function args for sf stuffz |
159 | 159 | */ |
160 | 160 | public final function formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ) { |
161 | 161 | global $sfgTabIndex; |
162 | 162 | |
163 | 163 | $this->coordinates = $coordinates; |
164 | 164 | |
165 | | - $showInput = $this->setMapProperties( $field_args ); |
| 165 | + $fatalError = $this->setMapProperties( $field_args ); |
166 | 166 | |
167 | | - if ( !$showInput ) { |
168 | | - return array( '' ); |
| 167 | + if ( $fatalError !== false ) { |
| 168 | + return array( |
| 169 | + '<div><span class="errorbox">' . |
| 170 | + htmlspecialchars( wfMsgExt( 'validator-fatal-error', 'parsemag', $fatalError->getMessage() ) ) . |
| 171 | + '</span></div><br /><br /><br /><br />', |
| 172 | + '' |
| 173 | + ); |
169 | 174 | } |
170 | 175 | |
171 | 176 | $this->setCoordinates(); |
— | — | @@ -216,7 +221,8 @@ |
217 | 222 | |
218 | 223 | $this->addFormDependencies(); |
219 | 224 | |
220 | | - return array( $this->output . $this->errorList, '' ); |
| 225 | + // TODO: errors |
| 226 | + return array( $this->output, '' ); |
221 | 227 | } |
222 | 228 | |
223 | 229 | /** |
— | — | @@ -391,6 +397,8 @@ |
392 | 398 | |
393 | 399 | $params['centre']->lowerCaseValue = false; |
394 | 400 | |
| 401 | + //$params['foobar'] = new Parameter('foobar'); |
| 402 | + |
395 | 403 | // TODO |
396 | 404 | //$params['geoservice']->setDefault( $egMapsDefaultGeoService ); |
397 | 405 | //$params['mappingservice']->setDefault( $egMapsDefaultServices['fi'] ); |
Index: trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInputs.php |
— | — | @@ -13,8 +13,6 @@ |
14 | 14 | die( 'Not an entry point.' ); |
15 | 15 | } |
16 | 16 | |
17 | | -$wgAutoloadClasses['SMFormInputs'] = __FILE__; |
18 | | - |
19 | 17 | $wgHooks['MappingFeatureLoad'][] = 'SMFormInputs::initialize'; |
20 | 18 | |
21 | 19 | final class SMFormInputs { |
— | — | @@ -46,12 +44,14 @@ |
47 | 45 | self::initFormHook( $service->getName(), $service->getName() ); |
48 | 46 | |
49 | 47 | // Loop through the service alliases, and add them as form input types. |
50 | | - foreach ( $service->getAliases() as $alias ) self::initFormHook( $alias, $service->getName() ); |
| 48 | + foreach ( $service->getAliases() as $alias ) { |
| 49 | + self::initFormHook( $alias, $service->getName() ); |
| 50 | + } |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Add the 'map' form input type if there are mapping services that have FI's loaded. |
54 | 54 | if ( $hasFormInputs ) self::initFormHook( 'map' ); |
55 | | - |
| 55 | + |
56 | 56 | return true; |
57 | 57 | } |
58 | 58 | |
— | — | @@ -65,10 +65,14 @@ |
66 | 66 | */ |
67 | 67 | private static function initFormHook( $inputName, $mainName = '' ) { |
68 | 68 | global $wgAutoloadClasses, $sfgFormPrinter, $smgDir; |
69 | | - |
| 69 | + |
70 | 70 | // Add the form input hook for the service. |
71 | 71 | $field_args = array(); |
72 | | - if ( strlen( $mainName ) > 0 ) $field_args['service_name'] = $mainName; |
| 72 | + |
| 73 | + if ( $mainName != '' ) { |
| 74 | + $field_args['service_name'] = $mainName; |
| 75 | + } |
| 76 | + |
73 | 77 | $sfgFormPrinter->setInputTypeHook( $inputName, 'smfSelectFormInputHTML', $field_args ); |
74 | 78 | } |
75 | 79 | |
Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_QueryPrinters.php |
— | — | @@ -13,8 +13,6 @@ |
14 | 14 | die( 'Not an entry point.' ); |
15 | 15 | } |
16 | 16 | |
17 | | -$wgAutoloadClasses['SMQueryPrinters'] = __FILE__; |
18 | | - |
19 | 17 | $wgHooks['MappingFeatureLoad'][] = 'SMQueryPrinters::initialize'; |
20 | 18 | |
21 | 19 | final class SMQueryPrinters { |
— | — | @@ -48,7 +46,9 @@ |
49 | 47 | } |
50 | 48 | |
51 | 49 | // Add the 'map' result format if there are mapping services that have QP's loaded. |
52 | | - if ( $hasQueryPrinters ) self::initFormat( 'map', 'SMMapper' ); |
| 50 | + if ( $hasQueryPrinters ) { |
| 51 | + self::initFormat( 'map', 'SMMapper' ); |
| 52 | + } |
53 | 53 | |
54 | 54 | return true; |
55 | 55 | } |