r63717 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63716‎ | r63717 | r63718 >
Date:00:38, 14 March 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Stylized with Stylize.php to conform with MW's specing conventions
Modified paths:
  • /trunk/extensions/UKGeocodingForMaps/GoogleMaps/UKG_GoogleMaps.php (modified) (history)
  • /trunk/extensions/UKGeocodingForMaps/GoogleMaps/UKG_GoogleMapsDispUkPoint.php (modified) (history)
  • /trunk/extensions/UKGeocodingForMaps/ParserFunctions/DisplayUkPoint/UKG_BaseUkPointMap.php (modified) (history)
  • /trunk/extensions/UKGeocodingForMaps/ParserFunctions/DisplayUkPoint/UKG_DisplayUkPoint.php (modified) (history)
  • /trunk/extensions/UKGeocodingForMaps/UKGeocodingForMaps.i18n.php (modified) (history)
  • /trunk/extensions/UKGeocodingForMaps/UKGeocodingForMaps.php (modified) (history)
  • /trunk/extensions/UKGeocodingForMaps/UKGeocodingForMaps_Settings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UKGeocodingForMaps/ParserFunctions/DisplayUkPoint/UKG_DisplayUkPoint.php
@@ -9,7 +9,7 @@
1010 * @author Jeroen De Dauw
1111 */
1212
13 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1414 die( 'Not an entry point.' );
1515 }
1616
@@ -27,14 +27,14 @@
2828 function efUKGDisplayUkPointMagic( &$magicWords, $langCode ) {
2929 $magicWords['display_uk_point'] = array( 0, 'display_uk_point', 'display_uk_points' );
3030 return true; // Unless we return true, other parser functions won't get loaded.
31 -}
 31+}
