Index: /extensions/edit_gmaps/admin/admin.php
===================================================================
--- /extensions/edit_gmaps/admin/admin.php	(revision 9376)
+++ /extensions/edit_gmaps/admin/admin.php	(revision 9377)
@@ -3,15 +3,42 @@
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 
+$colonnes = cl_get_columns_of(IMAGES_TABLE);
+$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
+*
+* @return array of array
+*/
+function cl_get_columns_of($table)
+{
+    $columns_of = array();
+    $query = 'DESC '.$table.';';
+    $result = mysql_query($query);	
+    $columns_of[$table] = array();   
+
+    if ($result)   
+        while ($row = mysql_fetch_row($result))
+           array_push($columns_of[$table], $row[0]);
+        
+    return $columns_of;
+}
+
+
 $template->set_filename('plugin_admin_content', dirname(__FILE__).'/admin.tpl');
 
 if (!isset($_GET['tab']))
-  $page['tab'] = 'config';
+  $page['tab'] = 'edit';
 else
   $page['tab'] = $_GET['tab'];
-  $page['tab'] =   'edit';
+
 $my_base_url = get_admin_plugin_menu_link(__FILE__);
 
 $tabsheet = new tabsheet();
 $tabsheet->add( 'edit', 'Edit', add_url_params( $my_base_url, array('tab'=>'edit') ) );
+//$tabsheet->add( 'edit_meta', 'Edit_meta', add_url_params( $my_base_url, array('tab'=>'edit_meta') ) );
 $tabsheet->select($page['tab']);
 $tabsheet->assign();
@@ -24,4 +51,3 @@
 $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
 
-
 ?>
Index: /extensions/edit_gmaps/admin/admin_edit.php
===================================================================
--- /extensions/edit_gmaps/admin/admin_edit.php	(revision 9376)
+++ /extensions/edit_gmaps/admin/admin_edit.php	(revision 9377)
@@ -14,13 +14,29 @@
 include (dirname(__FILE__).'\element_set.php');
 
+
+ 				
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+
+/***********************************************************************************/
+  if (!defined('TOOL_KIT_PATH')) define(  'TOOL_KIT_PATH',   EDIT_RV_PATH."admin/");
+  if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );                      
+  $Toolkit_Dir =INCLUDE_PATH           ;   
+
+   include $Toolkit_Dir . 'fonctions.php';
+/***********************************************************************************/
+
+ 
 $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']);
-if ( isset($_POST['submit']) and !is_adviser() )
+
+
+if ( isset($_POST['submit'])  )
 {
   $collection = array();
   if( !isset ($_POST['target']))
   {
-  $_POST['submit'] == l10n('Submit') ;
-  $_POST['target']='selection';
-    $collection = $_POST['selection'];
+        $_POST['submit'] == l10n('Submit') ;
+        $_POST['target']='selection';
+        $collection = $_POST['selection'];
 
   }
@@ -37,6 +53,5 @@
         $collection = $_POST['selection'];
       break;
-  }
-  
+  } 
 
   // test si mise à jour (valider) 
@@ -47,5 +62,6 @@
 		$lat = trim($_POST['lat']);
 		$lon = trim($_POST['lon']);
-
+        $alt = trim($_POST['alt']);
+ 
 		if ( strlen($lat)>0 and strlen($lon)>0 )
 		{
@@ -61,4 +77,11 @@
 		  $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))
 		{
@@ -67,5 +90,5 @@
 			WHERE id IN ('.implode(',',$collection).')';
 		  pwg_query($update_query);
-		  clm_invalidate_cache();
+		  cl_meta_invalidate_cache();
 		}
 	  }
