[Linpha-cvs] SF.net SVN: linpha: [4836] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <bz...@us...> - 2008-01-30 13:35:15
|
Revision: 4836 http://linpha.svn.sourceforge.net/linpha/?rev=4836&view=rev Author: bzrudi Date: 2008-01-30 05:35:12 -0800 (Wed, 30 Jan 2008) Log Message: ----------- "first try on spitting GPS geodata from images into maps plugin - expect it broken for all DB other than PostgreSQL" Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/sql/sql.mysql.php trunk/linpha2/lib/include/sql/sql.oci8po.php trunk/linpha2/lib/include/sql/sql.postgres.php trunk/linpha2/lib/include/sql/sql.sqlite.php trunk/linpha2/lib/include/sql/sql.tables.php trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php trunk/linpha2/lib/plugins/maps/module.maps.php trunk/linpha2/lib/plugins/maps/settings.maps.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/ChangeLog 2008-01-30 13:35:12 UTC (rev 4836) @@ -1,4 +1,11 @@ - +2008-01-30 bzrudi + * Split out GPS meta/geodata from meta_exif into a seperate relation within the + maps plugin. The relation is created when admin enables the maps plugin + and is called 'plugins_maps_image_geodata'. This is mostly done due to + expected performance issues and the mysql "big table" problem. + It should currently work partially with PostgresDB, other DB will follow + later. Needs "reset_database.php" to work and sys_import_use_exiftool=1 + 2008-01-29 flo * updated to latest protoype 1.6.0.2 and scriptaculous 1.8.1 * compressed javascript files with yui compresser Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -185,7 +185,8 @@ $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); - //echo '<pre>', print_r($dataArray), '</pre>'; + echo '<pre>', print_r($dataArray), '</pre>'; + $str_columns = "md5sum, "; $str_values = "'" . $md5sum . "', "; @@ -221,7 +222,6 @@ } } - /** * Simple method to return just exif date and orientation tag during * import as needed by linpha_photos, this is not used for any meta_x table. @@ -507,41 +507,7 @@ 'saturation' => 'Saturation', 'sharpness' => 'Sharpness', 'subjectdistancerange' => 'Subject Distance Range', - 'gamma' => 'Gamma', - - //GPS - 'gpsversionid' => 'GPS Version ID', - 'gpslatituderef' => 'GPS Latitude Ref', - 'gpslatitude' => 'GPS Latitude', - 'gpslongituderef' => 'GPS Longitude Ref', - 'gpslongitude' => 'GPS Longitude', - 'gpsaltituderef' => 'GPS Altitude Ref', - 'gpsaltitude' => 'GPS Altitude', - 'gpstimestamp' => 'GPS Time Stamp', - 'gpssatellites' => 'GPS Satellites', - 'gpsstatus' => 'GPS Status', - 'gpsmeasuremode' => 'GPS Measure Mode', - 'gpsdop' => 'GPS DOP', - 'gpsspeedref' => 'GPS Speed Ref', - 'gpsspeed' => 'GPS Speed', - 'gpstrackref' => 'GPS Track', - 'gpstrack' => 'GPS Track', - 'gpsimgdirectionref' => 'GPS Img Direction Ref', - 'gpsimgdirection' => 'GPS Img Direction', - 'gpsmapdatum' => 'GPS Map Datum', - 'gpsdestlatituderef' => 'GPS Dest Latitude Ref', - 'gpsdestlatitude' => 'GPS Dest Latitude', - 'gpsdestlongituderef' => 'GPS Dest Longitude Ref', - 'gpsdestlongitude' => 'GPS Dest Longitude', - 'gpsdestbearingref' => 'GPS Dest Bearing Ref', - 'gpsdestbearing' => 'GPS Dest Bearing', - 'gpsdestdistanceref' => 'GPS Dest Distance Ref', - 'gpsdestdistance' => 'GPS Dest Distance', - 'gpsprocessingmethod' => 'GPS Processing Method', - 'gpsareainformation' => 'GPS Area Information', - 'gpsdatestamp' => 'GPS Date Stamp', - 'gpsdatetime' => 'GPS Date Time', - 'gpsposition' => 'GPS Position' //not definied in exiftool!? + 'gamma' => 'Gamma' ) ); } Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -742,9 +742,10 @@ /** * This method is used to setup the initial most useful defaults for the - * MetaData tables EXIF/IPTC/XMP during creation - * @param string exif,iptc,xmp - * @return array initial metadata values used for table create + * MetaData tables EXIF/IPTC/XMP during creation and provides default + * Geodata (GPS) Tgas for the maps plugin + * @param string exif,iptc,xmp,gps + * @return array with metadata information * @author bzrudi,flo */ private function getDefaultMetaTags($type) @@ -801,6 +802,43 @@ 'supplementalcategories', ); break; + + case 'gps': + return array ( + 'gpsversionid', + 'gpslatituderef', + 'gpslatitude', + 'gpslongituderef', + 'gpslongitude', + 'gpsaltituderef', + 'gpsaltitude', + 'gpstimestamp', + 'gpssatellites', + 'gpsstatus', + 'gpsmeasuremode', + 'gpsdop', + 'gpsspeedref', + 'gpsspeed', + 'gpstrackref', + 'gpstrack', + 'gpsimgdirectionref', + 'gpsimgdirection', + 'gpsmapdatum', + 'gpsdestlatituderef', + 'gpsdestlatitude', + 'gpsdestlongituderef', + 'gpsdestlongitude', + 'gpsdestbearingref', + 'gpsdestbearing', + 'gpsdestdistanceref', + 'gpsdestdistance', + 'gpsprocessingmethod', + 'gpsareainformation', + 'gpsdatestamp', + 'gpsdatetime', + 'gpsposition', + ); + break; default: return array(); @@ -883,7 +921,67 @@ return $str; } + + /** + * Save all Image GeoData (GPS) to database. + * Used in maps plugin if enabled. We just get all information about images + * from the LIN_PREFIX.photos relation. For speed improvements a new value + * bool value "geodata" is altered to the photos relation to only parse all + * images once. + * + */ + function importGeoData() + { + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum + FROM ".LIN_PREFIX."photos + WHERE img_type <> 0 + AND img_type <> 9999999 + AND geodata <> 1 "); + + while ($data = $query->FetchRow()) + { + $filename = LinSql::getFullImagePath($data['0']); + $dataArray = $this->objMetaTool->readMetaDataFromFile('exif', $filename); + echo '<pre>', print_r($dataArray), '</pre>'; + + $str_columns = "md5sum, "; + $str_values = "'".$data['1']."', "; + + if(is_array($dataArray)) + { + /** + * Lower array data to make it compareable to $metaTags + */ + $lowerDataArray = array_change_key_case($dataArray, 'LOWER_CASE'); + + echo '<pre>', print_r($lowerDataArray), '</pre>'; + + foreach($this->getDefaultMetaTags('gps') AS $key => $value) + { + if(array_key_exists($value, $lowerDataArray)) + { + + $str_columns .= str_replace("_", "-", $value) . ', '; + $str_values .= "'".trim($lowerDataArray[$value])."', "; + } + } + /** + * Remove last two signs (the comma and the space) which we add to much + */ + $str_columns = substr($str_columns, 0, strlen($str_columns) - 2); + $str_values = substr($str_values, 0, strlen($str_values) - 2); + + $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_image_geodata " . + "(" . $str_columns . ") VALUES (" . $str_values . ")"); + + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . + "SET geodata='1' WHERE md5sum='".$data['1']."' "); + } + } + } + /** * Simple wrapper method for saveMetaData() * @param string $what meta type exif,iptc,xmp Modified: trunk/linpha2/lib/include/sql/sql.mysql.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.mysql.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.mysql.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -74,6 +74,7 @@ "stats_numbers INT NOT NULL default '0', " . "stats_views INT NOT NULL default '0', " . "stats_downloads INT NOT NULL default '0', " . + "geodata INT(1) default '0', " . "PRIMARY KEY (id) " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". Modified: trunk/linpha2/lib/include/sql/sql.oci8po.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.oci8po.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.oci8po.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -69,6 +69,7 @@ "stats_numbers NUMBER(10) DEFAULT '0', " . "stats_views NUMBER(10) DEFAULT '0', " . "stats_downloads NUMBER(10) DEFAULT '0'" . + "geodata NUMBER(1) default '0' " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". "id NUMBER PRIMARY KEY, " . Modified: trunk/linpha2/lib/include/sql/sql.postgres.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.postgres.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.postgres.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -68,7 +68,8 @@ "rotate INT NOT NULL default '0', " . "stats_numbers INT NOT NULL default '0', " . "stats_views INT NOT NULL default '0', " . - "stats_downloads INT NOT NULL default '0' " . + "stats_downloads INT NOT NULL default '0', " . + "geodata INT default '0' " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". "id SERIAL PRIMARY KEY, " . Modified: trunk/linpha2/lib/include/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.sqlite.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.sqlite.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -68,7 +68,8 @@ "rotate INTEGER NOT NULL default '0', " . "stats_numbers INTEGER NOT NULL default '0', " . "stats_views INTEGER NOT NULL default '0', " . - "stats_downloads INTEGER NOT NULL default '0' " . + "stats_downloads INTEGER NOT NULL default '0', " . + "geodata INTEGER default '0' " . ")", "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". "id INTEGER PRIMARY KEY, " . Modified: trunk/linpha2/lib/include/sql/sql.tables.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.tables.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/include/sql/sql.tables.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -17,10 +17,18 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/** - * linpha installer - */ - +if(isset($GLOBALS['linpha']->sql->config->value['plugins_maps_enable'])) +{ + // still need the plugin entries; workaround for reset_database.php + $plugins_maps_image_geodata = 'plugins_maps_image_geodata => plugins_maps_image_geodata'; + $plugins_maps_markers = 'plugins_maps_markers => plugins_maps_markers'; +} +else +{ + $plugins_maps_image_geodata = ''; + $plugins_maps_markers = ''; +} + $linpha_tables = Array( "config" => "config", "users" => "users", @@ -36,6 +44,9 @@ "meta_xmp" => "meta_xmp", "meta_comments" => "meta_comments", "meta_data" => "meta_data", - "plugins_maps_setMarkers" => "plugins_maps_markers", // still need the plugin entries; workaround for reset_database.php + "plugins_maps_image_geodata" => "plugins_maps_image_geodata", + "plugins_maps_markers" => "plugins_maps_markers", + //$plugins_maps_image_geodata."", + //$plugins_maps_markers, ); ?> Modified: trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php =================================================================== --- trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -10,9 +10,4 @@ $sql_queries[] = "INSERT INTO ".LIN_PREFIX."config (option_name, option_value, override, user_id) " . "VALUES ('plugins_filemanager_nrUploads', '0', '0', '0')"; - - -//$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . -// "VALUES ('plugins_example', ';public;')"; - -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/plugins/maps/module.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/plugins/maps/module.maps.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -1,327 +1,346 @@ -<?php -/* - * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> - * Florian Angehrn - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/** - * Google Maps - * @package Plugins - */ -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * xml load/save stuff - */ -if(isset($_GET['xml'])) -{ - if(isset($_REQUEST['cmd'])) // $_POST - { - switch($_REQUEST['cmd']) // $_POST - { - case 'loadMarkers': - - echo '{ "markers": [' . "\n"; - - $query = $GLOBALS['linpha']->db->Execute( - "SELECT id, albId, albPath, markerName, markerLat, markerLon, markerZoom " . - "FROM ".LIN_PREFIX."plugins_maps_markers" - ); - - if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) { - $allowed = true; - } else { - $allowed = false; - } - - while($data = $query->FetchRow()) - { - if( $data['albId']!=0 ) { - - $query2 = $GLOBALS['linpha']->db->Execute("SELECT P.parent_id " . - "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . - "WHERE gpslatituderef IS NOT NULL " . - "AND gpslatitude IS NOT NULL " . - "AND gpslongituderef IS NOT NULL " . - "AND gpslongitude IS NOT NULL " . - "AND P.parent_id = '".LinSql::linAddslashes($data['albId'])."'"); - if($query2->EOF) { - $type = 'album'; - } else { - $type = 'albumWithImg'; - } - - } else { - $type = 'marker'; - } - - $path = htmlspecialchars($data['albPath'],ENT_QUOTES); - - echo '{"id": '.$data['id'].', "type": "'.$type.'", "albId": '.$data['albId'].', "path": "'.$path.'", ' . - '"name": "'.htmlspecialchars($data['markerName'],ENT_QUOTES).'", ' . - '"lat": '.$data['markerLat'].', "lon": '.$data['markerLon'].', ' . - '"zoom": '.$data['markerZoom'].'}'; - - // firefox ignores the last comma, but IE produces an error! grmpf - if( !$query->EOF ) { - echo ",\n"; - } else { - echo "\n"; - } - } - - /* ?> { "markers": [ - {"id": 1, "path": "../../asd", "name": "my sweet home 1", "lat": 47.487868258751625, "lon": 9.388654232025146, "zoom": 17}, - {"id": 2, "path": "../../asd2", "name": "my sweet home 2", "lat": 47.587868258751625, "lon": 9.388654232025146, "zoom": 10}, - {"id": 3, "path": "../../asd3", "name": "my sweet home 3", "lat": 47.687868258751625, "lon": 9.388654232025146, "zoom": 15}, - ] } <?php */ - - echo '] }' . "\n"; - - break; - - case 'saveMarker': - case 'editMarker': - - header('Content-type: text/xml'); - echo '<?xml version="1.0" ?>'."\n"; - echo '<root>'."\n"; - - if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; - } - elseif( !isset($_POST['linInputMarkerName']) OR empty($_POST['linInputMarkerName'])) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.i18n("Error: no title specified").'</responseMsg>'."\n"; - } - elseif( !isset($_POST['linInputLat']) OR empty($_POST['linInputLat']) - OR !isset($_POST['linInputLon']) OR empty($_POST['linInputLon'])) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.i18n("Error: Missing Lat/Lon values").'</responseMsg>'."\n"; - } - else - { - if( !isset($_POST['linInputZoom']) OR empty($_POST['linInputZoom']) ) - { - $_POST['linInputZoom'] = $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; - } - - if( $_POST['cmd'] == 'saveMarker' ) - { - $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_markers " . - "(markerName, markerLat, markerLon, markerZoom) " . - "VALUES (" . - "'".LinSql::linAddslashes($_POST['linInputMarkerName'])."', " . - "'".floatval($_POST['linInputLat'])."', " . - "'".floatval($_POST['linInputLon'])."', " . - "'".intval($_POST['linInputZoom'])."')" - ); - } - else // edit Marker - { - if( !isset($_POST['linInputMarkerId']) OR empty($_POST['linInputMarkerId']) ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.i18n("Error: No valid marker").'</responseMsg>'."\n"; - } - } - - echo '<responseCode>success</responseCode>'."\n"; - } - - echo '</root>'."\n"; - - break; - case 'deleteMarker': - - header('Content-type: text/xml'); - echo '<?xml version="1.0" ?>'."\n"; - echo '<root>'."\n"; - - if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; - } - elseif( !isset($_REQUEST['markerId']) ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; - } - else - { - $markerId = intval($_REQUEST['markerId']); - $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."plugins_maps_markers " . - "WHERE id='".LinSql::linAddslashes($markerId)."'"); - - echo '<responseCode>success</responseCode>'."\n"; - echo '<responseData>'.$markerId.'</responseData>'."\n"; - } - - echo '</root>'."\n"; - - break; - - case 'assignAlbum': - case 'assignAlbumChange': - case 'assignAlbumDelete': - - header('Content-type: text/xml'); - echo '<?xml version="1.0" ?>'."\n"; - echo '<root>'."\n"; - - if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; - } - elseif( !isset($_REQUEST['markerId']) OR !isset($_REQUEST['albId']) ) - { - echo '<responseCode>failed</responseCode>'."\n"; - echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; - } - else - { - $markerId = intval($_REQUEST['markerId']); - $albId = intval($_REQUEST['albId']); - - $arrAlbPath = LinSql::getFullFilenameFromId($albId); - $albPath = implode('/',$arrAlbPath); - - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."plugins_maps_markers " . - "SET albId = '".LinSql::linAddslashes($albId)."', " . - "albPath = '".LinSql::linAddslashes($albPath)."' WHERE id='".LinSql::linAddslashes($markerId)."'"); - - echo '<responseCode>success</responseCode>'."\n"; - } - - echo '</root>'."\n"; - - break; - case 'loadAlbums': - - echo '{ "albums": [' . "\n"; - - $query = $GLOBALS['linpha']->db->Execute("SELECT DISTINCT P.parent_id " . - "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . - "WHERE gpslatituderef IS NOT NULL " . - "AND gpslatitude IS NOT NULL " . - "AND gpslongituderef IS NOT NULL " . - "AND gpslongitude IS NOT NULL "); - - echo '{"id": 0, "name": "'.i18n("All albums").'"},'."\n"; - - if( !$query ) - { - //echo "Error: Please enable EXIF GPS fields!"; - } - else - { - while($data = $query->FetchRow()) - { - echo '{"id": '.$data['parent_id'].', "name": "'. - htmlspecialchars( - implode( '/', LinSql::getFullFilenameFromId($data['parent_id']) ) - ,ENT_QUOTES).'"}'; - - // firefox ignores the last comma, but IE produces an error! grmpf - if( !$query->EOF ) { - echo ",\n"; - } else { - echo "\n"; - } - } - } - - echo '] }' . "\n"; - - break; - case 'loadImages': - - if( !isset($_REQUEST['albId']) ) { - break; - } - - $albId = intval($_REQUEST['albId']); - - if($albId == 0) { - $filterStr = ""; - } else { - $filterStr = "AND P.parent_id = '".$albId."'"; - } - - $query = $GLOBALS['linpha']->db->Execute("SELECT P.id, P.parent_id, P.name, gpslatituderef,gpslatitude,gpslongituderef,gpslongitude " . - "FROM ".LIN_PREFIX."meta_exif E INNER JOIN ".LIN_PREFIX."photos P on E.md5sum = P.md5sum " . - "WHERE gpslatituderef IS NOT NULL " . - "AND gpslatitude IS NOT NULL " . - "AND gpslongituderef IS NOT NULL " . - "AND gpslongitude IS NOT NULL " . - $filterStr); - - echo '{ "images": [' . "\n"; - - if( !$query ) - { - //echo "Error: Please enable EXIF GPS fields!"; - } - else - { - while($data = $query->FetchRow()) - { - $latlon = getExifLatLon($data); - - echo '{"id": '.$data['id'].', "parent_id": '.$data['parent_id'].', ' . - '"type": "images", "text": "", "name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . - '"lat": '.$latlon['gpslatitude'].', "lon": '.$latlon['gpslongitude'] . - "}"; - - // firefox ignores the last comma, but IE produces an error! grmpf - if( !$query->EOF ) { - echo ",\n"; - } else { - echo "\n"; - } - } - } - - echo '] }' . "\n"; - - break; - } - } - - exit(); -} - - -$urlFull = LINPHA_LINK.'&linCat=maps'; - -$linpha->template->setModuleName('maps'); -//$linpha->template->overrideModule('head','map'); -$linpha->template->URL_full = $urlFull; -$linpha->template->URL_base = $urlFull; -$linpha->template->output['title'] = i18n("Maps"); -include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); - - +<?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * Google Maps + * @package Plugins + */ +if(!defined('LINPHA_DIR')) { exit(1); } + + //$MetaData = new LinMetaData(); + //$MetaData->importGeoData(); +/** + * xml load/save stuff + */ +if(isset($_GET['xml'])) +{ + if(isset($_REQUEST['cmd'])) // $_POST + { + switch($_REQUEST['cmd']) // $_POST + { + case 'loadMarkers': + error_log("LOADING MARKERS",'','0'); + + echo '{ "markers": [' . "\n"; + + $query = $GLOBALS['linpha']->db->Execute( + "SELECT id, albid, albpath, markername, markerlat, markerlon, markerzoom " . + "FROM ".LIN_PREFIX."plugins_maps_markers" + ); + + if( $GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) { + $allowed = true; + } else { + $allowed = false; + } + + while($data = $query->FetchRow()) + { + if( $data['albid'] != '0' ) { + + $query2 = $GLOBALS['linpha']->db->Execute("SELECT P.parent_id " . + "FROM ".LIN_PREFIX."plugins_maps_image_geodata AS PM " . + "INNER JOIN ".LIN_PREFIX."photos P " . + "ON PM.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL " . + "AND P.parent_id = '".LinSql::linAddslashes($data['albid'])."'"); + + if($query2->EOF) { + $type = 'album'; + } else { + $type = 'albumWithImg'; + } + + } else { + $type = 'marker'; + } + + $path = htmlspecialchars($data['albpath'],ENT_QUOTES); + + echo '{"id": '.$data['id'].', "type": "'.$type.'", "albid": '.$data['albid'].', "path": "'.$path.'", ' . + '"name": "'.htmlspecialchars($data['markername'],ENT_QUOTES).'", ' . + '"lat": '.$data['markerlat'].', "lon": '.$data['markerlon'].', ' . + '"zoom": '.$data['markerzoom'].'}'; + + // firefox ignores the last comma, but IE produces an error! grmpf + if( !$query->EOF ) { + echo ",\n"; + } else { + echo "\n"; + } + } + + /* ?> { "markers": [ + {"id": 1, "path": "../../asd", "name": "my sweet home 1", "lat": 47.487868258751625, "lon": 9.388654232025146, "zoom": 17}, + {"id": 2, "path": "../../asd2", "name": "my sweet home 2", "lat": 47.587868258751625, "lon": 9.388654232025146, "zoom": 10}, + {"id": 3, "path": "../../asd3", "name": "my sweet home 3", "lat": 47.687868258751625, "lon": 9.388654232025146, "zoom": 15}, + ] } <?php */ + + echo '] }' . "\n"; + + break; + + case 'saveMarker': + + //error_log("SAVING MARKERS",'','0'); + + case 'editMarker': + + //error_log("EDITING MARKERS",'','0'); + + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; + } + elseif( !isset($_POST['linInputMarkerName']) OR empty($_POST['linInputMarkerName'])) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: no title specified").'</responseMsg>'."\n"; + } + elseif( !isset($_POST['linInputLat']) OR empty($_POST['linInputLat']) + OR !isset($_POST['linInputLon']) OR empty($_POST['linInputLon'])) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: Missing Lat/Lon values").'</responseMsg>'."\n"; + } + else + { + if( !isset($_POST['linInputZoom']) OR empty($_POST['linInputZoom']) ) + { + $_POST['linInputZoom'] = $GLOBALS['linpha']->sql->config->value['plugins_maps_defaultMarkerZoom']; + } + + if( $_POST['cmd'] == 'saveMarker' ) + { + $GLOBALS['linpha']->db->Execute("INSERT INTO ".LIN_PREFIX."plugins_maps_markers " . + "(markername, markerlat, markerlon, markerzoom) " . + "VALUES (" . + "'".LinSql::linAddslashes($_POST['linInputMarkerName'])."', " . + "'".floatval($_POST['linInputLat'])."', " . + "'".floatval($_POST['linInputLon'])."', " . + "'".intval($_POST['linInputZoom'])."')" + ); + } + else // edit Marker + { + if( !isset($_POST['linInputMarkerId']) OR empty($_POST['linInputMarkerId']) ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.i18n("Error: No valid marker").'</responseMsg>'."\n"; + } + } + + echo '<responseCode>success</responseCode>'."\n"; + } + + echo '</root>'."\n"; + + break; + case 'deleteMarker': + + //error_log("DELETING MARKERS",'','0'); + + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; + } + elseif( !isset($_REQUEST['markerId']) ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; + } + else + { + $markerId = intval($_REQUEST['markerId']); + $GLOBALS['linpha']->db->Execute("DELETE FROM ".LIN_PREFIX."plugins_maps_markers " . + "WHERE id='".LinSql::linAddslashes($markerId)."'"); + + echo '<responseCode>success</responseCode>'."\n"; + echo '<responseData>'.$markerId.'</responseData>'."\n"; + } + + echo '</root>'."\n"; + + break; + + case 'assignAlbum': + case 'assignAlbumChange': + case 'assignAlbumDelete': + + //error_log("ASSIGNING ALBUM MARKERS",'','0'); + header('Content-type: text/xml'); + echo '<?xml version="1.0" ?>'."\n"; + echo '<root>'."\n"; + + if( !$GLOBALS['linpha']->sql->checkPermission('plugins_maps_setMarkers') ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_ACCESSDENIED.'</responseMsg>'."\n"; + } + elseif( !isset($_REQUEST['markerId']) OR !isset($_REQUEST['albId']) ) + { + echo '<responseCode>failed</responseCode>'."\n"; + echo '<responseMsg>'.LIN_STR_NOVALIDDATA.'</responseMsg>'."\n"; + } + else + { + $markerId = intval($_REQUEST['markerId']); + $albid = intval($_REQUEST['albId']); + + $arralbpath = LinSql::getFullFilenameFromId($albid); + $albpath = implode('/',$arralbpath); + + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."plugins_maps_markers " . + "SET albid = '".LinSql::linAddslashes($albid)."', " . + "albpath = '".LinSql::linAddslashes($albpath)."' " . + "WHERE id='".LinSql::linAddslashes($markerId)."'"); + + echo '<responseCode>success</responseCode>'."\n"; + } + + echo '</root>'."\n"; + + break; + case 'loadAlbums': + + //error_log("LOADING ALBUMS",'','0'); + echo '{ "albums": [' . "\n"; + + $query = $GLOBALS['linpha']->db->Execute("SELECT DISTINCT P.parent_id " . + "FROM ".LIN_PREFIX."plugins_maps_image_geodata AS PM " . + "INNER JOIN ".LIN_PREFIX."photos P on PM.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL "); + + echo '{"id": 0, "name": "'.i18n("All albums").'"},'."\n"; + + if( !$query ) + { + //echo "Error: Please enable EXIF GPS fields!"; + } + else + { + while($data = $query->FetchRow()) + { + echo '{"id": '.$data['parent_id'].', "name": "'. + htmlspecialchars( + implode( '/', LinSql::getFullFilenameFromId($data['parent_id']) ) + ,ENT_QUOTES).'"}'; + + // firefox ignores the last comma, but IE produces an error! grmpf + if( !$query->EOF ) { + echo ",\n"; + } else { + echo "\n"; + } + } + } + + echo '] }' . "\n"; + + break; + case 'loadImages': + +// error_log("LOADING IMAGES",'','0'); + if( !isset($_REQUEST['albId']) ) { + break; + } + + $albid = intval($_REQUEST['albId']); + + if($albid == 0) { + $filterStr = ""; + } else { + $filterStr = "AND P.parent_id = '".$albid."'"; + } + + $query = $GLOBALS['linpha']->db->Execute("SELECT P.id, P.parent_id, " . + "P.name, gpslatituderef, gpslatitude, gpslongituderef, gpslongitude " . + "FROM ".LIN_PREFIX."plugins_maps_image_geodata PM " . + "INNER JOIN ".LIN_PREFIX."photos P on PM.md5sum = P.md5sum " . + "WHERE gpslatituderef IS NOT NULL " . + "AND gpslatitude IS NOT NULL " . + "AND gpslongituderef IS NOT NULL " . + "AND gpslongitude IS NOT NULL " . + $filterStr); + + echo '{ "images": [' . "\n"; + + if( $query->EOF ) + { + error_log("Error: Please enable EXIF GPS fields!",'',0); + } + else + { + while($data = $query->FetchRow()) + { + $latlon = getExifLatLon($data); + echo '{"id": '.$data['id'].', "parent_id": '.$data['parent_id'].', ' . + '"type": "images", "text": "", "name": "'.htmlspecialchars( $data['name'] ,ENT_QUOTES).'", ' . + '"lat": '.$latlon['gpslatitude'].', "lon": '.$latlon['gpslongitude'] . + "}"; + + // firefox ignores the last comma, but IE produces an error! grmpf + if( !$query->EOF ) { + echo ",\n"; + } else { + echo "\n"; + } + } + } + + echo '] }' . "\n"; + + break; + } + } + + exit(); +} + + +$urlFull = LINPHA_LINK.'&linCat=maps'; + +$linpha->template->setModuleName('maps'); +//$linpha->template->overrideModule('head','map'); +$linpha->template->URL_full = $urlFull; +$linpha->template->URL_base = $urlFull; +$linpha->template->output['title'] = i18n("Maps"); +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); + + function getExifLatLon(&$LatLon) { /*Array PJMT @@ -377,4 +396,4 @@ } return $return; } -?> \ No newline at end of file +?> Modified: trunk/linpha2/lib/plugins/maps/settings.maps.php =================================================================== --- trunk/linpha2/lib/plugins/maps/settings.maps.php 2008-01-30 12:59:00 UTC (rev 4835) +++ trunk/linpha2/lib/plugins/maps/settings.maps.php 2008-01-30 13:35:12 UTC (rev 4836) @@ -1,81 +1,90 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/** - * Settings for the admin section - * @package admin - */ - -if(!defined('LINPHA_DIR')) { exit(1); } - -echo '<a href="./?cat=permissions_plugins_maps_setMarkers">'.i18n("Set Edit Permissions For The Map Marker").'</a><br /><br />'; - - - -/** - * save settings - */ - if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') - { - $LinAdmin->saveConfig(Array( - 'plugins_maps_defaultMarkerZoom', - 'plugins_maps_mapType', - 'plugins_maps_google_key', - 'plugins_maps_markerThumbSize', - )); - } - -/** - * print options - */ -$LinAdmin->printAdminConfig( - 'text', - i18n("Default Zoom Level For Markers"), - 'plugins_maps_defaultMarkerZoom', - $LinAdmin->option_value_system['plugins_maps_defaultMarkerZoom'] -); -$LinAdmin->printAdminConfig( - 'text', - i18n("Marker Thumbnail Size"), - 'plugins_maps_markerThumbSize', - $LinAdmin->option_value_system['plugins_maps_markerThumbSize'] -); - -echo '<br /><br />'; - -$LinAdmin->printAdminConfig( - 'select', - i18n("Map Provider (Currently only google is implemented)"), - 'plugins_maps_mapType', - $LinAdmin->option_value_system['plugins_maps_mapType'], - array('options' => array('google','yahoo','openstreetmap')) -); -$LinAdmin->printAdminConfig( - 'text', - i18n("Key For Google Maps"), - 'plugins_maps_google_key', - $LinAdmin->option_value_system['plugins_maps_google_key'] -); -echo '<a href="http://code.google.com/apis/maps/signup.html">'.i18n("Sign Up for the Google Maps API Key").'</a><br />'; -echo i18n("The default key is only valid for the domain http://localhost").'<br /><br />'; - - - -?> \ No newline at end of file +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Settings for the admin section + * @package admin + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +echo '<a href="./?cat=permissions_plugins_maps_setMarkers">'.i18n("Set Edit Permissions For The Map Marker").'</a><br /><br />'; + + + +/** + * save settings + */ + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + $LinAdmin->saveConfig(Array( + 'plugins_maps_defaultMarkerZoom', + 'plugins_maps_mapType', + 'plugins_maps_google_key', + 'plugins_maps_markerThumbSize', + 'plugins_maps_enable_geotagged', + + )); + } + +/** + * print options + */ +$LinAdmin->printAdminConfig( + 'text', + i18n("Default Zoom Level For Markers"), + 'plugins_maps_defaultMarkerZoom', + $LinAdmin->option_value_system['plugins_maps_defaultMarkerZoom'] +); +$LinAdmin->printAdminConfig( + 'text', + i18n("Marker Thumbnail Size"), + 'plugins_maps_markerThumbSize', + $LinAdmin->option_value_system['plugins_maps_markerThumbSize'] +); + +echo '<br /><br />'; + +$LinAdmin->printAdminConfig( + 'select', + i18n("Map Provider (Currently only google is implemented)"), + 'plugins_maps_mapType', + $LinAdmin->option_value_system['plugins_maps_mapType'], + array('options' => array('google','yahoo','openstreetmap')) +); +$LinAdmin->printAdminConfig( + 'text', + i18n("Key For Google Maps"), + 'plugins_maps_google_key', + $LinAdmin->option_value_system['plugins_maps_google_key'] +); + +echo '<a href="http://code.google.com/apis/maps/signup.html">'.i18n("Sign Up for the Google Maps API Key").'</a><br />'; +echo i18n("The default key is only valid for the domain http://localhost").'<br /><br />'; + +$LinAdmin->printAdminConfig( + 'radio', + i18n("Enable Support For Geotagged Images"), + 'plugins_maps_enable_geotagged', + $LinAdmin->option_value_system['plugins_maps_enable_geotagged'] +); + + +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |