Index: /extensions/edit_gmaps/admin/admin.php
===================================================================
--- /extensions/edit_gmaps/admin/admin.php (revision 9411)
+++ /extensions/edit_gmaps/admin/admin.php (revision 9412)
@@ -4,9 +4,22 @@
$colonnes = cl_get_columns_of(IMAGES_TABLE);
+
+$key = array_search('lon', $colonnes[IMAGES_TABLE]);
+if (!$key){
+ $q = 'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `lon` DOUBLE(9,6)';
+ pwg_query($q);
+}
+$key = array_search('lat', $colonnes[IMAGES_TABLE]);
+if (!$key){
+ $q = 'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `lat` DOUBLE(9,6)';
+ pwg_query($q);
+}
$key = array_search('alt', $colonnes[IMAGES_TABLE]);
if (!$key){
$q = 'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `alt` DOUBLE(9,6)';
pwg_query($q);
-}
+}
+
+
/**
* list all columns of each given table
Index: /extensions/edit_gmaps/admin/admin_edit.php
===================================================================
--- /extensions/edit_gmaps/admin/admin_edit.php (revision 9411)
+++ /extensions/edit_gmaps/admin/admin_edit.php (revision 9412)
@@ -4,6 +4,4 @@
load_language('lang', dirname(__FILE__).'/../');
$admin_url = PHPWG_ROOT_PATH.'admin.php';
-
-
if ( !isset($_GET['cat']) ) $_GET['cat'] = 'caddie';
@@ -20,5 +18,5 @@
/***********************************************************************************/
- if (!defined('TOOL_KIT_PATH')) define( 'TOOL_KIT_PATH', EDIT_RV_PATH."admin/");
+ if (!defined('TOOL_KIT_PATH')) define( 'TOOL_KIT_PATH', EDIT_CL_PATH."admin/");
if (!defined('INCLUDE_PATH')) define( 'INCLUDE_PATH', TOOL_KIT_PATH.'include/' );
$Toolkit_Dir =INCLUDE_PATH ;
@@ -29,69 +27,152 @@
$template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']);
-
-
-if ( isset($_POST['submit']) )
-{
- $collection = array();
- if( !isset ($_POST['target']))
- {
- $_POST['submit'] == l10n('Submit') ;
- $_POST['target']='selection';
- $collection = $_POST['selection'];
-
- }
-
- switch ($_POST['target'])
- {
- case 'all' :
- $collection = $page['cat_elements_id'];
- break;
- case 'selection' :
- if (!isset($_POST['selection']) or count($_POST['selection']) == 0)
- array_push($page['errors'], l10n('Select at least one picture'));
- else
- $collection = $_POST['selection'];
- break;
- }
-
- // test si mise à jour (valider)
- if ( isset($_POST['submit']) and $_POST['submit'] == l10n('Submit') )
- {
- if ( count($collection)>0 )
- {
- $lat = trim($_POST['lat']);
- $lon = trim($_POST['lon']);
- $alt = trim($_POST['alt']);
+$info_message="" ;
+$error_message="";
+
+/************* Mise à jour des meta données ***************/
+if ( isset($_POST['update']) && $_POST['update']==l10n('update_exif'))
+{
+ $exif = @read_exif_data( $exif );
+ $exif = @array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
+
+ // error_reporting ( 0 );
+ // Hide any unknown EXIF tags
+ $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE;
+ include $Toolkit_Dir.'Toolkit_Version.php'; // Change: added as of version 1.11
+ // Include the required files for reading and writing Photoshop File Info
+ include $Toolkit_Dir.'JPEG.php';
+ include $Toolkit_Dir.'XMP.php';
+ include $Toolkit_Dir.'Photoshop_IRB.php';
+ include $Toolkit_Dir.'EXIF.php';
+ include $Toolkit_Dir.'GPS_File_Info.php';
+ $GLOBALS['HTTP_POST_VARS']=$_POST ;
+ // Copy all of the HTML Posted variables into an array
+ $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS'];
+ // Some characters are escaped with backslashes in HTML Posted variable
+ // Cycle through each of the HTML Posted variables, and strip out the slashes '
+ foreach( $new_ps_file_info_array as $var_key => $var_val ){
+ if ($var_key !="selection")
+ $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val );
+
+ }
+ $new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']);
+ foreach( $new_ps_file_info_array['selection'] as $filename ) {
+ //======================================================
+ //= $new_ps_file_info_array[ 'filename' ];
+ if($filename!="")
+ { // Protect against hackers editing other files
+
+ // copy( $filename, $filename.".bak" );
+ $path_parts = pathinfo( $filename );
+ if(1) {
+ if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 )
+ {
+ $error_message .= $filename ;
+ $error_message .="Incorrect File Type - JPEG Only\n";
+ $filename="";
+ // exit( );
+ }
+ // Change: removed limitation on file being in current directory - as of version 1.11
+ // Retrieve the header information
+ $jpeg_header_data = get_jpeg_header_data( $filename );
+ // Retreive the EXIF, XMP and Photoshop IRB information from
+ // the existing file, so that it can be updated
+ $Exif_array = get_EXIF_JPEG( $filename );
+ $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) );
+ $IRB_array = get_Photoshop_IRB( $jpeg_header_data );
+
+ // Update the JPEG header information with the new Photoshop File Info
+ $jpeg_header_data = put_GPS_file_info( $jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array );
+ // Check if the Update worked
+ if ( $jpeg_header_data == FALSE ) {
+ // Update of file info didn''t work - output error message
+ $error_message .= "jpeg_header_data
+ Error - Failure update Photoshop File Info : $filename
\n";
+
+ // Output HTML with the form and data which was
+ // sent, to allow the user to fix it
+
+ }else if ( FALSE == put_jpeg_header_data( $filename, $filename, $jpeg_header_data ) )
+ {// Attempt to write the new JPEG file
+ // Writing of the new file didn''t work - output error message
+ $error_message .= "Error - Failure to write new JPEG : $filename
\n";
+
+ // Output HTML with the form and data which was
+ // sent, to allow the user to fix it
+
+ }else{
+ $info_message .= l10n('update') . " Exif: " . $filename . " " . l10n('OK') ."
" ;
+
+ }
+ $_POST['submit']= l10n('update_database') ;
+ }
+ }
+ }
+ //================================================
+ $_POST['update'] ="ok";
+ }
+
+
+ if ( isset($_POST['submit']) ) {
+ $collection = array();
+ if( !isset ($_POST['target'])) {
+ $_POST['submit'] = l10n('Submit') ;
+ $_POST['target']='selection';
+ $collection = $_POST['selection'];
+ }
+
+ switch ($_POST['target'])
+ {
+ case 'all' :
+ $collection = $page['cat_elements_id'];
+ break;
+ case 'selection' :
+ if (!isset($_POST['selection']) or count($_POST['selection']) == 0)
+ array_push($page['errors'], l10n('Select at least one picture'));
+ else
+ $collection = $_POST['selection'];
+ break;
+ }
+
+ /******** Mise à jour base de données *****/
+ if ( $_POST['submit'] == l10n('update_database') )
+ {
+ if ( count($collection)>0 )
+ {
+ $lat = trim($_POST['lat']);
+ $lon = trim($_POST['lon']);
+ $alt = trim($_POST['alt']);
- if ( strlen($lat)>0 and strlen($lon)>0 )
- {
- if ( (double)$lat<=90 and (double)$lat>=-90
- and (double)$lon<=180 and (double)$lat>=-180 )
- $update_query = 'lat='.$lat.', lon='.$lon;
- else
- $page['errors'][] = 'Invalid lat or lon value';
- }
- elseif ( strlen($lat)==0 and strlen($lon)==0 )
- $update_query = 'lat=NULL, lon=NULL';
- else
- $page['errors'][] = 'Both lat/lon must be empty or not empty';
-
- if ( strlen($alt)==0)
- $update_query .= ', alt=NULL';
- else
- $update_query .= ', alt=' .$alt ;
-
-
-
- if (isset($update_query))
- {
- $update_query = '
- UPDATE '.IMAGES_TABLE.' SET '.$update_query.'
- WHERE id IN ('.implode(',',$collection).')';
- pwg_query($update_query);
- cl_meta_invalidate_cache();
- }
- }
- }
+ if ( strlen($lat)>0 and strlen($lon)>0 )
+ {
+ if ( (double)$lat<=90 and (double)$lat>=-90
+ and (double)$lon<=180 and (double)$lat>=-180 )
+ $update_query = 'lat='.$lat.', lon='.$lon;
+ else
+ $page['errors'][] = 'Invalid lat or lon value';
+ }
+ elseif ( strlen($lat)==0 and strlen($lon)==0 )
+ $update_query = 'lat=NULL, lon=NULL';
+ else
+ $page['errors'][] = 'Both lat/lon must be empty or not empty';
+
+ if ( strlen($alt)==0)
+ $update_query .= ', alt=NULL';
+ else
+ $update_query .= ', alt=' .$alt ;
+
+ if (isset($update_query))
+ {
+ $update_query = '
+ UPDATE '.IMAGES_TABLE.' SET '.$update_query.'
+ WHERE id IN ('.implode(',',$collection).')';
+ pwg_query($update_query);
+ cl_meta_invalidate_cache();
+ $info_message .= l10n('update') . " " . IMAGES_TABLE . " : " . l10n('OK') ;
+ $_POST['submit'] = l10n('Submit') ;
+ }
+
+ }
+ }
}
@@ -180,19 +261,19 @@
//==========================================================
- if (!defined('EDIT_RV_PATH')) define( 'EDIT_RV_PATH', EDIT_RV_PATH .'admin/' );
- $path = EDIT_RV_PATH;
+ if (!defined('EDIT_CL_PATH')) define( 'EDIT_CL_PATH', EDIT_CL_PATH .'admin/' );
+ $path = EDIT_CL_PATH;
$plg_data = implode( '', file($path.'main.inc.php') );
if (preg_match("|Version: (.*)|", $plg_data, $val))
- { $EDIT_RV_PATH_plugin['version'] = trim($val[1]); }
- $EDIT_RV_PATH_plugin = array_map('htmlspecialchars', $EDIT_RV_PATH_plugin);
- $version= $EDIT_RV_PATH_plugin['version'] ;
+ { $EDIT_CL_PATH_plugin['version'] = trim($val[1]); }
+ $EDIT_CL_PATH_plugin = array_map('htmlspecialchars', $EDIT_CL_PATH_plugin);
+ $version= $EDIT_CL_PATH_plugin['version'] ;
$icon_path = 'themes/default/icon/help.png';
$path_js= 'themes/default/js/' ;
//==================================================================================
-$match="";
+$match="";
+
if ( isset($_POST['submit']) )
{
-
if ($_POST['submit']==l10n('Submit') )
{
@@ -209,55 +290,48 @@
}
-
}
//=================================================================================
$src="";
+
$template->assign(
- array( 'EDIT_RV_PATH' => EDIT_RV_PATH,
+ array( 'EDIT_CL_PATH' => EDIT_CL_PATH,
'path_js' => $path_js,
'VERSION'=> $version,
- 'EDIT_RV_PATH_ABS' => dirname(__FILE__).'/',
+ 'EDIT_CL_PATH_ABS' => dirname(__FILE__).'/',
)
);
global $lang_info;
-if (date_default_timezone_get()) { $adresse = date_default_timezone_get() ;}
-else{
-
-}
-$adresse = $lang_info['country']; ;
-$adresse=str_replace("/",", ",$adresse);
-$template->assign( 'coordinates',
- array('LAT' => '100',
- 'LON' => '100',
- 'ADRESSE' => $adresse,
- 'ZOOM' => 18,
- 'ALT' => 0
- )
- );
- $filename ="";
+ if (date_default_timezone_get()) {
+ $adresse = date_default_timezone_get() ;
+ }else{
+
+ }
+ $adresse = $lang_info['country']; ;
+ $adresse=str_replace("/",", ",$adresse);
+ $template->assign( 'coordinates',
+ array( 'FILE' => '',
+ 'LAT' => '100',
+ 'LON' => '100',
+ 'ADRESSE' => $adresse,
+ 'ZOOM' => 18,
+ 'ALT' => 0
+ )
+ );
if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
{
if (isset($collection))
- { $lat =1000;
+ { $lat =1000;$first_image="";
+
foreach ($collection as $id_0) {
foreach ($images as $image) {
if (array_search($id_0,$image)) {
$_POST['selection'] = $collection ;
-
- $infos_gps= Get_exif_gps( $image['path'],$image) ;
- if( $image['lat'] == ''){
- $image['lat']=$infos_gps['lat'];
- $image['lon']=$infos_gps['lon'];
- $image['alt']=$infos_gps['alt'];
- }else {
- $image['lat']=$infos_gps['lat'];
- $image['lon']=$infos_gps['lon'];
- $image['alt']=$infos_gps['alt'];
- }
- $filename= $image;
-
-
- if ($lat==1000) {
+ $infos_gps= Get_exif_gps( $image['path'],$image) ;
+ $image['lat']=$infos_gps['lat'];
+ $image['lon']=$infos_gps['lon'];
+ $image['alt']=$infos_gps['alt'];
+
+ if ($lat==1000) {
$lat= ($image['lat'] <> '') ? $image['lat'] : '100' ;
$lon= ($image['lon'] <> '') ? $image['lon'] : '3.0' ;
@@ -266,5 +340,6 @@
//=====================================================
$template->assign( 'coordinates',
- array('LAT' => $lat ,
+ array('FILE' => $image['path'],
+ 'LAT' => $lat ,
'LON' => $lon ,
'ADRESSE' => $adresse ,
@@ -274,19 +349,23 @@
);
}
+
+ $lon=$image['lon'];
+ $lat=$image['lat'];
+ if($infos_gps['is_exif']) $info_message .='EXIF';
+
$lonDMS= dec2dms($lon) ;
$latDMS= dec2dms($lat) ;
- if ($infos_gps['lat']=="")
- $icon='icon/minus.png';
- else $icon='icon/minus.png';
+
$tpl_var = array_merge(
$image,
array(
- 'icon' => $icon ,
+ 'filename' => $image['path'],
+ 'exif' => $infos_gps['is_exif'] ,
'lat' => $image['lat'] ,
'lon' => $image['lon'] ,
'alt' => $image['alt'] ,
'latDMS' => $latDMS[3] ,
- 'lonDMS' => $lonDMS[3] ,
+ 'lonDMS' => "-->".$lonDMS[3] ,
'adresse' => $adresse ,
'U_TN' => get_thumbnail_url($image),
@@ -311,25 +390,19 @@
- if ( !empty($filename))
+ if ( !empty($first_image))
+ { $error_message .= cl_edit_controler::Memo_Vars($first_image);
+ if (isset($_POST['update']))
{
// document.Envoie.latDMS.value
- $image= $filename ;
- $filename= $filename['path'] ;
+
+
+ $image= first_image ;
+ $filename=$image['path'] ;
$Val_exif="";
$Val_XMP="";
- // error_reporting ( 0 );
- // Hide any unknown EXIF tags
-/*
- $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE;
- include $Toolkit_Dir . 'Toolkit_Version.php'; // Change: added as of version 1.11
- include $Toolkit_Dir . 'JPEG.php'; // Change: Allow this example file to be easily relocatable - as of version 1.11
- include $Toolkit_Dir . 'JFIF.php';
- include $Toolkit_Dir . 'PictureInfo.php';
- include $Toolkit_Dir . 'XMP.php';
- include $Toolkit_Dir . 'Photoshop_IRB.php';
- include $Toolkit_Dir . 'EXIF.php';
+
- $jpeg_header_data = get_jpeg_header_data($filename );
- */
+
+ /* */
if (!empty($infos_gps))
$Position = $infos_gps ;
@@ -339,9 +412,11 @@
+
+ $jpeg_header_data = get_jpeg_header_data($filename );
$template->assign( array(
'filename_abs' => $filename ,
'filename' => $filename,
'datas' => array(
- /* 'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ),
+/* 'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ),
'Val_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ),
'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ),
@@ -353,23 +428,15 @@
'Val_exif'=> Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename),
'Val_XMP' => Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data) ) ),
- */
+ */
//
),
'Datadase' => ($Position) ,
) );
-}
-
-function Memo_vars($variables)
-{
- ob_start();
- echo '
'; - print_r($variables); - echo ''; - $m= ob_get_contents(); - - ob_end_clean(); - return $m; - -} + + + } +} + + //======================================================================= function cl_make_map_picture_url($params) @@ -384,83 +451,58 @@ -function Get_exif_gps($filename,$image) -{ + +function Get_exif_gps($firt_image,$image) +{ + error_reporting ( 1 ); + $filename=$firt_image; + $datas = array(); $errors = array(); - // - - // $Exif_array = get_EXIF_JPEG( $filename ); - // if ( empty($Exif_array) ) return; - - $exif = @read_exif_data( $filename ); + + $exif = @read_exif_data( $filename ); +global $errors;global $template ; if ( empty($exif) ) return; $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); - - - error_reporting ( 1 ); - /* - if ( count($exif)<4) - return; - - - if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) ) - { - $errors[] = $filename. ': GPSLatitudeRef not S or N'; - return; - } - if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) ) - { - $errors[] = $filename. ': GPSLongitudeRef not W or E'; - return; - } - if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) ) - { - $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays'; - return; - } -*/ - - + +//==================================================================== $lat = $image['lat'] ; $lon = $image['lon'] ; - $alt=$image['alt']; + $alt = $image['alt']; + global $info_message ; + +$is_exif = "'".(is_array($exif['GPSLatitude']) and is_array($exif['GPSLongitude']) )."'" ; + if ($is_exif) { + $lat_exif = parse_lat_lon( $exif['GPSLatitude'] ); + $lon_exif = parse_lat_lon( $exif['GPSLongitude'] ); + $alt_exif = Parse_Fract( $exif['GPSAltitude'] ); + } if ($lat =="") -{ +{ $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); - if ( $exif['GPSLatitudeRef']=='S' )$lat = -$lat; - $latDMS=$exif['GPSLatitude'][0] . " | " . $exif['GPSLatitude'][1]. " | " . $exif['GPSLatitude'][2] ; - + if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat; + }else{ - + $is_exif="false" ; if($lat<0) $exif['GPSLatitudeRef']='S' ; else $exif['GPSLatitudeRef']='N' ; - $latDMS=dec2dms($lat); - $exif['GPSLatitude']= $latDMS ; -} -global $errors; -if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) ) - { - $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays'; - //return; - } - - if ($lon =="") { + + +} +if ($lon =="") { - $lon = parse_lat_lon( $exif['GPSLongitude'] ); - $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ; - if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon; + $lon = parse_lat_lon( $exif['GPSLongitude'] ); + if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon; }else{ if ($lon<0) $exif['GPSLongitudeRef'] ='W' ; else $exif['GPSLongitudeRef'] ='E' ; - $lonDMS=dec2dms($lon); - $exif['GPSLongitude']=$lonDMS ; + } - - + + //======================================================================= $altref = 0; @@ -474,7 +516,7 @@ $altref = $exif['GPSAltitudeRef']; } - //======================================================================== - + //======================================================================== $datas[] = array ( + 'is_exif' => $is_exif, ' filename=' => $filename , 'id' => $image['id'] , @@ -500,3 +542,7 @@ return $datas[0] ; } -?> +if ($info_message!="") +$template->assign('infos',$info_message); +if ($error_message!="") +$template->assign('errors',$error_message); +?> Index: /extensions/edit_gmaps/admin/admin_edit.tpl =================================================================== --- /extensions/edit_gmaps/admin/admin_edit.tpl (revision 9411) +++ /extensions/edit_gmaps/admin/admin_edit.tpl (revision 9412) @@ -2,5 +2,5 @@ {* $Id: admin_edit.tpl 2011-01-03 *} {if PHPWG_VERSION < 2.2 } {include -file=$EDIT_RV_PATH_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_RV_PATH_ABS|@cat:'header_2_2.tpl'} +file=$EDIT_CL_PATH_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_CL_PATH_ABS|@cat:'header_2_2.tpl'} {/if} @@ -11,5 +11,6 @@ {if isset($coordinates) && $coordinates.LAT <= 90 } var coordinates={ldelim} - LAT:'{$coordinates.LAT}', + FILE:'$coordinates.filename', + LAT:'{$coordinates.LAT}', LON:'{$coordinates.LON}', ADRESSE:'{$coordinates.ADRESSE}', @@ -19,5 +20,6 @@ {else} var coordinates={ldelim} - LAT:' ', + FILE:'', + LAT:' ', LON:' ', ADRESSE:'{$coordinates.ADRESSE}', @@ -52,5 +54,5 @@ {/html_head} - + {$file_name} @@ -104,5 +106,6 @@ {$thumbnail.lat},{$thumbnail.lon} {/if} - {$thumbnail.file} + {$thumbnail.file} + @@ -134,5 +137,6 @@