3232
3333 /**
3434 * Adds the parser function hooks
3535 */
36 -function efUKGRegisterDisplayPoint(&$wgParser) {
 36+function efUKGRegisterDisplayPoint( &$wgParser ) {
3737 // Hooks to enable the '#display_uk_point' and '#display_uk_points' parser functions.
38 - $wgParser->setFunctionHook( 'display_uk_point', array('UKGDisplayUkPoint', 'displayUkPointRender') );
 38+ $wgParser->setFunctionHook( 'display_uk_point', array( 'UKGDisplayUkPoint', 'displayUkPointRender' ) );
3939 return true;
4040 }
4141
@@ -61,58 +61,58 @@
6262 *
6363 * @return array
6464 */
65 - public static function displayUkPointRender(&$parser) {
 65+ public static function displayUkPointRender( &$parser ) {
6666 global $wgLang, $egValidatorErrorLevel;
6767
6868 $params = func_get_args();
6969
7070 array_shift( $params ); // We already know the $parser.
71 -
 71+
7272 $map = array();
7373 $coordFails = array();
7474
75 - $paramInfo = array_merge(MapsMapper::getMainParams(), self::$parameters);
 75+ $paramInfo = array_merge( MapsMapper::getMainParams(), self::$parameters );
7676
7777 // Go through all parameters, split their names and values, and put them in the $map array.
78 - foreach($params as $param) {
79 - $split = explode('=', $param);
80 - if (count($split) > 1) {
81 - $paramName = strtolower(trim($split[0]));
82 - $paramValue = trim($split[1]);
83 - if (strlen($paramName) > 0 && strlen($paramValue) > 0) {
 78+ foreach ( $params as $param ) {
 79+ $split = explode( '=', $param );
 80+ if ( count( $split ) > 1 ) {
 81+ $paramName = strtolower( trim( $split[0] ) );
 82+ $paramValue = trim( $split[1] );
 83+ if ( strlen( $paramName ) > 0 && strlen( $paramValue ) > 0 ) {
8484 $map[$paramName] = $paramValue;
85 - if (MapsParserFunctions::inParamAliases($paramName, 'coordinates', $paramInfo)) {
86 - $coordFails = MapsParserFunctions::filterInvalidCoords($map[$paramName]);
 85+ if ( MapsParserFunctions::inParamAliases( $paramName, 'coordinates', $paramInfo ) ) {
 86+ $coordFails = MapsParserFunctions::filterInvalidCoords( $map[$paramName] );
8787 }
8888 }
8989 }
90 - else if (count($split) == 1) { // Default parameter (without name)
91 - $split[0] = trim($split[0]);
92 - if (strlen($split[0]) > 0) $map['coordinates'] = $split[0];
93 - }
 90+ else if ( count( $split ) == 1 ) { // Default parameter (without name)
 91+ $split[0] = trim( $split[0] );
 92+ if ( strlen( $split[0] ) > 0 ) $map['coordinates'] = $split[0];
 93+ }
9494 }
9595
96 - if (! MapsParserFunctions::paramIsPresent('service', $map, $paramInfo)) $map['service'] = '';
 96+ if ( ! MapsParserFunctions::paramIsPresent( 'service', $map, $paramInfo ) ) $map['service'] = '';
9797
98 - $map['service'] = MapsMapper::getValidService($map['service'], 'pf', 'display_uk_point');
 98+ $map['service'] = MapsMapper::getValidService( $map['service'], 'pf', 'display_uk_point' );
9999
100 - $mapClass = MapsParserFunctions::getParserClassInstance($map['service'], 'display_uk_point');
 100+ $mapClass = MapsParserFunctions::getParserClassInstance( $map['service'], 'display_uk_point' );
101101
102102 // Call the function according to the map service to get the HTML output
103 - $output = $mapClass->displayMap($parser, $map);
 103+ $output = $mapClass->displayMap( $parser, $map );
104104
105 - if ($egValidatorErrorLevel >= Validator_ERRORS_WARN && count($coordFails) > 0) {
106 - $output .= '<i>' . wfMsgExt( 'maps_unrecognized_coords_for', array( 'parsemag' ), $wgLang->listToText( $coordFails ), count( $coordFails ) ) . '</i>';
 105+ if ( $egValidatorErrorLevel >= Validator_ERRORS_WARN && count( $coordFails ) > 0 ) {
 106+ $output .= '<i>' . wfMsgExt( 'maps_unrecognized_coords_for', array( 'parsemag' ), $wgLang->listToText( $coordFails ), count( $coordFails ) ) . '</i>';
107107 }
108108
109109 // Return the result
110 - return $parser->insertStripItem($output, $parser->mStripState);
 110+ return $parser->insertStripItem( $output, $parser->mStripState );
111111 }
112112
113113 private static function initializeParams() {
114114 global $egMapsDefaultCentre, $egMapsDefaultTitle, $egMapsDefaultLabel, $egMapsAvailableServices, $egMapsDefaultServices;
115115
116 - self::$parameters = array(
 116+ self::$parameters = array(
117117 'service' => array(
118118 'criteria' => array(
119119 'in_array' => $egMapsAvailableServices
@@ -120,7 +120,7 @@
121121 'default' => $egMapsDefaultServices['pf']
122122 ),
123123 'coordinates' => array(
124 - 'aliases' => array('coords', 'location', 'locations'),
 124+ 'aliases' => array( 'coords', 'location', 'locations' ),
125125 ),
126126 'title' => array(
127127 'default' => $egMapsDefaultTitle
@@ -128,11 +128,11 @@
129129 'label' => array(
130130 'default' => $egMapsDefaultLabel
131131 ),
132 - 'icon' => array(
 132+ 'icon' => array(
133133 'criteria' => array(
134134 'not_empty' => array()
135135 ),
136 - ),
 136+ ),
137137 );
138 - }
 138+ }
139139 }
\ No newline at end of file
Index: trunk/extensions/UKGeocodingForMaps/ParserFunctions/DisplayUkPoint/UKG_BaseUkPointMap.php
@@ -9,7 +9,7 @@
1010 * @author Jeroen De Dauw
1111 */
1212
13 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1414 die( 'Not an entry point.' );
1515 }
1616
@@ -36,24 +36,24 @@
3737 *
3838 * @return html
3939 */
40 - public final function displayMap(&$parser, array $params) {
 40+ public final function displayMap( &$parser, array $params ) {
4141 $this->setMapSettings();
4242
4343 $this->featureParameters = MapsDisplayPoint::$parameters;
4444
45 - if (parent::manageMapProperties($params, __CLASS__)) {
 45+ if ( parent::manageMapProperties( $params, __CLASS__ ) ) {
4646 $this->doMapServiceLoad();
4747
4848 $this->setMapName();
4949
50 - $this->setMarkerData($parser);
 50+ $this->setMarkerData( $parser );
5151
5252 $this->createMarkerString();
5353
5454 $this->setZoom();
5555
5656 $this->addSpecificMapHTML();
57 - }
 57+ }
5858
5959 return $this->output . $this->errorList;
6060 }
@@ -65,44 +65,44 @@
6666 *
6767 */
6868 private function setZoom() {
69 - if (strlen($this->zoom) < 1) {
70 - if (count($this->markerData) > 1) {
 69+ if ( strlen( $this->zoom ) < 1 ) {
 70+ if ( count( $this->markerData ) > 1 ) {
7171 $this->zoom = 'null';
7272 }
7373 else {
7474 $this->zoom = $this->defaultZoom;
7575 }
76 - }
77 - }
 76+ }
 77+ }
7878
7979 /**
8080 * Fills the $markerData array with the locations and their meta data.
8181 *
8282 * @param unknown_type $parser
8383 */
84 - private function setMarkerData($parser) {
85 - $this->coordinates = explode(';', $this->coordinates);
 84+ private function setMarkerData( $parser ) {
 85+ $this->coordinates = explode( ';', $this->coordinates );
8686
8787 $this->title = Xml::escapeJsString( $parser->recursiveTagParse( $this->title ) );
88 - $this->label = Xml::escapeJsString( $parser->recursiveTagParse( $this->label ) );
 88+ $this->label = Xml::escapeJsString( $parser->recursiveTagParse( $this->label ) );
8989
90 - foreach($this->coordinates as $coordinates) {
91 - $args = explode('~', $coordinates);
 90+ foreach ( $this->coordinates as $coordinates ) {
 91+ $args = explode( '~', $coordinates );
9292
93 - $args[0] = str_replace('″', '"', $args[0]);
94 - $args[0] = str_replace('′', "'", $args[0]);
 93+ $args[0] = str_replace( '″', '"', $args[0] );
 94+ $args[0] = str_replace( '′', "'", $args[0] );
9595
96 - $markerData = array('location' => $args[0]);
 96+ $markerData = array( 'location' => $args[0] );
9797
98 - if (count($args) > 1) {
 98+ if ( count( $args ) > 1 ) {
9999 // Parse and add the point specific title if it's present.
100100 $markerData['title'] = $parser->recursiveTagParse( $args[1] );
101101
102 - if (count($args) > 2) {
 102+ if ( count( $args ) > 2 ) {
103103 // Parse and add the point specific label if it's present.
104104 $markerData['label'] = $parser->recursiveTagParse( $args[2] );
105105
106 - if (count($args) > 3) {
 106+ if ( count( $args ) > 3 ) {
107107 // Add the point specific icon if it's present.
108108 $markerData['icon'] = $args[3];
109109 }
@@ -110,12 +110,12 @@
111111 }
112112
113113 // If there is no point specific icon, use the general icon parameter when available.
114 - if (! array_key_exists('icon', $markerData) && strlen($this->icon) > 0) $markerData['icon'] = $this->icon;
 114+ if ( ! array_key_exists( 'icon', $markerData ) && strlen( $this->icon ) > 0 ) $markerData['icon'] = $this->icon;
115115
116116 // Get the url for the icon when there is one, else set the icon to an empty string.
117 - if (array_key_exists('icon', $markerData)) {
 117+ if ( array_key_exists( 'icon', $markerData ) ) {
118118 $icon_image_page = new ImagePage( Title::newFromText( $markerData['icon'] ) );
119 - $markerData['icon'] = $icon_image_page->getDisplayedFile()->getURL();
 119+ $markerData['icon'] = $icon_image_page->getDisplayedFile()->getURL();
120120 }
121121 else {
122122 $markerData['icon'] = '';
@@ -131,9 +131,9 @@
132132 private function createMarkerString() {
133133 $markerItems = array();
134134
135 - foreach ($this->markerData as $markerData) {
136 - $title = array_key_exists('title', $markerData) ? Xml::escapeJsString($markerData['title']) : $this->title;
137 - $label = array_key_exists('label', $markerData) ? Xml::escapeJsString($markerData['label']) : $this->label;
 135+ foreach ( $this->markerData as $markerData ) {
 136+ $title = array_key_exists( 'title', $markerData ) ? Xml::escapeJsString( $markerData['title'] ) : $this->title;
 137+ $label = array_key_exists( 'label', $markerData ) ? Xml::escapeJsString( $markerData['label'] ) : $this->label;
138138
139139 $markerData['location'] = Xml::escapeJsString( $markerData['location'] );
140140 $icon = Xml::escapeJsString( $markerData['icon'] );
@@ -142,6 +142,6 @@
143143 $markerItems[] = "{'location': '$location', 'title': '$title', 'label': '$label', 'icon': '$icon'}";
144144 }
145145
146 - $this->markerString = implode(',', $markerItems);
 146+ $this->markerString = implode( ',', $markerItems );
147147 }
148148 }
Index: trunk/extensions/UKGeocodingForMaps/UKGeocodingForMaps.i18n.php
@@ -7,7 +7,7 @@
88 * @ingroup UKGeocodingForMaps
99 *
1010 * @author Jeroen De Dauw
11 - */
 11+ */
1212
1313 $messages = array();
1414
Index: trunk/extensions/UKGeocodingForMaps/UKGeocodingForMaps.php
@@ -17,19 +17,19 @@
1818 * @defgroup UKGeocodingForMaps UK Geocoding for Maps
1919 */
2020
21 -if( !defined( 'MEDIAWIKI' ) ) {
 21+if ( !defined( 'MEDIAWIKI' ) ) {
2222 die( 'Not an entry point.' );
2323 }
2424
25 -define('UKG_VERSION', '0.2 a1');
 25+define( 'UKG_VERSION', '0.2 a1' );
2626
27 -$ukggScriptPath = (isset($wgExtensionAssetsPath) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions') . '/UKGeocodingForMaps';
 27+$ukggScriptPath = ( isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/UKGeocodingForMaps';
2828 $ukggDir = dirname( __FILE__ ) . '/';
2929
3030 $ukggStyleVersion = $wgStyleVersion . '-' . UKG_VERSION;
3131
3232 // Include the settings file
33 -require_once($ukggDir . 'UKGeocodingForMaps_Settings.php');
 33+require_once( $ukggDir . 'UKGeocodingForMaps_Settings.php' );
3434
3535 $wgExtensionMessagesFiles['UKGeocodingForMaps'] = $ukggDir . 'UKGeocodingForMaps.i18n.php';
3636
@@ -47,7 +47,7 @@
4848
4949 wfLoadExtensionMessages( 'UKGeocodingForMaps' );
5050
51 - $wgExtensionCredits['parserhook'][]= array(
 51+ $wgExtensionCredits['parserhook'][] = array(
5252 'path' => __FILE__,
5353 'name' => wfMsg( 'ukgeocoding_name' ),
5454 'version' => UKG_VERSION,
@@ -56,5 +56,5 @@
5757 'descriptionmsg' => 'ukgeocoding_desc',
5858 );
5959
60 - return true;
 60+ return true;
6161 }
\ No newline at end of file
Index: trunk/extensions/UKGeocodingForMaps/UKGeocodingForMaps_Settings.php
@@ -13,7 +13,7 @@
1414 * @author Jeroen De Dauw
1515 */
1616
17 -if( !defined( 'MEDIAWIKI' ) ) {
 17+if ( !defined( 'MEDIAWIKI' ) ) {
1818 die( 'Not an entry point.' );
1919 }
2020
Index: trunk/extensions/UKGeocodingForMaps/GoogleMaps/UKG_GoogleMapsDispUkPoint.php
@@ -9,7 +9,7 @@
1010 * @author Jeroen De Dauw
1111 */
1212
13 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1414 die( 'Not an entry point.' );
1515 }
1616
@@ -27,7 +27,7 @@
2828 /**
2929 * @see MapsBaseMap::setMapSettings()
3030 *
31 - */
 31+ */
3232 protected function setMapSettings() {
3333 global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix, $egMapsGMapOverlays;
3434
@@ -36,19 +36,19 @@
3737
3838 $this->spesificParameters = array(
3939 'overlays' => array(
40 - 'type' => array('string', 'list'),
 40+ 'type' => array( 'string', 'list' ),
4141 'criteria' => array(
4242 'is_google_overlay' => array()
43 - ),
44 - 'default' => $egMapsGMapOverlays,
 43+ ),
 44+ 'default' => $egMapsGMapOverlays,
4545 ),
46 - );
 46+ );
4747 }
4848
4949 /**
5050 * @see MapsBaseMap::doMapServiceLoad()
5151 *
52 - */
 52+ */
5353 protected function doMapServiceLoad() {
5454 global $egGoogleMapsOnThisPage, $loadedAjaxApi, $egGoogleAjaxSearchKey;
5555
@@ -66,11 +66,11 @@
6767 /**
6868 * @see MapsBaseMap::addSpecificMapHTML()
6969 *
70 - */
 70+ */
7171 public function addSpecificMapHTML() {
7272 global $wgJsMimeType, $egValidatorErrorLevel;
7373
74 - $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
 74+ $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
7575
7676 if ( $egValidatorErrorLevel >= Validator_ERRORS_WARN ) {
7777 $couldNotGeocodeMsg = Xml::escapeJsString( wfMsg( 'ukgeocoding_couldNotGeocode' ) );
@@ -79,7 +79,7 @@
8080 $showErrorJs = '';
8181 }
8282
83 - $this->output .=<<<EOT
 83+ $this->output .= <<<EOT
8484 <div id="$this->mapName"></div>
8585 <div id="{$this->mapName}_errors"></div>
8686 <script type="$wgJsMimeType"> /*<![CDATA[*/
Index: trunk/extensions/UKGeocodingForMaps/GoogleMaps/UKG_GoogleMaps.php
@@ -6,8 +6,8 @@
77 * @ingroup UKGeocodingForMaps
88 */
99
10 -if( !defined( 'MEDIAWIKI' ) ) {
 10+if ( !defined( 'MEDIAWIKI' ) ) {
1111 die( 'Not an entry point.' );
1212 }
1313
14 -$egMapsServices['googlemaps2']['pf']['display_uk_point'] = array('class' => 'UKGGoogleMapsDispUkPoint', 'file' => 'UKGeocodingForMaps/GoogleMaps/UKG_GoogleMapsDispUkPoint.php');
\ No newline at end of file
 14+$egMapsServices['googlemaps2']['pf']['display_uk_point'] = array( 'class' => 'UKGGoogleMapsDispUkPoint', 'file' => 'UKGeocodingForMaps/GoogleMaps/UKG_GoogleMapsDispUkPoint.php' );
\ No newline at end of file

Status & tagging log