Index: trunk/extensions/Maps/ParserFunctions/GeoFunctions/Maps_GeoFunctions.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | $output = ''; |
106 | 106 | break; |
107 | 107 | case Validator_ERRORS_WARN: |
108 | | - $output = '<b>' . wfMsgExt( 'validator_warning_parameters', array( 'parsemag' ), count( $fails ) ) . '</b>'; |
| 108 | + $output = '<b>' . htmlspecialchars( wfMsgExt( 'validator_warning_parameters', array( 'parsemag' ), count( $fails ) ) ) . '</b>'; |
109 | 109 | break; |
110 | 110 | case Validator_ERRORS_SHOW: default: |
111 | 111 | global $wgLang; |
— | — | @@ -209,7 +209,7 @@ |
210 | 210 | $output = ''; |
211 | 211 | break; |
212 | 212 | case Validator_ERRORS_WARN: |
213 | | - $output = '<b>' . wfMsgExt( 'validator_warning_parameters', array( 'parsemag' ), 1 ) . '</b>'; |
| 213 | + $output = '<b>' . htmlspecialchars( wfMsgExt( 'validator_warning_parameters', array( 'parsemag' ), 1 ) ) . '</b>'; |
214 | 214 | break; |
215 | 215 | case Validator_ERRORS_SHOW: default: |
216 | 216 | // Show an error that the location could not be geocoded or the coordinates where not recognized. |
Index: trunk/extensions/Maps/ParserFunctions/Geocode/Maps_GeocodeFunctions.php |
— | — | @@ -54,13 +54,8 @@ |
55 | 55 | * Handler for the geocode parser function. Returns the latitude and longitude |
56 | 56 | * for the provided address, or an empty string, when the geocoding fails. |
57 | 57 | * |
58 | | - * @param $parser |
59 | | - * @param string $coordsOrAddress The address to geocode, or coordinates to reformat. |
60 | | - * @param string $service Optional. The geocoding service to use. |
61 | | - * @param string $mappingService Optional. The mapping service that will use the geocoded data. |
| 58 | + * @param Parser $parser |
62 | 59 | * |
63 | | - * TODO: rewrite |
64 | | - * |
65 | 60 | * @return string |
66 | 61 | */ |
67 | 62 | public static function renderGeocoder( Parser $parser ) { |
— | — | @@ -73,64 +68,47 @@ |
74 | 69 | // We already know the $parser. |
75 | 70 | array_shift( $args ); |
76 | 71 | |
77 | | - // For backward compatibility with pre 0.6. |
78 | | - $defaultParams = array( 'location', 'service', 'mappingservice' ); |
79 | | - $parameters = array(); |
| 72 | + $manager = new ValidatorManager(); |
80 | 73 | |
81 | | - // Determine all parameter names and value, and take care of default (nameless) |
82 | | - // parameters, by turning them into named ones. |
83 | | - foreach( $args as $arg ) { |
84 | | - $parts = explode( '=', $arg ); |
85 | | - if ( count( $parts ) == 1 ) { |
86 | | - if ( count( $defaultParams ) > 0 ) { |
87 | | - $defaultParam = array_shift( $defaultParams ); |
88 | | - $parameters[$defaultParam] = trim( $parts[0] ); |
89 | | - } |
90 | | - } else { |
91 | | - $name = strtolower( trim( array_shift( $parts ) ) ); |
92 | | - $parameters[$name] = trim( implode( $parts ) ); |
93 | | - } |
94 | | - } |
95 | | - |
96 | | - $parameterInfo = array( |
97 | | - 'location' => array( |
98 | | - 'required' => true |
99 | | - ), |
100 | | - 'mappingservice' => array( |
101 | | - 'criteria' => array( |
102 | | - 'in_array' => $egMapsAvailableServices |
| 74 | + $parameters = $manager->manageMapparameters( |
| 75 | + $args, |
| 76 | + array( |
| 77 | + 'location' => array( |
| 78 | + 'required' => true |
103 | 79 | ), |
104 | | - 'default' => false |
105 | | - ), |
106 | | - 'service' => array( |
107 | | - 'criteria' => array( |
108 | | - 'in_array' => $egMapsAvailableGeoServices |
| 80 | + 'mappingservice' => array( |
| 81 | + 'criteria' => array( |
| 82 | + 'in_array' => $egMapsAvailableServices |
| 83 | + ), |
| 84 | + 'default' => false |
109 | 85 | ), |
110 | | - 'default' => $egMapsDefaultGeoService |
111 | | - ), |
112 | | - 'format' => array( |
113 | | - 'criteria' => array( |
114 | | - 'in_array' => $egMapsAvailableCoordNotations |
| 86 | + 'service' => array( |
| 87 | + 'criteria' => array( |
| 88 | + 'in_array' => $egMapsAvailableGeoServices |
| 89 | + ), |
| 90 | + 'default' => $egMapsDefaultGeoService |
115 | 91 | ), |
116 | | - 'aliases' => array( |
117 | | - 'notation' |
118 | | - ), |
119 | | - 'default' => $egMapsCoordinateNotation |
| 92 | + 'format' => array( |
| 93 | + 'criteria' => array( |
| 94 | + 'in_array' => $egMapsAvailableCoordNotations |
| 95 | + ), |
| 96 | + 'aliases' => array( |
| 97 | + 'notation' |
| 98 | + ), |
| 99 | + 'default' => $egMapsCoordinateNotation |
| 100 | + ), |
| 101 | + 'allowcoordinates' => array( |
| 102 | + 'type' => 'boolean', |
| 103 | + 'default' => $egMapsAllowCoordsGeocoding |
| 104 | + ), |
| 105 | + 'directional' => array( |
| 106 | + 'type' => 'boolean', |
| 107 | + 'default' => $egMapsCoordinateDirectional |
| 108 | + ), |
120 | 109 | ), |
121 | | - 'allowcoordinates' => array( |
122 | | - 'type' => 'boolean', |
123 | | - 'default' => $egMapsAllowCoordsGeocoding |
124 | | - ), |
125 | | - 'directional' => array( |
126 | | - 'type' => 'boolean', |
127 | | - 'default' => $egMapsCoordinateDirectional |
128 | | - ), |
| 110 | + array( 'location', 'service', 'mappingservice' ) |
129 | 111 | ); |
130 | 112 | |
131 | | - $manager = new ValidatorManager(); |
132 | | - |
133 | | - $parameters = $manager->manageMapparameters( $parameters, $parameterInfo ); |
134 | | - |
135 | 113 | $doGeocoding = $parameters !== false; |
136 | 114 | |
137 | 115 | if ( $doGeocoding ) { |
— | — | @@ -140,7 +118,7 @@ |
141 | 119 | $parameters['service'], |
142 | 120 | $parameters['mappingservice'], |
143 | 121 | $parameters['allowcoordinates'], |
144 | | - $parameters['notation'], |
| 122 | + $parameters['format'], |
145 | 123 | $parameters['directional'] |
146 | 124 | ); |
147 | 125 | return ( $geovalues ? $geovalues : '' ) . $manager->getErrorList(); |
— | — | @@ -157,7 +135,7 @@ |
158 | 136 | * Handler for the geocode parser function. Returns the latitude |
159 | 137 | * for the provided address, or an empty string, when the geocoding fails. |
160 | 138 | * |
161 | | - * @param $parser |
| 139 | + * @param Parser $parser |
162 | 140 | * @param string $address The address to geocode. |
163 | 141 | * @param string $service Optional. The geocoding service to use. |
164 | 142 | * @param string $mappingService Optional. The mapping service that will use the geocoded data. |
— | — | @@ -173,7 +151,7 @@ |
174 | 152 | * Handler for the geocode parser function. Returns the longitude |
175 | 153 | * for the provided address, or an empty string, when the geocoding fails. |
176 | 154 | * |
177 | | - * @param $parser |
| 155 | + * @param Parser $parser |
178 | 156 | * @param string $address The address to geocode. |
179 | 157 | * @param string $service Optional. The geocoding service to use. |
180 | 158 | * @param string $mappingService Optional. The mapping service that will use the geocoded data. |
Index: trunk/extensions/Maps/ParserFunctions/Coordinates/Maps_Coordinates.php |
— | — | @@ -47,48 +47,31 @@ |
48 | 48 | // We already know the $parser. |
49 | 49 | array_shift( $args ); |
50 | 50 | |
51 | | - // For backward compatibility with pre 0.6. |
52 | | - $defaultParams = array( 'location', 'format', 'directional' ); |
53 | | - $parameters = array(); |
| 51 | + $manager = new ValidatorManager(); |
54 | 52 | |
55 | | - // Determine all parameter names and value, and take care of default (nameless) |
56 | | - // parameters, by turning them into named ones. |
57 | | - foreach( $args as $arg ) { |
58 | | - $parts = explode( '=', $arg ); |
59 | | - if ( count( $parts ) == 1 ) { |
60 | | - if ( count( $defaultParams ) > 0 ) { |
61 | | - $defaultParam = array_shift( $defaultParams ); |
62 | | - $parameters[$defaultParam] = trim( $parts[0] ); |
63 | | - } |
64 | | - } else { |
65 | | - $name = strtolower( trim( array_shift( $parts ) ) ); |
66 | | - $parameters[$name] = trim( implode( $parts ) ); |
67 | | - } |
68 | | - } |
69 | | - |
70 | | - $parameterInfo = array( |
71 | | - 'location' => array( |
72 | | - 'required' => true |
73 | | - ), |
74 | | - 'format' => array( |
75 | | - 'criteria' => array( |
76 | | - 'in_array' => $egMapsAvailableCoordNotations |
| 53 | + $parameters = $manager->manageMapparameters( |
| 54 | + $args, |
| 55 | + array( |
| 56 | + 'location' => array( |
| 57 | + 'required' => true |
77 | 58 | ), |
78 | | - 'aliases' => array( |
79 | | - 'notation' |
| 59 | + 'format' => array( |
| 60 | + 'criteria' => array( |
| 61 | + 'in_array' => $egMapsAvailableCoordNotations |
| 62 | + ), |
| 63 | + 'aliases' => array( |
| 64 | + 'notation' |
| 65 | + ), |
| 66 | + 'default' => $egMapsCoordinateNotation |
80 | 67 | ), |
81 | | - 'default' => $egMapsCoordinateNotation |
| 68 | + 'directional' => array( |
| 69 | + 'type' => 'boolean', |
| 70 | + 'default' => $egMapsCoordinateDirectional |
| 71 | + ), |
82 | 72 | ), |
83 | | - 'directional' => array( |
84 | | - 'type' => 'boolean', |
85 | | - 'default' => $egMapsCoordinateDirectional |
86 | | - ), |
| 73 | + array( 'location', 'format', 'directional' ) |
87 | 74 | ); |
88 | 75 | |
89 | | - $manager = new ValidatorManager(); |
90 | | - |
91 | | - $parameters = $manager->manageMapparameters( $parameters, $parameterInfo ); |
92 | | - |
93 | 76 | $doFormatting = $parameters !== false; |
94 | 77 | |
95 | 78 | if ( $doFormatting ) { |
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -7,6 +7,8 @@ |
8 | 8 | * @ingroup Maps |
9 | 9 | * |
10 | 10 | * @author Jeroen De Dauw |
| 11 | + * |
| 12 | + * TODO: clean up this stuff (goes together with refactoring MapsMapFeature and it's subclasses). |
11 | 13 | */ |
12 | 14 | |
13 | 15 | if ( !defined( 'MEDIAWIKI' ) ) { |
— | — | @@ -69,13 +71,13 @@ |
70 | 72 | /** |
71 | 73 | * Returns the output for the call to the specified parser function. |
72 | 74 | * |
73 | | - * @param $parser |
| 75 | + * @param Parser $parser |
74 | 76 | * @param array $params |
75 | 77 | * @param string $parserFunction |
76 | 78 | * |
77 | 79 | * @return array |
78 | 80 | */ |
79 | | - public static function getMapHtml( &$parser, array $params, $parserFunction ) { |
| 81 | + public static function getMapHtml( Parser &$parser, array $params, $parserFunction ) { |
80 | 82 | global $wgLang, $egValidatorErrorLevel; |
81 | 83 | |
82 | 84 | array_shift( $params ); // We already know the $parser. |