r58029 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58028‎ | r58029 | r58030 >
Date:17:34, 22 October 2009
Author:ialex
Status:deferred
Tags:
Comment:
svn:eol-style native
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/ThreadHistoryPager.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/TalkpageHistoryView.php (modified) (history)
  • /trunk/extensions/Maps/Geocoders/Maps_Geocoder.php (modified) (history)
  • /trunk/extensions/Maps/Geocoders/Maps_Geocoders.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Geocode/Maps_GeocodeFunctions.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.min.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/dragDropFile.js (modified) (history)

Diff [purge]

Property changes on: trunk/phase3/js2/mwEmbed/libAddMedia/dragDropFile.js
___________________________________________________________________
Name: svn:eol-style
11 + native
Property changes on: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.min.js
___________________________________________________________________
Name: svn:eol-style
22 + native
Property changes on: trunk/extensions/LiquidThreads/classes/ThreadHistoryPager.php
___________________________________________________________________
Name: svn:eol-style
33 + native
Property changes on: trunk/extensions/LiquidThreads/pages/TalkpageHistoryView.php
___________________________________________________________________
Name: svn:eol-style
44 + native
Index: trunk/extensions/Maps/ParserFunctions/Geocode/Maps_GeocodeFunctions.php
@@ -1,102 +1,102 @@
2 -<?php
3 -
4 -/**
5 - * This file contains registration
6 - *
7 - * {{#geocode:<Address>|<param1>=<value1>|<param2>=<value2>}}
8 - * {{#geocodelat:<Address>|<param1>=<value1>|<param2>=<value2>}}
9 - * {{#geocodelng:<Address>|<param1>=<value1>|<param2>=<value2>}}
10 - *
11 - * @file Maps_GeocodeFunctions.php
12 - * @ingroup Maps
13 - *
14 - * @author Jeroen De Dauw
15 - * @author Sergey Chernyshev
16 - */
17 -
18 -if( !defined( 'MEDIAWIKI' ) ) {
19 - die( 'Not an entry point.' );
20 -}
21 -
22 -$wgHooks['LanguageGetMagic'][] = 'efMapsGeoFunctionMagic';
23 -$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterGeoFunctions';
24 -
25 -/**
26 - * Adds the magic words for the parser functions
27 - */
28 -function efMapsGeoFunctionMagic( &$magicWords, $langCode ) {
29 - $magicWords['geocode'] = array( 0, 'geocode' );
30 - $magicWords['geocodelat'] = array ( 0, 'geocodelat' );
31 - $magicWords['geocodelng'] = array ( 0, 'geocodelng' );
32 -
33 - return true; // Unless we return true, other parser functions won't get loaded
34 -}
35 -
36 -/**
37 - * Adds the parser function hooks
38 - */
39 -function efMapsRegisterGeoFunctions(&$wgParser) {
40 - // Hooks to enable the geocoding parser functions
41 - $wgParser->setFunctionHook( 'geocode', array('MapsGeocodeFunctions', 'renderGeocoder') );
42 - $wgParser->setFunctionHook( 'geocodelat', array('MapsGeocodeFunctions', 'renderGeocoderLat') );
43 - $wgParser->setFunctionHook( 'geocodelng', array('MapsGeocodeFunctions', 'renderGeocoderLng') );
44 -
45 - return true;
46 -}
47 -
48 -final class MapsGeocodeFunctions {
49 -
50 - private static function geocoderIsAvailable() {
51 - global $wgAutoloadClasses;
52 - return array_key_exists('MapsGeocoder', $wgAutoloadClasses);
53 - }
54 -
55 - /**
56 - * Handler for the geocode parser function. Returns the latitude and longitude
57 - * for the provided address, or an empty string, when the geocoding fails.
58 - *
59 - * @param unknown_type $parser
60 - * @param string $address The address to geocode.
61 - * @param string $service Optional. The geocoding service to use.
62 - * @param string $mappingService Optional. The mapping service that will use the geocoded data.
63 - * @return string
64 - */
65 - public static function renderGeocoder($parser, $address, $service = '', $mappingService = '') {
66 - if (self::geocoderIsAvailable()) $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
67 - return $geovalues ? $geovalues['lat'].', '.$geovalues['lon'] : '';
68 - }
69 -
70 - /**
71 - * Handler for the geocode parser function. Returns the latitude
72 - * for the provided address, or an empty string, when the geocoding fails.
73 - *
74 - * @param unknown_type $parser
75 - * @param string $address The address to geocode.
76 - * @param string $service Optional. The geocoding service to use.
77 - * @param string $mappingService Optional. The mapping service that will use the geocoded data.
78 - * @return string
79 - */
80 - public static function renderGeocoderLat(&$parser, $address, $service = '', $mappingService = '') {
81 - if (self::geocoderIsAvailable()) $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
82 - return $geovalues ? $geovalues['lat'] : '';
83 - }
84 -
85 - /**
86 - * Handler for the geocode parser function. Returns the longitude
87 - * for the provided address, or an empty string, when the geocoding fails.
88 - *
89 - * @param unknown_type $parser
90 - * @param string $address The address to geocode.
91 - * @param string $service Optional. The geocoding service to use.
92 - * @param string $mappingService Optional. The mapping service that will use the geocoded data.
93 - * @return string
94 - */
95 - public static function renderGeocoderLng(&$parser, $address, $service = '', $mappingService = '') {
96 - if (self::geocoderIsAvailable()) $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
97 - return $geovalues ? $geovalues['lon'] : '';
98 - }
99 -
100 -}
101 -
102 -
103 -
 2+<?php
 3+
 4+/**
 5+ * This file contains registration
 6+ *
 7+ * {{#geocode:<Address>|<param1>=<value1>|<param2>=<value2>}}
 8+ * {{#geocodelat:<Address>|<param1>=<value1>|<param2>=<value2>}}
 9+ * {{#geocodelng:<Address>|<param1>=<value1>|<param2>=<value2>}}
 10+ *
 11+ * @file Maps_GeocodeFunctions.php
 12+ * @ingroup Maps
 13+ *
 14+ * @author Jeroen De Dauw
 15+ * @author Sergey Chernyshev
 16+ */
 17+
 18+if( !defined( 'MEDIAWIKI' ) ) {
 19+ die( 'Not an entry point.' );
 20+}
 21+
 22+$wgHooks['LanguageGetMagic'][] = 'efMapsGeoFunctionMagic';
 23+$wgHooks['ParserFirstCallInit'][] = 'efMapsRegisterGeoFunctions';
 24+
 25+/**
 26+ * Adds the magic words for the parser functions
 27+ */
 28+function efMapsGeoFunctionMagic( &$magicWords, $langCode ) {
 29+ $magicWords['geocode'] = array( 0, 'geocode' );
 30+ $magicWords['geocodelat'] = array ( 0, 'geocodelat' );
 31+ $magicWords['geocodelng'] = array ( 0, 'geocodelng' );
 32+
 33+ return true; // Unless we return true, other parser functions won't get loaded
 34+}
 35+
 36+/**
 37+ * Adds the parser function hooks
 38+ */
 39+function efMapsRegisterGeoFunctions(&$wgParser) {
 40+ // Hooks to enable the geocoding parser functions
 41+ $wgParser->setFunctionHook( 'geocode', array('MapsGeocodeFunctions', 'renderGeocoder') );
 42+ $wgParser->setFunctionHook( 'geocodelat', array('MapsGeocodeFunctions', 'renderGeocoderLat') );
 43+ $wgParser->setFunctionHook( 'geocodelng', array('MapsGeocodeFunctions', 'renderGeocoderLng') );
 44+
 45+ return true;
 46+}
 47+
 48+final class MapsGeocodeFunctions {
 49+
 50+ private static function geocoderIsAvailable() {
 51+ global $wgAutoloadClasses;
 52+ return array_key_exists('MapsGeocoder', $wgAutoloadClasses);
 53+ }
 54+
 55+ /**
 56+ * Handler for the geocode parser function. Returns the latitude and longitude
 57+ * for the provided address, or an empty string, when the geocoding fails.
 58+ *
 59+ * @param unknown_type $parser
 60+ * @param string $address The address to geocode.
 61+ * @param string $service Optional. The geocoding service to use.
 62+ * @param string $mappingService Optional. The mapping service that will use the geocoded data.
 63+ * @return string
 64+ */
 65+ public static function renderGeocoder($parser, $address, $service = '', $mappingService = '') {
 66+ if (self::geocoderIsAvailable()) $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 67+ return $geovalues ? $geovalues['lat'].', '.$geovalues['lon'] : '';
 68+ }
 69+
 70+ /**
 71+ * Handler for the geocode parser function. Returns the latitude
 72+ * for the provided address, or an empty string, when the geocoding fails.
 73+ *
 74+ * @param unknown_type $parser
 75+ * @param string $address The address to geocode.
 76+ * @param string $service Optional. The geocoding service to use.
 77+ * @param string $mappingService Optional. The mapping service that will use the geocoded data.
 78+ * @return string
 79+ */
 80+ public static function renderGeocoderLat(&$parser, $address, $service = '', $mappingService = '') {
 81+ if (self::geocoderIsAvailable()) $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 82+ return $geovalues ? $geovalues['lat'] : '';
 83+ }
 84+
 85+ /**
 86+ * Handler for the geocode parser function. Returns the longitude
 87+ * for the provided address, or an empty string, when the geocoding fails.
 88+ *
 89+ * @param unknown_type $parser
 90+ * @param string $address The address to geocode.
 91+ * @param string $service Optional. The geocoding service to use.
 92+ * @param string $mappingService Optional. The mapping service that will use the geocoded data.
 93+ * @return string
 94+ */
 95+ public static function renderGeocoderLng(&$parser, $address, $service = '', $mappingService = '') {
 96+ if (self::geocoderIsAvailable()) $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 97+ return $geovalues ? $geovalues['lon'] : '';
 98+ }
 99+
 100+}
 101+
 102+
 103+