@@ -127,5 +150,5 @@
 {
   $query='
-SELECT id,tn_ext,name,path,file,lat,lon FROM '.IMAGES_TABLE.'
+SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
   WHERE id IN ('.implode(',',$page['cat_elements_id']).')
   '.$conf['order_by'].'
@@ -157,17 +180,17 @@
 
 //==========================================================
-	if (!defined('EDIT_RV_ROOT')) define(  'EDIT_RV_ROOT',  PHPWG_PLUGINS_PATH.'edit_gmaps/admin/' ); 
+	if (!defined('EDIT_RV_PATH')) define(  'EDIT_RV_PATH',  EDIT_RV_PATH .'admin/' ); 
 	$path = EDIT_RV_PATH;
     $plg_data = implode( '', file($path.'main.inc.php') );
 	 if (preg_match("|Version: (.*)|", $plg_data, $val))
-          { $edit_rv_plugin['version'] = trim($val[1]);  }  
-    $edit_rv_plugin = array_map('htmlspecialchars', $edit_rv_plugin); 
-	$version= $edit_rv_plugin['version'] ;
-	$icon_path = 'themes/default/icon/help.png';
-	$path_js=  'themes/default/js/' ; 
+          { $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'] ;
+            $icon_path = 'themes/default/icon/help.png';
+            $path_js=  'themes/default/js/' ; 
 
 //==================================================================================
 $match="";  
-if ( isset($_POST['submit']) and !is_adviser() )
+if ( isset($_POST['submit'])   )
 { 	 
 
@@ -191,8 +214,8 @@
 $src="";
 $template->assign(
-    array(	'EDIT_RV_ROOT' => EDIT_RV_ROOT,
+    array(	'EDIT_RV_PATH' => EDIT_RV_PATH,
 	        'path_js' => $path_js,
             'VERSION'=> $version,
-            'EDIT_RV_ROOT_ABS' => dirname(__FILE__).'/',
+            'EDIT_RV_PATH_ABS' => dirname(__FILE__).'/',
 	      ) 
   );
@@ -209,37 +232,61 @@
 										 'ADRESSE' => $adresse,
 										 'ZOOM' => 18,
+                                         'ALT' => 0
+										)
+									); 
+                                    $filename ="";
+
+if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
+{
+    if (isset($collection))	
+        {  $lat =1000;
+            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) {
+			    $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('LAT' =>   $lat  ,
+										 'LON' =>   $lon  ,
+										 'ADRESSE' =>  $adresse ,
+										 'ZOOM' => 4,
+                                         'ALT' =>   $alt ,
 										)
 									);
-if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
-{
-
-if (isset($collection))	
-{   
-    $lat =1000;
-  foreach ($collection as $id_0)  {
-  		foreach ($images as $image)  {
-   			if (array_search($id_0,$image)) { 
-			  $_POST['selection'] = $collection ;
-
-			  if ($lat==1000) {
-			    $lat1= ($image['lat'] <> '') ? $image['lat'] : '100'  ;
-				$lon1= ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
-				if($lat1 != '100') $lat=$image['lat'];
- 				
-				$template->assign( 'coordinates',
-				                   array('LAT' =>   $lat1  ,
-										 'LON' =>   $lon1  ,
-										 'ADRESSE' =>  $adresse ,
-										 'ZOOM' => 4,
-										)
-									);
-
 				}
-
-			 $tpl_var = array_merge( 
+                $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(
-						   'lat'  =>   $image['lat']    ,
-						   'lon' =>  $image['lon']    ,
+                           'icon' => $icon ,
+						   'lat'  =>    $image['lat']    ,
+						   'lon' =>     $image['lon']    ,
+                           'alt' =>     $image['alt']    , 
+                           'latDMS' =>    $latDMS[3]     ,
+                           'lonDMS' =>   $lonDMS[3]     ,
 						   'adresse' =>  $adresse   ,
         					'U_TN' => get_thumbnail_url($image),
@@ -260,6 +307,69 @@
 	}
   }
-}
-
+
+} 
+
+
+ if ( !empty($filename))
+ {
+// document.Envoie.latDMS.value
+        $image= $filename ;
+        $filename= $filename['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 ;
+
+     else  $Position =  Get_exif_gps($filename,$image) ;
+
+
+
+     $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_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_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 '<pre>';
+		print_r($variables);
+		echo '</pre>';
+ 	  	$m= ob_get_contents();
+
+    	ob_end_clean();
+		return $m;
+		
+}
   //=======================================================================
 function cl_make_map_picture_url($params)
@@ -271,3 +381,122 @@
 	return add_url_params($map_url, array('map'=>null) );
 }
-?>
+$v1=0;
+
+
+function Get_exif_gps($filename,$image)
+{
+ error_reporting ( 1 );
+  $datas = array();
+  $errors = array();
+	//	
+
+     //	$Exif_array =    get_EXIF_JPEG( $filename );     
+     //  if ( empty($Exif_array) ) return;
+
+     $exif = @read_exif_data( $filename );  
+ 
+
+      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'];
+
+if ($lat =="") 
+{ 
+  $lat = Parse_Lat_Lon( $exif['GPSLatitude'] );  
+  if ( $exif['GPSLatitudeRef']=='S' )$lat = -$lat;
+     $latDMS=$exif['GPSLatitude'][0] . " | " . $exif['GPSLatitude'][1]. " | " . $exif['GPSLatitude'][2] ;
+
+}else{
+
+    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 =="") {
+       
+            $lon = parse_lat_lon( $exif['GPSLongitude'] );
+            $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ;
+  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;
+
+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 (
+            ' 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] ;
+}
+?> 
Index: /extensions/edit_gmaps/admin/admin_edit.tpl
===================================================================
--- /extensions/edit_gmaps/admin/admin_edit.tpl	(revision 9376)
+++ /extensions/edit_gmaps/admin/admin_edit.tpl	(revision 9377)
@@ -2,5 +2,5 @@
 {* $Id: admin_edit.tpl  2011-01-03   *}
 {if PHPWG_VERSION < 2.2 } {include
-file=$EDIT_RV_ROOT_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_RV_ROOT_ABS|@cat:'header_2_2.tpl'}
+file=$EDIT_RV_PATH_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_RV_PATH_ABS|@cat:'header_2_2.tpl'}
 {/if}
 
@@ -14,5 +14,6 @@
                  LON:'{$coordinates.LON}',
                  ADRESSE:'{$coordinates.ADRESSE}',
-                 ZOOM:18
+                 ZOOM:18,
+				 ALT:'{$coordinates.ALT}'
                  };
                  {else}
@@ -21,5 +22,6 @@
                  LON:' ',
                  ADRESSE:'{$coordinates.ADRESSE}',
-                 ZOOM:4
+                 ZOOM:4,
+				 ALT:' '
                  };
            {/if}           
@@ -29,5 +31,5 @@
                 });
 
-    // Event.observe(window, 'load', onLoad );
+ 
 
             </script>
@@ -166,5 +168,5 @@
 
         <label>{'Form'|@translate}</label> 
-        <table>
+        <table >
         <td >
   
@@ -173,16 +175,39 @@
         <input class="cluetip" title="{'lieu'|@translate}|{'hlp_line5'|@translate}." type="text" size="70"   value="{$match}"  name="match"   id="match"    />
         </td>
-        <tr>  
-        <td> 
+		<table >
+        <tr>   <input type="text" size="15" value="{$filename}"  name="filename" />
+        <td > 
         <label>Latitude (-90=S to 90=N)</label>
-        <input type="text" size="8" value="{$lat}"  name="lat" />
+        <input type="text" size="15" value="{$lat}"  name="lat" />
         </td>
         <td>          
         <label>Longitude (-180=E to 180=W) </label> 
-        <input type="text" size="9"value="{$lon}"  name="lon"  />         
-        </td>
-        </tr><tr>
-
-        <td><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$tag_input_enabled} /></td>
+        <input type="text" size="15"value="{$lon}"  name="lon"  />         
+        </td>
+        <td>          
+        <label>Altitude </label> 
+		<input type="hidden" size="2"value="0"  name="altRef"  />
+        <input type="text" size="15"value="{$alt}"  name="alt"  /> <label> m </label>         
+        </td>
+        </tr>
+		</table>
+		<tr>
+		<table >
+        <tr>  
+        <td > 
+        <label>Latitude DMS</label><input type="text" size="3" value="{$latRef}"  name="latRef" />
+        <input type="text" size="25" value="{$latDMS}"  name="latDMS" />
+        </td>
+        <td>          
+        <label>Longitude DMS </label><input type="text" size="3" value="{$lonRef}"  name="lonRef" /> 
+        <input type="text" size="25"value="{$lonDMS}"  name="lonDMS"  />         
+        </td>
+
+        </tr>
+		</table>
+		<tr>
+
+        <td>
+		<input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$tag_input_enabled} /></td>
         </td></tr>
         </table> 
@@ -198,4 +223,57 @@
     </fieldset>
   </fieldset>
-
 </form>
+
+ <fieldset style="display:none">
+<form name="EditJPEG" id="EditJPEG" action="{$EDIT_RV_PATH}Write_File_Info_Gps.php" method="post">
+  <input name="filename" size="60" id="filename" name="filename" type="test" value="../../../{$filename}"  />
+  <table> 
+    <tr>
+        <td>
+            Latitude Ref
+        </td>
+        <td>
+              <input size="60" id="latRef" name="GPSLatitudeRef" type="text" value="{$latRef}"> 
+        </td>
+     
+        <td>
+            Latitude
+        </td>
+        <td>
+             <input size="60" id="latDMS" name="GPSLatitude" type="text" value="{$latDMS}">   
+        </td>
+    </tr>
+        <tr>
+        <td>
+            Longitude Ref
+        </td>
+        <td>
+            <input size="60" id="lonRef" name="GPSLongitudeRef" type="text" value="{$lonRef}">
+        </td>
+  
+        <td>
+            Longitude
+        </td>
+        <td>
+<input size=60 id="lonDMS" name="GPSLongitude" type=\"text\" value="{$lonDMS}"> 
+        </td>
+    </tr>
+        <tr>
+		       <td>
+            Altitude Ref
+        </td>
+        <td>
+<input size=60 id="altRef" name="GPSAltitudeRef" type=\"text\" value="{$altRef}"> 
+        </td>
+        <td>
+            Altitude
+        </td>
+        <td>
+<input size=60 id="alt" name="GPSAltitude" type=\"text\" value="{$alt}"> 
+        </td>
+    </tr>
+</table>
+<br>
+<input type="submit" value="Update!">
+</form>
+</fieldset>
Index: /extensions/edit_gmaps/admin/admin_edit_meta.php
===================================================================
--- /extensions/edit_gmaps/admin/admin_edit_meta.php	(revision 9377)
+++ /extensions/edit_gmaps/admin/admin_edit_meta.php	(revision 9377)
@@ -0,0 +1,502 @@
+<?php 
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+global $lang;
+load_language('lang', dirname(__FILE__).'/../');
+$admin_url = PHPWG_ROOT_PATH.'admin.php';
+
+
+
+if ( !isset($_GET['cat']) )   $_GET['cat'] = 'caddie';
+$_GET['mode'] = 'map';
+if (PHPWG_VERSION < 2.2 ) 
+ include (PHPWG_ROOT_PATH.'admin/element_set.php');
+else 
+include (dirname(__FILE__).'\element_set.php');
+
+
+ 				
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+
+/***********************************************************************************/
+  if (!defined('TOOL_KIT_PATH')) define(  'TOOL_KIT_PATH',   EDIT_RV_PATH."admin/");
+  if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );                      
+  $Toolkit_Dir =INCLUDE_PATH           ;   
+
+   include $Toolkit_Dir . 'fonctions.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'])
+  {
+    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']);
+ 
+		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();
+		}
+	  }
+	}
+}
+
+
+$template->append(
+  'specials',
+  array(
+		$admin_url.get_query_string_diff(array('start','cat')).'&amp;cat=caddie' => l10n('Caddie')
+    ),
+	true
+  );
+
+$query = '
+SELECT id,name,uppercats,global_rank
+  FROM '.CATEGORIES_TABLE.'
+;';
+$result = pwg_query($query);
+$categories = array();
+$selecteds = array();
+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;
+    $row['id']=$url;
+    array_push($categories, $row);
+  }
+}
+usort($categories, 'global_rank_compare');
+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']) )
+{
+  $nav_bar = create_navigation_bar(
+    $admin_url.get_query_string_diff(array('start')),
+    count($page['cat_elements_id']),
+    $page['start'],
+    $page['nb_images']
+    );
+  $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,
+      array(
+        '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);
+}
+
+$template->assign(
+    array(
+      'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display'))
+    ) 
+  );
+
+//==========================================================
+	if (!defined('EDIT_RV_PATH')) define(  'EDIT_RV_PATH',  EDIT_RV_PATH .'admin/' ); 
+	$path = EDIT_RV_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'] ;
+            $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);
+		}
+ 
+
+ }
+//=================================================================================
+$src="";
+$template->assign(
+    array(	'EDIT_RV_PATH' => EDIT_RV_PATH,
+	        'path_js' => $path_js,
+            'VERSION'=> $version,
+            'EDIT_RV_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 (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
+{
+    if (isset($collection))	
+        {  $lat =1000;
+            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) {
+			    $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('LAT' =>   $lat  ,
+										 'LON' =>   $lon  ,
+										 'ADRESSE' =>  $adresse ,
+										 'ZOOM' => 4,
+                                         'ALT' =>   $alt ,
+										)
+									);
+				}
+                $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 ,
+						   'lat'  =>    $image['lat']    ,
+						   'lon' =>     $image['lon']    ,
+                           'alt' =>     $image['alt']    , 
+                           'latDMS' =>    $latDMS[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($filename))
+ {
+// document.Envoie.latDMS.value
+        $image= $filename ;
+        $filename= $filename['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 ;
+
+     else  $Position =  Get_exif_gps($filename,$image) ;
+
+
+
+     $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_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_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 '<pre>';
+		print_r($variables);
+		echo '</pre>';
+ 	  	$m= ob_get_contents();
+
+    	ob_end_clean();
+		return $m;
+		
+}
+  //=======================================================================
+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) );
+}
+$v1=0;
+
+
+function Get_exif_gps($filename,$image)
+{
+ error_reporting ( 1 );
+  $datas = array();
+  $errors = array();
+	//	
+
+     //	$Exif_array =    get_EXIF_JPEG( $filename );     
+     //  if ( empty($Exif_array) ) return;
+
+     $exif = @read_exif_data( $filename );  
+ 
+
+      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'];
+
+if ($lat =="") 
+{ 
+  $lat = Parse_Lat_Lon( $exif['GPSLatitude'] );  
+  if ( $exif['GPSLatitudeRef']=='S' )$lat = -$lat;
+     $latDMS=$exif['GPSLatitude'][0] . " | " . $exif['GPSLatitude'][1]. " | " . $exif['GPSLatitude'][2] ;
+
+}else{
+
+    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 =="") {
+       
+            $lon = parse_lat_lon( $exif['GPSLongitude'] );
+            $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ;
+  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;
+
+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 (
+            ' 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] ;
+}
+?> 
Index: /extensions/edit_gmaps/admin/admin_edit_meta.tpl
===================================================================
--- /extensions/edit_gmaps/admin/admin_edit_meta.tpl	(revision 9377)
+++ /extensions/edit_gmaps/admin/admin_edit_meta.tpl	(revision 9377)
@@ -0,0 +1,293 @@
+{html_head}
+{* $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'}
+{/if}
+
+ {assign var='visible' value = true }
+  {if not empty($Selectthumbnails)  }
+    <script src="http://maps.google.com/maps/api/js?sensor=false&amp;hl={$lang_info.code}" type="text/javascript"></script>
+         <script type="text/javascript"> 
+            {if isset($coordinates) && $coordinates.LAT <= 90 }
+		      var   coordinates={ldelim} 
+                 LAT:'{$coordinates.LAT}',
+                 LON:'{$coordinates.LON}',
+                 ADRESSE:'{$coordinates.ADRESSE}',
+                 ZOOM:18,
+				 ALT:'{$coordinates.ALT}'
+                 };
+                 {else}
+             var    coordinates={ldelim} 
+                 LAT:' ',
+                 LON:' ',
+                 ADRESSE:'{$coordinates.ADRESSE}',
+                 ZOOM:4,
+				 ALT:' '
+                 };
+           {/if}           
+         
+        jQuery(window).load(function(){ldelim}
+                onLoad();
+                });
+
+ 
+
+            </script>
+ {/if}
+
+    <style type="text/css">{literal}
+#map{ 
+ left:0px;
+  width:100%;
+  height:500px;
+ border:outset;
+}
+ 
+
+{/literal}
+</style>
+
+
+
+{/html_head}
+ 
+
+  
+
+    <fieldset class="fieldset">
+        <legend>{'Display options'|@translate}</legend>
+        <table ><td class="cluetip" title="{'set'|translate}|{'hlp_line1'|@translate}." align="left"  >
+        <form>
+        Set:
+        <select onchange="document.location = this.options[this.selectedIndex].value;"   >
+        <optgroup label="Specials">
+        {html_options options=$specials}
+        </optgroup>
+        <optgroup label="{'Categories'|@translate}">
+        {html_options options=$categories selected=$categories_selected}
+        </optgroup>
+        <!-- <optgroup label="{'Tags'|@translate}"></optgroup> -->
+        </select>
+        </form>
+        </td>
+        <td   > {'hlp_line2'|@translate} </td>
+        </table>
+        <p>{'elements per page'|@translate}:
+            <a href="{$U_DISPLAY}&amp;display=20">20</a>
+        | <a href="{$U_DISPLAY}&amp;display=50">50</a>
+        | <a href="{$U_DISPLAY}&amp;display=100">100</a>
+        | <a href="{$U_DISPLAY}&amp;display=all">{'all'|@translate}</a>
+        </p>
+    </fieldset>
+ {if  empty($Selectthumbnails) }{/if}
+
+
+<form action="" method="post" id="Envoie" name="Envoie"   >
+  {if not empty($thumbnails) &&  empty($Selectthumbnails) }  {/if} 
+
+<fieldset  id="Elements"  class="fieldset">
+	<legend>{'Elements'|@translate}</legend>
+
+    {if !empty($navbar) }{include file='navigation_bar.tpl'} {/if}
+        <fieldset >   
+	        <ul class="thumbnails">
+		        {foreach from=$thumbnails item=thumbnail}
+		        <li><span class="wrap1">
+			        <label>
+				        <span class="wrap2"><span>
+					        <img src="{$thumbnail.U_TN}" alt="{$thumbnail.file}" title="{$thumbnail.TITLE}" class="thumbnail" />
+				        </span></span>
+				        <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>
+			         {/if}
+                     {$thumbnail.file}  
+			        </span>
+
+			        </span>
+		        </li>
+		        {/foreach}
+	        </ul>	  
+        </fieldset>
+
+        <fieldset>
+        <label> {'target'|@translate}</label>
+        <table>
+        <td><label><input type="radio" name="target" value="all" /> {'all'|@translate}</label></td>
+        <td><label><input type="radio" name="target" value="selection" checked="checked" /> {'selection'|@translate}</label></td>
+        <td><input class="cluetip submit " title="{'selection'|@translate}|{'hlp_line3'|@translate}." type="submit" name="submit" value="{'selection'|@translate}"  {$tag_input_enabled} /></td>
+        </table>
+    </fieldset>
+</fieldset>
+ <script>
+   {if empty($Selectthumbnails)  }
+  
+   var no_affiche=true ;
+   {else}
+   var no_affiche=false ;
+   {/if} </script>
+<fieldset   id ="geoposition"  class="fieldset">
+<legend>{'Selection'|@translate}</legend>
+  
+    <fieldset>    
+	    <ul class="thumbnails">
+		    {foreach from=$Selectthumbnails item=thumbnail}		 
+			<li><span class="wrap1">
+				<label>
+					<span class="wrap2"><span>
+						<img src="{$thumbnail.U_TN}" alt="{$thumbnail.file}" title="{$thumbnail.TITLE}" class="thumbnail" />
+					</span>					
+					</span>
+					<br/>
+                </label>
+				<input type="hidden"  value={$thumbnail.id}  name="selection[]"    />				
+				<span class="thumbLegend">
+				{if isset($thumbnail.U_MAP)}
+					<a href="{$thumbnail.U_MAP}" target="_blank">{$thumbnail.lat},{$thumbnail.lon}</a>
+				{/if}
+				{$thumbnail.file}  
+				</span>
+				</span>
+			</li>			
+		{/foreach}
+	</ul>
+</fieldset>
+    <fieldset>
+    <label>{'command'|@translate}</label>
+
+        <table>
+            <td>
+            <input class="cluetip" title="{'reset'|@translate}|{'hlp_line4'|@translate}."  type="submit" name="submit" value="{'reset'|@translate}" /><br />
+            </td>
+            <td>
+        <input class="cluetip" title="{'selection'|@translate}|{'hlp_line3'|@translate}." type="submit" name="submit" value="{'selection'|@translate}" />
+            </td>
+        </table>
+
+        <label>{'Form'|@translate}</label> 
+        <table >
+        <td >
+  
+        <input class="cluetip" title="{'search_title'|@translate}|{'hlp_line6'|@translate}." type=button  value="{'search_title'|@translate}" id="search" />
+
+        <input class="cluetip" title="{'lieu'|@translate}|{'hlp_line5'|@translate}." type="text" size="70"   value="{$match}"  name="match"   id="match"    />
+        </td>
+		<table >
+        <tr>   <input type="text" size="15" value="{$filename}"  name="filename" />
+        <td > 
+        <label>Latitude (-90=S to 90=N)</label>
+        <input type="text" size="15" value="{$lat}"  name="lat" />
+        </td>
+        <td>          
+        <label>Longitude (-180=E to 180=W) </label> 
+        <input type="text" size="15"value="{$lon}"  name="lon"  />         
+        </td>
+        <td>          
+        <label>Altitude </label> 
+		<input type="hidden" size="2"value="0"  name="altRef"  />
+        <input type="text" size="15"value="{$alt}"  name="alt"  /> <label> m </label>         
+        </td>
+        </tr>
+		</table>
+		<tr>
+		<table >
+        <tr>  
+        <td > 
+        <label>Latitude DMS</label><input type="text" size="3" value="{$latRef}"  name="latRef" />
+        <input type="text" size="25" value="{$latDMS}"  name="latDMS" />
+        </td>
+        <td>          
+        <label>Longitude DMS </label><input type="text" size="3" value="{$lonRef}"  name="lonRef" /> 
+        <input type="text" size="25"value="{$lonDMS}"  name="lonDMS"  />         
+        </td>
+
+        </tr>
+		</table>
+		<tr>
+
+        <td>
+		<input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$tag_input_enabled} /></td>
+        </td></tr>
+        </table> 
+    </fieldset>
+
+    <fieldset>
+        <label>{'map'|@translate}</label>
+        <table>
+        <td><div id="markerStatus"></div></td>
+        <td><div id="markerAdress"></div></td>
+        </table>
+        <div id="map"></div>
+    </fieldset>
+  </fieldset>
+
+<fieldset   id ="metadata"  class="fieldset">
+<legend>{'Metadata'|@translate}</legend>
+<h4><a href="{$EDIT_RV_PATH}Edit_File_gps.php?jpeg_fname={$filename_abs}" >
+Click here to edit the Photoshop File Info for this file</a></h4>{$filename_abs}</fieldset>
+<table>
+ {foreach from=$datas item=valeur}   
+				{$valeur}
+	{/foreach}
+</table>			 
+</fieldset>
+
+
+
+</form>
+
+ <fieldset>
+<form name="EditJPEG" id="EditJPEG" action="{$EDIT_RV_PATH}Write_File_Info_Gps.php" method="post">
+  <input name="filename" size="60" id="filename" name="filename" type="test" value="../../../{$filename}"  />
+  <table> 
+    <tr>
+        <td>
+            Latitude Ref
+        </td>
+        <td>
+              <input size="60" id="latRef" name="GPSLatitudeRef" type="text" value="{$latRef}"> 
+        </td>
+     
+        <td>
+            Latitude
+        </td>
+        <td>
+             <input size="60" id="latDMS" name="GPSLatitude" type="text" value="{$latDMS}">   
+        </td>
+    </tr>
+        <tr>
+        <td>
+            Longitude Ref
+        </td>
+        <td>
+            <input size="60" id="lonRef" name="GPSLongitudeRef" type="text" value="{$lonRef}">
+        </td>
+  
+        <td>
+            Longitude
+        </td>
+        <td>
+<input size=60 id="lonDMS" name="GPSLongitude" type=\"text\" value="{$lonDMS}"> 
+        </td>
+    </tr>
+        <tr>
+		       <td>
+            Altitude Ref
+        </td>
+        <td>
+<input size=60 id="altRef" name="GPSAltitudeRef" type=\"text\" value="{$altRef}"> 
+        </td>
+        <td>
+            Altitude
+        </td>
+        <td>
+<input size=60 id="alt" name="GPSAltitude" type=\"text\" value="{$alt}"> 
+        </td>
+    </tr>
+</table>
+<br>
+<input type="submit" value="Update!">
+</form>
+</fieldset>
Index: /extensions/edit_gmaps/admin/header_2_1.tpl
===================================================================
--- /extensions/edit_gmaps/admin/header_2_1.tpl	(revision 9376)
+++ /extensions/edit_gmaps/admin/header_2_1.tpl	(revision 9377)
@@ -3,4 +3,4 @@
 {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_RV_ROOT|@cat:"js/JScript.js"} 
