r65692 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65691‎ | r65692 | r65693 >
Date:15:02, 30 April 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Fix typos in documentation and remove trailing whitespace
Modified paths:
  • /trunk/extensions/Maps/Maps_Mapper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Maps_Mapper.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -/**
 4+/**
55 * A class that holds static helper functions for common functionality that is not map-spesific.
66 *
77 * @file Maps_Mapper.php
@@ -14,7 +14,7 @@
1515 }
1616
1717 final class MapsMapper {
18 -
 18+
1919 public static function initialize() {
2020 global $egMapsSizeRestrictions, $egMapsMapWidth, $egMapsMapHeight;
2121
@@ -26,7 +26,7 @@
2727 Validator::addOutputFormat( 'coordinateSet', array( __CLASS__, 'formatLocation' ) );
2828 Validator::addOutputFormat( 'coordinateSets', array( __CLASS__, 'formatLocations' ) );
2929 }
30 -
 30+
3131 public static function isLocation( $location ) {
3232 if ( self::geocoderIsAvailable() ) {
3333 return MapsGeocoder::isLocation( $location );
@@ -34,7 +34,7 @@
3535 return MapsCoordinateParser::areCoordinates( $location );
3636 }
3737 }
38 -
 38+
3939 public static function areLocations( $locations ) {
4040 $locations = (array)$locations;
4141 foreach ( $locations as $location ) {
@@ -44,7 +44,7 @@
4545 }
4646 return true;
4747 }
48 -
 48+
4949 public static function formatLocation( &$location ) {
5050 if ( self::geocoderIsAvailable() ) {
5151 $location = MapsGeocoder::attemptToGeocodeToString( $location );
@@ -52,21 +52,21 @@
5353 $location = MapsCoordinateParser::parseAndFormat( $location );
5454 }
5555 }
56 -
 56+
5757 public static function formatLocations( &$locations ) {
5858 $locations = (array)$locations;
5959 foreach ( $locations as &$location ) {
6060 self::formatLocation( $location );
6161 }
6262 }
63 -
 63+
6464 /**
6565 * Returns a valid service. When an invalid service is provided, the default one will be returned.
6666 * Aliases are also chancged into the main service names @see MapsMapper::getMainServiceName().
6767 *
6868 * @param string $service
6969 * @param string $feature
70 - *
 70+ *
7171 * @return string
7272 */
7373 public static function getValidService( $service, $feature ) {
@@ -93,10 +93,10 @@
9494 $service = $egMapsDefaultService;
9595 }
9696 }
97 -
 97+
9898 return $service;
9999 }
100 -
 100+
101101 /**
102102 * Checks if the service name is an alias for an actual service,
103103 * and changes it into the main service name if this is the case.
@@ -106,7 +106,7 @@
107107 */
108108 private static function getMainServiceName( $service ) {
109109 global $egMapsServices;
110 -
 110+
111111 if ( ! array_key_exists( $service, $egMapsServices ) ) {
112112 foreach ( $egMapsServices as $serviceName => $serviceInfo ) {
113113 if ( in_array( $service, $serviceInfo['aliases'] ) ) {
@@ -115,23 +115,23 @@
116116 }
117117 }
118118 }
119 -
 119+
120120 return $service;
121121 }
122 -
 122+
123123 /**
124124 * Determines if a value is a valid map dimension, and optionally corrects it.
125 - *
 125+ *
126126 * @param string or number $value The value as it was entered by the user.
127 - * @param string $dimension Must be width or hieght.
 127+ * @param string $dimension Must be width or height.
128128 * @param boolean $correct If true, the value will be corrected when invalid. Defaults to false.
129129 * @param number $default The default value for this dimension. Must be set when $correct = true.
130 - *
 130+ *
131131 * @return boolean
132132 */
133133 public static function isMapDimension( &$value, $dimension, $correct = false, $default = 0 ) {
134134 global $egMapsSizeRestrictions;
135 -
 135+
136136 // See if the notation is valid.
137137 if ( !preg_match( '/^\d+(\.\d+)?(px|ex|em|%)?$/', $value ) ) {
138138 if ( $correct ) {
@@ -140,7 +140,7 @@
141141 return false;
142142 }
143143 }
144 -
 144+
145145 // Determine the minimum and maximum values.
146146 if ( preg_match( '/^.*%$/', $value ) ) {
147147 if ( count( $egMapsSizeRestrictions[$dimension] >= 4 ) ) {
@@ -155,7 +155,7 @@
156156 $min = $egMapsSizeRestrictions[$dimension][0];
157157 $max = $egMapsSizeRestrictions[$dimension][1];
158158 }
159 -
 159+
160160 // See if the actual value is withing the limits.
161161 $number = preg_replace( '/[^0-9]/', '', $value );
162162 if ( $number < $egMapsSizeRestrictions[$dimension][0] ) {
@@ -171,22 +171,22 @@
172172 return false;
173173 }
174174 }
175 -
 175+
176176 // If this is a 'correct the value call', add 'px' if no unit has been provided.
177177 if ( $correct ) {
178178 if ( !preg_match( '/(px|ex|em|%)$/', $value ) ) {
179179 $value .= 'px';
180180 }
181181 }
182 -
 182+
183183 return true;
184184 }
185 -
 185+
186186 /**
187187 * Corrects the provided map demension value when not valid.
188 - *
 188+ *
189189 * @param string or number $value The value as it was entered by the user.
190 - * @param string $dimension Must be width or hieght.
 190+ * @param string $dimension Must be width or height.
191191 * @param number $default The default value for this dimension.
192192 */
193193 public static function setMapDimension( &$value, $dimension, $default ) {
@@ -194,41 +194,41 @@
195195 }
196196
197197 /**
198 - * Returns a boolean indicating if MapsGeocoder is available.
199 - *
 198+ * Returns a boolean indicating if MapsGeocoder is available.
 199+ *
200200 * @return Boolean
201201 */
202202 public static function geocoderIsAvailable() {
203203 global $wgAutoloadClasses;
204204 return array_key_exists( 'MapsGeocoder', $wgAutoloadClasses );
205205 }
206 -
 206+
207207 /**
208208 * Returns an array containing all the possible values for the service parameter, including aliases.
209 - *
 209+ *
210210 * @return array
211211 */
212212 public static function getAllServiceValues() {
213213 global $egMapsAvailableServices, $egMapsServices;
214 -
 214+
215215 $allServiceValues = array();
216 -
 216+
217217 foreach ( $egMapsAvailableServices as $availableService ) {
218218 $allServiceValues[] = $availableService;
219219 $allServiceValues = array_merge( $allServiceValues, $egMapsServices[$availableService]['aliases'] );
220220 }
221 -
 221+
222222 return $allServiceValues;
223223 }
224 -
 224+
225225 /**
226 - * This function returns the definitions for the parameters used by every map feature.
227 - *
 226+ * This function returns the definitions for the parameters used by every map feature.
 227+ *
228228 * @return array
229229 */
230230 public static function getCommonParameters() {
231231 global $egMapsAvailableServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService, $egMapsMapWidth, $egMapsMapHeight;
232 -
 232+
233233 return array(
234234 'service' => array(
235235 'criteria' => array(
@@ -265,5 +265,5 @@
266266 ),
267267 );
268268 }
269 -
 269+
270270 }

Status & tagging log