Property changes on: trunk/extensions/Maps/ParserFunctions/Geocode/Maps_GeocodeFunctions.php
___________________________________________________________________
Name: svn:eol-style
104104 + native
Index: trunk/extensions/Maps/Geocoders/Maps_Geocoders.php
@@ -1,36 +1,36 @@
2 -<?php
3 -
4 -/**
5 - * Initialization file for geocoder functionality in the Maps extension
6 - *
7 - * @file Maps_Geocoders.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -/**
18 - * Initialization class for geocoder functionality in the Maps extension.
19 - *
20 - * @author Jeroen De Dauw
21 - *
22 - */
23 -final class Geocoders {
24 -
25 - /**
26 - * Initialization function for Maps geocoder functionality.
27 - */
28 - public static function initialize() {
29 - global $wgAutoloadClasses, $egMapsIP, $egMapsGeoServices;
30 -
31 - $egMapsGeoServices = array();
32 -
33 - $wgAutoloadClasses['MapsBaseGeocoder'] = $egMapsIP . '/Geocoders/Maps_BaseGeocoder.php';
34 - $wgAutoloadClasses['MapsGeocoder'] = $egMapsIP . '/Geocoders/Maps_Geocoder.php';
35 - }
36 -
 2+<?php
 3+
 4+/**
 5+ * Initialization file for geocoder functionality in the Maps extension
 6+ *
 7+ * @file Maps_Geocoders.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+/**
 18+ * Initialization class for geocoder functionality in the Maps extension.
 19+ *
 20+ * @author Jeroen De Dauw
 21+ *
 22+ */
 23+final class Geocoders {
 24+
 25+ /**
 26+ * Initialization function for Maps geocoder functionality.
 27+ */
 28+ public static function initialize() {
 29+ global $wgAutoloadClasses, $egMapsIP, $egMapsGeoServices;
 30+
 31+ $egMapsGeoServices = array();
 32+
 33+ $wgAutoloadClasses['MapsBaseGeocoder'] = $egMapsIP . '/Geocoders/Maps_BaseGeocoder.php';
 34+ $wgAutoloadClasses['MapsGeocoder'] = $egMapsIP . '/Geocoders/Maps_Geocoder.php';
 35+ }
 36+
3737 }
\ No newline at end of file
Property changes on: trunk/extensions/Maps/Geocoders/Maps_Geocoders.php
___________________________________________________________________
Name: svn:eol-style
3838 + native
Index: trunk/extensions/Maps/Geocoders/Maps_Geocoder.php
@@ -1,119 +1,119 @@
2 -<?php
3 -
4 -/**
5 - * Geocoding class. Provides methods to geocode a string to a pair of coordinates
6 - * using one of the available geocoding services.
7 - *
8 - * @file Maps_Geocoder.php
9 - * @ingroup Maps
10 - *
11 - * @author Jeroen De Dauw
12 - * @author Sergey Chernyshev
13 - */
14 -
15 -if( !defined( 'MEDIAWIKI' ) ) {
16 - die( 'Not an entry point.' );
17 -}
18 -
19 -final class MapsGeocoder {
20 -
21 - /**
22 - * Holds if geocoded data should be cached or not.
23 - *
24 - * @var boolean
25 - */
26 - private static $mEnableCache = true;
27 -
28 - /**
29 - * The geocoder cache, holding geocoded data when enabled.
30 - *
31 - * @var array
32 - */
33 - private static $mGeocoderCache = array();
34 -
35 - /**
36 - * Geocodes an address with the provided geocoding service and returns the result
37 - * as a string with the optionally provided format, or false when the geocoding failed.
38 - *
39 - * @param string $address
40 - * @param string $service
41 - * @param string $mappingService
42 - * @param string $format
43 - * @return formatted coordinate string or false
44 - */
45 - public static function geocodeToString($address, $service = '', $mappingService = '', $format = '%1$s, %2$s') {
46 - $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
47 - return $geovalues ? sprintf($format, $geovalues['lat'], $geovalues['lon']) : false;
48 - }
49 -
50 - /**
51 - * Geocodes an address with the provided geocoding service and returns the result
52 - * as an array, or false when the geocoding failed.
53 - *
54 - * @param string $address
55 - * @param string $service
56 - * @param string $mappingService
57 - * @return array with coordinates or false
58 - */
59 - public static function geocode($address, $service, $mappingService) {
60 - global $egMapsAvailableGeoServices, $wgAutoloadClasses, $egMapsIP, $IP;
61 -
62 - // If the adress is already in the cache and the cache is enabled, return the coordinates.
63 - if (self::$mEnableCache && array_key_exists($address, MapsGeocoder::$mGeocoderCache)) {
64 - return self::$mGeocoderCache[$address];
65 - }
66 -
67 - $coordinates = false;
68 -
69 - $service = self::getValidGeoService($service, $mappingService);
70 -
71 - // Make sure the needed class is loaded.
72 - $file = $egMapsAvailableGeoServices[$service]['local'] ? $egMapsIP . '/' . $egMapsAvailableGeoServices[$service]['file'] : $IP . '/extensions/' . $egMapsAvailableGeoServices[$service]['file'];
73 - $wgAutoloadClasses[$egMapsAvailableGeoServices[$service]['class']] = $file;
74 -
75 - // Call the geocode function in the spesific geocoder class.
76 - $phpAtLeast523 = MapsUtils::phpVersionIsEqualOrBigger('5.2.3');
77 - $coordinates = call_user_func(array($egMapsAvailableGeoServices[$service]['class'], 'geocode'), $phpAtLeast523 ? $address : array($address));
78 -
79 - // Add the obtained coordinates to the cache when there is a result and the cache is enabled.
80 - if (self::$mEnableCache && $coordinates) {
81 - MapsGeocoder::$mGeocoderCache[$address] = $coordinates;
82 - }
83 -
84 - return $coordinates;
85 - }
86 -
87 - /**
88 - * Makes sure that the geo service is one of the available ones.
89 - * Also enforces licencing restrictions when no geocoding service is explicitly provided.
90 - *
91 - * @param string $service
92 - * @param string $mappingService
93 - * @return string
94 - */
95 - private static function getValidGeoService($service, $mappingService) {
96 - global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
97 -
98 - if (strlen($service) < 1) {
99 - // If no service has been provided, check if there are overrides for the default.
100 - foreach ($egMapsAvailableGeoServices as $geoService => $serviceData) {
101 - if (in_array($mappingService, $serviceData)) {
102 - $service = $geoService; // Use the override
103 - continue;
104 - }
105 - }
106 -
107 - // If no overrides where applied, use the default mapping service.
108 - if (strlen($service) < 1) $service = $egMapsDefaultGeoService;
109 - }
110 - else {
111 - // If a service is provided, but is not supported, use the default.
112 - if(!array_key_exists($service, $egMapsAvailableGeoServices)) $service = $egMapsDefaultGeoService;
113 - }
114 -
115 - return $service;
116 - }
117 -}
118 -
119 -
120 -
 2+<?php
 3+
 4+/**
 5+ * Geocoding class. Provides methods to geocode a string to a pair of coordinates
 6+ * using one of the available geocoding services.
 7+ *
 8+ * @file Maps_Geocoder.php
 9+ * @ingroup Maps
 10+ *
 11+ * @author Jeroen De Dauw
 12+ * @author Sergey Chernyshev
 13+ */
 14+
 15+if( !defined( 'MEDIAWIKI' ) ) {
 16+ die( 'Not an entry point.' );
 17+}
 18+
 19+final class MapsGeocoder {
 20+
 21+ /**
 22+ * Holds if geocoded data should be cached or not.
 23+ *
 24+ * @var boolean
 25+ */
 26+ private static $mEnableCache = true;
 27+
 28+ /**
 29+ * The geocoder cache, holding geocoded data when enabled.
 30+ *
 31+ * @var array
 32+ */
 33+ private static $mGeocoderCache = array();
 34+
 35+ /**
 36+ * Geocodes an address with the provided geocoding service and returns the result
 37+ * as a string with the optionally provided format, or false when the geocoding failed.
 38+ *
 39+ * @param string $address
 40+ * @param string $service
 41+ * @param string $mappingService
 42+ * @param string $format
 43+ * @return formatted coordinate string or false
 44+ */
 45+ public static function geocodeToString($address, $service = '', $mappingService = '', $format = '%1$s, %2$s') {
 46+ $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 47+ return $geovalues ? sprintf($format, $geovalues['lat'], $geovalues['lon']) : false;
 48+ }
 49+
 50+ /**
 51+ * Geocodes an address with the provided geocoding service and returns the result
 52+ * as an array, or false when the geocoding failed.
 53+ *
 54+ * @param string $address
 55+ * @param string $service
 56+ * @param string $mappingService
 57+ * @return array with coordinates or false
 58+ */
 59+ public static function geocode($address, $service, $mappingService) {
 60+ global $egMapsAvailableGeoServices, $wgAutoloadClasses, $egMapsIP, $IP;
 61+
 62+ // If the adress is already in the cache and the cache is enabled, return the coordinates.
 63+ if (self::$mEnableCache && array_key_exists($address, MapsGeocoder::$mGeocoderCache)) {
 64+ return self::$mGeocoderCache[$address];
 65+ }
 66+
 67+ $coordinates = false;
 68+
 69+ $service = self::getValidGeoService($service, $mappingService);
 70+
 71+ // Make sure the needed class is loaded.
 72+ $file = $egMapsAvailableGeoServices[$service]['local'] ? $egMapsIP . '/' . $egMapsAvailableGeoServices[$service]['file'] : $IP . '/extensions/' . $egMapsAvailableGeoServices[$service]['file'];
 73+ $wgAutoloadClasses[$egMapsAvailableGeoServices[$service]['class']] = $file;
 74+
 75+ // Call the geocode function in the spesific geocoder class.
 76+ $phpAtLeast523 = MapsUtils::phpVersionIsEqualOrBigger('5.2.3');
 77+ $coordinates = call_user_func(array($egMapsAvailableGeoServices[$service]['class'], 'geocode'), $phpAtLeast523 ? $address : array($address));
 78+
 79+ // Add the obtained coordinates to the cache when there is a result and the cache is enabled.
 80+ if (self::$mEnableCache && $coordinates) {
 81+ MapsGeocoder::$mGeocoderCache[$address] = $coordinates;
 82+ }
 83+
 84+ return $coordinates;
 85+ }
 86+
 87+ /**
 88+ * Makes sure that the geo service is one of the available ones.
 89+ * Also enforces licencing restrictions when no geocoding service is explicitly provided.
 90+ *
 91+ * @param string $service
 92+ * @param string $mappingService
 93+ * @return string
 94+ */
 95+ private static function getValidGeoService($service, $mappingService) {
 96+ global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
 97+
 98+ if (strlen($service) < 1) {
 99+ // If no service has been provided, check if there are overrides for the default.
 100+ foreach ($egMapsAvailableGeoServices as $geoService => $serviceData) {
 101+ if (in_array($mappingService, $serviceData)) {
 102+ $service = $geoService; // Use the override
 103+ continue;
 104+ }
 105+ }
 106+
 107+ // If no overrides where applied, use the default mapping service.
 108+ if (strlen($service) < 1) $service = $egMapsDefaultGeoService;
 109+ }
 110+ else {
 111+ // If a service is provided, but is not supported, use the default.
 112+ if(!array_key_exists($service, $egMapsAvailableGeoServices)) $service = $egMapsDefaultGeoService;
 113+ }
 114+
 115+ return $service;
 116+ }
 117+}
 118+
 119+
 120+
Property changes on: trunk/extensions/Maps/Geocoders/Maps_Geocoder.php
___________________________________________________________________
Name: svn:eol-style
121121 + native

Status & tagging log