r39422 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39421‎ | r39422 | r39423 >
Date:18:37, 15 August 2008
Author:siebrand
Status:old
Tags:
Comment:
* remove dependency on ExtensionFunctions.php
* add $wgExtensionAliasesFiles
* use author array in extension credits
* method special page renamed for consistency with other extensions
* delayed message loading
* remove some obsolete, commented out code
* EOL whitespace fixes
Modified paths:
  • /trunk/extensions/gis/Geo.alias.php (added) (history)
  • /trunk/extensions/gis/GeoParam.php (modified) (history)
  • /trunk/extensions/gis/GisDatabase.php (modified) (history)
  • /trunk/extensions/gis/README (modified) (history)
  • /trunk/extensions/gis/Specialgeo_body.php (modified) (history)
  • /trunk/extensions/gis/geo.php (modified) (history)
  • /trunk/extensions/gis/gissettings.php (modified) (history)
  • /trunk/extensions/gis/gisversion.php (modified) (history)
  • /trunk/extensions/gis/greatcircle.php (modified) (history)
  • /trunk/extensions/gis/kml.php (modified) (history)
  • /trunk/extensions/gis/maparea.php (modified) (history)
  • /trunk/extensions/gis/mapsources.php (modified) (history)
  • /trunk/extensions/gis/neighbors.php (modified) (history)
  • /trunk/extensions/gis/transversemercator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/gis/transversemercator.php
