diff --git a/GeolocationPlugin.php b/GeolocationPlugin.php
index d766e0d..ab78045 100644
--- a/GeolocationPlugin.php
+++ b/GeolocationPlugin.php
@@ -81,6 +81,10 @@ public function hookInstall()
set_option('geolocation_per_page', GEOLOCATION_DEFAULT_LOCATIONS_PER_PAGE);
set_option('geolocation_add_map_to_contribution_form', '1');
set_option('geolocation_use_metric_distances', '1');
+ set_option('geolocation_default_loc_set', 'Dublin Core');
+ set_option('geolocation_default_loc_field', 'Coverage');
+ set_option('geolocation_use_in_import','0');
+ set_option('geolocation_use_coordinates','0');
}
public function hookUninstall()
@@ -92,10 +96,18 @@ public function hookUninstall()
delete_option('geolocation_per_page');
delete_option('geolocation_add_map_to_contribution_form');
delete_option('geolocation_use_metric_distances');
+ delete_option('geolocation_use_coordinates');
// This is for older versions of Geolocation, which used to store a Google Map API key.
delete_option('geolocation_gmaps_key');
+ // CSV import Geolocation support
+
+ delete_option('geolocation_default_loc_set');
+ delete_option('geolocation_default_loc_field');
+ delete_option('geolocation_use_in_import');
+
+
// Drop the Location table
$db = get_db();
$db->query("DROP TABLE IF EXISTS `$db->Location`");
@@ -136,6 +148,11 @@ public function hookConfig($args)
set_option('geolocation_link_to_nav', $_POST['geolocation_link_to_nav']);
set_option('geolocation_use_metric_distances', $_POST['geolocation_use_metric_distances']);
set_option('geolocation_map_type', $_POST['map_type']);
+ set_option('geolocation_default_loc_set', $_POST['geolocation_default_loc_set']);
+ set_option('geolocation_default_loc_field', $_POST['geolocation_default_loc_field']);
+ set_option('geolocation_use_in_import', $_POST['geolocation_use_in_import']);
+ set_option('geolocation_use_coordinates',$_POST['geolocation_use_coordinates']);
+
}
public function hookDefineAcl($args)
@@ -169,13 +186,28 @@ public function hookDefineRoutes($args)
public function hookAfterSaveItem($args)
{
- if (!($post = $args['post'])) {
- return;
+ // Let's check if there's CSV import process going on and are we willing to use
+ // Geolocation in current import
+ $db = Zend_Registry::get('bootstrap')->getResource('db');
+ $table = $db->getTable('CsvImport_Import');
+ $sql = $table->getSelectForCount()->where('`status` = ?');
+ $importInProgress = $db->fetchOne($sql, 'in_progress');
+ $useCoords = get_option('geolocation_use_in_import');
+ if ($importInProgress && $useCoords ) {
+ $geolocation_with_csv = true;
+ $item = $args['record'];
+ $coordinates_or_address = metadata($item, array(get_option('geolocation_default_loc_set'), get_option('geolocation_default_loc_field')));
+ debug(array(get_option('geolocation_default_loc_set'), get_option('geolocation_default_loc_field')));
+
+ }
+
+ if (!($post = $args['post']) && !($geolocation_with_csv)) {
+ return;
}
$item = $args['record'];
// If we don't have the geolocation form on the page, don't do anything!
- if (!$post['geolocation']) {
+ if (!$post['geolocation'] && !($geolocation_with_csv)) {
return;
}
@@ -194,9 +226,66 @@ public function hookAfterSaveItem($args)
}
$location->setPostData($geolocationPost);
$location->save();
- // If the form is empty, then we want to delete whatever location is
- // currently stored
- } else {
+
+ } elseif ($geolocation_with_csv && !empty($coordinates_or_address)){
+ $coordinates_or_address = metadata($item, array(get_option('geolocation_default_loc_set'), get_option('geolocation_default_loc_field')));
+ if (get_option('geolocation_use_coordinates')) {
+ $rawCoordinates = explode(',', $coordinates_or_address);
+ $latitude = substr($rawCoordinates[0],4);
+ $longitude = substr($rawCoordinates[1],0,-1);
+ $location = new Location; // Create new location object for this new item
+ $location->item_id = $item->id;
+ $location->latitude = $latitude;
+ $location->longitude = $longitude;
+ $location->address = $latitude .'.'.$longitude;
+ $location->zoom_level = get_option('geolocation_default_zoom_level'); // use the default zoom level
+ $location->map_type = "Google Maps v".GOOGLE_MAPS_API_VERSION;
+ $location->save();
+ }
+ else {
+ try {
+ // Get the value of the default location element of this item.
+ $address = metadata($item, array(get_option('geolocation_default_loc_set'), get_option('geolocation_default_loc_field')));
+
+ if ($address != "") {
+ // Make a request to the Google Geocoding API
+ $client = new Zend_Http_Client('http://maps.googleapis.com/maps/api/geocode/xml?address='.urlencode($address).'&sensor=false');
+ $response = $client->request();
+
+ if ($response->isSuccessful()) {
+ $body = $response->getBody();
+ $data = simplexml_load_string($body);
+
+ if ($data->status == "OK") {
+ $lat = $data->result->geometry->location->lat;
+ $lng = $data->result->geometry->location->lng;
+ // Get lat and lng from XML results
+
+ $location = new Location; // Create new location object for this new item
+ $location->item_id = $item->id;
+ $location->latitude = $lat;
+ $location->longitude = $lng;
+ $location->address = $address;
+ $location->zoom_level = get_option('geolocation_default_zoom_level'); // use the default zoom level
+ $location->map_type = "Google Maps v".GOOGLE_MAPS_API_VERSION;
+
+ $location->save();
+ }
+ }
+ }
+ } catch (Exception $e) {
+ // Invalid field for this item, or some other issue. So, just don't do anything.
+ }
+
+ }
+
+ }
+
+
+ // If the form is empty, then we want to delete whatever location is
+ // currently stored
+
+ else {
if ($location) {
$location->delete();
}
@@ -257,7 +346,7 @@ public function hookPublicItemsShow($args)
$width = get_option('geolocation_item_map_width') ? get_option('geolocation_item_map_width') : '';
$height = get_option('geolocation_item_map_height') ? get_option('geolocation_item_map_height') : '300px';
$html = "
";
- $html .= '
Geolocation
';
+ $html .= ''.__('Geolocation').'
';
$html .= $view->itemGoogleMap($item, $width, $height);
$html .= "";
echo $html;
diff --git a/config_form.php b/config_form.php
index 1235b7c..8edff7f 100644
--- a/config_form.php
+++ b/config_form.php
@@ -130,3 +130,49 @@
+
+
+
+
+
+
diff --git a/languages/fi_FI.mo b/languages/fi_FI.mo
index 4de2c03..502a523 100644
Binary files a/languages/fi_FI.mo and b/languages/fi_FI.mo differ
diff --git a/languages/fi_FI.po b/languages/fi_FI.po
index fe2f824..9934271 100644
--- a/languages/fi_FI.po
+++ b/languages/fi_FI.po
@@ -1,7 +1,7 @@
# Translation for the Geolocation plugin for Omeka.
# Copyright (C) 2011 Roy Rosenzweig Center for History and New Media
# This file is distributed under the same license as the Omeka package.
-#
+#
# Translators:
# Matti Lassila , 2013
msgid ""
@@ -9,20 +9,26 @@ msgstr ""
"Project-Id-Version: Omeka\n"
"Report-Msgid-Bugs-To: http://github.com/omeka/plugin-Geolocation/issues\n"
"POT-Creation-Date: 2012-01-09 21:49-0500\n"
-"PO-Revision-Date: 2013-06-09 08:34+0000\n"
+"PO-Revision-Date: 2014-06-03 21:08+0200\n"
"Last-Translator: Matti Lassila \n"
-"Language-Team: Finnish (Finland) (http://www.transifex.com/projects/p/omeka/language/fi_FI/)\n"
+"Language-Team: Finnish (Finland) (http://www.transifex.com/projects/p/omeka/"
+"language/fi_FI/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: fi_FI\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Poedit 1.5.7\n"
#: GeolocationPlugin.php:334 GeolocationPlugin.php:340
#: GeolocationPlugin.php:364
msgid "Map"
msgstr "Kartta"
+#: GeolocationPlugin.php:349
+msgid "Geolocation"
+msgstr "Kartta"
+
#: GeolocationPlugin.php:373 views/public/map/browse.php:23
msgid "Browse Map"
msgstr "Selaa karttaa"
@@ -47,7 +53,8 @@ msgstr "Sijainteja sivua kohti"
msgid ""
"The number of locations displayed per page when browsing the map. (Maximum "
"is "
-msgstr "Kerralla näytettyjen sijaintien määrä karttaselausnäkymässä. (Enimmäismäärä "
+msgstr ""
+"Kerralla näytettyjen sijaintien määrä karttaselausnäkymässä. (Enimmäismäärä "
#: config_form.php:16
msgid "Default Latitude"
@@ -57,7 +64,9 @@ msgstr "Pohjoiskoordinaatti"
msgid ""
"Latitude of the map's initial center point, in degrees. Must be between -90 "
"and 90."
-msgstr "Kartan aloitusnäkymän koordinaattikeskipiste asteina. Arvon tulee olla välillä -90 ja 90."
+msgstr ""
+"Kartan aloitusnäkymän koordinaattikeskipiste asteina. Arvon tulee olla "
+"välillä -90 ja 90."
#: config_form.php:28
msgid "Default Longitude"
@@ -67,7 +76,9 @@ msgstr "Itäkoordinaatti"
msgid ""
"Longitude of the map's initial center point, in degrees. Must be between "
"-180 and 180."
-msgstr "Kartan aloitusnäkymän koordinaattikeskipiste asteina. Arvon tulee olla välillä -180 ja 180."
+msgstr ""
+"Kartan aloitusnäkymän koordinaattikeskipiste asteina. Arvon tulee olla "
+"välillä -180 ja 180."
#: config_form.php:40
msgid "Default Zoom Level"
@@ -77,17 +88,46 @@ msgstr "Zoomausaste"
msgid ""
"An integer greater than or equal to 0, where 0 represents the most zoomed "
"out scale."
-msgstr "Aloitusnäkymän zoomausaste. Arvon tulee olla nolla tai sitä suurempi kokonaisluku. Arvolla nolla kartta on zoomattu kauimpaan asetukseensa."
+msgstr ""
+"Aloitusnäkymän zoomausaste. Arvon tulee olla välillä 0-18. Arvolla nolla "
+"kartta on zoomattu kauimpaan asetukseensa. Mitä suurempi luku, sen "
+"yksityiskohtaisempi kartta näytetään."
#: config_form.php:52
msgid "Width for Item Map"
msgstr "Aineistonäkymän kartan leveys"
+#: config_form.php:52
+msgid "Map Type"
+msgstr "Kartan tyyppi"
+
+#: config_form.php:52
+msgid "The type of map to display"
+msgstr "Karttanäkymän karttatyyppi"
+
+#: config_form.php:52
+msgid "Roadmap"
+msgstr "Maantiekartta"
+
+#: config_form.php:52
+msgid "Satellite"
+msgstr "Ilmakuva"
+
+#: config_form.php:52
+msgid "Hybrid"
+msgstr "Yhdistelmä"
+
+#: config_form.php:52
+msgid "Terrain"
+msgstr "Maasto"
+
#: config_form.php:55
msgid ""
"The width of the map displayed on your items/show page. If left blank, the "
"default width of 100% will be used."
-msgstr "Karttanäkymän leveys aineistosivulla. Oletuksena kartta näytetään sivupohjan suhteen täysleveänä (100%)."
+msgstr ""
+"Karttanäkymän leveys aineistosivulla. Oletuksena kartta näytetään sivupohjan "
+"suhteen täysleveänä (100%)."
#: config_form.php:64
msgid "Height for Item Map"
@@ -105,7 +145,9 @@ msgstr "Käytä mittayksikkönä kilometrejä"
#: config_form.php:79
msgid "Use metric distances in proximity search."
-msgstr "Käytä läheisyyteen perustuvassa haussa yksikkönä kilometrejä. Oletuksena mittayksikkö on maili."
+msgstr ""
+"Käytä läheisyyteen perustuvassa haussa yksikkönä kilometrejä. Oletuksena "
+"mittayksikkö on maili."
#: config_form.php:89
msgid "Add Link to Map on Items/Browse Navigation"
@@ -121,10 +163,46 @@ msgstr "Lisää kartta julkiselle tallennuslomakkeelle"
#: config_form.php:106
msgid ""
-"If the Contribution plugin is installed and activated, Geolocation will add"
-" a geolocation map field to the contribution form to associate a location to"
-" a contributed item."
-msgstr "Jos Contribution-lisäosa on asennettuna, julkisella tallennuslomakkeella voidaan näyttää karttanäkymä sijaintitietoa varten."
+"If the Contribution plugin is installed and activated, Geolocation will add "
+"a geolocation map field to the contribution form to associate a location to "
+"a contributed item."
+msgstr ""
+"Jos Contribution-lisäosa on asennettuna, julkisella tallennuslomakkeella "
+"voidaan näyttää karttanäkymä sijaintitietoa varten."
+
+#: config_form.php:136
+msgid "Use Geolocation in CSV import"
+msgstr "Käytä sijaintitietoja CSV-tuonnissa"
+
+#: config_form.php:139
+msgid "Geolocate items during CSV import."
+msgstr ""
+"Lisää aineistoihin sijaintitiedot CSV-taulukkoon tallennetun paikan nimen "
+"tai koordinaatin perusteella."
+
+#: config_form.php:149
+msgid "Location field"
+msgstr "Sijaintitietokenttä"
+
+#: config_form.php:163
+msgid ""
+"The location of new items will automatically be set to the position in this "
+"field."
+msgstr ""
+"Aineistojen sijainniksi määritetään kentässä annettu koordinaattipiste tai "
+"paikannimi."
+
+#: config_form.php:169
+msgid "Use WGS84 coordinates"
+msgstr "Käytä WGS84 koordinaatteja"
+
+#: config_form.php:172
+msgid ""
+"Instead of address or place name, the location field contains WGS84-"
+"coordinates saved in format POS(68.073611,29.315278)."
+msgstr ""
+"Sijaintitietokenttä sisältää WGS84-koordinaatin tallennettuna muodossa POS"
+"(68.073611,29.315278)."
#: helpers/ItemGoogleMap.php:47
msgid "This item has no location info associated with it."