-{known_script id="fieldset" src=$EDIT_RV_ROOT|@cat:"js/fieldset.js"} 
+{known_script id="EDIT_RV_script" src=$EDIT_RV_PATH|@cat:"admin/js/JScript.js"} 
+{known_script id="fieldset" src=$EDIT_RV_PATH|@cat:"admin/js/fieldset.js"} 
Index: /extensions/edit_gmaps/admin/header_2_2.tpl
===================================================================
--- /extensions/edit_gmaps/admin/header_2_2.tpl	(revision 9376)
+++ /extensions/edit_gmaps/admin/header_2_2.tpl	(revision 9377)
@@ -7,4 +7,4 @@
 
 
-{combine_script id="EDIT_RV_script" path=$EDIT_RV_ROOT|@cat:"js/JScript.js" require="jquery"} 
-{combine_script id="fieldset" path=$EDIT_RV_ROOT|@cat:"js/fieldset.js" require="jquery"} 
+{combine_script id="EDIT_RV_script" path=$EDIT_RV_PATH|@cat:"admin/js/JScript.js" require="jquery"} 
+{combine_script id="fieldset" path=$EDIT_RV_PATH|@cat:"admin/js/fieldset.js" require="jquery"} 
Index: /extensions/edit_gmaps/admin/include/fonctions.php
===================================================================
--- /extensions/edit_gmaps/admin/include/fonctions.php	(revision 9377)
+++ /extensions/edit_gmaps/admin/include/fonctions.php	(revision 9377)
@@ -0,0 +1,126 @@
+<?php 
+  //
+  // DECIMAL TO FRACTION
+  //
+  function dec2frac( $decimal ) {
+    $decimal = (string)$decimal;
+    $num = '';
+    $den = 1;
+    $dec = false;
+
+    // find least reduced fractional form of number
+    for( $i = 0, $ix = strlen( $decimal ); $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{$i} == '.' ) $dec = true;
+     else $num .= $decimal{$i};
+    }
+    $num = (int)$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 ) ;
+        $ret1->Denominator=($den / $rem);
+
+    // now $rem holds the gcd of the numerator and denominator of our fraction
+    return $ret1;
+  }
+
+ 
+function dec2dms($value) { 
+        $value= abs($value);
+        $degrees= floor($value);
+        $tmp=($value-$degrees)*60; 
+        $minutes= floor($tmp); 
+        $seconds= round(($tmp-$minutes)*6000)/100;
+       
+        $sec=  dec2frac($seconds);
+ 
+        $ret[0]['Numerator'] =$degrees ;
+        $ret[0]['Denominator'] = 1 ;        
+        $ret[1]['Numerator']  =$minutes ;
+        $ret[1]['Denominator']=1;  
+        $ret[2]['Numerator']  =$sec->Numerator ;
+        $ret[2]['Denominator']=$sec->Denominator;
+  $ret[3]= " Deg: " . $degrees . " Min: " . $minutes . " Sec: " . $seconds."  " ;
+        
+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){
+
+echo  ($number)."<br />" ;
+$numerator = 1; 
+$denominator = 0; 
+$reste1->min =$number;
+
+
+for(  ; $numerator < 100; $numerator++){ 
+
+$temp =   ($numerator / $number);
+$reste=ceil($temp) - $temp;
+echo "<br />
+$reste --- $reste1->min " ; 
+if ($reste<$reste1->min) {
+        $reste1->numerator = $numerator;
+        $reste1->min =$reste ;
+        $reste1->denominator =$temp ;
+}
+
+    if(ceil($temp) - $temp == 0){ 
+                $denominator = $temp;
+                 break;
+        } 
+} 
+echo "<br />". $reste1->numerator . " /  " .$reste1->denominator ;
+
+return ($denominator > 0) ? $numerator . '/' . $denominator : false; 
+} 
+
+ function Parse_Fract( $f )
+{
+  $nd = explode( '/', $f );
+  return $nd[0]/$nd[1];
+}
+
+
+function Parse_Lat_Lon( $arr )
+{
+  $v=0;
+  $v += parse_fract( $arr[0] );
+  $v += parse_fract( $arr[1] )/60;
+  $v += parse_fract( $arr[2] )/3600;
+  return $v;
+}
+?>
Index: /extensions/edit_gmaps/admin/js/JScript.js
===================================================================
--- /extensions/edit_gmaps/admin/js/JScript.js	(revision 9376)
+++ /extensions/edit_gmaps/admin/js/JScript.js	(revision 9377)
@@ -80,18 +80,28 @@
 
             google.maps.event.addListener(marker,
-        'dragend',
-        function () {
-            updateMarkerStatus('Drag ended');
-            geocodePosition(marker.getPosition());
-           
-            }
+                                            'dragend',
+                                            function () {
+
+                                             
+                                     
+                                              // getElevation({ latLng: marker.getPosition() });
+                                                geocodePosition(marker.getPosition());
+                                                updateMarkerStatus('Drag ended');
+                                                getElevation({ 'latLng': marker.getPosition() });
+                                                document.Envoie.alt.value = coordinates.ALT;
+
+                                            }
         );
 
