Index: extensions/edit_gmaps/admin/admin_edit.php
===================================================================
--- extensions/edit_gmaps/admin/admin_edit.php	(revision 11529)
+++ extensions/edit_gmaps/admin/admin_edit.php	(revision 12126)
@@ -1,3 +1,3 @@
-<?php 
+<?php
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 global $lang;
@@ -6,110 +6,44 @@
 
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
- 
+
 /***********************************************************************************/
 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           ;   
- 
+if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );
+
+$Toolkit_Dir =INCLUDE_PATH           ;
+
 include $Toolkit_Dir . 'fonctions.php';
-/***********************************************************************************/
+//==========================================================
+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_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/' ;
+/****************************************************************/
 $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 <br>\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 <br>\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') ."<br />" ;
-          }    
-          $_POST['submit']= l10n('update_database') ;
-        }
-      }
-    }
-    $_POST['update'] ="ok";
-  } 
+$erreur_message=""; 
 /****************************************************************/
 if ( !isset($_GET['cat']) )   $_GET['cat'] = 'caddie';
 $_GET['mode'] = 'map';
-if (PHPWG_VERSION < 2.2 ) {
- include (PHPWG_ROOT_PATH.'admin/element_set.php'); 				 
- } else {
-if (!isset($page['title'])) $page['title']="";
-    include (PHPWG_ROOT_PATH.'admin/batch_manager.php');		 
+    if (PHPWG_VERSION < 2.2 ) {
+      include (PHPWG_ROOT_PATH.'admin/element_set.php');
+    } else {
+      if (!isset($page['title'])) $page['title']="";
+      include (PHPWG_ROOT_PATH.'admin/batch_manager.php');
     $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'])
-  {
+  }
+//===============================================================
+$collection = array(); 
+if(!isset($_POST['target'])) $_POST['target']="";
+
+  switch ($_POST['target']){
     case 'all' :
       $collection = $page['cat_elements_id'];
-      break;
+    break;
     case 'selection' :
       if (!isset($_POST['selection']) or count($_POST['selection']) == 0)
@@ -117,57 +51,161 @@
       else
         $collection = $_POST['selection'];
-      break;
-  } 
-
+    break;
+  }
+if (isset($_POST['selection'])){}
+//===============================================================        
+  $images=array();   
+if (!empty($_GET['display']))
+{
+  if ('all' == $_GET['display'])
+    $page['nb_images'] = count($page['cat_elements_id']);
+  else
+    $page['nb_images'] = intval($_GET['display']);
+}
+else
+  $page['nb_images'] = 20;
+
+if ( !empty($page['cat_elements_id']) )
+{
+  $query='
+SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
+  WHERE id IN ('.implode(',',$page['cat_elements_id']).')
+  '.$conf['order_by'].'
+  LIMIT '.$page['start'].', '.   $page['nb_images'] .'
+;';
+  $result = pwg_query($query);
+  while ( $row=mysql_fetch_assoc($result) )
+    $images[] = $row;
+}
+//===============================================================
+global $lang_info;
+if (date_default_timezone_get()) {
+  $adresse =  date_default_timezone_get()   ;
+}else{
+
+}
+$adresse =  $lang_info['country'];   ;
+$adresse=str_replace("/",", ",$adresse);
+ 
+if (count($collection)>0 )
+//=============================================================
+  if (isset($_POST['update']) && $_POST['update']==l10n('update_exif')){
+  /************* Mise à jour des meta données ***************/
+    // 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 );
+    }
+    
+      $init_info =true;
+      $first_image="";   
+      $_POST['submit']="";
+
+      foreach ($collection as $id_0){
+          foreach ($images as $image) {  
+            if (array_search($id_0,$image)) {   
+              //=================================================================
+              // Donnée base de donnée
+              //=================================================================
+         //     $info_message .= "<div style='border:2px solid red'>$id_0 Image:" . cl_edit_functions::Memo_vars($image)."</div>" ;
+                
+              //=================================================================
+              // Meta donnée
+              //=================================================================
+                $infos_gps  = array();
+                $infos_gps  = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
+                if($image['lat']=='' || $image['lon']==''){ 
+                    $image['lat']=$infos_gps['lat'];
+                    $image['lon']=$infos_gps['lon'];
+                    $image['alt']=$infos_gps['alt'];
+                }     
+
+                if($image['lat']!=''){
+                      $new_ps_file_info_array=  base_to_meta($image);
+                  }
+
+                $new_ps_file_info_array['filename'] =  $image['path'];
+                $new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']);
+   //   
+          if( $image['lat']=="" ){
+              $image['lat']=  $new_ps_file_info_array['lat'] ;
+              $image['lon']=  $new_ps_file_info_array['lon'] ;
+              $image['alt']=  $new_ps_file_info_array['alt'] ; 
+          }
+        if($_POST['update']==l10n('update_exif')) unset($_POST['submit']);
+        if(1) {
+ 
+           if(  cl_edit_controler::add_meta_gps($new_ps_file_info_array,$image)){
+              
+                $exif = @read_exif_data( $image['path']);
+                 $infos_gps  = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
+                $info_message .= $image['path'] . " : " . $image['file'] . " : ok<BR />";
+                }else{
+
+                }
+           }
+        }else{
+         
+        } // fin search
+      }   // fin id_0
+    }     // fin collection     
+    $_POST['update'] ="ok";
+  }
+
+if ( isset($_POST['submit'])  ) {
   /******** 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';
+    if ( count($collection)>0 ){
+        $lat = trim($_POST['lat']);
+        $lon = trim($_POST['lon']);
+        $alt = trim($_POST['alt']);
+        //===============================================================
+       if($lat !="") cl_edit_controler::add_data_base($collection,$lat,$lon,$alt) ;
+        $_POST['submit'] = l10n('Submit') ;
+            foreach ($collection as $id_0){
+          foreach ($images as $image) {  
+            if (array_search($id_0,$image)) {  
+              $image['lat'] =    $lat ;
+              $image['lon']= $lon  ;
+              $image['alt'] =$alt  ;
+           }
+          }
+        }  
+      }
     }
-    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') ;
-     }
-    }
-  }
  }
 /**************************************/
+
 $specials_selected = null;
-foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v)
-{
-	$link = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$k;
-	$template->append(
-		'specials',
-		array(
-			$link => l10n($v),
-			),
-		true
-		);
-	if ($k == $_GET['cat']) $specials_selected = $link;
-}
+foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v){
+    $link = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$k;
+    $template->append(
+        'specials',
+        array(
+            $link => l10n($v),
+            ),
+        true
+        );
+    if ($k == $_GET['cat']) $specials_selected = $link;
+}
+
+
 $template->assign('specials_selected', $specials_selected);
 /****************************************/
@@ -179,8 +217,6 @@
 $categories = array();
 $selecteds = array();
-if (!empty($result))
-{
-  while ($row = mysql_fetch_assoc($result))
-  {
+if (!empty($result)){
+  while ($row = mysql_fetch_assoc($result))  {
     $url = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$row['id'];
     if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url;
@@ -192,16 +228,6 @@
 display_select_categories($categories, $selecteds, 'categories', false);
 
-if (!empty($_GET['display']))
-{
-  if ('all' == $_GET['display'])
-    $page['nb_images'] = count($page['cat_elements_id']);
-  else
-    $page['nb_images'] = intval($_GET['display']);
-}
-else
-  $page['nb_images'] = 20;
-
-if ( !empty($page['cat_elements_id']) )
-{
+
+if ( !empty($page['cat_elements_id']) ){
   $nav_bar = create_navigation_bar(
     $admin_url.get_query_string_diff(array('start')),
@@ -212,200 +238,196 @@
   $template->assign('navbar', $nav_bar);
 }
-
-$images=array();
-if ( !empty($page['cat_elements_id']) )
-{
-  $query='
-SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
-  WHERE id IN ('.implode(',',$page['cat_elements_id']).')
-  '.$conf['order_by'].'
-  LIMIT '.$page['start'].', '.$page['nb_images'].'
-;';
-  $result = pwg_query($query);
-  while ( $row=mysql_fetch_assoc($result) )
-    $images[] = $row;
-}
-
-foreach ($images as $image)
-{
-	$tpl_var = array_merge( $image,
+//========================================================================
+  $v_exif="";
+foreach ($images as $image){  
+  
+    $infos_gps  = array();
+    $infos_gps  =  cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
+    $v_exif=$infos_gps['is_exif']?true:false ;   
+    $v_db=false  ; 
+    $v_db=$image['lat']!=0 && $image['lon']!=0;
+
+    if(  $infos_gps['lat'] !=0  || $infos_gps['lon'] !=0 ) {  
+    
+      $new= ( !isset($image['lat'])? true: $image['lat']!=$infos_gps['lat'] ) ;
+      $image['lat']=$infos_gps['lat'];
+      $image['lon']=$infos_gps['lon'];
+      $image['alt']=$infos_gps['alt'];
+      $sel_img= array($image['id']);
+      if ($new) cl_edit_controler::add_data_base( $sel_img,$image['lat'],$image['lon'],$image['alt']) ;              
+   }         
+   //================================================= 
+   $tpl_var = array_merge( $image,
       array(
+        'U_EXIF' => $v_exif,
+        'U_DB' => $v_db,
         'U_TN' => get_thumbnail_url($image),
         'TITLE' => get_thumbnail_title($image)
-      )
-    );
-  if ( isset($image['lat']) )
-    $tpl_var['U_MAP'] = cl_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) );
-	$template->append('thumbnails', $tpl_var);
-}
+      ) );
+
+  if ( isset($image['lat']) ){
+    $tpl_var['U_MAP'] = cl_make_map_picture_url( 
+    array('image_id'=>$image['id'],
+          'image_file'=>$image['file']) );
+         } 
+            
+    $template->append('thumbnails', $tpl_var);
+}
+
 
 $template->assign(
     array(
       'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display'))
-    ) 
+    )
   );
 
