r51695 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51694‎ | r51695 | r51696 >
Date:13:34, 10 June 2009
Author:yaron
Status:deferred
Tags:
Comment:
Tag for version 0.6.3
Modified paths:
  • /tags/extensions/SemanticGoogleMaps/REL_0_6_3 (added) (history)

Diff [purge]

Index: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SGM_QueryPrinter.php
@@ -0,0 +1,258 @@
 2+<?php
 3+if (!defined('MEDIAWIKI')) die();
 4+/**
 5+ * Print query results in a Google Map. Based on Google Maps API code
 6+ * written by Robert Buzink and query results printing code written by
 7+ * Markus Krötzsch.
 8+ *
 9+ * @author Yaron Koren
 10+ */
 11+
 12+class SGMResultPrinter extends SMWResultPrinter {
 13+
 14+ public function getName() {
 15+ wfLoadExtensionMessages('SemanticGoogleMaps');
 16+ return wfMsg('semanticgooglemaps_printername');
 17+ }
 18+
 19+ public function getResult($results, $params, $outputmode) {
 20+ // skip checks, results with 0 entries are normal
 21+ $this->readParameters($params, $outputmode);
 22+ return $this->getResultText($results, $params, SMW_OUTPUT_HTML);
 23+ }
 24+
 25+ protected function getResultText($res, $outputmode) {
 26+ global $smwgIQRunningNumber, $wgUser;
 27+ $skin = $wgUser->getSkin();
 28+ $result = "";
 29+
 30+ $locations = array();
 31+ $legend_labels = array();
 32+ // print all result rows
 33+ while ( $row = $res->getNext() ) {
 34+ $lat = $lon = $title = $text = $icon = "";
 35+ $coords_for_page = array();
 36+ foreach ($row as $i => $field) {
 37+ $pr = $field->getPrintRequest();
 38+ while ( ($object = $field->getNextObject()) !== false ) {
 39+ if ($object->getTypeID() == '_geo') { // use shorter "LongText" for wikipage
 40+ // don't add geographical coordinates to the display
 41+ } elseif ($object->getTypeID() == '_wpg') { // use shorter "LongText" for wikipage
 42+ $text .= $pr->getHTMLText($skin) . " " . $object->getLongText($outputmode, $skin) . "<br />";
 43+ if ($i == 0) {
 44+ $title = $object->getShortWikiText(false);
 45+ }
 46+ } else {
 47+ $text .= $pr->getHTMLText($skin) . " " . $object->getShortText($outputmode, $skin) . "<br />";
 48+ }
 49+ if ($pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo') {
 50+ list($lat,$lon) = explode(',', $object->getXSDValue());
 51+ if ($lat != '' && $lon != '')
 52+ $coords_for_page[] = array($lat, $lon);
 53+ }
 54+ }
 55+ }
 56+ foreach ($coords_for_page as $coords) {
 57+ // look for display_options field, which can
 58+ // be set by Semantic Compound Queries
 59+ if (property_exists($row[0], 'display_options')) {
 60+ if (array_key_exists('icon', $row[0]->display_options)) {
 61+ $icon = $row[0]->display_options['icon'];
 62+ // this is somewhat of a hack - if a
 63+ // legend label has been set, we're
 64+ // getting it for every point,
 65+ // instead of just once per icon
 66+ if (array_key_exists('legend label', $row[0]->display_options)) {
 67+ $legend_label = $row[0]->display_options['legend label'];
 68+ if (! array_key_exists($icon, $legend_labels)) {
 69+ $legend_labels[$icon] = $legend_label;
 70+ }
 71+ }
 72+ }
 73+ // icon can be set even for regular, non-compound
 74+ // queries -if it is, though, we have to translate
 75+ // the name into a URL here
 76+ } elseif (array_key_exists('icon', $this->m_params)) {
 77+ $icon_title = Title::newFromText($this->m_params['icon']);
 78+ $icon_image_page = new ImagePage($icon_title);
 79+ $icon = $icon_image_page->getDisplayedFile()->getURL();
 80+ }
 81+
 82+ list($lat, $lon) = $coords;
 83+ $locations[] = array($lat, $lon, $title, $text, $icon);
 84+ }
 85+ }
 86+
 87+ $coordinates = '1,1';
 88+ $class = 'pmap';
 89+ if (array_key_exists('width', $this->m_params)) {
 90+ $width = $this->m_params['width'];
 91+ } else {
 92+ $width = 400;
 93+ }
 94+ if (array_key_exists('height', $this->m_params)) {
 95+ $height = $this->m_params['height'];
 96+ } else {
 97+ $height = 400;
 98+ }
 99+ if (array_key_exists('center', $this->m_params)) {
 100+ $center = $this->m_params['center'];
 101+ } else {
 102+ $center = null;
 103+ }
 104+ if (array_key_exists('zoom', $this->m_params)) {
 105+ $zoom = $this->m_params['zoom'];
 106+ } else {
 107+ $zoom = 0;
 108+ }
 109+ if (array_key_exists('map type', $this->m_params)) {
 110+ $type = $this->m_params['map type'];
 111+ } else {
 112+ $type = 'G_NORMAL_MAP';
 113+ }
 114+ if (array_key_exists('map control', $this->m_params)) {
 115+ $control_class = $this->m_params['map control'];
 116+ } else {
 117+ $control_class = 'GLargeMapControl';
 118+ }
 119+ global $wgJsMimeType, $wgGoogleMapsKey, $wgGoogleMapsOnThisPage;
 120+ global $wgLang;
 121+
 122+ if (!$wgGoogleMapsOnThisPage) {$wgGoogleMapsOnThisPage = 0;}
 123+ $wgGoogleMapsOnThisPage++;
 124+
 125+ $map_text = <<<END
 126+<script src="http://maps.google.com/maps?file=api&v=2&key=$wgGoogleMapsKey&hl={$wgLang->getCode()}" type="$wgJsMimeType"></script>
 127+<script type="text/javascript">
 128+function createMarker(point, title, label, icon) {
 129+ if (icon!='') {
 130+ var iconObj = new GIcon(G_DEFAULT_ICON);
 131+ iconObj.image = icon;
 132+ var marker = new GMarker(point, {title:title, icon:iconObj});
 133+ } else {
 134+ var marker = new GMarker(point, {title:title});
 135+ }
 136+ GEvent.addListener(marker, 'click',
 137+ function() {
 138+ marker.openInfoWindowHtml(label, {maxWidth:350});
 139+ });
 140+ return marker;
 141+}
 142+function addLoadEvent(func) {
 143+ var oldonload = window.onload;
 144+ if (typeof oldonload == 'function') {
 145+ window.onload = function() {
 146+ oldonload();
 147+ func();
 148+ };
 149+ } else {
 150+ window.onload = func;
 151+ }
 152+}
 153+window.unload = GUnload;
 154+</script>
 155+<div id="map$wgGoogleMapsOnThisPage" class="$class"></div>
 156+<script type="text/javascript">
 157+function makeMap{$wgGoogleMapsOnThisPage}() {
 158+ if (GBrowserIsCompatible()) {
 159+ var map = new GMap2(document.getElementById("map$wgGoogleMapsOnThisPage"), {size: new GSize('$width', '$height')});
 160+ map.setMapType($type);
 161+ map.addControl(new {$control_class}());
 162+ map.addControl(new GMapTypeControl());
 163+END;
 164+ if (count($locations) > 0 && $center == null) {
 165+ // get the extremes among these points to calculate
 166+ // the correct zoom level for the map
 167+ $min_lat = 90;
 168+ $max_lat = -90;
 169+ $min_lon = 180;
 170+ $max_lon = -180;
 171+ foreach ($locations as $i => $location) {
 172+ list($lat, $lon) = $location;
 173+ if ($lat < $min_lat) {$min_lat = $lat; }
 174+ if ($lat > $max_lat) {$max_lat = $lat; }
 175+ if ($lon < $min_lon) {$min_lon = $lon; }
 176+ if ($lon > $max_lon) {$max_lon = $lon; }
 177+ }
 178+ $center_lat = ($min_lat + $max_lat) / 2;
 179+ $center_lon = ($min_lon + $max_lon) / 2;
 180+ $lat_width = $max_lat - $min_lat;
 181+ $lon_width = $max_lon - $min_lon;
 182+ // get coordinates a little beyond the farthest
 183+ // points among this set of locations, so that
 184+ // the zoom level doesn't set some points at
 185+ // the very edge of the map
 186+ $max_lat_plus = $max_lat + (0.05 * $lat_width);
 187+ $min_lat_plus = $min_lat - (0.05 * $lat_width);
 188+ $max_lon_plus = $max_lon + (0.05 * $lon_width);
 189+ $min_lon_plus = $min_lon - (0.05 * $lon_width);
 190+ $map_text .=<<<END
 191+ var center = new GLatLng($center_lat, $center_lon);
 192+ var sw_point = new GLatLng($min_lat_plus, $min_lon_plus);
 193+ var ne_point = new GLatLng($max_lat_plus, $max_lon_plus);
 194+ var bounds = new GLatLngBounds(sw_point, ne_point);
 195+ var zoom = map.getBoundsZoomLevel(bounds);
 196+ map.setCenter(center, zoom);
 197+
 198+END;
 199+ } else {
 200+ if ($center == null) {
 201+ $center_lat = 0;
 202+ $center_lon = 0;
 203+ } else {
 204+ // GLatLng class expects only numbers, no
 205+ // letters or degree symbols
 206+ list($center_lat, $center_lon) = SGMUtils::getLatLon($center);
 207+ }
 208+ $map_text .= " map.setCenter(new GLatLng($center_lat, $center_lon), $zoom);\n";
 209+ }
 210+ // add a marker to the map for each location
 211+ foreach ($locations as $i => $location) {
 212+ list($lat, $lon, $title, $label, $icon) = $location;
 213+ $title = str_replace("'", "\'", $title);
 214+ $label = str_replace("'", "\'", $label);
 215+ $map_text .=<<<END
 216+ map.addOverlay(createMarker(new GLatLng($lat, $lon), '$title', '$label', '$icon'));
 217+END;
 218+ }
 219+
 220+ $map_text .=<<<END
 221+ }
 222+}
 223+addLoadEvent(makeMap{$wgGoogleMapsOnThisPage});
 224+</script>
 225+END;
 226+ // to avoid wiki parsing adding random '<p>' tags, we have
 227+ // to replace all newlines with spaces
 228+ $map_text = preg_replace('/\s+/m', ' ', $map_text);
 229+
 230+ // add the legend, if any labels have been defined
 231+ if (count($legend_labels) > 0) {
 232+ $map_text .= "\n<div style=\"margin: 10px; padding: 5px;\">\n";
 233+ foreach ($legend_labels as $icon => $legend_label) {
 234+/*
 235+ $icon_title = Title::newFromText($icon);
 236+ $icon_image = new ImagePage($icon_title);
 237+ $icon_url = $icon_image->getDisplayedFile()->getURL();
 238+*/
 239+ $map_text .= "<img src=\"$icon\" />&nbsp;$legend_label&nbsp;&nbsp;&nbsp; ";
 240+ }
 241+ $map_text .= "</div>\n";
 242+ }
 243+ $result .= $map_text;
 244+
 245+ // print further results footer
 246+ // getSearchLabel() method was added in SMW 1.3
 247+ if (method_exists($this, 'getSearchLabel')) {
 248+ $search_label = $this->getSearchLabel(SMW_OUTPUT_HTML);
 249+ } else {
 250+ $search_label = $this->mSearchlabel;
 251+ }
 252+ if ( $this->mInline && $res->hasFurtherResults() && $search_label !== '') {
 253+ $link = $res->getQueryLink();
 254+ $link->setCaption($search_label);
 255+ $result .= "\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . $res->getColumnCount() . '"> ' . $link->getText($outputmode,$this->mLinker) . "</td></tr>\n";
 256+ }
 257+ return array($result, 'noparse' => 'true', 'isHTML' => 'true');
 258+ }
 259+}