-
-
-		        // Update current position info.    
+       // 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() });
+		       document.Envoie.alt.value = coordinates.ALT;
 	          return false;
     
@@ -109,6 +119,52 @@
                 document.Envoie.lat.value=latLng.lat() ;
                 document.Envoie.lon.value = latLng.lng();
-               
-                
+                dms_frac = dec2dms(latLng.lng());
+                if (dms_frac.Degre < 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 (dms_frac.Degre < 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;
+                    }
+
+
+
+                }
+                )
+
+                   
+
                 }
            
@@ -119,11 +175,43 @@
             }
 
-
-       
-
-
-        function geocodePosition(pos) {
-            geocoder.geocode({ 'latLng': pos },
-               function (results, status) {
+            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;
+                                update_datas();
+                                   //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) {
@@ -198,5 +286,5 @@
 
         coordinates = { ADRESSE: jQuery("#match").val(),
-                        LAT:0,LON:0,ZOOM: 18 
+                        LAT:0,LON:0,ZOOM: 18 ,ALT:0
                        };
         codeAddress();
@@ -212,5 +300,5 @@
         if (Code != 13) return true;
         coordinates = { ADRESSE: jQuery("#match").val(),
-                        LAT:0,LON:0,ZOOM: 18 
+            LAT: 0, LON: 0, ZOOM: 18, ALT: 0
                        };
         codeAddress();
@@ -221,2 +309,63 @@
 });
 
+
+
+
+  // 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};
+}
+
Index: /extensions/edit_gmaps/include/functions.php
===================================================================
--- /extensions/edit_gmaps/include/functions.php	(revision 9376)
+++ /extensions/edit_gmaps/include/functions.php	(revision 9377)
@@ -1,5 +1,5 @@
 <?php
 