-//==========================================================
-	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_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=""; 
-     
-if ( isset($_POST['submit'])   )
-{ 	 
-  if ($_POST['submit']==l10n('Submit') )
-   {
-      $_POST['selection']=array();  
-      $collection =array(); 
-	  unset($collection); 
-  }
- 
-
- if ($_POST['submit']==l10n('reset' ) )
-		{
-			$_POST['selection']=array();
-			unset($collection);
-		}
- 
- }
+$match="";
+if ( isset($_POST['submit'])   ) {
+  if ($_POST['submit']==l10n('Submit') ) {
+    $_POST['selection']=array();
+    $collection =array();
+    unset($collection);
+  }
+  if ($_POST['submit']==l10n('reset' ) ) {
+    $_POST['selection']=array();
+    unset($collection);
+  }
+}
 //=================================================================================
 $src="";
-
 $template->assign(
-    array(	'EDIT_CL_PATH' => EDIT_CL_PATH,
-	        'path_js' => $path_js,
+    array(  'EDIT_CL_PATH' => EDIT_CL_PATH,
+            'path_js' => $path_js,
             'VERSION'=> $version,
             '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(  '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;$first_image="";                           
+ 
+$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)) {
+    $init_info =true;
+    $first_image=""; 
+    $_POST['selection'] = $collection ;
     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) ;   
-            $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'  ;
-              $alt= ($image['alt']  <> '') ? $image['alt'] : '0'  ;
-				      if($lat != '100') $lat=$image['lat'];
- 				      //=====================================================
-				      $template->assign( 'coordinates',
-				             array('FILE' => $image['path'],
-                     'LAT' =>   $lat  ,
-										 'LON' =>   $lon  ,
-										 'ADRESSE' =>  $adresse ,
-										 'ZOOM' => 4,
-                     'ALT' =>   $alt ,
-										)
-									);
-				}
-                                               
+        foreach ($images as $image) {
+            if (array_search($id_0,$image)) {    
+              $infos_gps  = array();   
+              if($image['lat']=='' || $image['lon']==''){    }
+              $infos_gps  =array();
+              $infos_gps  =  cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
+              if(isset($infos_gps['lat']) && $infos_gps['is_exif']){        
+                $image['lat']=$infos_gps['lat'];
+                $image['lon']=$infos_gps['lon'];
+                $image['alt']=$infos_gps['alt'];
+              }                    
+              if ( $init_info && $image['lat'] <> '' ) {
+                $init_info = false ;
+                $lat = ($image['lat'] <> '') ? $image['lat'] : '100'  ;
+                $lon = ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
+                $alt = ($image['alt']  <> '') ? $image['alt'] : '0'  ;
+                     
+                //=====================================================
+                $template->assign( 'coordinates',
+                        array(
+                            'FILE' => $image['path'],
+                            'LAT' =>   $lat  ,
+                            'LON' =>   $lon  ,
+                            'ADRESSE' =>  $adresse ,
+                            'ZOOM' => 4,
+                            'ALT' =>  $alt ,
+                              )
+                          );                              
+              }
+              //===================================================== 
                     $lon=$image['lon'];
-                    $lat=$image['lat'];    
-                    if($infos_gps['is_exif'])  	$info_message .='EXIF';    
-
-                $lonDMS= dec2dms($lon) ;
-                $latDMS= dec2dms($lat) ;
-
-
-			    $tpl_var = array_merge( 
-			            $image,
-      					array(
+                    $lat=$image['lat'];
+                    if($infos_gps['is_exif']) {                                       
+                     $info_message .='EXIF';
+                    }
+                    $lonDMS= dec2dms($lon) ;
+                    $latDMS= dec2dms($lat) ;
+
+                        $v_db=false  ; 
+    $v_db=$lon!=0 && $lat!=0;
+
+                $tpl_var = array_merge(
+                        $image,
+                        array(
                   'filename' =>  $image['path'],
-                  'exif' => $infos_gps['is_exif'] ,
+                  'exif' => '"'.$infos_gps['is_exif'].'"' ,
                   'lat'  =>    $image['lat']    ,
                   'lon' =>     $image['lon']    ,
-                  'alt' =>     $image['alt']    , 
+                  'alt' =>     $image['alt']    ,
                   'latDMS' =>    $latDMS[3]     ,
-                  'lonDMS' =>   "-->".$lonDMS[3]     ,
+                  'lonDMS' =>   $lonDMS[3]     ,
                   'adresse' =>  $adresse   ,
                   'U_TN' => get_thumbnail_url($image),
                   'TITLE' => get_thumbnail_title($image),
-							    'U_MAP' => cl_make_map_picture_url(
-							                                    array(
-							                                         'image_id'=>$image['id'],
-							                                         'image_file'=>$image['file'],
-							                                         ) 
-      						                                    ),
-								  )  								
-    						);	 
-				$template->append('Selectthumbnails', $tpl_var);			
-			}
-		}	
-	}
-  }
-
-} 
-
-
- if ( !empty($first_image))
- { $error_message .= cl_edit_controler::Memo_Vars($first_image);
- if (isset($_POST['update'])) {
-// document.Envoie.latDMS.value
-        $image= first_image ;
-        $filename=$image['path'] ;
-        $Val_exif="";
-        $Val_XMP="";         	
-   /*  */   
-     if (!empty($infos_gps)) 
-     $Position = $infos_gps ;
-     else  $Position =  Get_exif_gps($filename,$image) ;
-
-  $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 ), 
+                  'U_EXIF' =>  $infos_gps['is_exif'] ,
+                  'U_BD' =>  $v_db ,
+                  'U_MAP' => cl_make_map_picture_url(
+                                                array(
+                                                      'image_id'=>$image['id'],
+                                                      'image_file'=>$image['file'],
+                                                      )
+                                                    ),
+                                  )
+                            );
+          $template->append('Selectthumbnails', $tpl_var);
+        }
+      }
+    }
+  }
+}
+
+//============================================================
+ if ( !empty($first_image)) { 
+   $erreur_message .= cl_edit_functions::Memo_Vars($first_image);
+   
+   if (isset($_POST['update'])) {
+          // document.Envoie.latDMS.value
+          $image= first_image ;
+          $filename=$image['path'] ;
+          $Val_exif="";
+          $Val_XMP="";
+   /*  */
+     if (!empty($infos_gps))
+         $Position = $infos_gps ;
+     else  $Position =  cl_edit_controler::Get_exif_gps($filename,$image,false) ;
+
+      $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_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ),
-        'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ), 
+        'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ),
         'Val_JFIF'=> Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ),
-        'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ), 
-        'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ),          
-        'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ), 
+        'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ),
+        'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ),
+        'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ),
 
         '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) ,
+          'Datadase' =>  ($Position) ,
           ) );
-        
-
-          }
+  }
 }
 