Property changes on: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SGM_QueryPrinter.php
___________________________________________________________________
Name: svn:eol-style
1260 + native
Index: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SemanticGoogleMaps.i18n.php
@@ -0,0 +1,359 @@
 2+<?php
 3+/**
 4+ * Internationalization file for the Semantic Google Maps extension
 5+ *
 6+ * @addtogroup Extensions
 7+*/
 8+
 9+$messages = array();
 10+
 11+/** English
 12+ * @author Yaron Koren
 13+ */
 14+$messages['en'] = array(
 15+ // user messages
 16+ 'semanticgooglemaps_printername' => 'Google Maps',
 17+ 'semanticgooglemaps_lookupcoordinates' => 'Look up coordinates',
 18+ 'semanticgooglemaps-desc' => 'Allows users to edit and display semantic coordinate data using Google Maps',
 19+ 'semanticgooglemaps-enteraddresshere' => 'Enter address here',
 20+);
 21+
 22+/** Message documentation (Message documentation)
 23+ * @author Purodha
 24+ */
 25+$messages['qqq'] = array(
 26+ 'semanticgooglemaps-desc' => 'Short description of this extension, shown in [[Special:Version]]. Do not translate or change links.',
 27+);
 28+
 29+/** Afrikaans (Afrikaans)
 30+ * @author Naudefj
 31+ */
 32+$messages['af'] = array(
 33+ 'semanticgooglemaps_lookupcoordinates' => 'Soek koördinate op',
 34+ 'semanticgooglemaps-desc' => 'Laat gebruikers toe om Google Maps by wiki bladsye te voeg op grond van gestruktureerde gegewens',
 35+);
 36+
 37+/** Arabic (العربية)
 38+ * @author Meno25
 39+ */
 40+$messages['ar'] = array(
 41+ 'semanticgooglemaps_lookupcoordinates' => 'ابحث عن الإحداثيات',
 42+ 'semanticgooglemaps-desc' => 'يسمح للمستخدمين بتعديل وعرض بيانات سيمانتيك الإحداثية باستخدام خرائط جوجل',
 43+ 'semanticgooglemaps-enteraddresshere' => 'أدخل العنوان هنا',
 44+);
 45+
 46+/** Egyptian Spoken Arabic (مصرى)
 47+ * @author Ghaly
 48+ * @author Meno25
 49+ */
 50+$messages['arz'] = array(
 51+ 'semanticgooglemaps_lookupcoordinates' => 'ابحث عن الإحداثيات',
 52+ 'semanticgooglemaps-desc' => 'مسموح لليوزرز إضافة خرايط جوجول لصفحات الويكى بالاعتماد على بيانات هيكلية',
 53+ 'semanticgooglemaps-enteraddresshere' => 'أدخل العنوان هنا',
 54+);
 55+
 56+/** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца))
 57+ * @author EugeneZelenko
 58+ * @author Jim-by
 59+ */
 60+$messages['be-tarask'] = array(
 61+ 'semanticgooglemaps_lookupcoordinates' => 'Пошук каардынатаў',
 62+ 'semanticgooglemaps-desc' => 'Дазваляе ўдзельнікам рэдагаваць і паказваць сэмантычныя зьвесткі пра каардынаты з выкарыстаньнем Google Maps',
 63+ 'semanticgooglemaps-enteraddresshere' => 'Увядзіце тут адрас',
 64+);
 65+
 66+/** Breton (Brezhoneg)
 67+ * @author Fulup
 68+ */
 69+$messages['br'] = array(
 70+ 'semanticgooglemaps_lookupcoordinates' => 'Istimañ an daveennoù',
 71+ 'semanticgooglemaps-desc' => 'Aotren a ra an implijerien da aozañ ha da ziskwel roadennoù semantek daveennoù dre ober gant Google Maps',
 72+ 'semanticgooglemaps-enteraddresshere' => "Merkit ar chomlec'h amañ",
 73+);
 74+
 75+/** Bosnian (Bosanski)
 76+ * @author CERminator
 77+ */
 78+$messages['bs'] = array(
 79+ 'semanticgooglemaps_lookupcoordinates' => 'Nađi koordinate',
 80+ 'semanticgooglemaps-desc' => 'Omogućuje korisnicima uređivanje i prikaz semantičkih podataka koordinata koristeći Google Maps',
 81+ 'semanticgooglemaps-enteraddresshere' => 'Unesite adresu ovdje',
 82+);
 83+
 84+/** German (Deutsch)
 85+ * @author DaSch
 86+ * @author Umherirrender
 87+ */
 88+$messages['de'] = array(
 89+ 'semanticgooglemaps_lookupcoordinates' => 'Koordinaten nachschlagen',
 90+ 'semanticgooglemaps-desc' => 'Bietet die Möglichkeit, semantische Koordinaten mit Hilfe von Google Maps zu bearbeiten und anzuzeigen.',
 91+ 'semanticgooglemaps-enteraddresshere' => 'Adresse hier eingeben',
 92+);
 93+
 94+/** Lower Sorbian (Dolnoserbski)
 95+ * @author Michawiki
 96+ */
 97+$messages['dsb'] = array(
 98+ 'semanticgooglemaps_lookupcoordinates' => 'Za koordinatami póglědaś',
 99+ 'semanticgooglemaps-desc' => 'Dowólujo wužywarjam semantiske koordinatowe daty z pomocu Google Maps wobúěłaś a zwobrazniś',
 100+ 'semanticgooglemaps-enteraddresshere' => 'Zapódaj how adresu',
 101+);
 102+
 103+/** Esperanto (Esperanto)
 104+ * @author Yekrats
 105+ */
 106+$messages['eo'] = array(
 107+ 'semanticgooglemaps_lookupcoordinates' => 'Rigardi koordinatojn',
 108+ 'semanticgooglemaps-desc' => 'Permesas al uzantoj por aldoni Guglo-Mapojn al vikipaĝojn laŭ strukturaj datenoj.',
 109+);
 110+
 111+/** Spanish (Español)
 112+ * @author Crazymadlover
 113+ */
 114+$messages['es'] = array(
 115+ 'semanticgooglemaps_lookupcoordinates' => 'Busque las coordenadas',
 116+ 'semanticgooglemaps-desc' => 'Permite a los usuario editar y mostrar datos de coordinación semántica usando Google Maps',
 117+ 'semanticgooglemaps-enteraddresshere' => 'Ingresar dirección aquí',
 118+);
 119+
 120+/** Basque (Euskara)
 121+ * @author An13sa
 122+ */
 123+$messages['eu'] = array(
 124+ 'semanticgooglemaps_lookupcoordinates' => 'Koordenatuak bilatu',
 125+);
 126+
 127+/** French (Français)
 128+ * @author Crochet.david
 129+ * @author Grondin
 130+ */
 131+$messages['fr'] = array(
 132+ 'semanticgooglemaps_lookupcoordinates' => 'Estimer les coordonnées',
 133+ 'semanticgooglemaps-desc' => 'Permet aux utilisateurs d’éditer et d’afficher les données sémantiques de coordonnées utilisant Google Maps',
 134+ 'semanticgooglemaps-enteraddresshere' => 'Entrez ici l’adresse',
 135+);
 136+
 137+/** Galician (Galego)
 138+ * @author Toliño
 139+ */
 140+$messages['gl'] = array(
 141+ 'semanticgooglemaps_lookupcoordinates' => 'Ver as coordenadas',
 142+ 'semanticgooglemaps-desc' => 'Permite aos usuarios editar e mostrar datos de coordenadas semánticas usando os mapas do Google (Google Maps)',
 143+ 'semanticgooglemaps-enteraddresshere' => 'Introduza o enderezo aquí',
 144+);
 145+
 146+/** Swiss German (Alemannisch)
 147+ * @author Als-Holder
 148+ */
 149+$messages['gsw'] = array(
 150+ 'semanticgooglemaps_lookupcoordinates' => 'Koordinate nooluege',
 151+ 'semanticgooglemaps-desc' => 'Bietet d Megligkeit, semantischi Koordinate mit Hilf vu Google Maps z bearbeiten un aazzeige.',
 152+ 'semanticgooglemaps-enteraddresshere' => 'Doo Adräss yygee',
 153+);
 154+
 155+/** Hebrew (עברית)
 156+ * @author Rotemliss
 157+ * @author YaronSh
 158+ */
 159+$messages['he'] = array(
 160+ 'semanticgooglemaps_lookupcoordinates' => 'חיפוש קואורדינטות',
 161+ 'semanticgooglemaps-desc' => 'מתן האפשרות למשתמשים לערוך ולהציג נתוני קואורדינטות סמנטיים באמצעות מפות Google.',
 162+ 'semanticgooglemaps-enteraddresshere' => 'כתבו כתובת כאן',
 163+);
 164+
 165+/** Upper Sorbian (Hornjoserbsce)
 166+ * @author Michawiki
 167+ */
 168+$messages['hsb'] = array(
 169+ 'semanticgooglemaps_lookupcoordinates' => 'Za koordinatami hladać',
 170+ 'semanticgooglemaps-desc' => 'Dowola wužiwarjam semantiske koordinatowe daty z pomocu Google Maps wobdźěłać a zwobraznić',
 171+ 'semanticgooglemaps-enteraddresshere' => 'Zapodaj tu adresu',
 172+);
 173+
 174+/** Interlingua (Interlingua)
 175+ * @author McDutchie
 176+ */
 177+$messages['ia'] = array(
 178+ 'semanticgooglemaps_lookupcoordinates' => 'Cercar coordinatas',
 179+ 'semanticgooglemaps-desc' => 'Permitte que usatores modifica e monstra datos semantic de coordinatas per medio de Google Maps',
 180+ 'semanticgooglemaps-enteraddresshere' => 'Entra adresse hic',
 181+);
 182+
 183+/** Japanese (日本語)
 184+ * @author Fryed-peach
 185+ * @author Mizusumashi
 186+ */
 187+$messages['ja'] = array(
 188+ 'semanticgooglemaps_lookupcoordinates' => '座標を調べる',
 189+ 'semanticgooglemaps-desc' => '利用者が Google マップを使って意味的な座標データを編集・表示できるようにする',
 190+ 'semanticgooglemaps-enteraddresshere' => 'アドレスをここに入力します',
 191+);
 192+
 193+/** Khmer (ភាសាខ្មែរ)
 194+ * @author Thearith
 195+ */
 196+$messages['km'] = array(
 197+ 'semanticgooglemaps_lookupcoordinates' => 'ក្រឡេក​មើល​កូអរដោនេ',
 198+);
 199+
 200+/** Ripoarisch (Ripoarisch)
 201+ * @author Purodha
 202+ */
 203+$messages['ksh'] = array(
 204+ 'semanticgooglemaps_lookupcoordinates' => 'Koordinate nohkike',
 205+ 'semanticgooglemaps-desc' => 'Määt et müjjelesch, op semantesche Ko\'odinaate-Date opjeboute <i lang="en">Google Maps</i> (Landkaate) en et Wiki ennzeboue, un esu en Date ze beärbeide.',
 206+ 'semanticgooglemaps-enteraddresshere' => 'Donn hee de Address enjäve',
 207+);
 208+
 209+/** Luxembourgish (Lëtzebuergesch)
 210+ * @author Robby
 211+ */
 212+$messages['lb'] = array(
 213+ 'semanticgooglemaps_lookupcoordinates' => 'Koordinaten nokucken',
 214+ 'semanticgooglemaps-desc' => "Erlaabt et de Benotzer fir Google Maps op Wiki-Säiten op Basis vu srukturéierten Donnéeën ze weisen an z'änneren.",
 215+ 'semanticgooglemaps-enteraddresshere' => 'Adress hei aginn',
 216+);
 217+
 218+/** Dutch (Nederlands)
 219+ * @author Siebrand
 220+ */
 221+$messages['nl'] = array(
 222+ 'semanticgooglemaps_lookupcoordinates' => 'Coördinaten opzoeken',
 223+ 'semanticgooglemaps-desc' => 'Staat gebruikers toe semantische gegevens te bewerken en weer te geven met behulp van Google Maps',
 224+ 'semanticgooglemaps-enteraddresshere' => 'Voer hier het adres in',
 225+);
 226+
 227+/** Norwegian Nynorsk (‪Norsk (nynorsk)‬)
 228+ * @author Harald Khan
 229+ */
 230+$messages['nn'] = array(
 231+ 'semanticgooglemaps_lookupcoordinates' => 'Sjekk koordinatar',
 232+ 'semanticgooglemaps-desc' => 'Lèt brukarar endra og syna semantiske koordinatar ved å nytta Google Maps.',
 233+ 'semanticgooglemaps-enteraddresshere' => 'Skriv inn adressa her',
 234+);
 235+
 236+/** Norwegian (bokmål)‬ (‪Norsk (bokmål)‬)
 237+ * @author Jon Harald Søby
 238+ * @author Nghtwlkr
 239+ */
 240+$messages['no'] = array(
 241+ 'semanticgooglemaps_lookupcoordinates' => 'Sjekk koordinater',
 242+ 'semanticgooglemaps-desc' => 'Lar brukere endre og vise semantiske koordinater ved å bruke Google Maps',
 243+ 'semanticgooglemaps-enteraddresshere' => 'Skriv inn adressen her',
 244+);
 245+
 246+/** Occitan (Occitan)
 247+ * @author Cedric31
 248+ */
 249+$messages['oc'] = array(
 250+ 'semanticgooglemaps_lookupcoordinates' => 'Estimar las coordenadas',
 251+ 'semanticgooglemaps-desc' => "Permet als utilizaires d'editar e d'afichar las donadas semanticas de coordenadas qu'utilizan Google Maps",
 252+ 'semanticgooglemaps-enteraddresshere' => 'Picatz aicí l’adreça',
 253+);
 254+
 255+/** Polish (Polski)
 256+ * @author Derbeth
 257+ * @author Leinad
 258+ * @author Sp5uhe
 259+ */
 260+$messages['pl'] = array(
 261+ 'semanticgooglemaps_lookupcoordinates' => 'Wyszukaj współrzędne',
 262+ 'semanticgooglemaps-desc' => 'Umożliwia użytkownikom edycję i prezentację współrzędnych geograficznych z użyciem Google Maps',
 263+ 'semanticgooglemaps-enteraddresshere' => 'Podaj adres',
 264+);
 265+
 266+/** Portuguese (Português)
 267+ * @author Malafaya
 268+ */
 269+$messages['pt'] = array(
 270+ 'semanticgooglemaps_lookupcoordinates' => 'Pesquisar coordenadas',
 271+ 'semanticgooglemaps-desc' => 'Permite aos utilizadores editarem e apresentarem dados semânticos coordenados usando Google Maps',
 272+ 'semanticgooglemaps-enteraddresshere' => 'Introduza um endereço aqui',
 273+);
 274+
 275+/** Brazilian Portuguese (Português do Brasil)
 276+ * @author Eduardo.mps
 277+ */
 278+$messages['pt-br'] = array(
 279+ 'semanticgooglemaps_lookupcoordinates' => 'Pesquisar coordenadas',
 280+ 'semanticgooglemaps-desc' => 'Permite aos utilizadores editarem e apresentarem dados semânticos de coordenadas usando Google Maps',
 281+ 'semanticgooglemaps-enteraddresshere' => 'Introduza um endereço aqui',
 282+);
 283+
 284+/** Tarandíne (Tarandíne)
 285+ * @author Joetaras
 286+ */
 287+$messages['roa-tara'] = array(
 288+ 'semanticgooglemaps_lookupcoordinates' => 'Ingroce le coordinate',
 289+ 'semanticgooglemaps-desc' => "Permette a l'utinde de cangià e visualizzà le date de le coordinate semandfiche ausanne '''Google Maps'''",
 290+ 'semanticgooglemaps-enteraddresshere' => "Scaffe l'indirizze aqquà",
 291+);
 292+
 293+/** Russian (Русский)
 294+ * @author Eugene Mednikov
 295+ */
 296+$messages['ru'] = array(
 297+ 'semanticgooglemaps_lookupcoordinates' => 'Найти координаты',
 298+ 'semanticgooglemaps-desc' => 'Позволяет редактировать и показывать семантические координатные данные с помощью Google Maps',
 299+ 'semanticgooglemaps-enteraddresshere' => 'Введите адрес',
 300+);
 301+
 302+/** Slovak (Slovenčina)
 303+ * @author Helix84
 304+ */
 305+$messages['sk'] = array(
 306+ 'semanticgooglemaps_lookupcoordinates' => 'Vyhľadať súradnice',
 307+ 'semanticgooglemaps-desc' => 'Umožňuje používateľom upravovať a zobrazovať sémantické súradnicové údaje pomocou Google Maps',
 308+ 'semanticgooglemaps-enteraddresshere' => 'Sem zadajte emailovú adresu',
 309+);
 310+
 311+/** Swedish (Svenska)
 312+ * @author Boivie
 313+ * @author Najami
 314+ */
 315+$messages['sv'] = array(
 316+ 'semanticgooglemaps_lookupcoordinates' => 'Kolla upp koordinater',
 317+ 'semanticgooglemaps-desc' => 'Tillåter användare att redigera och visa semantiska koordinater för att använda Google Maps',
 318+ 'semanticgooglemaps-enteraddresshere' => 'Skriv in adress här',
 319+);
 320+
 321+/** Tagalog (Tagalog)
 322+ * @author AnakngAraw
 323+ */
 324+$messages['tl'] = array(
 325+ 'semanticgooglemaps_lookupcoordinates' => "Hanapin ang mga tugmaang-pampook (''coordinate'')",
 326+ 'semanticgooglemaps-desc' => 'Nagpapahintulot sa mga tagagamit na makapagbago at makapagpakita/mapagpalitaw ng dato na pangtugmaang pampook na patungkol/umaayon sa kahulugan o ibig sabihin ng salita na ginagamitan ng mga Mapa ng Google',
 327+ 'semanticgooglemaps-enteraddresshere' => 'Ipasok ang adres dito',
 328+);
 329+
 330+/** Vietnamese (Tiếng Việt)
 331+ * @author Vinhtantran
 332+ */
 333+$messages['vi'] = array(
 334+ 'semanticgooglemaps_lookupcoordinates' => 'Tra tọa độ',
 335+ 'semanticgooglemaps-desc' => 'Cho phép thành viên sửa đổi và hiển thị dữ liệu tọa độ ngữ nghĩa bằng Google Maps',
 336+ 'semanticgooglemaps-enteraddresshere' => 'Nhập địa chỉ vào đây',
 337+);
 338+
 339+/** Volapük (Volapük)
 340+ * @author Smeira
 341+ */
 342+$messages['vo'] = array(
 343+ 'semanticgooglemaps_lookupcoordinates' => 'Tuvön koordinatis',
 344+ 'semanticgooglemaps-desc' => 'Dälon gebanes ad votükön e jonön koordinatanünodis yufü el Google Maps.',
 345+);
 346+
 347+/** Simplified Chinese (‪中文(简体)‬)
 348+ * @author Gzdavidwong
 349+ */
 350+$messages['zh-hans'] = array(
 351+ 'semanticgooglemaps_lookupcoordinates' => '查找坐标',
 352+);
 353+
 354+/** Traditional Chinese (‪中文(繁體)‬)
 355+ * @author Wrightbus
 356+ */
 357+$messages['zh-hant'] = array(
 358+ 'semanticgooglemaps_lookupcoordinates' => '尋找座標',
 359+);
 360+