-function clm_get_cache_file_name()
+function cl_meta_get_cache_file_name()
 {
 	global $conf;
@@ -8,10 +8,10 @@
 }
 
-function clm_invalidate_cache()
+function cl_meta_invalidate_cache()
 {
-	@unlink(  clm_get_cache_file_name() );
+	@unlink(  cl_meta_get_cache_file_name() );
 }
 
-function clm_load_language()
+function cl_meta_load_language()
 {
 	global $lang,$lang_info,$conf;
@@ -21,5 +21,5 @@
 }
 
-function clm_items_have_latlon($items)
+function cl_meta_items_have_latlon($items)
 {
   $query = '
@@ -34,5 +34,5 @@
 }
 
-function clm_make_map_picture_url($params)
+function cl_meta_make_map_picture_url($params)
 {
 	global $conf;
@@ -43,5 +43,5 @@
 }
 
-function clm_duplicate_map_picture_url()
+function cl_meta_duplicate_map_picture_url()
 {
 	global $conf;
@@ -52,7 +52,7 @@
 }
 
-function clm_make_map_index_url($params=array())
+function cl_meta_make_map_index_url($params=array())
 {
-	global $conf, $clm_dir;
+	global $conf, $cl_meta_dir;
 	if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
 		return "";
@@ -67,22 +67,22 @@
 }
 
