r74341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74340‎ | r74341 | r74342 >
Date:09:28, 6 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7 - made forms work again after changes to Validator and Maps
Modified paths:
  • /trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInputs.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/queryprinters/SM_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/services/GoogleMaps/SM_GoogleMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/services/OpenLayers/SM_OpenLayersFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/services/YahooMaps/SM_YahooMapsFormInput.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/includes/services/YahooMaps/SM_YahooMapsFormInput.php
@@ -48,7 +48,7 @@
4949 global $wgOut;
5050 global $smgScriptPath, $smgYahooFormsOnThisPage, $smgStyleVersion;
5151
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" ) );
5353 $this->service->addDependencies( $wgOut );
5454 }
5555
@@ -56,8 +56,6 @@
5757 * @see MapsMapFeature::addSpecificMapHTML
5858 */
5959 public function addSpecificMapHTML() {
60 - global $wgOut;
61 -
6260 $mapName = $this->service->getMapId( false );
6361
6462 $this->output .= Html::element(
@@ -69,9 +67,7 @@
7068 wfMsg( 'maps-loading-map' )
7169 );
7270
73 - $wgOut->addInlineScript( <<<EOT
74 -addOnloadHook(
75 - function() {
 71+ MapsMapper::addInlineScript( $this->service, <<<EOT
7672 makeFormInputYahooMap(
7773 "$mapName",
7874 "$this->coordsFieldName",
@@ -85,8 +81,6 @@
8682 {$this->markerCoords['lat']},
8783 {$this->markerCoords['lon']}
8884 );
89 - }
90 -);
9185 EOT
9286 );
9387
Index: trunk/extensions/SemanticMaps/includes/services/OpenLayers/SM_OpenLayersFormInput.php
@@ -38,7 +38,7 @@
3939 global $wgOut;
4040 global $smgScriptPath, $smgOLFormsOnThisPage, $smgStyleVersion;
4141
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" ) );
4343 $this->service->addDependencies( $wgOut );
4444 }
4545
@@ -46,7 +46,7 @@
4747 * @see MapsMapFeature::addSpecificMapHTML
4848 */
4949 public function addSpecificMapHTML() {
50 - global $wgOut, $wgLang;
 50+ global $wgLang;
5151
5252 $mapName = $this->service->getMapId( false );
5353
@@ -63,9 +63,7 @@
6464
6565 $langCode = $wgLang->getCode();
6666
67 - $wgOut->addInlineScript( <<<EOT
68 -addOnloadHook(
69 - function() {
 67+ MapsMapper::addInlineScript( $this->service,<<<EOT
7068 makeFormInputOpenLayer(
7169 "$mapName",
7270 "$this->coordsFieldName",
@@ -78,8 +76,6 @@
7977 [$this->controls],
8078 "$langCode"
8179 );
82 - }
83 -);
8480 EOT
8581 );
8682
Index: trunk/extensions/SemanticMaps/includes/services/GoogleMaps/SM_GoogleMapsFormInput.php
@@ -52,7 +52,7 @@
5353 global $wgOut;
5454 global $smgScriptPath, $smgGoogleFormsOnThisPage, $smgStyleVersion;
5555
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" ) );
5757 $this->service->addDependencies( $wgOut );
5858 }
5959
@@ -60,8 +60,6 @@
6161 * @see MapsMapFeature::addSpecificFormInputHTML
6262 */
6363 public function addSpecificMapHTML() {
64 - global $wgOut;
65 -
6664 $mapName = $this->service->getMapId( false );
6765
6866 // Remove the overlays control in case it's present.
@@ -79,9 +77,7 @@
8078 wfMsg( 'maps-loading-map' )
8179 );
8280
83 - $wgOut->addInlineScript( <<<EOT
84 -addOnloadHook(
85 - function() {
 81+ MapsMapper::addInlineScript( $this->service, <<<EOT
8682 makeGoogleMapFormInput(
8783 "$mapName",
8884 "$this->coordsFieldName",
@@ -98,8 +94,6 @@
9995 {$this->markerCoords['lat']},
10096 {$this->markerCoords['lon']}
10197 );
102 - }
103 -);
10498 EOT
10599 );
106100 }
Index: trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInput.php
@@ -92,7 +92,7 @@
9393 *
9494 * @param array $mapProperties
9595 *
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
9797 */
9898 protected final function setMapProperties( array $mapProperties ) {
9999 /*
@@ -129,9 +129,9 @@
130130
131131 $validator->validateParameters();
132132
133 - $showMap = $validator->hasFatalError();
 133+ $fatalError = $validator->hasFatalError();
134134
135 - if ( $showMap ) {
 135+ if ( $fatalError === false ) {
136136 $parameters = $validator->getParameterValues();
137137
138138 foreach ( $parameters as $paramName => $paramValue ) {
@@ -145,26 +145,31 @@
146146 }
147147 }
148148
149 - return $showMap;
 149+ return $fatalError;
150150 }
151151
152152 /**
153153 * This function is a hook for Semantic Forms, and returns the HTML needed in
154154 * the form to handle coordinate data.
155155 *
 156+ * TODO: Use function args for sf stuffz
 157+ *
156158 * @return array
157 - *
158 - * TODO: Use function args for sf stuffz
159159 */
160160 public final function formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ) {
161161 global $sfgTabIndex;
162162
163163 $this->coordinates = $coordinates;
164164
165 - $showInput = $this->setMapProperties( $field_args );
 165+ $fatalError = $this->setMapProperties( $field_args );
166166
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+ );
169174 }
170175
171176 $this->setCoordinates();
@@ -216,7 +221,8 @@
217222
218223 $this->addFormDependencies();
219224
220 - return array( $this->output . $this->errorList, '' );
 225+ // TODO: errors
 226+ return array( $this->output, '' );
221227 }
222228
223229 /**
@@ -391,6 +397,8 @@
392398
393399 $params['centre']->lowerCaseValue = false;
394400
 401+ //$params['foobar'] = new Parameter('foobar');
 402+
395403 // TODO
396404 //$params['geoservice']->setDefault( $egMapsDefaultGeoService );
397405 //$params['mappingservice']->setDefault( $egMapsDefaultServices['fi'] );
Index: trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInputs.php
@@ -13,8 +13,6 @@
1414 die( 'Not an entry point.' );
1515 }
1616
17 -$wgAutoloadClasses['SMFormInputs'] = __FILE__;
18 -
1917 $wgHooks['MappingFeatureLoad'][] = 'SMFormInputs::initialize';
2018
2119 final class SMFormInputs {
@@ -46,12 +44,14 @@
4745 self::initFormHook( $service->getName(), $service->getName() );
4846
4947 // 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+ }
5151 }
5252
5353 // Add the 'map' form input type if there are mapping services that have FI's loaded.
5454 if ( $hasFormInputs ) self::initFormHook( 'map' );
55 -
 55+
5656 return true;
5757 }
5858
@@ -65,10 +65,14 @@
6666 */
6767 private static function initFormHook( $inputName, $mainName = '' ) {
6868 global $wgAutoloadClasses, $sfgFormPrinter, $smgDir;
69 -
 69+
7070 // Add the form input hook for the service.
7171 $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+
7377 $sfgFormPrinter->setInputTypeHook( $inputName, 'smfSelectFormInputHTML', $field_args );
7478 }
7579
Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_QueryPrinters.php
@@ -13,8 +13,6 @@
1414 die( 'Not an entry point.' );
1515 }
1616
17 -$wgAutoloadClasses['SMQueryPrinters'] = __FILE__;
18 -
1917 $wgHooks['MappingFeatureLoad'][] = 'SMQueryPrinters::initialize';
2018
2119 final class SMQueryPrinters {
@@ -48,7 +46,9 @@
4947 }
5048
5149 // 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+ }
5353
5454 return true;
5555 }

Status & tagging log