Property changes on: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SemanticGoogleMaps.i18n.php
___________________________________________________________________
Name: svn:eol-style
1361 + native
Index: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SemanticGoogleMaps.php
@@ -0,0 +1,60 @@
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+/**
 7+ * An extension that allows users to add, edit and display coordinate
 8+ * information stored by the Semantic MediaWiki extension using Google Maps
 9+ *
 10+ * @addtogroup Extensions
 11+ *
 12+ * @author Robert Buzink
 13+ * @author Yaron Koren
 14+ */
 15+
 16+// credits
 17+$wgExtensionCredits['parserhook'][] = array(
 18+ 'path' => __FILE__,
 19+ 'name' => 'Semantic Google Maps',
 20+ 'version' => '0.6.3',
 21+ 'author' => array( 'Robert Buzink', 'Yaron Koren' ),
 22+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Google_Maps',
 23+ 'description' => 'Allows users to edit and display semantic coordinate data using Google Maps',
 24+ 'descriptionmsg' => 'semanticgooglemaps-desc',
 25+);
 26+
 27+$wgExtensionFunctions[] = 'sgmSetup';
 28+
 29+$wgHooks['LanguageGetMagic'][] = 'sgmFunctionMagic';
 30+
 31+$wgExtensionMessagesFiles['SemanticGoogleMaps'] = dirname(__FILE__) . '/SemanticGoogleMaps.i18n.php';
 32+
 33+$sgmgIP = $IP . '/extensions/SemanticGoogleMaps';
 34+$wgAutoloadClasses['SGMUtils'] = $sgmgIP . '/SGM_Utils.inc';
 35+$wgAutoloadClasses['SGMResultPrinter'] = $sgmgIP . '/SGM_QueryPrinter.php';
 36+
 37+function sgmSetup() {
 38+ global $wgParser, $wgExtensionCredits;
 39+
 40+ // a hook to enable the '#semantic_google_map' parser function
 41+ $wgParser->setFunctionHook( 'semantic_google_map', array('SGMUtils', 'functionRender' ));
 42+ // add the 'googlemap' form input type, if Semantic Forms is installed
 43+ global $sfgFormPrinter;
 44+ if ($sfgFormPrinter) {
 45+ $sfgFormPrinter->setInputTypeHook('googlemap', array('SGMUtils', 'formInputHTML'), array());
 46+ }
 47+
 48+ // global variable introduced in SMW 1.2.2
 49+ global $smwgResultFormats;
 50+ if (isset($smwgResultFormats))
 51+ $smwgResultFormats['googlemap'] = 'SGMResultPrinter';
 52+ else
 53+ SMWQueryProcessor::$formats['googlemap'] = 'SGMResultPrinter';
 54+
 55+}
 56+
 57+function sgmFunctionMagic( &$magicWords, $langCode ) {
 58+ $magicWords['semantic_google_map'] = array( 0, 'semantic_google_map' );
 59+ // unless we return true, other parser functions won't get loaded
 60+ return true;
 61+}