-function clm_duplicate_map_index_url($redefined=array(), $removed=array())
+function cl_meta_duplicate_map_index_url($redefined=array(), $removed=array())
 {
-	return clm_make_map_index_url(
+	return cl_meta_make_map_index_url(
 		params_for_duplication($redefined, $removed)
 		);
 }
 
-function clm_duplicate_kml_index_url($redefined=array(), $removed=array())
+function cl_meta_duplicate_kml_index_url($redefined=array(), $removed=array())
 {
-	return clm_make_kml_index_url(
+	return cl_meta_make_kml_index_url(
 		params_for_duplication($redefined, $removed)
 		);
 }
 
-function clm_make_kml_index_url($params)
+function cl_meta_make_kml_index_url($params)
 {
-	global $conf, $clm_dir;
-	$url = get_root_url().'plugins/'.$clm_dir.'/kml.php';
+	global $conf, $cl_meta_dir;
+	$url = get_root_url().'plugins/'.$cl_meta_dir.'/kml.php';
 	if ($conf['question_mark_in_urls'])
 		$url .= '?';
Index: /extensions/edit_gmaps/main.inc.php
===================================================================
--- /extensions/edit_gmaps/main.inc.php	(revision 9376)
+++ /extensions/edit_gmaps/main.inc.php	(revision 9377)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: Edit Maps&Earth
-Version: 2.1.4
+Version: auto
 Description:  Editor for rv gmaps 
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=330
@@ -17,5 +17,5 @@
 {
  	include_once( dirname(__FILE__) .'/include/functions.php');
-	add_event_handler('invalidate_user_cache', 'clm_invalidate_cache' );
+	add_event_handler('invalidate_user_cache', 'cl_meta_invalidate_cache' );
 	array_push($menu,
 			array(			
Index: /extensions/edit_gmaps/maintain.inc.php
===================================================================
--- /extensions/edit_gmaps/maintain.inc.php	(revision 9376)
+++ /extensions/edit_gmaps/maintain.inc.php	(revision 9377)
@@ -2,5 +2,7 @@
 function plugin_install()
 {
-
+  $q = '
+ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `alt` DOUBLE(9,6)';
+  pwg_query($q);
 }
 
@@ -14,9 +16,12 @@
 {
  
-  clm_invalidate_cache();
+  cl_meta_invalidate_cache();
 }
 
 function plugin_uninstall()
 {
+  $q = '
+ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `alt`';
+  pwg_query( $q );
 }
 ?>