@@ -414,9 +436,9 @@
 function cl_make_map_picture_url($params)
 {
-	global $conf;
-	/*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
-		return "";*/
-	$map_url = make_picture_url($params);
-	return add_url_params($map_url, array('map'=>null) );
+    global $conf;
+    /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
+        return "";*/
+    $map_url = make_picture_url($params);
+    return add_url_params($map_url, array('map'=>null) );
 }
 $v1=0;
@@ -424,97 +446,10 @@
 
 
-function Get_exif_gps($firt_image,$image)
-{
-
- error_reporting ( 1 );
- $filename=$firt_image;
-  
-  $datas = array();
-  $errors = array();
- 
-
-  $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') ) );
-
-//====================================================================
-    $lat = $image['lat'] ;          
-    $lon = $image['lon'] ; 
-    $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;
-  
-}else{
-    $is_exif="false" ;
-    if($lat<0)      $exif['GPSLatitudeRef']='S' ;
-        else        $exif['GPSLatitudeRef']='N' ;
-        
-     
-}   
-if ($lon =="") {
-       
-                $lon = parse_lat_lon( $exif['GPSLongitude'] );
-                if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
-           }else{
-             if ($lon<0) $exif['GPSLongitudeRef'] ='W' ;
-             else $exif['GPSLongitudeRef'] ='E' ;
-                 
-           }
-
-    
- 
-//=======================================================================          
-           $altref = 0;
-
-if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) )
-		{
-			 $exif['GPSAltitude']=$alt;
-             $exif['GPSAltitudeRef']=0;
-		}	else {
-        	$alt =		 $exif['GPSAltitude'];
-            $altref = $exif['GPSAltitudeRef'];
-        }
- //========================================================================      
-		$datas[] = array (
-            'is_exif' => $is_exif, 
-            ' filename=' => $filename ,
-			'id' =>    $image['id'] ,
-			'lat' =>   $lat ,
-			'lon' =>   $lon ,
-			'latDMS' =>     $exif['GPSLatitude'][0]['Numerator']  . "/" .
-                            $exif['GPSLatitude'][0]['Denominator'] . " " .    
-                            $exif['GPSLatitude'][1]['Numerator'] . "/" .
-                            $exif['GPSLatitude'][1]['Denominator']. " " .    
-                            $exif['GPSLatitude'][2]['Numerator'] . "/" .
-                            $exif['GPSLatitude'][2]['Denominator'],
-			'lonDMS' =>     $exif['GPSLongitude'][0]['Numerator']  . "/" .
-                            $exif['GPSLongitude'][0]['Denominator'] . " " .    
-                            $exif['GPSLongitude'][1]['Numerator'] . "/" .
-                            $exif['GPSLongitude'][1]['Denominator']. " " .    
-                            $exif['GPSLongitude'][2]['Numerator'] . "/" .
-                            $exif['GPSLongitude'][2]['Denominator'],
-            'altref' => $exif['GPSAltitudeRef'],
-            'alt' =>   $exif['GPSAltitude'] ,
-
-			);  
-
-return $datas[0] ;
-}
+
 if ($info_message!="")
 $template->assign('infos',$info_message);
-if ($error_message!="")
-$template->assign('errors',$error_message);
+if ($erreur_message!="")
+$template->assign('errors',$erreur_message);
+
+
 ?>
Index: extensions/edit_gmaps/admin/admin_edit.tpl
===================================================================
--- extensions/edit_gmaps/admin/admin_edit.tpl	(revision 11529)
+++ extensions/edit_gmaps/admin/admin_edit.tpl	(revision 12126)
@@ -101,9 +101,18 @@
 				        <input type="checkbox" name="selection[]" value="{$thumbnail.id}"    />
 			        </label>
-			        <span class="thumbLegend">
-			         {if isset($thumbnail.U_MAP)}
-			           <a href="{$thumbnail.U_MAP}" target="_blank">{$thumbnail.lat},{$thumbnail.lon}</a>
+			        <span class="thumbLegend" >
+              <div> {$thumbnail.file} </div>
+              {if isset($thumbnail.U_MAP)}
+              <div ><a href="{$thumbnail.U_MAP}" target="_blank" >
+              {if $thumbnail.U_EXIF  } 
+              EXIF
+              {/if}
+              {if $thumbnail.U_DB  } 
+                BD
+              {/if}</a>
+              </div>			         
+			          
 			         {/if}
-                     {$thumbnail.file} 
+                    
 					
 			        </span>
@@ -121,4 +130,7 @@
         <td><label><input type="radio" name="target" value="selection" checked="checked" /> {'selection'|@translate}</label></td>
         <input class="cluetip submit" title="{'selection'|@translate}|{'hlp_line3'|@translate}." type="submit" name="submit" value="{'selection'|@translate}"   />
+        			<td>
+			<input class="cluetip submit" title="{'update_exif'|@translate}|{'hlp_update_exif'|@translate}." type="submit" value="{'update_exif'|@translate}" name="update" {$tag_input_enabled} /></td>
+
 </table>
         </fieldset>
@@ -149,10 +161,11 @@
                 </label>
 				<input type="hidden"  value={$thumbnail.id}  name="selection[]"    />				
-				<span class="thumbLegend">
+				<span class="thumbLegend">	<div>{$thumbnail.file} </div> 		
+        {if $thumbnail.U_EXIF } Exif{/if}
+         {if $thumbnail.U_BD } Bd {/if}
 				{if isset($thumbnail.U_MAP)}
-					<a href="{$thumbnail.U_MAP}" target="_blank">{$thumbnail.lat},{$thumbnail.lon}</a>
+					<a href="{$thumbnail.U_MAP}" target="_blank"><div>{$thumbnail.lat}</div><div>{$thumbnail.lon}</div></a>
 				{/if}
-				{$thumbnail.file}  
-				  
+					  
 				</span>
 				</span>
@@ -190,4 +203,5 @@
 				{foreach from=$Selectthumbnails item=thumbnail}	
 					{assign var="filename" value=$filename|@cat:$thumbnail.filename|@cat:";"}
+
 				{if  $thumbnail.lat<>0 }
 					{if $thumbnail.lon<>0}
Index: extensions/edit_gmaps/admin/admin_edit_meta.php
===================================================================
--- extensions/edit_gmaps/admin/admin_edit_meta.php	(revision 11529)
+++ extensions/edit_gmaps/admin/admin_edit_meta.php	(revision 12126)
@@ -119,5 +119,6 @@
 }
 usort($categories, 'global_rank_compare');
-display_select_categories($categories, $selecteds, 'categories', false);
+
+display_select_categories($categories, $selecteds, 'categories', true);
 
 if (!empty($_GET['display']))