@@ -252,16 +252,16 @@
253253 }
254254
255255 $northing = $this->Northing_Offset + $this->Scale *
256 - ( ($M - $M0) + $v*tan($lat_rad) *
257 - ( $A*$A/2
 256+ ( ($M - $M0) + $v*tan($lat_rad) *
 257+ ( $A*$A/2
258258 + (5 - $T + 9*$C + 4*$C*$C) * pow($A,4)/24
259 - + (61 - 58*$T + $T*$T
 259+ + (61 - 58*$T + $T*$T
260260 + 600*$C - 330*$e_prime_sq) * pow($A,6)/720 ));
261261
262262 $easting = $this->Easting_Offset + $this->Scale * $v *
263 - ( $A
 263+ ( $A
264264 + (1-$T+$C)*pow($A,3)/6
265 - + (5 - 18*$T + pow($T,2) + 72*$C
 265+ + (5 - 18*$T + pow($T,2) + 72*$C
266266 - 58 * $e_prime_sq)*pow($A,5)/120 );
267267
268268 # FIXME: Use zone_letter
Index: trunk/extensions/gis/GeoParam.php
@@ -8,7 +8,7 @@
99 *
1010 * include( "extensions/gis/geo.php" );
1111 *
12 - * If $wgMapsourcesURL is not defined, there will not be links to the
 12+ * If $wgMapsourcesURL is not defined, there will not be links to the
1313 * "Map sources" page, but the geo tag will still be rendered.
1414 *
1515 * To add the points to a database, see the gis/geodb extension
@@ -123,7 +123,7 @@
124124 $this->londeg_min = $this->londeg_max = $this->londeg;
125125 $this->updateInternal();
126126
127 -
 127+
128128 }
129129
130130 /**
@@ -201,7 +201,7 @@
202202 }
203203
204204 /**
205 - * Given decimal degrees, convert to
 205+ * Given decimal degrees, convert to
206206 * minutes, seconds and direction
207207 */
208208 function make_minsec( $deg ) {
@@ -215,7 +215,7 @@
216216 # Round to a suitable number of digits
217217 # FIXME: should reflect precision
218218 $deg = round($deg, 6);
219 - $min = 60.0 * (abs($deg) - intval(abs($deg)));
 219+ $min = 60.0 * (abs($deg) - intval(abs($deg)));
220220 $min = round($min, 4);
221221 $sec = 60.0 * ($min - intval($min));
222222 $sec = round($sec, 2);
@@ -317,13 +317,13 @@
318318 * Produce markup suitable for use in page
319319 * Use original content as much as possible
320320 */
321 - function get_markup()
 321+ function get_markup()
322322 {
323323 $n = count($this->coor);
324324
325325 if ($n == 0) {
326326 # Range is special case
327 - return $this->make_position( $this->latdeg_min,
 327+ return $this->make_position( $this->latdeg_min,
328328 $this->londeg_min )
329329 . " to "
330330 . $this->make_position( $this->latdeg_max,
@@ -335,7 +335,7 @@
336336 $this->coor['latdeg'].'° '. $this->coor['latns'],
337337 $this->coor['londeg'].'° '. $this->coor['lonew'] );
338338 } elseif ($n == 6) {
339 - return $this->getMicroformat(
 339+ return $this->getMicroformat(
340340 $this->coor['latdeg'].'°'. $this->coor['latmin'].'′ '.
341341 $this->coor['latns'],
342342 $this->coor['londeg'].'°'. $this->coor['lonmin'].'′ '.
@@ -358,5 +358,3 @@
359359 '">' . $lon . '</abbr></span>';
360360 }
361361 }
362 -
363 -
Index: trunk/extensions/gis/Geo.alias.php
@@ -0,0 +1,11 @@
 2+<?php
 3+/**
 4+ * Aliases for special pages
 5+ *
 6+ */
 7+
 8+$aliases = array();
 9+
 10+$aliases['en'] = array(
 11+ 'Geo' => array( 'Geo' ),
 12+);
Property changes on: trunk/extensions/gis/Geo.alias.php
___________________________________________________________________
Added: svn:eol-style
113 + native
Added: svn:keywords
214 + Id
Index: trunk/extensions/gis/gissettings.php
@@ -4,5 +4,3 @@
55 # different!
66
77 $wikibasedir = "../..";
8 -
9 -
Index: trunk/extensions/gis/maparea.php
@@ -131,7 +131,7 @@
132132 }
133133 return $out;
134134 }
135 -
 135+
136136 function map_pos( $lat, $lon )
137137 {
138138 #
@@ -158,4 +158,3 @@
159159 return $out;
160160 }
161161 }
162 -
Index: trunk/extensions/gis/GisDatabase.php
@@ -56,7 +56,7 @@
5757 /**
5858 * Add a position to the database
5959 */
60 - function add_position( $id, $latmin, $lonmin,
 60+ function add_position( $id, $latmin, $lonmin,
6161 $latmax, $lonmax, $globe, $type, $type_arg )
6262 {
6363 $fname = 'GisDatabase::add_position';
@@ -115,9 +115,9 @@
116116 * Select entities belonging to or overlapping an area
117117 * Also select by globe and type if specified
118118 */
119 - function select_area( $latmin, $lonmin, $latmax, $lonmax,
 119+ function select_area( $latmin, $lonmin, $latmax, $lonmax,
120120 $globe, $type, $type_arg )
121 - {
 121+ {
122122 if (!$globe) $globe = "";
123123
124124 $condition = "gis_globe = '" . $globe . "'";
@@ -160,7 +160,7 @@
161161 'gis_longitude_min',
162162 'gis_longitude_max',
163163 'gis_globe',
164 - 'gis_type',
 164+ 'gis_type',
165165 'gis_type_arg',
166166 'page_title',
167167 'page_namespace' ),
@@ -176,4 +176,3 @@
177177 return $this->db->fetchObject ( $this->result );
178178 }
179179 }
180 -
Index: trunk/extensions/gis/README
@@ -1,12 +1,12 @@
2 -The GIS extension is based on the experience learned from WikiProject
 2+The GIS extension is based on the experience learned from WikiProject
33 Geographical coordinates. The extensions can be enabled individually, but
4 -the concept is certainly more powerful when they are all enabled.
 4+the concept is certainly more powerful when they are all enabled.
55
66 For more information, please see:
77 http://meta.wikimedia.org/wiki/Gis
88 http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Geographical_coordinates
99
10 -Magnus Manske has been extremely helpful in the work on integration with
 10+Magnus Manske has been extremely helpful in the work on integration with
1111 Wikimaps, and that work will continue. I would also like to give a big thank
1212 you to all participants in WikiProject Geographical coordinates who have
1313 helped immensely with suggestions practical work.
Index: trunk/extensions/gis/geo.php
@@ -8,7 +8,7 @@
99 *
1010 * include( "extensions/gis/geo.php" );
1111 *
12 - * If $wgMapsourcesURL is not defined, there will not be links to the
 12+ * If $wgMapsourcesURL is not defined, there will not be links to the
1313 * "Map sources" page, but the geo tag will still be rendered.
1414 *
1515 * To add the points to a database, see the gis/geodb extension
@@ -37,11 +37,10 @@
3838 */
3939
4040 if ( !defined( 'MEDIAWIKI' ) ) {
41 - echo "Geo extension\n";
42 - exit( 1 ) ;
 41+ echo "Geo extension\n";
 42+ exit( 1 ) ;
4343 }
4444
45 -
4645 $wgExtensionFunctions[] = "wfGeoExtension";
4746
4847 /**
@@ -54,28 +53,27 @@
5554 $wgHooks['ArticleDelete'][] = 'articleDeleteGeo';
5655 }
5756
58 -if ( !function_exists( 'extAddSpecialPage' ) ) {
59 - require( dirname(__FILE__) . '/../ExtensionFunctions.php' );
60 -}
61 -extAddSpecialPage( dirname(__FILE__) . '/Specialgeo_body.php', 'Geo', 'GeoPage' );
62 -
6357 $wgExtensionCredits['specialpage'][] = array(
6458 'name' => 'Geo',
6559 'description' => 'Enables rich geotagging functionality',
66 - 'author' => 'Egil Kvaleberg, Jens Frank'
 60+ 'author' => array( 'Egil Kvaleberg', 'Jens Frank' ),
6761 );
6862
69 -global $wgAutoloadClasses;
70 -$wgAutoloadClasses['GeoParam'] = dirname(__FILE__) . '/GeoParam.php';
71 -$wgAutoloadClasses['GisDatabase'] = dirname(__FILE__) . '/GisDatabase.php';
 63+$dir = dirname(__FILE__) . '/';
 64+$wgExtensionAliasesFiles['Geo'] = $dir . 'Geo.alias.php';
 65+$wgAutoloadClasses['SpecialGeo'] = $dir . 'Specialgeo_body.php';
 66+$wgSpecialPages['Geo'] = 'SpecialGeo';
7267
 68+$wgAutoloadClasses['GeoParam'] = $dir . 'GeoParam.php';
 69+$wgAutoloadClasses['GisDatabase'] = $dir . 'GisDatabase.php';
7370
 71+
7472 /**
7573 * Hook function called every time a page is saved
7674 * Use the ArticleSaveComplete instead of ArticleSave since the ID is
7775 * not available upon ArticleSave for new articles
7876 */
79 -function articleSaveGeo ( $article, $user, $text )
 77+function articleSaveGeo ( $article, $user, $text )
8078 {
8179 $id = $article->getID();
8280
@@ -92,7 +90,7 @@
9391 $content = $tagresult[1];
9492 $params = $tagresult[2];
9593 $full = $tagresult[3];
96 -
 94+
9795 if ( $tagname != 'geo' ) {
9896 continue;
9997 }
@@ -112,7 +110,7 @@
113111 /**
114112 * Hook function called every time a page is deleted
115113 */
116 -function articleDeleteGeo ( $article )
 114+function articleDeleteGeo ( $article )
117115 {
118116 $id = $article->getID();
119117
@@ -160,5 +158,3 @@
161159 return $skin->makeKnownLink( 'Special:Geo', $geo->get_markup(), $geo->get_param_string() );
162160
163161 }
164 -
165 -
Index: trunk/extensions/gis/neighbors.php
@@ -38,7 +38,7 @@
3939 var $title;
4040 var $attr;
4141
42 - function neighbors( $dist )
 42+ function neighbors( $dist )
4343 {
4444 $this->p = new GeoParam();
4545 $this->d = $dist;
@@ -47,7 +47,7 @@
4848 $this->attr = $this->p->get_attr();
4949 }
5050
51 - function show()
 51+ function show()
5252 {
5353 global $wgOut, $wgUser, $wgContLang;
5454
@@ -74,7 +74,10 @@
7575
7676 $g = new GisDatabase();
7777 $g->select_radius_m( $lat0, $lon0, $this->d * 1000,
 78+ // FIXME: Notice: Undefined index: globe in extensions\gis\neighbors.php on line 79
 79+ // FIXME: Notice: Undefined index: type in extensions\gis\neighbors.php on line 79
7880 $this->attr['globe'], $this->attr['type'],
 81+ // FIXME: Notice: Undefined index: arg:type in extensions\gis\neighbors.php on line 81
7982 $this->attr['arg:type'] );
8083 $all = array();
8184 $all_pos = array(); /* temporary store reqd due to sort */
@@ -120,7 +123,7 @@
121124 }
122125 return "$out\n<table class=\"gisneighbourtable\">$table</table>\n";
123126 }
124 -
 127+
125128 function show_location( $id, $d, $pos )
126129 {
127130 $id = $pos->gis_page;
@@ -128,7 +131,7 @@
129132 $out = "<tr><th>[[{$pos['name']}]]</th>";
130133
131134 $type = $pos['type'];
132 -
 135+
133136 $out .= "<td>$type</td>";
134137 if ($d < 1000) {
135138 $out .= '<td>'.round($d).' m</td>';
@@ -150,4 +153,3 @@
151154 . "</td></tr>\r\n";
152155 }
153156 }
154 -
Index: trunk/extensions/gis/mapsources.php
@@ -56,7 +56,7 @@
5757 $wgOut->setPagetitle( $this->mapsources );
5858 $wgOut->addWikiText( $this->build_output() );
5959 }
60 -
 60+
6161 function build_output() {
6262 global $wgOut, $wgUser, $wgContLang, $wgRequest;
6363
@@ -89,7 +89,7 @@
9090 'landmark' => 10000 # 10 thousand
9191 );
9292
93 - $attr['default'] =
 93+ $attr['default'] =
9494 $default_scale[$attr['type']];
9595 # FIXME: Scale according to city size, if available
9696 }
@@ -139,7 +139,7 @@
140140
141141 /*
142142 * MSN uses an altitude equivalent
143 - * instead of a scale:
 143+ * instead of a scale:
144144 * 143 == 1:1000000 scale
145145 */
146146 $altitude = intval( $attr['scale'] * 143/1000000 );
@@ -226,7 +226,7 @@
227227 /*
228228 * Replace in page
229229 */
230 - $search = array(
 230+ $search = array(
231231 "{latdegdec}", "{londegdec}",
232232 "{londegneg}", "{latdegint}",
233233 "{londegint}", "{latdegabs}",
@@ -289,5 +289,3 @@
290290 return str_replace( $search, $replace, $bstext );
291291 }
292292 }
293 -
294 -
Index: trunk/extensions/gis/kml.php
@@ -3,7 +3,7 @@
44 * Support the "Map sources" list mechanism, see also:
55 * http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Geographical_coordinates
66 *
7 - * This extension was designed to work together with the geo tag
 7+ * This extension was designed to work together with the geo tag
88 * extension (geo.php). It can be useful in its own right also, but
99 * class GeoParam from geo.php needs to be avalibale
1010 *
@@ -46,7 +46,7 @@
4747 require_once( "{$wikibasedir}/includes/Setup.php" );
4848 require_once( "geo.php" );
4949 }
50 -
 50+
5151 require_once( "mapsources.php");
5252 require_once( "neighbors.php");
5353 require_once( "maparea.php");
@@ -119,5 +119,3 @@
120120 }
121121
122122 exit ( 0 ) ;
123 -
124 -?>
Index: trunk/extensions/gis/greatcircle.php
@@ -91,4 +91,3 @@
9292 /* Assumes Earth radius of 6366.71 km */
9393 }
9494 }
95 -
Index: trunk/extensions/gis/Specialgeo_body.php
@@ -3,7 +3,7 @@
44 * Support the "Map sources" list mechanism, see also:
55 * http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Geographical_coordinates
66 *
7 - * This extension was designed to work together with the geo tag
 7+ * This extension was designed to work together with the geo tag
88 * extension (geo.php). It can be useful in its own right also, but
99 * class GeoParam from geo.php needs to be avalibale
1010 *
@@ -36,21 +36,14 @@
3737 exit( 1 );
3838 }
3939
40 -# Add messages
41 -global $wgMessageCache, $wgDesysopMessages;
42 -// !JF1
43 -/*
44 -foreach( $wgDesysopMessages as $key => $value ) {
45 - $wgMessageCache->addMessages( $wgDesysopMessages[$key], $key );
46 -}
47 -*/
4840 require_once('mapsources.php');
4941
50 -class GeoPage extends SpecialPage {
51 - function __construct() {
52 - parent::__construct( 'Geo', 'geo' );
53 - }
 42+class SpecialGeo extends SpecialPage {
5443
 44+ function __construct() {
 45+ parent::__construct( 'Geo', 'geo' );
 46+ }
 47+
5548 function execute( $subpage ) {
5649 global $wgOut, $wgRequest, $wgCookiePrefix;
5750 $params = $wgRequest->getValues();
@@ -73,7 +66,7 @@
7467 }
7568 unset( $params['subaction'] );
7669 unset( $params[$wgCookiePrefix.'_session'] );
77 -
 70+
7871 foreach ( $params as $key => $val ) {
7972 $wgOut->addHTML( "<input type=\"hidden\" name=\"$key\" value=\"$val\">\n" );
8073 }
@@ -95,29 +88,3 @@
9689 }
9790 }
9891 }
99 -/*
100 -global $wgRequest;
101 -
102 -if ( isset ( $_GET['geo'] ) ) {
103 - $geo = $wgRequest->getVal( 'geo' );
104 - $title = $wgRequest->getVal( 'title' );
105 - $bsl = new map_sources( $geo, $title );
106 - $bsl->show();
107 -} else if ( isset ( $_GET['near'] ) ) {
108 - $near = $wgRequest->getVal( 'near' );
109 - $dist = $wgRequest->getVal( 'dist' );
110 - $title = $wgRequest->getVal( 'title' );
111 - $bsl = new neighbors( $near, $dist, $title );
112 - $bsl->show();
113 -} else if ( isset ( $_GET['maparea'] ) ) {
114 - $maparea = $wgRequest->getVal( 'maparea' );
115 - $action = $wgRequest->getVal( 'action' );
116 - $bsl = new maparea( $maparea );
117 - $bsl->show( $action );
118 -} else if ( isset ( $_GET['version'] ) ) {
119 - $bsl = new gis_version( );
120 - $bsl->show();
121 -}
122 -
123 -*/
124 -
Index: trunk/extensions/gis/gisversion.php
@@ -39,20 +39,20 @@
4040
4141 $wgOut->setPagetitle( "Version" );
4242 $wgOut->addHTML( '
43 - <p><b><a href="http://www.mediawiki.org/">MediaWiki</a></b>
 43+ <p><b><a href="http://www.mediawiki.org/">MediaWiki</a></b>
4444 <a href="http://meta.wikimedia.org/wiki/Gis">GIS extension</a>,
4545 copyright (C) 2005 by Egil Kvaleberg.</p>
46 -
 46+
4747 <p>The GIS extension is free software; you can redistribute it and/or modify
4848 it under the terms of the GNU General Public License as published by
4949 the Free Software Foundation; either version 2 of the License, or
5050 (at your option) any later version.</p>
51 -
 51+
5252 <p>The GIS extension is distributed in the hope that it will be useful,
5353 but WITHOUT ANY WARRANTY; without even the implied warranty of
5454 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5555 GNU General Public License for more details.</p>
56 -
 56+
5757 <p>You should have received <a href="../COPYING">a copy of the GNU General Public License</a>
5858 along with this program; if not, write to the Free Software
5959 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -64,5 +64,3 @@
6565 $wgOut->addWikiText( $out );
6666 }
6767 }
68 -
69 -

Status & tagging log