Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -21,7 +21,6 @@ |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @see MapsMapFeature::setMapSettings() |
25 | | - * |
26 | 25 | */ |
27 | 26 | protected function setMapSettings() { |
28 | 27 | global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix; |
— | — | @@ -36,10 +35,9 @@ |
37 | 36 | |
38 | 37 | /** |
39 | 38 | * @see MapsMapFeature::addFormDependencies() |
40 | | - * |
41 | 39 | */ |
42 | 40 | protected function addFormDependencies() { |
43 | | - global $wgJsMimeType, $wgParser; |
| 41 | + global $wgOut, $wgParser; |
44 | 42 | global $smgScriptPath, $smgYahooFormsOnThisPage, $smgStyleVersion, $egMapsJsExt; |
45 | 43 | |
46 | 44 | MapsYahooMaps::addYMapDependencies( $wgParser ); |
— | — | @@ -47,24 +45,15 @@ |
48 | 46 | if ( empty( $smgYahooFormsOnThisPage ) ) { |
49 | 47 | $smgYahooFormsOnThisPage = 0; |
50 | 48 | |
51 | | - $wgParser->getOutput()->addHeadItem( |
52 | | - Html::element( |
53 | | - 'script', |
54 | | - array( |
55 | | - 'type' => $wgJsMimeType, |
56 | | - 'src' => "$smgScriptPath/YahooMaps/SM_YahooMapsFunctions{$egMapsJsExt}?$smgStyleVersion" |
57 | | - ) |
58 | | - ) |
59 | | - ); |
| 49 | + $wgOut->addScriptFile( "$smgScriptPath/Services/YahooMaps/SM_YahooMapsFunctions{$egMapsJsExt}?$smgStyleVersion" ); |
60 | 50 | } |
61 | 51 | } |
62 | 52 | |
63 | 53 | /** |
64 | 54 | * @see MapsMapFeature::doMapServiceLoad() |
65 | | - * |
66 | 55 | */ |
67 | 56 | protected function doMapServiceLoad() { |
68 | | - global $egYahooMapsOnThisPage, $smgYahooFormsOnThisPage; |
| 57 | + global $egYahooMapsOnThisPage, $smgYahooFormsOnThisPage, $egMapsYahooMapsPrefix; |
69 | 58 | |
70 | 59 | self::addFormDependencies(); |
71 | 60 | |
— | — | @@ -72,13 +61,13 @@ |
73 | 62 | $smgYahooFormsOnThisPage++; |
74 | 63 | |
75 | 64 | $this->elementNr = $egYahooMapsOnThisPage; |
| 65 | + $this->mapName = $egMapsYahooMapsPrefix . '_' . $egYahooMapsOnThisPage; |
76 | 66 | } |
77 | 67 | |
78 | 68 | /** |
79 | 69 | * @see MapsMapFeature::addSpecificMapHTML() |
80 | | - * |
81 | 70 | */ |
82 | | - protected function addSpecificMapHTML( Parser $parser ) { |
| 71 | + protected function addSpecificMapHTML() { |
83 | 72 | global $wgOut; |
84 | 73 | |
85 | 74 | $this->output .= Html::element( |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php |
— | — | @@ -21,7 +21,6 @@ |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @see MapsMapFeature::setMapSettings() |
25 | | - * |
26 | 25 | */ |
27 | 26 | protected function setMapSettings() { |
28 | 27 | global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix; |
— | — | @@ -35,10 +34,9 @@ |
36 | 35 | |
37 | 36 | /** |
38 | 37 | * @see MapsMapFeature::addFormDependencies() |
39 | | - * |
40 | 38 | */ |
41 | 39 | protected function addFormDependencies() { |
42 | | - global $wgJsMimeType, $wgParser; |
| 40 | + global $wgOut, $wgParser; |
43 | 41 | global $smgScriptPath, $smgOLFormsOnThisPage, $smgStyleVersion, $egMapsJsExt; |
44 | 42 | |
45 | 43 | MapsOpenLayers::addOLDependencies( $wgParser ); |
— | — | @@ -46,24 +44,15 @@ |
47 | 45 | if ( empty( $smgOLFormsOnThisPage ) ) { |
48 | 46 | $smgOLFormsOnThisPage = 0; |
49 | 47 | |
50 | | - $wgParser->getOutput()->addHeadItem( |
51 | | - Html::element( |
52 | | - 'script', |
53 | | - array( |
54 | | - 'type' => $wgJsMimeType, |
55 | | - 'src' => "$smgScriptPath/OpenLayers/SM_OpenLayersFunctions{$egMapsJsExt}?$smgStyleVersion" |
56 | | - ) |
57 | | - ) |
58 | | - ); |
| 48 | + $wgOut->addScriptFile( "$smgScriptPath/Services/OpenLayers/SM_OpenLayersFunctions{$egMapsJsExt}?$smgStyleVersion" ); |
59 | 49 | } |
60 | 50 | } |
61 | 51 | |
62 | 52 | /** |
63 | 53 | * @see MapsMapFeature::doMapServiceLoad() |
64 | | - * |
65 | 54 | */ |
66 | 55 | protected function doMapServiceLoad() { |
67 | | - global $egOpenLayersOnThisPage, $smgOLFormsOnThisPage; |
| 56 | + global $egOpenLayersOnThisPage, $smgOLFormsOnThisPage, $egMapsOpenLayersPrefix; |
68 | 57 | |
69 | 58 | self::addFormDependencies(); |
70 | 59 | |
— | — | @@ -71,13 +60,13 @@ |
72 | 61 | $smgOLFormsOnThisPage++; |
73 | 62 | |
74 | 63 | $this->elementNr = $egOpenLayersOnThisPage; |
| 64 | + $this->mapName = $egMapsOpenLayersPrefix . '_' . $egOpenLayersOnThisPage; |
75 | 65 | } |
76 | 66 | |
77 | 67 | /** |
78 | 68 | * @see MapsMapFeature::addSpecificMapHTML() |
79 | | - * |
80 | 69 | */ |
81 | | - protected function addSpecificMapHTML( Parser $parser ) { |
| 70 | + protected function addSpecificMapHTML() { |
82 | 71 | global $wgOut; |
83 | 72 | |
84 | 73 | $this->output .= Html::element( |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php |
— | — | @@ -23,7 +23,6 @@ |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @see MapsMapFeature::setMapSettings() |
27 | | - * |
28 | 27 | */ |
29 | 28 | protected function setMapSettings() { |
30 | 29 | global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix; |
— | — | @@ -41,32 +40,22 @@ |
42 | 41 | * @see smw/extensions/SemanticMaps/FormInputs/SMFormInput#addFormDependencies() |
43 | 42 | */ |
44 | 43 | protected function addFormDependencies() { |
45 | | - global $wgJsMimeType, $wgParser; |
| 44 | + global $wgOut; |
46 | 45 | global $smgScriptPath, $smgGoogleFormsOnThisPage, $smgStyleVersion, $egMapsJsExt; |
47 | 46 | |
48 | | - MapsGoogleMaps::addGMapDependencies( $wgParser ); |
| 47 | + MapsGoogleMaps::addGMapDependencies( $wgOut ); |
49 | 48 | |
50 | 49 | if ( empty( $smgGoogleFormsOnThisPage ) ) { |
51 | 50 | $smgGoogleFormsOnThisPage = 0; |
52 | | - |
53 | | - $wgParser->getOutput()->addHeadItem( |
54 | | - Html::element( |
55 | | - 'script', |
56 | | - array( |
57 | | - 'type' => $wgJsMimeType, |
58 | | - 'src' => "$smgScriptPath/GoogleMaps/SM_GoogleMapsFunctions{$egMapsJsExt}?$smgStyleVersion" |
59 | | - ) |
60 | | - ) |
61 | | - ); |
| 51 | + $wgOut->addScriptFile( "$smgScriptPath/Services/GoogleMaps/SM_GoogleMapsFunctions{$egMapsJsExt}?$smgStyleVersion" ); |
62 | 52 | } |
63 | 53 | } |
64 | 54 | |
65 | 55 | /** |
66 | 56 | * @see MapsMapFeature::doMapServiceLoad() |
67 | | - * |
68 | 57 | */ |
69 | 58 | protected function doMapServiceLoad() { |
70 | | - global $egGoogleMapsOnThisPage, $smgGoogleFormsOnThisPage; |
| 59 | + global $egGoogleMapsOnThisPage, $smgGoogleFormsOnThisPage, $egMapsGoogleMapsPrefix; |
71 | 60 | |
72 | 61 | self::addFormDependencies(); |
73 | 62 | |
— | — | @@ -74,19 +63,19 @@ |
75 | 64 | $smgGoogleFormsOnThisPage++; |
76 | 65 | |
77 | 66 | $this->elementNr = $egGoogleMapsOnThisPage; |
| 67 | + $this->mapName = $egMapsGoogleMapsPrefix . '_' . $egGoogleMapsOnThisPage; |
78 | 68 | } |
79 | 69 | |
80 | 70 | /** |
81 | 71 | * @see MapsMapFeature::addSpecificFormInputHTML() |
82 | | - * |
83 | 72 | */ |
84 | | - protected function addSpecificMapHTML( Parser $parser ) { |
| 73 | + protected function addSpecificMapHTML() { |
85 | 74 | global $wgOut; |
86 | 75 | |
87 | 76 | // Remove the overlays control in case it's present. |
| 77 | + // TODO: make less insane |
88 | 78 | if ( in_string( 'overlays', $this->controls ) ) { |
89 | | - $this->controls = str_replace( ",'overlays'", '', $this->controls ); |
90 | | - $this->controls = str_replace( "'overlays',", '', $this->controls ); |
| 79 | + $this->controls = str_replace( array( ",'overlays'", "'overlays'," ), '', $this->controls ); |
91 | 80 | } |
92 | 81 | |
93 | 82 | $this->output .= Html::element( |
— | — | @@ -124,12 +113,11 @@ |
125 | 114 | |
126 | 115 | /** |
127 | 116 | * @see SMFormInput::manageGeocoding() |
128 | | - * |
129 | 117 | */ |
130 | 118 | protected function manageGeocoding() { |
131 | | - global $egGoogleMapsKey; |
132 | | - $this->enableGeocoding = strlen( trim( $egGoogleMapsKey ) ) > 0; |
133 | | - if ( $this->enableGeocoding ) MapsGoogleMaps::addGMapDependencies( $this->output, $this->parser ); |
| 119 | + global $egGoogleMapsKey, $wgParser; |
| 120 | + $this->enableGeocoding = $egGoogleMapsKey != ''; |
| 121 | + if ( $this->enableGeocoding ) MapsGoogleMaps::addGMapDependencies( $wgParser ); |
134 | 122 | } |
135 | 123 | |
136 | 124 | } |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php |
— | — | @@ -119,8 +119,6 @@ |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @see SMWDataValue::getShortWikiText |
123 | | - * |
124 | | - * TODO: make the output here more readible (and if possible informative) |
125 | 123 | */ |
126 | 124 | public function getShortWikiText( $linked = null ) { |
127 | 125 | if ( $this->isValid() && ( $linked !== null ) && ( $linked !== false ) ) { |
Index: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | */ |
27 | 27 | protected abstract function addFormDependencies(); |
28 | 28 | |
| 29 | + protected $mapName; |
| 30 | + |
29 | 31 | // TODO: change into a single array |
30 | 32 | protected $marker_lat; |
31 | 33 | protected $marker_lon; |
— | — | @@ -53,23 +55,30 @@ |
54 | 56 | * by the feature parameters (the ones spesific to a feature). The result is then |
55 | 57 | * again overidden by the service parameters (the ones spesific to the service), |
56 | 58 | * and finally by the spesific parameters (the ones spesific to a service-feature combination). |
57 | | - * |
58 | | - * FIXME: this causes some wicked error? |
59 | 59 | */ |
60 | | - $parameterInfo = /* array_merge_recursive( MapsMapper::getCommonParameters(), */ SMFormInputs::$parameters /* ) */; |
| 60 | + $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), SMFormInputs::$parameters ); |
61 | 61 | $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$this->serviceName]['parameters'] ); |
62 | 62 | $parameterInfo = array_merge_recursive( $parameterInfo, $this->spesificParameters ); |
63 | | - $parameterInfo = array(); |
64 | 63 | |
65 | 64 | $manager = new ValidatorManager(); |
66 | 65 | |
67 | 66 | $showMap = $manager->manageParameters( $mapProperties, $parameterInfo ); |
68 | 67 | |
69 | 68 | if ( $showMap ) { |
70 | | - $this->setMapProperties( $manager->getParameters( false ), __CLASS__ ); |
| 69 | + $parameters = $manager->getParameters( false ); |
| 70 | + |
| 71 | + foreach ( $parameters as $paramName => $paramValue ) { |
| 72 | + if ( !property_exists( __CLASS__, $paramName ) ) { |
| 73 | + $this-> { $paramName } = $paramValue; |
| 74 | + } |
| 75 | + else { |
| 76 | + // If this happens in any way, it could be a big vunerability, so throw an exception. |
| 77 | + throw new Exception( 'Attempt to override a class field during map property assignment. Field name: ' . $paramName ); |
| 78 | + } |
| 79 | + } |
71 | 80 | } |
72 | 81 | |
73 | | - $this->errorList = $manager->getErrorList(); |
| 82 | + $this->errorList = $manager->getErrorList(); |
74 | 83 | |
75 | 84 | return $showMap; |
76 | 85 | } |
— | — | @@ -83,14 +92,18 @@ |
84 | 93 | * TODO: Use function args for sf stuffz |
85 | 94 | */ |
86 | 95 | public final function formInputHTML( $coordinates, $input_name, $is_mandatory, $is_disabled, $field_args ) { |
87 | | - global $wgParser, $sfgTabIndex; |
| 96 | + global $sfgTabIndex; |
88 | 97 | |
89 | 98 | $this->coordinates = $coordinates; |
90 | 99 | |
91 | 100 | $this->setMapSettings(); |
92 | 101 | |
93 | | - $this->setMapProperties( $field_args ); |
| 102 | + $showInput = $this->setMapProperties( $field_args ); |
94 | 103 | |
| 104 | + if ( !$showInput ) { |
| 105 | + return array( $this->errorList ); |
| 106 | + } |
| 107 | + |
95 | 108 | $this->doMapServiceLoad(); |
96 | 109 | |
97 | 110 | $this->manageGeocoding(); |
— | — | @@ -100,8 +113,6 @@ |
101 | 114 | $this->setZoom(); |
102 | 115 | |
103 | 116 | // Create html element names. |
104 | | - $this->setMapName(); |
105 | | - $this->mapName .= '_' . $sfgTabIndex; |
106 | 117 | $this->geocodeFieldName = $this->elementNamePrefix . '_geocode_' . $this->elementNr . '_' . $sfgTabIndex; |
107 | 118 | $this->coordsFieldName = $this->elementNamePrefix . '_coords_' . $this->elementNr . '_' . $sfgTabIndex; |
108 | 119 | $this->infoFieldName = $this->elementNamePrefix . '_info_' . $this->elementNr . '_' . $sfgTabIndex; |
— | — | @@ -128,7 +139,7 @@ |
129 | 140 | |
130 | 141 | if ( $this->enableGeocoding ) $this->addGeocodingField(); |
131 | 142 | |
132 | | - $this->addSpecificMapHTML( $wgParser ); |
| 143 | + $this->addSpecificMapHTML(); |
133 | 144 | |
134 | 145 | return array( $this->output . $this->errorList, '' ); |
135 | 146 | } |