r59685 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59684‎ | r59685 | r59686 >
Date:22:39, 2 December 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.5. Moved GeoCoords type from SMW.
Modified paths:
  • /trunk/extensions/SemanticMaps/SM_GeoCoordsValue.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.i18n.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/SM_GeoCoordsValue.php
@@ -37,7 +37,6 @@
3838 // Note: signs are used as e.g. on Google maps, i.e. S and W are negative numbers.
3939
4040 protected function parseUserValue($value) {
41 - wfLoadExtensionMessages('SemanticMediaWiki');
4241 $this->m_lat = false;
4342 $this->m_long = false;
4443 $this->m_latparts = false;
@@ -66,7 +65,7 @@
6766 $angles[0] = $curnum;
6867 $curnum = false;
6968 } else {
70 - $this->addError(wfMsgForContent('smw_lonely_unit', $part));
 69+ $this->addError(wfMsgForContent('semanticmaps_lonely_unit', $part));
7170 }
7271 break;
7372 case SM_GEO_MIN:
@@ -75,7 +74,7 @@
7675 if ($angles[0] === false) $angles[0] = 0;
7776 $curnum = false;
7877 } else {
79 - $this->addError(wfMsgForContent('smw_lonely_unit', $part));
 78+ $this->addError(wfMsgForContent('semanticmaps_lonely_unit', $part));
8079 }
8180 break;
8281 case SM_GEO_SEC:
@@ -85,13 +84,13 @@
8685 if ($angles[1] === false) $angles[1] = 0;
8786 $curnum = false;
8887 } else {
89 - $this->addError(wfMsgForContent('smw_lonely_unit', $part));
 88+ $this->addError(wfMsgForContent('semanticmaps_lonely_unit', $part));
9089 }
9190 break;
9291 case 'N': case 'S': // interpret findings as latitude
9392 if ( $curnum !== false ) { // work off number without °
9493 if ($angles[0] !== false) { // "12° 34" as coordinate, complain
95 - $this->addError(wfMsgForContent('smw_bad_latlong'));
 94+ $this->addError(wfMsgForContent('semanticmaps_bad_latlong'));
9695 break;
9796 } else {
9897 $angles[0] = $curnum;
@@ -101,13 +100,13 @@
102101 if (($this->m_lat === false) && ($angles[0] !== false)) {
103102 $this->setAngleValues($part,$angles);
104103 } else {
105 - $this->addError(wfMsgForContent('smw_bad_latlong'));
 104+ $this->addError(wfMsgForContent('semanticmaps_bad_latlong'));
106105 }
107106 break;
108107 case 'E': case 'W': // interpret findings as longitude
109108 if ( $curnum !== false ) { // work off number without °
110109 if ($angles[0] !== false) { // "12° 34" as coordinate, complain
111 - $this->addError(wfMsgForContent('smw_bad_latlong'));
 110+ $this->addError(wfMsgForContent('semanticmaps_bad_latlong'));
112111 break;
113112 } else {
114113 $angles[0] = $curnum;
@@ -117,13 +116,13 @@
118117 if (($this->m_long === false) && ($angles[0] !== false)) {
119118 $this->setAngleValues($part,$angles);
120119 } else {
121 - $this->addError(wfMsgForContent('smw_bad_latlong'));
 120+ $this->addError(wfMsgForContent('semanticmaps_bad_latlong'));
122121 }
123122 break;
124123 case ';': // interpret findings as latitude
125124 if ( $curnum !== false ) { // work off number without °
126125 if ($angles[0] !== false) { // "12° 34" as coordinate, complain
127 - $this->addError(wfMsgForContent('smw_bad_latlong'));
 126+ $this->addError(wfMsgForContent('semanticmaps_bad_latlong'));
128127 break;
129128 } else {
130129 $angles[0] = $curnum;
@@ -137,7 +136,7 @@
138137 case '': break; // ignore
139138 default: // should be a number (if not, errors appear elsewhere)
140139 // no kiloseps in coordinates, use as decsep as a convenience to some users (Bug 11808):
141 - $curnum = str_replace(wfMsgForContent('smw_kiloseparator'), wfMsgForContent('smw_decseparator'), $part);
 140+ $curnum = str_replace(wfMsgForContent('semanticmaps_kiloseparator'), wfMsgForContent('semanticmaps_decseparator'), $part);
142141 break;
143142 }
144143 }
@@ -168,11 +167,10 @@
169168
170169 public function getShortWikiText($linked = NULL) {
171170 if ($this->isValid() && ($linked !== NULL) && ($linked !== false)) {
172 - wfLoadExtensionMessages('SemanticMediaWiki');
173171 SMWOutputs::requireHeadItem(SMW_HEADER_TOOLTIP);
174172 return '<span class="smwttinline">' . $this->m_caption . '<span class="smwttcontent">' .
175 - wfMsgForContent('smw_label_latitude') . ' ' . $this->formatAngleValues(true) . '<br />' .
176 - wfMsgForContent('smw_label_longitude') . ' ' . $this->formatAngleValues(false) .
 173+ wfMsgForContent('semanticmaps_label_latitude') . ' ' . $this->formatAngleValues(true) . '<br />' .
 174+ wfMsgForContent('semanticmaps_label_longitude') . ' ' . $this->formatAngleValues(false) .
177175 '</span></span>';
178176 } else {
179177 return $this->m_caption;
@@ -218,11 +216,10 @@
219217 * Get and cache localised direction labels. Just for convenience.
220218 */
221219 protected function initDirectionLabels() {
222 - wfLoadExtensionMessages('SemanticMediaWiki');
223 - $this->m_N = wfMsgForContent('smw_abb_north');
224 - $this->m_E = wfMsgForContent('smw_abb_east');
225 - $this->m_W = wfMsgForContent('smw_abb_west');
226 - $this->m_S = wfMsgForContent('smw_abb_south');
 220+ $this->m_N = wfMsgForContent('semanticmaps_abb_north');
 221+ $this->m_E = wfMsgForContent('semanticmaps_abb_east');
 222+ $this->m_W = wfMsgForContent('semanticmaps_abb_west');
 223+ $this->m_S = wfMsgForContent('semanticmaps_abb_south');
227224 }
228225
229226 /**
@@ -231,7 +228,6 @@
232229 * each possibly false if unset.
233230 */
234231 protected function setAngleValues($direction, &$angles) {
235 - wfLoadExtensionMessages('SemanticMediaWiki');
236232 $numvalue = SMWDataValueFactory::newTypeIDValue('_num');
237233 $res = 0;
238234 $factor = 1;
@@ -241,7 +237,7 @@
242238 if ($numvalue->isValid() && ($numvalue->getUnit() == '')) {
243239 $res += $numvalue->getNumericValue() / $factor;
244240 } else {
245 - $this->addError(wfMsgForContent('smw_nofloat', $angles[$i]));
 241+ $this->addError(wfMsgForContent('semanticmaps_nofloat', $angles[$i]));
246242 }
247243 }
248244 $factor = $factor * 60;
Index: trunk/extensions/SemanticMaps/SemanticMaps.i18n.php
@@ -16,24 +16,39 @@
1717 */
1818
1919 $messages['en'] = array(
 20+ // General
2021 'semanticmaps_name' => 'Semantic Maps',
2122 'semanticmaps_desc' => "Provides the ability to view and edit coordinate data stored through the Semantic MediaWiki extension ([http://wiki.bn2vs.com/wiki/Semantic_Maps demo]).
2223 Available map services: $1",
23 - 'semanticmaps_lookupcoordinates' => 'Look up coordinates',
24 - 'semanticmaps_enteraddresshere' => 'Enter address here',
25 - 'semanticmaps_notfound' => 'not found',
26 - 'semanticmaps_paramdesc_format' => 'The mapping service used to generate the map',
 24+
 25+ // Geo coord data type
 26+ 'semanticmaps_lonely_unit' => 'No number found before the symbol "$1".', // $1 is something like °
 27+ 'semanticmaps_bad_latlong' => 'Latitude and longitude must be given only once, and with valid coordinates.',
 28+ 'semanticmaps_abb_north' => 'N',
 29+ 'semanticmaps_abb_east' => 'E',
 30+ 'semanticmaps_abb_south' => 'S',
 31+ 'semanticmaps_abb_west' => 'W',
 32+ 'semanticmaps_label_latitude' => 'Latitude:',
 33+ 'semanticmaps_label_longitude' => 'Longitude:',
 34+
 35+ // Forms
 36+ 'semanticmaps_lookupcoordinates' => 'Look up coordinates',
 37+ 'semanticmaps_enteraddresshere' => 'Enter address here',
 38+ 'semanticmaps_notfound' => 'not found',
 39+
 40+ // Parameter descriptions
 41+ 'semanticmaps_paramdesc_format' => 'The mapping service used to generate the map',
2742 'semanticmaps_paramdesc_geoservice' => 'The geocoding service used to turn addresses into coordinates',
28 - 'semanticmaps_paramdesc_height' => 'The height of the map, in pixels (default is $1)',
29 - 'semanticmaps_paramdesc_width' => 'The width of the map, in pixels (default is $1)',
30 - 'semanticmaps_paramdesc_zoom' => 'The zoom level of the map',
31 - 'semanticmaps_paramdesc_centre' => 'The coordinates of the maps\' centre',
32 - 'semanticmaps_paramdesc_controls' => 'The user controls placed on the map',
33 - 'semanticmaps_paramdesc_types' => 'The map types available on the map',
34 - 'semanticmaps_paramdesc_type' => 'The default map type for the map',
35 - 'semanticmaps_paramdesc_overlays' => 'The overlays available on the map',
36 - 'semanticmaps_paramdesc_autozoom' => 'Whether or not one can zoom in and out by using the mouse scroll wheel',
37 - 'semanticmaps_paramdesc_layers' => 'The layers available on the map',
 43+ 'semanticmaps_paramdesc_height' => 'The height of the map, in pixels (default is $1)',
 44+ 'semanticmaps_paramdesc_width' => 'The width of the map, in pixels (default is $1)',
 45+ 'semanticmaps_paramdesc_zoom' => 'The zoom level of the map',
 46+ 'semanticmaps_paramdesc_centre' => 'The coordinates of the maps\' centre',
 47+ 'semanticmaps_paramdesc_controls' => 'The user controls placed on the map',
 48+ 'semanticmaps_paramdesc_types' => 'The map types available on the map',
 49+ 'semanticmaps_paramdesc_type' => 'The default map type for the map',
 50+ 'semanticmaps_paramdesc_overlays' => 'The overlays available on the map',
 51+ 'semanticmaps_paramdesc_autozoom' => 'Whether or not one can zoom in and out by using the mouse scroll wheel',
 52+ 'semanticmaps_paramdesc_layers' => 'The layers available on the map',
3853 );
3954
4055 /** Message documentation (Message documentation)
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -23,7 +23,7 @@
2424 die( 'Not an entry point.' );
2525 }
2626
27 -define('SM_VERSION', '0.5 a13');
 27+define('SM_VERSION', '0.5 a14');
2828
2929 $smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps';
3030 $smgIP = $IP . '/extensions/SemanticMaps';
@@ -37,11 +37,12 @@
3838
3939 $wgHooks['AdminLinks'][] = 'smfAddToAdminLinks';
4040
41 -//$wgAutoloadClasses['SMGeoCoordsValue'] = $smgIP . '/SM_GeoCoordsValue.php';
42 -//$wgHooks['smwInitDatatypes'][] = 'smfInitGeoCoordsType';
43 -
4441 $wgExtensionMessagesFiles['SemanticMaps'] = $smgIP . '/SemanticMaps.i18n.php';
4542
 43+// Registration of the Geographical Coordinate type.
 44+$wgAutoloadClasses['SMGeoCoordsValue'] = $smgIP . '/SM_GeoCoordsValue.php';
 45+$wgHooks['smwInitDatatypes'][] = 'smfInitGeoCoordsType';
 46+
4647 /**
4748 * 'Initialization' function for the Semantic Maps extension.
4849 * The only work done here is creating the extension credits for

Status & tagging log