@@ -454,5 +455,5 @@
       if ($lon =="") {
        
-            $lon = parse_lat_lon( $exif['GPSLongitude'] );
+            $lon = Parse_Lat_Lon( $exif['GPSLongitude'] );
             $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ;
   if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
Index: extensions/edit_gmaps/admin/admin_edit_meta.tpl
===================================================================
--- extensions/edit_gmaps/admin/admin_edit_meta.tpl	(revision 11529)
+++ extensions/edit_gmaps/admin/admin_edit_meta.tpl	(revision 12126)
@@ -188,4 +188,5 @@
         <label>Altitude </label> 
 		<input type="hidden" size="2"value="0"  name="altRef"  />
+          <input type="hidden" size="2" value="0" name="altDMS" />
         <input type="text" size="15"value="{$alt}"  name="alt"  /> <label> m </label>         
         </td>
@@ -280,4 +281,5 @@
 <input size=60 id="altRef" name="GPSAltitudeRef" type=\"text\" value="{$altRef}"> 
         </td>
+     <input size=60 id="altDMS" name="GPSAltitudeRef" type=\"text\" value="{$altRef}"> 
         <td>
             Altitude
Index: extensions/edit_gmaps/admin/element_set.php
===================================================================
--- extensions/edit_gmaps/admin/element_set.php	(revision 11529)
+++ extensions/edit_gmaps/admin/element_set.php	(revision 12126)
@@ -1,3 +1,3 @@
-﻿<?php
+<?php
 // +-----------------------------------------------------------------------+
 // | Piwigo - a PHP based picture gallery                                  |
Index: extensions/edit_gmaps/admin/header_2_1.tpl
===================================================================
--- extensions/edit_gmaps/admin/header_2_1.tpl	(revision 11529)
+++ extensions/edit_gmaps/admin/header_2_1.tpl	(revision 12126)
@@ -1,6 +1,6 @@
-﻿{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.js" now=0} 
+{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.js" now=0}
 {known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"}
 {known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.core.js"}
 {known_script id="jquery.ui.resizable" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.resizable.js"}
-{known_script id="EDIT_RV_script" src=$EDIT_CL_PATH|@cat:"admin/js/JScript.js"} 
-{known_script id="fieldset" src=$EDIT_CL_PATH|@cat:"admin/js/fieldset.js"} 
+{known_script id="EDIT_RV_script" src=$EDIT_CL_PATH|@cat:"admin/js/JScript.js"}
+{known_script id="fieldset" src=$EDIT_CL_PATH|@cat:"admin/js/fieldset.js"}
Index: extensions/edit_gmaps/admin/include/EXIF.php
===================================================================
--- extensions/edit_gmaps/admin/include/EXIF.php	(revision 11529)
+++ extensions/edit_gmaps/admin/include/EXIF.php	(revision 12126)
@@ -118,5 +118,5 @@
 function get_EXIF_JPEG( $filename )
 {
-global $error_message ;
+global $erreur_message ;
         // Change: Added as of version 1.11
         // Check if a wrapper is being used - these are not currently supported (see notes at top of file)
@@ -124,8 +124,8 @@
         {
                 // A HTTP or FTP wrapper is being used - show a warning and abort
-                $error_message .= "HTTP and FTP wrappers are currently not supported with EXIF - See EXIF functionality documentation - a local file must be specified<br>";
-                $error_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
-                $error_message .= "\$newfilename = tempnam ( \$dir, \"tmpexif\" );<br>\n";
-                $error_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
+                $erreur_message .= "HTTP and FTP wrappers are currently not supported with EXIF - See EXIF functionality documentation - a local file must be specified<br>";
+                $erreur_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
+                $erreur_message .= "\$newfilename = tempnam ( \$dir, \"tmpexif\" );<br>\n";
+                $erreur_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
                 return FALSE;
         }
@@ -168,5 +168,5 @@
         {
                 // Could't open the file - exit
-                $error_message .= "<p>Could not open file $filename</p>\n";
+                $erreur_message .= "<p>Could not open file $filename</p>\n";
                 return FALSE;
         }
@@ -297,5 +297,5 @@
 function get_Meta_JPEG( $filename )
 {
-global $error_message ;
+global $erreur_message ;
         // Change: Added as of version 1.11
         // Check if a wrapper is being used - these are not currently supported (see notes at top of file)
@@ -303,8 +303,8 @@
         {
                 // A HTTP or FTP wrapper is being used - show a warning and abort
-                $error_message .= "HTTP and FTP wrappers are currently not supported with Meta - See EXIF/Meta functionality documentation - a local file must be specified<br>";
-                $error_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
-                $error_message .= "\$newfilename = tempnam ( \$dir, \"tmpmeta\" );<br>\n";
-                $error_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
+                $erreur_message .= "HTTP and FTP wrappers are currently not supported with Meta - See EXIF/Meta functionality documentation - a local file must be specified<br>";
+                $erreur_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
+                $erreur_message .= "\$newfilename = tempnam ( \$dir, \"tmpmeta\" );<br>\n";
+                $erreur_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
                 return FALSE;
         }
@@ -347,5 +347,5 @@
         {
                 // Could't open the file - exit
-                $error_message .= "<p>Could not open file $filename</p>\n";
+                $erreur_message .= "<p>Could not open file $filename</p>\n";
                 return FALSE;
         }
@@ -474,5 +474,5 @@
 function get_EXIF_TIFF( $filename )
 {
-global $error_message ;
+global $erreur_message ;
         // Change: Added as of version 1.11
         // Check if a wrapper is being used - these are not currently supported (see notes at top of file)
@@ -480,8 +480,8 @@
         {
                 // A HTTP or FTP wrapper is being used - show a warning and abort
-                $error_message .= "HTTP and FTP wrappers are currently not supported with TIFF - See EXIF/TIFF functionality documentation - a local file must be specified<br>";
-                $error_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
-                $error_message .= "\$newfilename = tempnam ( \$dir, \"tmptiff\" );<br>\n";
-                $error_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
+                $erreur_message .= "HTTP and FTP wrappers are currently not supported with TIFF - See EXIF/TIFF functionality documentation - a local file must be specified<br>";
+                $erreur_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
+                $erreur_message .= "\$newfilename = tempnam ( \$dir, \"tmptiff\" );<br>\n";
+                $erreur_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
                 return FALSE;
         }
@@ -494,5 +494,5 @@
         {
                 // Could't open the file - exit
-                $error_message .= "<p>Could not open file $filename</p>\n";
+                $erreur_message .= "<p>Could not open file $filename</p>\n";
                 return FALSE;
         }
@@ -1131,5 +1131,5 @@
 function read_Multiple_IFDs( $filehnd, $Tiff_offset, $Byte_Align, $Tag_Definitions_Name, $local_offsets = FALSE, $read_next_ptr = TRUE )
 {
-global $error_message ;
+global $erreur_message ;
         // Start at the offset of the first IFD
         $Next_Offset = 0;
@@ -1144,5 +1144,5 @@
                 {
                         // Error seeking to position of next IFD
-                        $error_message .= "<p>Error: Corrupted EXIF</p>\n";
+                        $erreur_message .= "<p>Error: Corrupted EXIF</p>\n";
                         return FALSE;
                 }
@@ -1193,6 +1193,7 @@
 function read_IFD_universal( $filehnd, $Tiff_offset, $Byte_Align, $Tag_Definitions_Name, $local_offsets = FALSE, $read_next_ptr = TRUE )
 {
-global $error_message ;
-
+global $erreur_message ;
+        global $nom_fichier;
+       
         if ( ( $filehnd == NULL ) || ( feof( $filehnd ) ) )
         {
@@ -1213,8 +1214,8 @@
         // If the data is corrupt, the number of entries may be huge, which will cause errors
         // This is often caused by a lack of a Next-IFD pointer
-        if ( $No_Entries> 10000 )
+        if ( $No_Entries> 12800 )
         {
                 // Huge number of entries - abort
-                $error_message .= "<p>".$No_Entries."Error: huge number of EXIF entries - EXIF is probably Corrupted</p>\n";
+                $erreur_message .=  $nom_fichier."  Error: huge number  (".$No_Entries.") of EXIF entries - EXIF is probably Corrupted.<br />";
 
                 return array ( FALSE , 0);
@@ -1241,5 +1242,5 @@
         {
                 // Couldn't read the IFD Data properly, Some Casio files have no Next IFD pointer, hence cause this error
-                $error_message .= "<p>Error: EXIF Corrupted</p>\n";
+                $erreur_message .= "<p>Error: EXIF Corrupted</p>\n";
                 return array(FALSE, 0);
         }
@@ -1297,5 +1298,5 @@
                 if ( $Data_Count > 100000 )
                 {
-                     //   $error_message .= "<p>Error: huge EXIF data count - EXIF is probably Corrupted</p>\n";
+                     //   $erreur_message .= "<p>Error: huge EXIF data count - EXIF is probably Corrupted</p>\n";
 
                         // Some Casio files have no Next IFD pointer, hence cause errors
@@ -2209,5 +2210,5 @@
 
 function get_IFD_Data_Type( $input_data, $data_type, $Byte_Align ){
-global $error_message ;
+global $erreur_message ;
         // Check if this is a Unsigned Byte, Unsigned Short or Unsigned Long
         if (( $data_type == 1 ) || ( $data_type == 3 ) || ( $data_type == 4 ))
@@ -2234,5 +2235,5 @@
                 // to return multiple values instead of a single value
 
-                $error_message .= "<p>Error - ASCII Strings should not be processed in get_IFD_Data_Type</p>\n";
+                $erreur_message .= "<p>Error - ASCII Strings should not be processed in get_IFD_Data_Type</p>\n";
                 return "Error Should never get here"; //explode( "\x00", $input_data );
         }
Index: extensions/edit_gmaps/admin/include/fonctions.php
===================================================================
--- extensions/edit_gmaps/admin/include/fonctions.php	(revision 11529)
+++ extensions/edit_gmaps/admin/include/fonctions.php	(revision 12126)
@@ -1,6 +1,59 @@
 <?php 
-  //
-  // DECIMAL TO FRACTION
-  //
+
+function base_to_meta($image){
+      $info_meta['lat']=$image['lat'];
+      $info_meta['lon']=$image['lon'];
+      $info_meta['alt']=$image['alt']; 
+      //===========================================================================
+      $info_meta['latRef'] = ($image['lat']<0)? 'S' : "N" ;
+      $info_meta['GPSLatitudeRef'] = ($image['lat']<0)? 'S' : "N" ;
+      $p1=dec2dms($image['lat']);
+ 
+      $info_meta['latDMS']=$p1[0]['Numerator']  . "/" .
+            $p1[0]['Denominator'] ." ".
+            $p1[1]['Numerator'] . "/" .
+            $p1[1]['Denominator'] ." ".
+            $p1[2]['Numerator'] . "/" .
+            $p1[2]['Denominator'] ;
+
+      $info_meta['GPSLatitude']=array(
+            $p1[0]['Numerator']  . "/" .
+            $p1[0]['Denominator'] ,
+            $p1[1]['Numerator'] . "/" .
+            $p1[1]['Denominator'] ,
+            $p1[2]['Numerator'] . "/" .
+            $p1[2]['Denominator']
+            );
+
+      //===========================================================================
+      $info_meta['GPSLongitudeRef']  = ($image['lon']<0)? 'W' : "E" ;
+      $info_meta['lonRef']  = ($image['lon']<0)? 'W' : "E" ;
+      $p1=dec2dms($image['lon']);
+      $info_meta['lonDMS']=$p1[0]['Numerator']  . "/" .
+            $p1[0]['Denominator'] ." ".
+            $p1[1]['Numerator'] . "/" .
+            $p1[1]['Denominator'] ." ".
+            $p1[2]['Numerator'] . "/" .
+            $p1[2]['Denominator'] ;
+      $info_meta['GPSLongitude']=array(
+            $p1[0]['Numerator']  . "/" .
+            $p1[0]['Denominator'] ,
+            $p1[1]['Numerator'] . "/" .
+            $p1[1]['Denominator'] ,
+            $p1[2]['Numerator'] . "/" .
+            $p1[2]['Denominator']
+            );
+      //===========================================================================
+        $info_meta['GPSAltitudeRef'] = "0";
+        $p1= round( $image['alt'] * 5000000000 );
+        $info_meta['GPSAltitude']= $p1.'/'."500000000000"; 
+        $info_meta['altDMS']= $p1.'/'."500000000000"; 
+        $info_meta['altRef']= "0"; 
+  return $info_meta ;
+}
+
+/**********************************
+* DECIMAL TO FRACTION             *
+**********************************/ 
   function dec2frac( $decimal ) {
     $decimal = (string)$decimal;
@@ -10,6 +63,5 @@
 
     // find least reduced fractional form of number
-    for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ )
-    {
+    for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ ){
      // build the denominator as we 'shift' the decimal to the right
      if( $dec ) $den *= 10;
@@ -42,5 +94,7 @@
   }
 
- 
+/**********************************
+* Decimal vers Deg Min Sec        *
+**********************************/ 
 function dec2dms($value) { 
         $value= abs($value);
@@ -59,23 +113,9 @@
         $ret[2]['Denominator']=$sec->Denominator;
   $ret[3]= " Deg: " . $degrees . " Min: " . $minutes . " Sec: " . $seconds."  " ;
-        
+        $ret[4]= " " . $degrees . "/1 " . $minutes . "/1 " . $sec->Numerator."/".$sec->Denominator ; 
 return( $ret); 
 
 }
 
-
-/*
-//Array ( 
-[GPSLatitudeRef] => S 
-[GPSLatitude] => 
-Array ( [0] => 41/1 
-[1] => 54/1 
-[2] => 26543/3238 ) 
-[GPSLongitudeRef] => E 
-[GPSLongitude] => Array ( 
-[0] => 146/1 
-[1] => 21/1 
-[2] => 61393/1729 ) ) 
-*/
 
 function toFraction($number){
@@ -108,7 +148,6 @@
 return ($denominator > 0) ? $numerator . '/' . $denominator : false; 
 } 
-
- function Parse_Fract( $f )
-{
+//==============================================
+ function Parse_Fract( $f ){
   $nd = explode( '/', $f );
   return $nd[0]/$nd[1];
Index: extensions/edit_gmaps/admin/js/JScript.js
===================================================================
--- extensions/edit_gmaps/admin/js/JScript.js	(revision 11529)
+++ extensions/edit_gmaps/admin/js/JScript.js	(revision 12126)
@@ -8,244 +8,225 @@
 
 function onLoad() {
-    var reg = new RegExp('/', "g");
-    
-    if (coordinates.ADRESSE)
-        coordinates.ADRESSE = coordinates.ADRESSE.replace("/", ", ");
-
-          document.getElementById("match").value = coordinates.ADRESSE;
-                geocoder = new google.maps.Geocoder();
-	            var mapElement = document.getElementById("map");
-	            if (coordinates.LAT <= 90 && coordinates.LAT != " " && coordinates.LAT != "" ) {
-
-		        } else {
-		            coordinates.LAT=49 ;coordinates.LON = 3;
-		            coordinates.ZOOM = coordinates.ZOOM | 18;
-		            geocoder.geocode({ 'address': coordinates.ADRESSE }, function (results, status) {
-		                /* Si l'adresse a pu être géolocalisée */
-		                if (status == google.maps.GeocoderStatus.OK) {
-		                    /* Récupération de sa latitude et de sa longitude */
-		                    coordinates.LAT = results[0].geometry.location.lat();
-		                    coordinates.LON = results[0].geometry.location.lng();
-		                    LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
-		                    updateMarkerPosition(LatLng);
-		                    geocodePosition(LatLng);
-		                }
-		            });
-
-		           
-		        }
+  var reg = new RegExp('/', "g");
+
+  if (coordinates.ADRESSE)
+    coordinates.ADRESSE = coordinates.ADRESSE.replace("/", ", ");
+
+  document.getElementById("match").value = coordinates.ADRESSE;
+  geocoder = new google.maps.Geocoder();
+  var mapElement = document.getElementById("map");
+  if (coordinates.LAT <= 90 && coordinates.LAT != " " && coordinates.LAT != "") {
+
+  } else {
+    coordinates.LAT = 49; coordinates.LON = 3;
+    coordinates.ZOOM = coordinates.ZOOM | 18;
+    geocoder.geocode({ 'address': coordinates.ADRESSE }, function (results, status) {
+      /* Si l'adresse a pu être géolocalisée */
+      if (status == google.maps.GeocoderStatus.OK) {
+        /* Récupération de sa latitude et de sa longitude */
+        coordinates.LAT = results[0].geometry.location.lat();
+        coordinates.LON = results[0].geometry.location.lng();
+        LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
+        updateMarkerPosition(LatLng);
+        geocodePosition(LatLng);
+      }
+    });
+
+
+  }
   zoom = coordinates.ZOOM;
-   LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
-  
-
-            /*
-             MapTypeId.ROADMAP affiche un plan (de type carte routière).
-             MapTypeId.SATELLITE affiche une vue satellite.
-             MapTypeId.HYBRID affiche une vue mixte entre les deux précédentes.
-             MapTypeId.TERRAIN affiche une vue du relief.
-            */
- var mapOpts = {      
-                    center:LatLng,
-                    zoom:zoom,
-		            mapTypeId: google.maps.MapTypeId.SATELLITE 
-	            };
-	
-	            map = new google.maps.Map( mapElement, mapOpts );
-
-	      
-
-
-         if (coordinates) 
-	           marker = new google.maps.Marker( { 
-		            position: map.getCenter(),
-		            map: map,
-                    draggable: true 
-		            });
-
-
-                // Add dragging event listeners.    
-                google.maps.event.addListener(marker,
+  LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
+
+
+  /*
+  MapTypeId.ROADMAP affiche un plan (de type carte routière).
+  MapTypeId.SATELLITE affiche une vue satellite.
+  MapTypeId.HYBRID affiche une vue mixte entre les deux précédentes.
+  MapTypeId.TERRAIN affiche une vue du relief.
+  */
+  var mapOpts = {
+    center: LatLng,
+    zoom: zoom,
+    mapTypeId: google.maps.MapTypeId.SATELLITE
+  };
+
+  map = new google.maps.Map(mapElement, mapOpts);
+
+
+
+
+  if (coordinates)
+    marker = new google.maps.Marker({
+      position: map.getCenter(),
+      map: map,
+      draggable: true
+    });
+
+
+  // Add dragging event listeners.    
+  google.maps.event.addListener(marker,
         'dragstart',
         function () {
-            updateMarkerAddress('Dragging...');
+          updateMarkerAddress('Dragging...');
         });
 
-        google.maps.event.addListener(marker,
+  google.maps.event.addListener(marker,
             'drag',
             function () {
-                updateMarkerStatus('Dragging...');
-                updateMarkerPosition(marker.getPosition());
+              updateMarkerStatus('Dragging...');
+              updateMarkerPosition(marker.getPosition());
             }
             );
 
-            google.maps.event.addListener(marker,
+  google.maps.event.addListener(marker,
                                             'dragend',
                                             function () {
 
-                                             
-                                     
+
+
                                               // getElevation({ latLng: marker.getPosition() });
-                                                geocodePosition(marker.getPosition());
-                                                updateMarkerStatus('Drag ended');
-                                                getElevation({ 'latLng': marker.getPosition() });
-                                               
+                                              geocodePosition(marker.getPosition());
+                                              updateMarkerStatus('Drag ended');
+                                              getElevation({ 'latLng': marker.getPosition() });
+
 
                                             }
         );
 
-       // styleIcon = new StyledIcon(StyledIconTypes.BUBBLE, { color: "#cccccc", text: "Drag Me!" });
-       // var styleMaker1 = new StyledMarker({ styleIcon: styleIcon, position: new google.maps.LatLng(37.383477473067, -121.880502070713), map: map, draggable: true });
-
-       // google.maps.event.addDomListener(styleMaker1, "dragend", getElevation);
-                                            // Update current position info.    
-
-		       updateMarkerPosition(LatLng);
-		       geocodePosition(LatLng);
-		       getElevation({ 'latLng': marker.getPosition() });
-		      
-	          return false;
-    
-
- 
-
-
- }
-
-       function updateMarkerStatus(str) {    
-                document.getElementById('markerStatus').innerHTML = str; 
-        }    
-        
-        function updateMarkerPosition(latLng) {    
-                document.Envoie.lat.value=latLng.lat() ;
-                document.Envoie.lon.value = latLng.lng();
-                dms_frac = dec2dms(latLng.lng());
-                if (document.Envoie.lon.value < 0)  
-                document.Envoie.lonRef.value = "W";
-                else                     
-                document.Envoie.lonRef.value = "E";
-                document.Envoie.lonDMS.value = Math.abs(dms_frac.Degre) +"/1" + " " + dms_frac.Minute +"/1" + " " +    dms_frac.Numerator + "/" + dms_frac.Denominator;
-                dms_frac = dec2dms(latLng.lat());
-                if (document.Envoie.lat.value < 0)
-                    document.Envoie.latRef.value = "S";
-                else
-                    document.Envoie.latRef.value = "N";
-                document.Envoie.latDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator;
-              //  update_datas();
-            }
-
-
-                function update_datas() {
-                n= jQuery(document.EditJPEG);
-
-                jQuery.each(n[0], function (i) {
-
-
-                    n00 = this;
-                    n0 = n00.id;
-                    n1 = n00.name;
-                    n2 = jQuery(n00).val();
-                    try {
-                        if (n0 == "alt") {
-                            n3 = dec2frac(document.Envoie[n0].value);
-                            n3 = n3.Numerator + "/" + n3.Denominator;
-                            jQuery(this).val(n3);
-                        }
-                        else {
-                            n3 = document.Envoie[n0].value;
-                            jQuery(this).val(n3);
-                        }
-                    }
-                    catch (e) {
-                        n3 = n0;
-                    }
-
-
-
-                }
-                )
-
-                   
-
-                }
-           
-           function updateMarkerAddress(str) {
-               document.getElementById('markerAdress').innerHTML = str;
-        
-               jQuery("#match").val(str);
-            }
-
-            function getElevation(event) {
-                var elevator = new google.maps.ElevationService();
-                var locations = [];
-
-                // Retrieve the clicked location and push it on the array
-                var clickedLocation = event.latLng;
-                locations.push(clickedLocation);
-
-                // Create a LocationElevationRequest object using the array's one value
-                var positionalRequest = {
-                    'locations': locations
-                }
-
-                // Initiate the location request
-                if (elevator) {
-                    elevator.getElevationForLocations(positionalRequest, function (results, status) {
-                        if (status == google.maps.ElevationStatus.OK) {
-
-                            // Retrieve the first result
-                            if (results[0]) {
-                                coordinates.ALT = results[0].elevation;
-                                document.Envoie.alt.value = coordinates.ALT;
-                                altDMS = dec2frac(coordinates.ALT);
-                                document.Envoie.altRef.value = "0";
-                                document.Envoie.altDMS.value =  altDMS.Numerator + "/" +  altDMS.Denominator;
-                                //styleIcon.set("text", "Elevation: " + results[0].elevation + "m");
-                            } else {
-                                // alert("No results found");
-                            }
-                        } else {
-                            alert("Elevation service failed due to: " + status);
-                        }
+  // styleIcon = new StyledIcon(StyledIconTypes.BUBBLE, { color: "#cccccc", text: "Drag Me!" });
+  // var styleMaker1 = new StyledMarker({ styleIcon: styleIcon, position: new google.maps.LatLng(37.383477473067, -121.880502070713), map: map, draggable: true });
+
+  // google.maps.event.addDomListener(styleMaker1, "dragend", getElevation);
+  // Update current position info.    
+
+  updateMarkerPosition(LatLng);
+  geocodePosition(LatLng);
+  getElevation({ 'latLng': marker.getPosition() });
+
+  return false;
+
+
+
+
+
+}
+
+function updateMarkerStatus(str) {
+  document.getElementById('markerStatus').innerHTML = str;
+}
+
+function updateMarkerPosition(latLng) {
+  document.Envoie.lat.value = latLng.lat();
+  document.Envoie.lon.value = latLng.lng();
+  dms_frac = dec2dms(latLng.lng());
+  if (document.Envoie.lon.value < 0)
+    document.Envoie.lonRef.value = "W";
+  else
+    document.Envoie.lonRef.value = "E";
+  document.Envoie.lonDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator;
+  dms_frac = dec2dms(latLng.lat());
+  if (document.Envoie.lat.value < 0)
+    document.Envoie.latRef.value = "S";
+  else
+    document.Envoie.latRef.value = "N";
+  document.Envoie.latDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator;
+  //  update_datas();
+}
+
+function update_datas() {
+  n = jQuery(document.EditJPEG);
+  jQuery.each(n[0], function (i) {
+    n00 = this;
+    n0 = n00.id;
+    n1 = n00.name;
+    n2 = jQuery(n00).val();
+    try {
+      if (n0 == "alt") {
+        n3 = dec2frac(document.Envoie[n0].value);
+        n3 = n3.Numerator + "/" + n3.Denominator;
+        jQuery(this).val(n3);
+      }
+      else {
+        n3 = document.Envoie[n0].value;
+        jQuery(this).val(n3);
+      }
+    }
+    catch (e) {
+      n3 = n0;
+    }
+  })
+}
+
+function updateMarkerAddress(str) {
+  document.getElementById('markerAdress').innerHTML = str;
+  jQuery("#match").val(str);
+}
+
+function getElevation(event) {
+  var elevator = new google.maps.ElevationService();
+  var locations = [];
+
+  // Retrieve the clicked location and push it on the array
+  var clickedLocation = event.latLng;
+  locations.push(clickedLocation);
+
+  // Create a LocationElevationRequest object using the array's one value
+  var positionalRequest = {
+    'locations': locations
+  }
+
+  // Initiate the location request
+  if (elevator) {
+    elevator.getElevationForLocations(positionalRequest, function (results, status) {
+      if (status == google.maps.ElevationStatus.OK) {
+
+        // Retrieve the first result
+        if (results[0]) {
+          coordinates.ALT = results[0].elevation;
+          document.Envoie.alt.value = coordinates.ALT;
+          altDMS = dec2frac(coordinates.ALT);
+          document.Envoie.altRef.value = "0";
+
+          document.Envoie.altDMS.value = altDMS.Numerator + "/" + altDMS.Denominator;
+          //styleIcon.set("text", "Elevation: " + results[0].elevation + "m");
+        } else {
+          // alert("No results found");
+        }
+      } else {
+        alert("Elevation service failed due to: " + status);
+      }
+    });
+  }
+}
+function geocodePosition(pos) {
+  geocoder.geocode({ 'latLng': pos },
+                    function (results, status) {
+                      /* Si le géocodage inversé a réussi */
+                      if (status == google.maps.GeocoderStatus.OK) {
+                        updateMarkerAddress(results[0].formatted_address);
+                      } else {
+                        updateMarkerAddress('Cannot determine address at this location.');
+                      }
                     });
-                }
-            }
-
-
-
-            function geocodePosition(pos) {
-                     geocoder.geocode({ 'latLng': pos },
-                    function (results, status) {
-                   /* Si le géocodage inversé a réussi */
-                   if (status == google.maps.GeocoderStatus.OK) {
-                       updateMarkerAddress(results[0].formatted_address);
-                   } else {
-                       updateMarkerAddress('Cannot determine address at this location.');
-                   }
-               });
-        }
-
- 
-        /* Fonction de géocodage déclenchée en cliquant surle bouton "Geocoder"  */
-        function codeAddress() {
-            /* Récupération de la valeur de l'adresse saisie */
-          
-            /* Appel au service de geocodage avec l'adresse en paramètre */
-            if (typeof map == "undefined") onLoad();
-
-            var address = document.getElementById("match").value;
+}
+/* Fonction de géocodage déclenchée en cliquant surle bouton "Geocoder"  */
+function codeAddress() {
+  /* Récupération de la valeur de l'adresse saisie */
+
+  /* Appel au service de geocodage avec l'adresse en paramètre */
+  if (typeof map == "undefined") onLoad();
+
+  var address = document.getElementById("match").value;
 
   geocoder.geocode({ 'address': address }, function (results, status) {
-      /* Si l'adresse a pu être géolocalisée */
-      if (status == google.maps.GeocoderStatus.OK) {
-          /* Récupération de sa latitude et de sa longitude */
-          coordinates.LAT = results[0].geometry.location.lat();
-          coordinates.LON = results[0].geometry.location.lng();
-          onLoad();
-          
-           
-
-      } else {
-          alert("Cannot determine location at this adress.: " + status);
-      }
+    /* Si l'adresse a pu être géolocalisée */
+    if (status == google.maps.GeocoderStatus.OK) {
+      /* Récupération de sa latitude et de sa longitude */
+      coordinates.LAT = results[0].geometry.location.lat();
+      coordinates.LON = results[0].geometry.location.lng();
+      onLoad();
+    } else {
+      alert("Cannot determine location at this adress.: " + status);
+    }
   });
 }
@@ -253,58 +234,58 @@
 //=======================================================
 function On_Click(a, b, c) {
-    document.Envoie.lat.value = b;
-    document.Envoie.lon.value = c;
-
-    coordinates = {LAT:a,
-     LON : b} ;
-    LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
-    updateMarkerPosition(LatLng);
-
-
+  document.Envoie.lat.value = b;
+  document.Envoie.lon.value = c;
+  coordinates = { LAT: a,
+    LON: b
+  };
+  LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
+  updateMarkerPosition(LatLng);
 }
 
 jQuery(window).load(
-
       function () {
-//Récupérer tous les inputs radios appartenant à un même groupe
- /*         a = jQuery('input[type=hidden][name=Selectthumbnail]');
-          b = a.length;
-          c = jQuery('input[type=hidden]:checked').length;
-          d = jQuery('input[type=hidden][name="Selectthumbnail"]').attr('value'); 
-*/
+        //Récupérer tous les inputs radios appartenant à un même groupe
+        /*         a = jQuery('input[type=hidden][name=Selectthumbnail]');
+        b = a.length;
+        c = jQuery('input[type=hidden]:checked').length;
+        d = jQuery('input[type=hidden][name="Selectthumbnail"]').attr('value'); 
+        */
 
         //  onLoad();
-      }); 
+      });
 
 jQuery(document).ready(function () {
 
-    jQuery('.cluetip').cluetip({
-        width: 300, height: 100,
-        splitTitle: '|',
-        clickThrough: true
-    }
+ /*
+  jQuery('.cluetip').cluetip({
+    width: 300, height: 100,
+    splitTitle: '|',
+    clickThrough: true
+  }
   );
+  */
+  jQuery('.cluetip').tipTip({ maxWidth: '600px', 'delay': 0, 'fadeIn': 200, 'fadeOut': 200 });  
   jQuery("#search").click(function (e) {
 
-        coordinates = { ADRESSE: jQuery("#match").val(),
-                        LAT:0,LON:0,ZOOM: 18 ,ALT:0
-                       };
-        codeAddress();
-        return false;
-    });
-
-    jQuery("#match").keydown(function (e) {
-        // e.target         pour FireFox
-        // event.srcElement pour IE
-        var Obj = e ? e.target : event.srcElement;
-        if (Obj.tagName != "INPUT") return false;
-        var Code = e.keyCode || e.which;
-        if (Code != 13) return true;
-        coordinates = { ADRESSE: jQuery("#match").val(),
-            LAT: 0, LON: 0, ZOOM: 18, ALT: 0
-                       };
-        codeAddress();
-        return false;
-    });
+    coordinates = { ADRESSE: jQuery("#match").val(),
+      LAT: 0, LON: 0, ZOOM: 18, ALT: 0
+    };
+    codeAddress();
+    return false;
+  });
+
+  jQuery("#match").keydown(function (e) {
+    // e.target         pour FireFox
+    // event.srcElement pour IE
+    var Obj = e ? e.target : event.srcElement;
+    if (Obj.tagName != "INPUT") return false;
+    var Code = e.keyCode || e.which;
+    if (Code != 13) return true;
+    coordinates = { ADRESSE: jQuery("#match").val(),
+      LAT: 0, LON: 0, ZOOM: 18, ALT: 0
+    };
+    codeAddress();
+    return false;
+  });
 
 
@@ -314,60 +295,60 @@
 
 
-  // DECIMAL TO FRACTION
-  //
-  function dec2frac( valeur_decimal ) {
-     decimal = valeur_decimal.toString() ;
-      num = '';
-      den = 1;
-      dec = false;
-
-      // find least reduced fractional form of number
-      for( i = 0, ix =   decimal.length  ; i < ix; i++ )
-      {
-      // build the denominator as we 'shift' the decimal to the right
-      if( dec ) den *= 10;
-
-      // find the decimal place/ build the numberator
-      if( decimal.charAt(i) == '.' ) dec = true;
-      else num += decimal.charAt(i);
-      }
-      num = parseInt(num);
-  
-      // whole number, just return it
-      if( den == 1 ) return num;
-
-      num2 = num;
-      den2 = den;
-      rem  = 1;
-      // Euclid's Algorithm (to find the gcd)
-      while( num2 % den2 ) {
-      rem = num2 % den2;
-      num2 = den2;
-      den2 = rem;
-      }
-      if( den2 != den ) rem = den2;
-      ret1 = { Numerator: (num / rem), Denominator: (den / rem) };
-      // new Array()
-    // ret1->Numerator =(num / rem ) ;
-    // ret1->Denominator=(den / rem);
-
-      // now $rem holds the gcd of the numerator and denominator of our fraction
-      return ret1;
-      
-  }
+// DECIMAL TO FRACTION
+//
+function dec2frac(valeur_decimal) {
+  decimal = valeur_decimal.toString();
+  num = '';
+  den = 1;
+  dec = false;
+
+  // find least reduced fractional form of number
+  for (i = 0, ix = decimal.length; i < ix; i++) {
+    // build the denominator as we 'shift' the decimal to the right
+    if (dec) den *= 10;
+
+    // find the decimal place/ build the numberator
+    if (decimal.charAt(i) == '.') dec = true;
+    else num += decimal.charAt(i);
+  }
+  num = parseInt(num);
+
+  // whole number, just return it
+  if (den == 1) return num;
+
+  num2 = num;
+  den2 = den;
+  rem = 1;
+  // Euclid's Algorithm (to find the gcd)
+  while (num2 % den2) {
+    rem = num2 % den2;
+    num2 = den2;
+    den2 = rem;
+  }
+  if (den2 != den) rem = den2;
+  ret1 = { Numerator: (num / rem), Denominator: (den / rem) };
+  // new Array()
+  // ret1->Numerator =(num / rem ) ;
+  // ret1->Denominator=(den / rem);
+
+  // now $rem holds the gcd of the numerator and denominator of our fraction
+  return ret1;
+
+}
 
 function dec2dms(l) {
-    sign = 1;
-    if (l < 0) { sign = -1; }
-    l = Math.abs(Math.round(l * 1000000.))
-    d = Math.floor(l / 1000000) * sign;
-    m = Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60);
-    s = Math.floor(((((l / 1000000) - Math.floor(l / 1000000)) * 60) - Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60)) * 100000) * 60 / 100000;
-    frac_s = dec2frac(s);
-    s2 = (frac_s.Numerator / frac_s.Denominator);
-    return { dms: d + "° " + m + "' " + s + "''",
-        Degre:d, Minute:m,Sec:s,
-        Numerator: frac_s.Numerator,
-        Denominator:frac_s.Denominator};
-}
-
+  sign = 1;
+  if (l < 0) { sign = -1; }
+  l = Math.abs(Math.round(l * 1000000.))
+  d = Math.floor(l / 1000000) * sign;
+  m = Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60);
+  s = Math.floor(((((l / 1000000) - Math.floor(l / 1000000)) * 60) - Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60)) * 100000) * 60 / 100000;
+  frac_s = dec2frac(s);
+  s2 = (frac_s.Numerator / frac_s.Denominator);
+  return { dms: d + "° " + m + "' " + s + "''",
+    Degre: d, Minute: m, Sec: s,
+    Numerator: frac_s.Numerator,
+    Denominator: frac_s.Denominator
+  };
+}
+
Index: extensions/edit_gmaps/edit_gmaps.inc.php
===================================================================
--- extensions/edit_gmaps/edit_gmaps.inc.php	(revision 11529)
+++ extensions/edit_gmaps/edit_gmaps.inc.php	(revision 12126)
@@ -66,4 +66,191 @@
 class cl_edit_controler {
 
+static public  function add_meta_gps($new_ps_file_info_array,$image){
+            global $nom_fichier,$erreur_message, $info_message;  
+            
+
+ // $exif = @read_exif_data( $exif );
+//  $exif = @array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
+ 
+  foreach( $new_ps_file_info_array['selection']  as $filename )   {
+    //======================================================
+         if($new_ps_file_info_array['lat']=='') {    
+            $erreur_message .= "Error - lon or lat = null : $filename <br>\n";
+            }else{
+     if($filename!="") {                   
+            //= $new_ps_file_info_array[ 'filename' ];
+            // Protect against hackers editing other files
+            // copy( $filename,  $filename.".bak" );
+            $path_parts = pathinfo( $filename );     
+
+            if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) {
+              $erreur_message .= $filename ;
+              $erreur_message .="Incorrect File Type - JPEG Only\n";
+              $filename="";
+              return;
+            }
+            // Change: removed limitation on file being in current directory - as of version 1.11
+            // Retrieve the header information
+
+            $nom_fichier=$filename;
+            $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
+              $erreur_message .= "jpeg_header_data
+              Error - Failure update Photoshop File Info : $filename <br>\n";
+              return false;
+              // 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
+              $erreur_message .= "Error - Failure to write new JPEG : $filename <br>\n";
+              return false;
+              // Output HTML with the form and data which was
+              // sent, to allow the user to fix it
+            }else{            
+              return true;
+          } 
+     }// test filename}
+   } //for each
+
+  }   
+
+
+}
+//==========================================================
+static public function Get_exif_gps($firt_image,$image,$hight_gps) {
+  global $errors;global $template ;
+    global $info_message ; 
+    error_reporting ( 1 );
+    $filename=$firt_image;
+   
+    $datas = array();
+    $errors = array();
+    $exif = @read_exif_data( $filename );
+    if ( empty($exif) ) return;
+
+ $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
+ if(count($exif)==0 || $hight_gps ){
+  $path_parts = pathinfo( $filename );
+  $exif = @read_exif_data( $path_parts['dirname']."/pwg_high/".$path_parts['basename']);
+  $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
+ }
+ if(count($exif)==0) return ; 
+//====================================================================
+    $lat = $image['lat'] ;
+    $lon = $image['lon'] ;
+    $alt = $image['alt'];
+   
+        $p1=base_to_meta($image);
+        
+ if($exif['GPSLatitude'][0]=="1/1" && $lat!=""){
+        $exif['GPSLatitudeRef'] = $p1['GPSLatitudeRef'] ;    
+        $exif['GPSLatitude']=$p1['GPSLatitude'];  
+        $exif['GPSLongitudeRef']  = $p1['GPSLongitudeRef'];
+        $exif['GPSLongitude']=$p1['GPSLongitude'];
+        $exif['GPSAltitudeRef'] =$p1['GPSAltitudeRef'];        
+        $exif['GPSAltitude']= $p1['GPSAltitude'];         
+
+   }
+    
+$is_exif =  is_array($exif['GPSLatitude']) && $exif['GPSLatitude']!=''   ;
+$is_exif =  is_array($exif['GPSLongitude']) && $exif['GPSLongitude']!=''  & $is_exif  ;
+
+ if ($is_exif) {  
+     $lat_exif = Parse_Lat_Lon( $exif['GPSLatitude'] );
+     $lon_exif = Parse_Lat_Lon( $exif['GPSLongitude'] );
+     $alt_exif = Parse_Fract( $exif['GPSAltitude'] );
+ }
+
+$is_exif =    $lat_exif!=0; 
+//============================== 
+if ($lat =="" || $hight_gps){
+  $lat = Parse_Lat_Lon( $exif['GPSLatitude'] );
+  if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat;
+}else{
+      if($lat<0)      $exif['GPSLatitudeRef']='S' ;
+        else        $exif['GPSLatitudeRef']='N' ;
+}
+//==============================
+          if ($lon =="" || $hight_gps) {
+             $lon = Parse_Lat_Lon( $exif['GPSLongitude'] );
+             if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
+          }else{
+            if ($lon<0) $exif['GPSLongitudeRef'] ='W' ;
+            else $exif['GPSLongitudeRef'] ='E' ;
+          }
+//=======================================================================
+           $altref = 0;
+          if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) ){
+                  $exif['GPSAltitude']=$alt;
+                  $exif['GPSAltitudeRef']=0;
+            }   else {
+                $alt =       $exif['GPSAltitude'];
+                $altref = $exif['GPSAltitudeRef'];
+            }
+   //========================================================================
+        $datas[] = array (
+            'is_exif' =>  $is_exif ,
+            ' filename=' => $filename ,
+            'id' =>    $image['id'] ,
+            'lat' =>   $lat ,
+            'lon' =>   $lon ,
+            'latDMS' =>     $exif['GPSLatitude'][0]." ".
+                            $exif['GPSLatitude'][1]." ".
+                            $exif['GPSLatitude'][2]." ".
+                            $exif['GPSLatitudeRef'],
+            'lonDMS' =>     $exif['GPSLongitude'][0]." ".
+                            $exif['GPSLongitude'][1]." ".
+                            $exif['GPSLongitude'][2]." ".
+                            $exif['GPSLongitudeRef'],
+            'altref' => $exif['GPSAltitudeRef'],
+            'alt' =>   $exif['GPSAltitude'] 
+            );
+
+return $datas[0] ;
+}
+//======================================================
+/*
+ *
+ */
+ static public function add_data_base($sel,$lat,$lon,$alt){
+    global $page,$info_message,$erreur_message ;
+
+    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
+        $erreur_message .= 'Invalid lat or lon value';
+    }
+    elseif ( strlen($lat)==0 and strlen($lon)==0 )
+      $update_query = 'lat=NULL, lon=NULL';
+    else
+       $erreur_message .= '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(',',$sel).')';
+        pwg_query($update_query) ;
+        cl_meta_invalidate_cache();
+        $info_message .=  l10n('update') . " " . implode(',',$sel)  . " ". IMAGES_TABLE . " : " .  l10n('OK') ."<br />";        
+       }
+  }
+//======================================================
      static public function cl_edit_admin_menu($menu)
     {
@@ -77,10 +264,4 @@
 	    return $menu;
     }
-
-
-
-
-
-
 	/*
 	*
Index: extensions/edit_gmaps/main.inc.php
===================================================================
--- extensions/edit_gmaps/main.inc.php	(revision 11529)
+++ extensions/edit_gmaps/main.inc.php	(revision 12126)
@@ -4,5 +4,5 @@
 Version: auto
 Description:  Editor for rv gmaps 
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=330
+Plugin URI: http://piwigo.org/ext/extension_view.php
 Author: rvelices cljosse
 Author URI: http://cl.josse.free.fr/