Property changes on: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SemanticGoogleMaps.php
___________________________________________________________________
Name: svn:eol-style
162 + native
Index: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SGM_Utils.inc
@@ -0,0 +1,298 @@
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+/**
 7+ * A class that holds static helper functions for Semantic Google Maps
 8+ *
 9+ * @author Robert Buzink
 10+ * @author Yaron Koren
 11+ */
 12+
 13+class SGMUtils {
 14+
 15+ /**
 16+ * Render the #semantic_google_map function - the output is HTML
 17+ */
 18+ function functionRender( &$parser, $coordinates = '1,1', $zoom = '14', $type = 'G_NORMAL_MAP', $control_class = 'GSmallMapControl', $class = 'pmap', $width = '200', $height = '200', $style = '' ) {
 19+ global $wgJsMimeType, $wgGoogleMapsKey, $wgGoogleMapsOnThisPage;
 20+ global $wgLang;
 21+
 22+ if (!$wgGoogleMapsOnThisPage) {$wgGoogleMapsOnThisPage = 0;}
 23+ $wgGoogleMapsOnThisPage++;
 24+
 25+ $coordinates = str_replace('″', '"', $coordinates);
 26+ $coordinates = str_replace('′', "'", $coordinates);
 27+
 28+ list($lat, $lon) = SGMUtils::getLatLon($coordinates);
 29+
 30+ $output =<<<END
 31+<script src="http://maps.google.com/maps?file=api&v=2&key=$wgGoogleMapsKey&hl={$wgLang->getCode()}" type="$wgJsMimeType"></script>
 32+<script type="text/javascript"> function createMarker(point, label) { var marker = new GMarker(point); GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(label, GInfoWindoOptions.maxWidth=100); }); return marker; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof oldonload == 'function') { window.onload = function() { oldonload(); func(); }; } else { window.onload = func; } } window.unload = GUnload;</script>
 33+<div id="map$wgGoogleMapsOnThisPage" class="$class" style="$style" ></div>
 34+<script type="text/javascript"> function makeMap{$wgGoogleMapsOnThisPage}() { if (GBrowserIsCompatible()) {var map = new GMap2(document.getElementById("map{$wgGoogleMapsOnThisPage}"), {size: new GSize('$width', '$height')}); map.addControl(new {$control_class}()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng({$lat}, {$lon}), {$zoom}, {$type}); var point = new GLatLng({$lat}, {$lon}); var marker = new GMarker(point); map.addOverlay(marker); } else { } } addLoadEvent(makeMap{$wgGoogleMapsOnThisPage});</script>
 35+
 36+END;
 37+
 38+ return array( $output, 'noparse' => true, 'isHTML' => true );
 39+ }
 40+
 41+ function getLatLon($param2) {
 42+ $coordinates = preg_split("/,/", $param2);
 43+ if (count($coordinates) == 2) {
 44+ $lat = SGMUtils::convertCoord($coordinates[0]);
 45+ $lon = SGMUtils::convertCoord($coordinates[1]);
 46+ return array($lat, $lon);
 47+ }
 48+ return array(null, null);
 49+ }
 50+
 51+ function degree2Decimal($deg_coord = "") {
 52+ $dpos = mb_strpos($deg_coord, '°');
 53+ $mpos = mb_strpos($deg_coord, '.');
 54+ $spos = mb_strpos($deg_coord, '"');
 55+ $mlen = ($mpos - $dpos) - 1;
 56+ $slen = ($spos - $mpos) - 1;
 57+ $direction = substr(strrev($deg_coord), 0, 1);
 58+ $degrees = mb_substr($deg_coord, 0,$dpos);
 59+ $minutes = mb_substr($deg_coord, $dpos + 1, $mlen);
 60+ $seconds = mb_substr($deg_coord, $mpos + 1, $slen);
 61+ $seconds = $seconds / 60;
 62+ $minutes = $minutes + $seconds;
 63+ $minutes = $minutes / 60;
 64+ $decimal = $degrees + $minutes;
 65+ //South latitudes and West longitudes need to return a negative result
 66+ if (($direction=="S") or ($direction=="W")) {
 67+ $decimal *= -1;
 68+ }
 69+ return $decimal;
 70+ }
 71+
 72+ function decDegree2Decimal($deg_coord = "") {
 73+ $direction = substr(strrev($deg_coord), 0, 1);
 74+ $decimal = floatval($deg_coord);
 75+ if (($direction == "S") or ($direction == "W")) {
 76+ $decimal *= -1;
 77+ }
 78+ return $decimal;
 79+ }
 80+
 81+ function convertCoord($deg_coord = "") {
 82+ if (preg_match('/°/', $deg_coord)) {
 83+ if (preg_match('/"/', $deg_coord)) {
 84+ return SGMUtils::degree2Decimal($deg_coord);
 85+ } else {
 86+ return SGMUtils::decDegree2Decimal($deg_coord);
 87+ }
 88+ }
 89+ return $deg_coord;
 90+ }
 91+
 92+ function latDecimal2Degree($decimal) {
 93+ if ($decimal < 0) {
 94+ return abs($decimal) . "° S";
 95+ } else {
 96+ return $decimal . "° N";
 97+ }
 98+ }
 99+
 100+ function lonDecimal2Degree($decimal) {
 101+ if ($decimal < 0) {
 102+ return abs($decimal) . "° W";
 103+ } else {
 104+ return $decimal . "° E";
 105+ }
 106+ }
 107+
 108+ // the function that outputs the custom form html
 109+ function formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args) {
 110+ global $gTabIndex, $gDisabledText, $wgJsMimeType;
 111+ global $wgGoogleMapsKey, $wgGoogleMapsOnThisPage;
 112+
 113+ // default values
 114+ $flat = 0;
 115+ $flon = 0;
 116+
 117+ if ($coordinates) {
 118+ // can show up here either as an array or a string,
 119+ // depending on whether it came from user input or a wiki page
 120+ if (is_array($coordinates)) {
 121+ // todo if relevant
 122+ } else {
 123+ list($flat, $flon) = SGMUtils::getLatLon($coordinates);
 124+ }
 125+ $zoom = '14';
 126+ } else {
 127+ // if there's no starting value, get the value for the
 128+ // map center and zoom from the form input, if they exist
 129+ if (array_key_exists('center', $field_args)) {
 130+ list($flat, $flon) = SGMUtils::getLatLon($field_args['center']);
 131+ $zoom = '14';
 132+ } else {
 133+ $zoom = '0';
 134+ }
 135+ if (array_key_exists('zoom', $field_args)) {
 136+ $zoom = $field_args['zoom'];
 137+ }
 138+ }
 139+ if (!$wgGoogleMapsOnThisPage) {$wgGoogleMapsOnThisPage = 0;}
 140+ $wgGoogleMapsOnThisPage++;
 141+ if (array_key_exists('width', $field_args)) {
 142+ $width = $field_args['width'];
 143+ } else {
 144+ $width = '200';
 145+ }
 146+ if (array_key_exists('height', $field_args)) {
 147+ $height = $field_args['height'];
 148+ } else {
 149+ $height = '200';
 150+ }
 151+ $class = 'sm_map';
 152+ if (array_key_exists('map type', $field_args)) {
 153+ $type = $field_args['map type'];
 154+ } else {
 155+ $type = 'G_NORMAL_MAP';
 156+ }
 157+ if (array_key_exists('map control', $field_args)) {
 158+ $control_class = $field_args['map control'];
 159+ } else {
 160+ $control_class = 'GSmallMapControl';
 161+ }
 162+ if ($flat == 0) { $lat = '50';} else {$lat = $flat;}
 163+ if ($flon == 0) { $lon = '5';} else {$lon = $flon;}
 164+
 165+ // input field
 166+ $starting_coords = "";
 167+ if ($coordinates != null && $flat != 0 && $flon != 0) {
 168+ $deg_lat = SGMUtils::latDecimal2Degree($flat);
 169+ $deg_lon = SGMUtils::lonDecimal2Degree($flon);
 170+ $starting_coords = "$deg_lat, $deg_lon";
 171+ }
 172+ $info_id = "info_$gTabIndex";
 173+ $text =<<<END
 174+ <input tabindex="$gTabIndex" id="input_$gTabIndex" name="$input_name" type="text" value="$starting_coords" size="40" $gDisabledText>
 175+ <span id="$info_id" class="error_message"></span>
 176+
 177+END;
 178+
 179+ //geocoder HTML
 180+ wfLoadExtensionMessages( 'SemanticGoogleMaps' );
 181+ $enter_address_here_text = wfMsg('semanticgooglemaps-enteraddresshere');
 182+ $lookup_coordinates_text = wfMsg('semanticgooglemaps_lookupcoordinates');
 183+ $text .= <<<END
 184+ <p>
 185+ <input size="30" id= "geocode" name="geocode" value="$enter_address_here_text" style="color: #707070" onFocus="if (this.value=='$enter_address_here_text') {this.value=''}" type="text">
 186+ <input type="submit" onClick="showAddress(document.forms['createbox'].geocode.value); return false" value="$lookup_coordinates_text" />
 187+ </p>
 188+
 189+END;
 190+
 191+ // map div
 192+ $text .= '<div id="sm_map'.$wgGoogleMapsOnThisPage.'" class="'.$class.'"></div>';
 193+
 194+ // map Javascript
 195+ global $wgLang;
 196+ $text .= <<<END
 197+<script src="http://maps.google.com/maps?file=api&v=2&key=$wgGoogleMapsKey&hl={$wgLang->getCode()}" type="$wgJsMimeType"></script>
 198+<script type="text/javascript">
 199+function showAddress(address) {
 200+ makeMap{$wgGoogleMapsOnThisPage}();
 201+ if (geocoder) {
 202+ geocoder.getLatLng(address,
 203+ function(point) {
 204+ if (!point) {
 205+ alert(address + " not found");
 206+ } else {
 207+ map.clearOverlays()
 208+ map.setCenter(point, 14);
 209+ var marker = new GMarker(point);
 210+ map.addOverlay(marker);
 211+ document.getElementById("input_$gTabIndex").value = convertLatToDMS(point.y)+', '+convertLngToDMS(point.x);
 212+ }
 213+ }
 214+ );
 215+ }
 216+}
 217+
 218+function convertLatToDMS (val) {
 219+ if (val < 0) {
 220+ return Math.abs(val) + "° " + "S";
 221+ } else {
 222+ return Math.abs(val) + "° " + "N";
 223+ }
 224+}
 225+
 226+function convertLngToDMS (val) {
 227+ if (val < 0) {
 228+ return Math.abs(val) + "° " + "W";
 229+ } else {
 230+ return Math.abs(val) + "° " + "E";
 231+ }
 232+}
 233+
 234+function addLoadEvent(func) {
 235+ var oldonload = window.onload;
 236+ if (typeof oldonload == 'function') {
 237+ window.onload = function() {
 238+ oldonload();
 239+ func();
 240+ };
 241+ } else {
 242+ window.onload = func;
 243+ }
 244+}
 245+
 246+window.unload = GUnload;
 247+</script>
 248+
 249+END;
 250+ $javascript_text = <<<END
 251+<script type="text/javascript">
 252+function makeMap{$wgGoogleMapsOnThisPage}() {
 253+ if (GBrowserIsCompatible()) {
 254+ window.map = new GMap2(document.getElementById("sm_map{$wgGoogleMapsOnThisPage}"), {size: new GSize('$width', '$height')});
 255+ geocoder = new GClientGeocoder();
 256+ map.addControl(new {$control_class}());
 257+ map.addControl(new GMapTypeControl());
 258+ map.setCenter(new GLatLng({$lat}, {$lon}), {$zoom}, {$type});
 259+
 260+END;
 261+ // show a starting marker only if a value already exists
 262+ if ($coordinates != null) {
 263+ $javascript_text .= <<<END
 264+ var point = new GLatLng({$lat}, {$lon});
 265+ var marker = new GMarker(point);
 266+ map.addOverlay(marker);
 267+
 268+END;
 269+ }
 270+ $javascript_text .= <<<END
 271+ GEvent.addListener(map, "click",
 272+ function(overlay, point) {
 273+ place = null;
 274+ if (overlay) {
 275+ map.removeOverlay (overlay);
 276+ } else {
 277+ var marker = new GMarker (point);
 278+ map.clearOverlays();
 279+ document.getElementById("input_$gTabIndex").value = convertLatToDMS(point.y)+', '+convertLngToDMS(point.x);
 280+ map.addOverlay(marker);
 281+ map.panTo(point);
 282+ }
 283+ }
 284+ );
 285+ }
 286+}
 287+addLoadEvent(makeMap{$wgGoogleMapsOnThisPage});
 288+</script>
 289+
 290+END;
 291+ // remove all newlines, to avoid wiki parsing inserting unwanted
 292+ // <p> tags within the Javascript
 293+ $javascript_text = preg_replace('/\s+/m', ' ', $javascript_text);
 294+ $text .= $javascript_text;
 295+
 296+ $output = array($text, '');
 297+ return $output;
 298+ }
 299+}
Property changes on: tags/extensions/SemanticGoogleMaps/REL_0_6_3/SGM_Utils.inc
___________________________________________________________________
Name: svn:eol-style
1300 + native

Status & tagging log