Changeset 12126


Ignore:
Timestamp:
Sep 10, 2011, 5:02:19 PM (13 years ago)
Author:
cljosse
Message:

[extensions] edit_gmaps add functions

Location:
extensions/edit_gmaps
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/edit_gmaps/admin/admin_edit.php

    r10060 r12126  
    1 <?php 
     1<?php
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33global $lang;
     
    66
    77if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    8  
     8
    99/***********************************************************************************/
    1010if (!defined('TOOL_KIT_PATH')) define(  'TOOL_KIT_PATH',   EDIT_CL_PATH."admin/");
    11 if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );                     
    12 $Toolkit_Dir =INCLUDE_PATH           ;   
    13  
     11if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );
     12
     13$Toolkit_Dir =INCLUDE_PATH           ;
     14
    1415include $Toolkit_Dir . 'fonctions.php';
    15 /***********************************************************************************/
     16//==========================================================
     17if (!defined('EDIT_CL_PATH')) define(  'EDIT_CL_PATH',  EDIT_CL_PATH .'admin/' );
     18$path = EDIT_CL_PATH;
     19$plg_data = implode( '', file($path.'main.inc.php') );
     20if (preg_match("|Version: (.*)|", $plg_data, $val)) {
     21  $EDIT_CL_PATH_plugin['version'] = trim($val[1]); 
     22}
     23$EDIT_CL_PATH_plugin = array_map('htmlspecialchars', $EDIT_CL_PATH_plugin);
     24$version= $EDIT_CL_PATH_plugin['version'] ;
     25$icon_path = 'themes/default/icon/help.png';
     26$path_js=  'themes/default/js/' ;
     27/****************************************************************/
    1628$info_message="" ;
    17 $error_message="";
    18  
    19 /************* Mise à jour des meta données ***************/
    20 if ( isset($_POST['update']) && $_POST['update']==l10n('update_exif')){
    21   $exif = @read_exif_data( $exif );     
    22   $exif = @array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
    23 
    24   // error_reporting ( 0 );
    25   // Hide any unknown EXIF tags       
    26   $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE;
    27   include $Toolkit_Dir.'Toolkit_Version.php';   // Change: added as of version 1.11
    28     // Include the required files for reading and writing Photoshop File Info
    29   include  $Toolkit_Dir.'JPEG.php';
    30   include  $Toolkit_Dir.'XMP.php';
    31   include  $Toolkit_Dir.'Photoshop_IRB.php';
    32   include  $Toolkit_Dir.'EXIF.php';
    33   include  $Toolkit_Dir.'GPS_File_Info.php';
    34   $GLOBALS['HTTP_POST_VARS']=$_POST ;
    35   // Copy all of the HTML Posted variables into an array
    36   $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS'];
    37   // Some characters are escaped with backslashes in HTML Posted variable
    38   // Cycle through each of the HTML Posted variables, and strip out the slashes '
    39   foreach( $new_ps_file_info_array as $var_key => $var_val ){
    40     if ($var_key !="selection")
    41         $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val );                           
    42   }         
    43   $new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']);
    44   foreach( $new_ps_file_info_array['selection']  as $filename )   {
    45     //======================================================
    46     //= $new_ps_file_info_array[ 'filename' ];
    47     if($filename!="") {   // Protect against hackers editing other files                               
    48       // copy( $filename,  $filename.".bak" ); 
    49       $path_parts = pathinfo( $filename );   
    50       if(1) {
    51         if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) {
    52           $error_message .= $filename ;                                 
    53           $error_message .="Incorrect File Type - JPEG Only\n";
    54           $filename="";
    55           //  exit( );
    56          }
    57         // Change: removed limitation on file being in current directory - as of version 1.11
    58         // Retrieve the header information
    59         $jpeg_header_data = get_jpeg_header_data( $filename );
    60         // Retreive the EXIF, XMP and Photoshop IRB information from
    61         // the existing file, so that it can be updated
    62         $Exif_array = get_EXIF_JPEG( $filename );
    63         $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) );
    64         $IRB_array = get_Photoshop_IRB( $jpeg_header_data );
    65 
    66         // Update the JPEG header information with the new Photoshop File Info
    67         $jpeg_header_data = put_GPS_file_info( $jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array );
    68         // Check if the Update worked
    69         if ( $jpeg_header_data == FALSE ) {
    70             // Update of file info didn''t work - output error message
    71             $error_message .= "jpeg_header_data
    72             Error - Failure update Photoshop File Info : $filename <br>\n";
    73             // Output HTML with the form and data which was
    74             // sent, to allow the user to fix it
    75           }else if ( FALSE == put_jpeg_header_data(  $filename, $filename, $jpeg_header_data ) ) {
    76             // Attempt to write the new JPEG file
    77             // Writing of the new file didn''t work - output error message
    78             $error_message .= "Error - Failure to write new JPEG : $filename <br>\n";
    79             // Output HTML with the form and data which was
    80             // sent, to allow the user to fix it
    81           }else{
    82             $info_message .= l10n('update') . " Exif: " . $filename . " " .  l10n('OK') ."<br />" ;
    83           }   
    84           $_POST['submit']= l10n('update_database') ;
    85         }
    86       }
    87     }
    88     $_POST['update'] ="ok";
    89   }
     29$erreur_message="";
    9030/****************************************************************/
    9131if ( !isset($_GET['cat']) )   $_GET['cat'] = 'caddie';
    9232$_GET['mode'] = 'map';
    93 if (PHPWG_VERSION < 2.2 ) {
    94  include (PHPWG_ROOT_PATH.'admin/element_set.php');                             
    95  } else {
    96 if (!isset($page['title'])) $page['title']="";
    97     include (PHPWG_ROOT_PATH.'admin/batch_manager.php');                 
     33    if (PHPWG_VERSION < 2.2 ) {
     34      include (PHPWG_ROOT_PATH.'admin/element_set.php');
     35    } else {
     36      if (!isset($page['title'])) $page['title']="";
     37      include (PHPWG_ROOT_PATH.'admin/batch_manager.php');
    9838    $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']);
    99    }   
    100 
    101 if ( isset($_POST['submit'])  ) {
    102         $collection = array();
    103                 if( !isset ($_POST['target'])) {
    104                     $_POST['submit'] = l10n('Submit') ;
    105                     $_POST['target']='selection';
    106                     $collection = $_POST['selection'];
    107                }
    108 
    109   switch ($_POST['target'])
    110   {
     39  }
     40//===============================================================
     41$collection = array();
     42if(!isset($_POST['target'])) $_POST['target']="";
     43
     44  switch ($_POST['target']){
    11145    case 'all' :
    11246      $collection = $page['cat_elements_id'];
    113       break;
     47    break;
    11448    case 'selection' :
    11549      if (!isset($_POST['selection']) or count($_POST['selection']) == 0)
     
    11751      else
    11852        $collection = $_POST['selection'];
    119       break;
    120   }
    121 
     53    break;
     54  }
     55if (isset($_POST['selection'])){}
     56//===============================================================       
     57  $images=array();   
     58if (!empty($_GET['display']))
     59{
     60  if ('all' == $_GET['display'])
     61    $page['nb_images'] = count($page['cat_elements_id']);
     62  else
     63    $page['nb_images'] = intval($_GET['display']);
     64}
     65else
     66  $page['nb_images'] = 20;
     67
     68if ( !empty($page['cat_elements_id']) )
     69{
     70  $query='
     71SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
     72  WHERE id IN ('.implode(',',$page['cat_elements_id']).')
     73  '.$conf['order_by'].'
     74  LIMIT '.$page['start'].', '.   $page['nb_images'] .'
     75;';
     76  $result = pwg_query($query);
     77  while ( $row=mysql_fetch_assoc($result) )
     78    $images[] = $row;
     79}
     80//===============================================================
     81global $lang_info;
     82if (date_default_timezone_get()) {
     83  $adresse =  date_default_timezone_get()   ;
     84}else{
     85
     86}
     87$adresse =  $lang_info['country'];   ;
     88$adresse=str_replace("/",", ",$adresse);
     89 
     90if (count($collection)>0 )
     91//=============================================================
     92  if (isset($_POST['update']) && $_POST['update']==l10n('update_exif')){
     93  /************* Mise à jour des meta données ***************/
     94    // error_reporting ( 0 );
     95    // Hide any unknown EXIF tags   
     96    $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE;
     97    include $Toolkit_Dir.'Toolkit_Version.php';   // Change: added as of version 1.11
     98      // Include the required files for reading and writing Photoshop File Info
     99    include  $Toolkit_Dir.'JPEG.php';
     100    include  $Toolkit_Dir.'XMP.php';
     101    include  $Toolkit_Dir.'Photoshop_IRB.php';
     102    include  $Toolkit_Dir.'EXIF.php';
     103    include  $Toolkit_Dir.'GPS_File_Info.php';
     104
     105    $GLOBALS['HTTP_POST_VARS']=$_POST ;
     106    // Copy all of the HTML Posted variables into an array
     107    $new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS'];
     108
     109    // Some characters are escaped with backslashes in HTML Posted variable
     110    // Cycle through each of the HTML Posted variables, and strip out the slashes '
     111
     112    foreach( $new_ps_file_info_array as $var_key => $var_val ){
     113      if ($var_key !="selection")
     114          $new_ps_file_info_array[ $var_key ] = stripslashes( $var_val );
     115    }
     116   
     117      $init_info =true;
     118      $first_image="";   
     119      $_POST['submit']="";
     120
     121      foreach ($collection as $id_0){
     122          foreach ($images as $image) { 
     123            if (array_search($id_0,$image)) {   
     124              //=================================================================
     125              // Donnée base de donnée
     126              //=================================================================
     127         //     $info_message .= "<div style='border:2px solid red'>$id_0 Image:" . cl_edit_functions::Memo_vars($image)."</div>" ;
     128               
     129              //=================================================================
     130              // Meta donnée
     131              //=================================================================
     132                $infos_gps  = array();
     133                $infos_gps  = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     134                if($image['lat']=='' || $image['lon']==''){
     135                    $image['lat']=$infos_gps['lat'];
     136                    $image['lon']=$infos_gps['lon'];
     137                    $image['alt']=$infos_gps['alt'];
     138                }     
     139
     140                if($image['lat']!=''){
     141                      $new_ps_file_info_array=  base_to_meta($image);
     142                  }
     143
     144                $new_ps_file_info_array['filename'] =  $image['path'];
     145                $new_ps_file_info_array['selection'] = explode(";",$new_ps_file_info_array['filename']);
     146   //   
     147          if( $image['lat']=="" ){
     148              $image['lat']=  $new_ps_file_info_array['lat'] ;
     149              $image['lon']=  $new_ps_file_info_array['lon'] ;
     150              $image['alt']=  $new_ps_file_info_array['alt'] ;
     151          }
     152        if($_POST['update']==l10n('update_exif')) unset($_POST['submit']);
     153        if(1) {
     154 
     155           if(  cl_edit_controler::add_meta_gps($new_ps_file_info_array,$image)){
     156             
     157                $exif = @read_exif_data( $image['path']);
     158                 $infos_gps  = cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     159                $info_message .= $image['path'] . " : " . $image['file'] . " : ok<BR />";
     160                }else{
     161
     162                }
     163           }
     164        }else{
     165         
     166        } // fin search
     167      }   // fin id_0
     168    }     // fin collection     
     169    $_POST['update'] ="ok";
     170  }
     171
     172if ( isset($_POST['submit'])  ) {
    122173  /******** Mise à jour base de données *****/
    123174   if (   $_POST['submit'] == l10n('update_database') ){
    124         if ( count($collection)>0 ){
    125     $lat = trim($_POST['lat']);
    126     $lon = trim($_POST['lon']);
    127         $alt = trim($_POST['alt']);
    128 
    129     if ( strlen($lat)>0 and strlen($lon)>0 ) {
    130       if ( (double)$lat<=90 and (double)$lat>=-90
    131           and (double)$lon<=180 and (double)$lat>=-180 )
    132         $update_query = 'lat='.$lat.', lon='.$lon;
    133       else
    134         $page['errors'][] = 'Invalid lat or lon value';
     175    if ( count($collection)>0 ){
     176        $lat = trim($_POST['lat']);
     177        $lon = trim($_POST['lon']);
     178        $alt = trim($_POST['alt']);
     179        //===============================================================
     180       if($lat !="") cl_edit_controler::add_data_base($collection,$lat,$lon,$alt) ;
     181        $_POST['submit'] = l10n('Submit') ;
     182            foreach ($collection as $id_0){
     183          foreach ($images as $image) { 
     184            if (array_search($id_0,$image)) { 
     185              $image['lat'] =    $lat ;
     186              $image['lon']= $lon  ;
     187              $image['alt'] =$alt  ;
     188           }
     189          }
     190        } 
     191      }
    135192    }
    136     elseif ( strlen($lat)==0 and strlen($lon)==0 )
    137       $update_query = 'lat=NULL, lon=NULL';
    138     else
    139       $page['errors'][] = 'Both lat/lon must be empty or not empty';
    140 
    141               if ( strlen($alt)==0)
    142                      $update_query .= ', alt=NULL';
    143                   else
    144                      $update_query .= ', alt=' .$alt ;
    145 
    146         if (isset($update_query)){
    147       $update_query = '
    148                 UPDATE '.IMAGES_TABLE.' SET '.$update_query.'
    149                 WHERE id IN ('.implode(',',$collection).')';
    150         pwg_query($update_query);
    151                 cl_meta_invalidate_cache();
    152                 $info_message .= l10n('update') . " " . IMAGES_TABLE . " : " .  l10n('OK') ;
    153                 $_POST['submit'] = l10n('Submit') ;
    154      }
    155     }
    156   }
    157193 }
    158194/**************************************/
     195
    159196$specials_selected = null;
    160 foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v)
    161 {
    162         $link = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$k;
    163         $template->append(
    164                 'specials',
    165                 array(
    166                         $link => l10n($v),
    167                         ),
    168                 true
    169                 );
    170         if ($k == $_GET['cat']) $specials_selected = $link;
    171 }
     197foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v){
     198    $link = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$k;
     199    $template->append(
     200        'specials',
     201        array(
     202            $link => l10n($v),
     203            ),
     204        true
     205        );
     206    if ($k == $_GET['cat']) $specials_selected = $link;
     207}
     208
     209
    172210$template->assign('specials_selected', $specials_selected);
    173211/****************************************/
     
    179217$categories = array();
    180218$selecteds = array();
    181 if (!empty($result))
    182 {
    183   while ($row = mysql_fetch_assoc($result))
    184   {
     219if (!empty($result)){
     220  while ($row = mysql_fetch_assoc($result))  {
    185221    $url = $admin_url.get_query_string_diff(array('start','cat')).'&amp;cat='.$row['id'];
    186222    if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url;
     
    192228display_select_categories($categories, $selecteds, 'categories', false);
    193229
    194 if (!empty($_GET['display']))
    195 {
    196   if ('all' == $_GET['display'])
    197     $page['nb_images'] = count($page['cat_elements_id']);
    198   else
    199     $page['nb_images'] = intval($_GET['display']);
    200 }
    201 else
    202   $page['nb_images'] = 20;
    203 
    204 if ( !empty($page['cat_elements_id']) )
    205 {
     230
     231if ( !empty($page['cat_elements_id']) ){
    206232  $nav_bar = create_navigation_bar(
    207233    $admin_url.get_query_string_diff(array('start')),
     
    212238  $template->assign('navbar', $nav_bar);
    213239}
    214 
    215 $images=array();
    216 if ( !empty($page['cat_elements_id']) )
    217 {
    218   $query='
    219 SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
    220   WHERE id IN ('.implode(',',$page['cat_elements_id']).')
    221   '.$conf['order_by'].'
    222   LIMIT '.$page['start'].', '.$page['nb_images'].'
    223 ;';
    224   $result = pwg_query($query);
    225   while ( $row=mysql_fetch_assoc($result) )
    226     $images[] = $row;
    227 }
    228 
    229 foreach ($images as $image)
    230 {
    231         $tpl_var = array_merge( $image,
     240//========================================================================
     241  $v_exif="";
     242foreach ($images as $image){ 
     243 
     244    $infos_gps  = array();
     245    $infos_gps  =  cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     246    $v_exif=$infos_gps['is_exif']?true:false ;   
     247    $v_db=false  ;
     248    $v_db=$image['lat']!=0 && $image['lon']!=0;
     249
     250    if(  $infos_gps['lat'] !=0  || $infos_gps['lon'] !=0 ) { 
     251   
     252      $new= ( !isset($image['lat'])? true: $image['lat']!=$infos_gps['lat'] ) ;
     253      $image['lat']=$infos_gps['lat'];
     254      $image['lon']=$infos_gps['lon'];
     255      $image['alt']=$infos_gps['alt'];
     256      $sel_img= array($image['id']);
     257      if ($new) cl_edit_controler::add_data_base( $sel_img,$image['lat'],$image['lon'],$image['alt']) ;             
     258   }         
     259   //=================================================
     260   $tpl_var = array_merge( $image,
    232261      array(
     262        'U_EXIF' => $v_exif,
     263        'U_DB' => $v_db,
    233264        'U_TN' => get_thumbnail_url($image),
    234265        'TITLE' => get_thumbnail_title($image)
    235       )
    236     );
    237   if ( isset($image['lat']) )
    238     $tpl_var['U_MAP'] = cl_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) );
    239         $template->append('thumbnails', $tpl_var);
    240 }
     266      ) );
     267
     268  if ( isset($image['lat']) ){
     269    $tpl_var['U_MAP'] = cl_make_map_picture_url(
     270    array('image_id'=>$image['id'],
     271          'image_file'=>$image['file']) );
     272         }
     273           
     274    $template->append('thumbnails', $tpl_var);
     275}
     276
    241277
    242278$template->assign(
    243279    array(
    244280      'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display'))
    245     ) 
     281    )
    246282  );
    247283
    248 //==========================================================
    249         if (!defined('EDIT_CL_PATH')) define(  'EDIT_CL_PATH',  EDIT_CL_PATH .'admin/' );
    250         $path = EDIT_CL_PATH;
    251     $plg_data = implode( '', file($path.'main.inc.php') );
    252          if (preg_match("|Version: (.*)|", $plg_data, $val))
    253           { $EDIT_CL_PATH_plugin['version'] = trim($val[1]);  } 
    254             $EDIT_CL_PATH_plugin = array_map('htmlspecialchars', $EDIT_CL_PATH_plugin);
    255             $version= $EDIT_CL_PATH_plugin['version'] ;
    256             $icon_path = 'themes/default/icon/help.png';
    257             $path_js=  'themes/default/js/' ;
    258284
    259285//==================================================================================
    260 $match="";
    261      
    262 if ( isset($_POST['submit'])   )
    263 {       
    264   if ($_POST['submit']==l10n('Submit') )
    265    {
    266       $_POST['selection']=array(); 
    267       $collection =array();
    268           unset($collection);
    269   }
    270  
    271 
    272  if ($_POST['submit']==l10n('reset' ) )
    273                 {
    274                         $_POST['selection']=array();
    275                         unset($collection);
    276                 }
    277  
    278  }
     286$match="";
     287if ( isset($_POST['submit'])   ) {
     288  if ($_POST['submit']==l10n('Submit') ) {
     289    $_POST['selection']=array();
     290    $collection =array();
     291    unset($collection);
     292  }
     293  if ($_POST['submit']==l10n('reset' ) ) {
     294    $_POST['selection']=array();
     295    unset($collection);
     296  }
     297}
    279298//=================================================================================
    280299$src="";
    281 
    282300$template->assign(
    283     array(      'EDIT_CL_PATH' => EDIT_CL_PATH,
    284                 'path_js' => $path_js,
     301    array(  'EDIT_CL_PATH' => EDIT_CL_PATH,
     302            'path_js' => $path_js,
    285303            'VERSION'=> $version,
    286304            'EDIT_CL_PATH_ABS' => dirname(__FILE__).'/',
    287               )
     305          )
    288306  );
    289   global $lang_info;
    290     if (date_default_timezone_get()) {
    291             $adresse =  date_default_timezone_get()   ;
    292         }else{
    293 
    294         }
    295     $adresse =  $lang_info['country'];   ;
    296     $adresse=str_replace("/",", ",$adresse);
    297     $template->assign( 'coordinates',
    298                                         array(  'FILE' => '',
    299                                 'LAT' => '100',
    300                                                                 'LON' => '100',
    301                                                                 'ADRESSE' => $adresse,
    302                                                                 'ZOOM' => 18,
    303                                 'ALT' => 0
    304                                                         )
    305                                                 );   
    306 
    307 if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
    308 {
    309   if (isset($collection)) { 
    310     $lat =1000;$first_image="";                           
     307 
     308$template->assign( 'coordinates',
     309                    array(  'FILE' => '',
     310                            'LAT' => '100',
     311                            'LON' => '100',
     312                            'ADRESSE' => $adresse,
     313                            'ZOOM' => 18,
     314                            'ALT' => 0
     315                        )
     316                    );
     317//======================================================================
     318if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' )){
     319  if (isset($collection)) {
     320    $init_info =true;
     321    $first_image="";
     322    $_POST['selection'] = $collection ;
    311323    foreach ($collection as $id_0)  {
    312                 foreach ($images as $image) {
    313                         if (array_search($id_0,$image)) {
    314             $_POST['selection'] = $collection ;   
    315             $infos_gps=  Get_exif_gps( $image['path'],$image) ;   
    316             $image['lat']=$infos_gps['lat'];
    317             $image['lon']=$infos_gps['lon'];
    318             $image['alt']=$infos_gps['alt'];
    319             if ($lat==1000) {
    320                                 $lat= ($image['lat'] <> '') ? $image['lat'] : '100'  ;
    321                                       $lon= ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
    322               $alt= ($image['alt']  <> '') ? $image['alt'] : '0'  ;
    323                                       if($lat != '100') $lat=$image['lat'];
    324                                       //=====================================================
    325                                       $template->assign( 'coordinates',
    326                                              array('FILE' => $image['path'],
    327                      'LAT' =>   $lat  ,
    328                                                                                  'LON' =>   $lon  ,
    329                                                                                  'ADRESSE' =>  $adresse ,
    330                                                                                  'ZOOM' => 4,
    331                      'ALT' =>   $alt ,
    332                                                                                 )
    333                                                                         );
    334                                 }
    335                                                
     324        foreach ($images as $image) {
     325            if (array_search($id_0,$image)) {   
     326              $infos_gps  = array();   
     327              if($image['lat']=='' || $image['lon']==''){    }
     328              $infos_gps  =array();
     329              $infos_gps  =  cl_edit_controler::Get_exif_gps( $image['path'],$image,false) ;
     330              if(isset($infos_gps['lat']) && $infos_gps['is_exif']){       
     331                $image['lat']=$infos_gps['lat'];
     332                $image['lon']=$infos_gps['lon'];
     333                $image['alt']=$infos_gps['alt'];
     334              }                   
     335              if ( $init_info && $image['lat'] <> '' ) {
     336                $init_info = false ;
     337                $lat = ($image['lat'] <> '') ? $image['lat'] : '100'  ;
     338                $lon = ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
     339                $alt = ($image['alt']  <> '') ? $image['alt'] : '0'  ;
     340                     
     341                //=====================================================
     342                $template->assign( 'coordinates',
     343                        array(
     344                            'FILE' => $image['path'],
     345                            'LAT' =>   $lat  ,
     346                            'LON' =>   $lon  ,
     347                            'ADRESSE' =>  $adresse ,
     348                            'ZOOM' => 4,
     349                            'ALT' =>  $alt ,
     350                              )
     351                          );                             
     352              }
     353              //=====================================================
    336354                    $lon=$image['lon'];
    337                     $lat=$image['lat'];   
    338                     if($infos_gps['is_exif'])   $info_message .='EXIF';   
    339 
    340                 $lonDMS= dec2dms($lon) ;
    341                 $latDMS= dec2dms($lat) ;
    342 
    343 
    344                             $tpl_var = array_merge(
    345                                     $image,
    346                                         array(
     355                    $lat=$image['lat'];
     356                    if($infos_gps['is_exif']) {                                       
     357                     $info_message .='EXIF';
     358                    }
     359                    $lonDMS= dec2dms($lon) ;
     360                    $latDMS= dec2dms($lat) ;
     361
     362                        $v_db=false  ;
     363    $v_db=$lon!=0 && $lat!=0;
     364
     365                $tpl_var = array_merge(
     366                        $image,
     367                        array(
    347368                  'filename' =>  $image['path'],
    348                   'exif' => $infos_gps['is_exif'] ,
     369                  'exif' => '"'.$infos_gps['is_exif'].'"' ,
    349370                  'lat'  =>    $image['lat']    ,
    350371                  'lon' =>     $image['lon']    ,
    351                   'alt' =>     $image['alt']    , 
     372                  'alt' =>     $image['alt']    ,
    352373                  'latDMS' =>    $latDMS[3]     ,
    353                   'lonDMS' =>   "-->".$lonDMS[3]     ,
     374                  'lonDMS' =>   $lonDMS[3]     ,
    354375                  'adresse' =>  $adresse   ,
    355376                  'U_TN' => get_thumbnail_url($image),
    356377                  'TITLE' => get_thumbnail_title($image),
    357                                                             'U_MAP' => cl_make_map_picture_url(
    358                                                                                             array(
    359                                                                                                  'image_id'=>$image['id'],
    360                                                                                                  'image_file'=>$image['file'],
    361                                                                                                  )
    362                                                                                     ),
    363                                                                   )                                                             
    364                                                 );       
    365                                 $template->append('Selectthumbnails', $tpl_var);                       
    366                         }
    367                 }       
    368         }
    369   }
    370 
    371 }
    372 
    373 
    374  if ( !empty($first_image))
    375  { $error_message .= cl_edit_controler::Memo_Vars($first_image);
    376  if (isset($_POST['update'])) {
    377 // document.Envoie.latDMS.value
    378         $image= first_image ;
    379         $filename=$image['path'] ;
    380         $Val_exif="";
    381         $Val_XMP="";           
    382    /*  */   
    383      if (!empty($infos_gps))
    384      $Position = $infos_gps ;
    385      else  $Position =  Get_exif_gps($filename,$image) ;
    386 
    387   $jpeg_header_data = get_jpeg_header_data($filename );
    388      $template->assign( array(
    389       'filename_abs' =>   $filename ,
    390       'filename' => $filename,
    391      'datas'    =>    array(
    392 /*       'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ),
     378                  'U_EXIF' =>  $infos_gps['is_exif'] ,
     379                  'U_BD' =>  $v_db ,
     380                  'U_MAP' => cl_make_map_picture_url(
     381                                                array(
     382                                                      'image_id'=>$image['id'],
     383                                                      'image_file'=>$image['file'],
     384                                                      )
     385                                                    ),
     386                                  )
     387                            );
     388          $template->append('Selectthumbnails', $tpl_var);
     389        }
     390      }
     391    }
     392  }
     393}
     394
     395//============================================================
     396 if ( !empty($first_image)) {
     397   $erreur_message .= cl_edit_functions::Memo_Vars($first_image);
     398   
     399   if (isset($_POST['update'])) {
     400          // document.Envoie.latDMS.value
     401          $image= first_image ;
     402          $filename=$image['path'] ;
     403          $Val_exif="";
     404          $Val_XMP="";
     405   /*  */
     406     if (!empty($infos_gps))
     407         $Position = $infos_gps ;
     408     else  $Position =  cl_edit_controler::Get_exif_gps($filename,$image,false) ;
     409
     410      $jpeg_header_data = get_jpeg_header_data($filename );
     411      $template->assign( array(
     412      'filename_abs' =>   $filename ,
     413      'filename' => $filename,
     414      'datas'    =>    array(
     415/*       
     416        'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ),
    393417        'Val_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ),
    394         'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ), 
     418        'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ),
    395419        'Val_JFIF'=> Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ),
    396         'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ), 
    397         'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ),         
    398         'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ), 
     420        'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ),
     421        'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ),
     422        'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ),
    399423
    400424        'Val_exif'=>  Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename),
    401425        'Val_XMP' =>  Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data) ) ),
    402426          */
    403      // 
     427     //
    404428         ),
    405  'Datadase' =>  ($Position) ,
     429          'Datadase' =>  ($Position) ,
    406430          ) );
    407        
    408 
    409           }
     431  }
    410432}
    411433
     
    414436function cl_make_map_picture_url($params)
    415437{
    416         global $conf;
    417         /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
    418                 return "";*/
    419         $map_url = make_picture_url($params);
    420         return add_url_params($map_url, array('map'=>null) );
     438    global $conf;
     439    /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
     440        return "";*/
     441    $map_url = make_picture_url($params);
     442    return add_url_params($map_url, array('map'=>null) );
    421443}
    422444$v1=0;
     
    424446
    425447
    426 function Get_exif_gps($firt_image,$image)
    427 {
    428 
    429  error_reporting ( 1 );
    430  $filename=$firt_image;
    431  
    432   $datas = array();
    433   $errors = array();
    434  
    435 
    436   $exif = @read_exif_data( $filename ); 
    437 global $errors;global $template ;
    438 
    439       if ( empty($exif) ) return;
    440          $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
    441 
    442 //====================================================================
    443     $lat = $image['lat'] ;         
    444     $lon = $image['lon'] ;
    445     $alt = $image['alt'];
    446     global $info_message ;
    447 
    448 $is_exif = "'".(is_array($exif['GPSLatitude']) and is_array($exif['GPSLongitude']) )."'" ;
    449  if ($is_exif) {
    450      $lat_exif = parse_lat_lon( $exif['GPSLatitude'] );         
    451      $lon_exif = parse_lat_lon( $exif['GPSLongitude'] );
    452      $alt_exif = Parse_Fract( $exif['GPSAltitude'] ); 
    453  }
    454 
    455 if ($lat =="")
    456 {   
    457   $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); 
    458   if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat;
    459  
    460 }else{
    461     $is_exif="false" ;
    462     if($lat<0)      $exif['GPSLatitudeRef']='S' ;
    463         else        $exif['GPSLatitudeRef']='N' ;
    464        
    465      
    466 }   
    467 if ($lon =="") {
    468        
    469                 $lon = parse_lat_lon( $exif['GPSLongitude'] );
    470                 if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
    471            }else{
    472              if ($lon<0) $exif['GPSLongitudeRef'] ='W' ;
    473              else $exif['GPSLongitudeRef'] ='E' ;
    474                  
    475            }
    476 
    477    
    478  
    479 //=======================================================================         
    480            $altref = 0;
    481 
    482 if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) )
    483                 {
    484                          $exif['GPSAltitude']=$alt;
    485              $exif['GPSAltitudeRef']=0;
    486                 }       else {
    487                 $alt =           $exif['GPSAltitude'];
    488             $altref = $exif['GPSAltitudeRef'];
    489         }
    490  //========================================================================     
    491                 $datas[] = array (
    492             'is_exif' => $is_exif,
    493             ' filename=' => $filename ,
    494                         'id' =>    $image['id'] ,
    495                         'lat' =>   $lat ,
    496                         'lon' =>   $lon ,
    497                         'latDMS' =>     $exif['GPSLatitude'][0]['Numerator']  . "/" .
    498                             $exif['GPSLatitude'][0]['Denominator'] . " " .   
    499                             $exif['GPSLatitude'][1]['Numerator'] . "/" .
    500                             $exif['GPSLatitude'][1]['Denominator']. " " .   
    501                             $exif['GPSLatitude'][2]['Numerator'] . "/" .
    502                             $exif['GPSLatitude'][2]['Denominator'],
    503                         'lonDMS' =>     $exif['GPSLongitude'][0]['Numerator']  . "/" .
    504                             $exif['GPSLongitude'][0]['Denominator'] . " " .   
    505                             $exif['GPSLongitude'][1]['Numerator'] . "/" .
    506                             $exif['GPSLongitude'][1]['Denominator']. " " .   
    507                             $exif['GPSLongitude'][2]['Numerator'] . "/" .
    508                             $exif['GPSLongitude'][2]['Denominator'],
    509             'altref' => $exif['GPSAltitudeRef'],
    510             'alt' =>   $exif['GPSAltitude'] ,
    511 
    512                         ); 
    513 
    514 return $datas[0] ;
    515 }
     448
    516449if ($info_message!="")
    517450$template->assign('infos',$info_message);
    518 if ($error_message!="")
    519 $template->assign('errors',$error_message);
     451if ($erreur_message!="")
     452$template->assign('errors',$erreur_message);
     453
     454
    520455?>
  • extensions/edit_gmaps/admin/admin_edit.tpl

    r10060 r12126  
    101101                                        <input type="checkbox" name="selection[]" value="{$thumbnail.id}"    />
    102102                                </label>
    103                                 <span class="thumbLegend">
    104                                  {if isset($thumbnail.U_MAP)}
    105                                    <a href="{$thumbnail.U_MAP}" target="_blank">{$thumbnail.lat},{$thumbnail.lon}</a>
     103                                <span class="thumbLegend" >
     104              <div> {$thumbnail.file} </div>
     105              {if isset($thumbnail.U_MAP)}
     106              <div ><a href="{$thumbnail.U_MAP}" target="_blank" >
     107              {if $thumbnail.U_EXIF  }
     108              EXIF
     109              {/if}
     110              {if $thumbnail.U_DB  }
     111                BD
     112              {/if}</a>
     113              </div>                             
     114                                 
    106115                                 {/if}
    107                      {$thumbnail.file}
     116                   
    108117                                       
    109118                                </span>
     
    121130        <td><label><input type="radio" name="target" value="selection" checked="checked" /> {'selection'|@translate}</label></td>
    122131        <input class="cluetip submit" title="{'selection'|@translate}|{'hlp_line3'|@translate}." type="submit" name="submit" value="{'selection'|@translate}"   />
     132                                <td>
     133                        <input class="cluetip submit" title="{'update_exif'|@translate}|{'hlp_update_exif'|@translate}." type="submit" value="{'update_exif'|@translate}" name="update" {$tag_input_enabled} /></td>
     134
    123135</table>
    124136        </fieldset>
     
    149161                </label>
    150162                                <input type="hidden"  value={$thumbnail.id}  name="selection[]"    />                           
    151                                 <span class="thumbLegend">
     163                                <span class="thumbLegend">      <div>{$thumbnail.file} </div>           
     164        {if $thumbnail.U_EXIF } Exif{/if}
     165         {if $thumbnail.U_BD } Bd {/if}
    152166                                {if isset($thumbnail.U_MAP)}
    153                                         <a href="{$thumbnail.U_MAP}" target="_blank">{$thumbnail.lat},{$thumbnail.lon}</a>
     167                                        <a href="{$thumbnail.U_MAP}" target="_blank"><div>{$thumbnail.lat}</div><div>{$thumbnail.lon}</div></a>
    154168                                {/if}
    155                                 {$thumbnail.file} 
    156                                  
     169                                         
    157170                                </span>
    158171                                </span>
     
    190203                                {foreach from=$Selectthumbnails item=thumbnail}
    191204                                        {assign var="filename" value=$filename|@cat:$thumbnail.filename|@cat:";"}
     205
    192206                                {if  $thumbnail.lat<>0 }
    193207                                        {if $thumbnail.lon<>0}
  • extensions/edit_gmaps/admin/admin_edit_meta.php

    r9412 r12126  
    119119}
    120120usort($categories, 'global_rank_compare');
    121 display_select_categories($categories, $selecteds, 'categories', false);
     121
     122display_select_categories($categories, $selecteds, 'categories', true);
    122123
    123124if (!empty($_GET['display']))
     
    454455      if ($lon =="") {
    455456       
    456             $lon = parse_lat_lon( $exif['GPSLongitude'] );
     457            $lon = Parse_Lat_Lon( $exif['GPSLongitude'] );
    457458            $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ;
    458459  if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
  • extensions/edit_gmaps/admin/admin_edit_meta.tpl

    r9412 r12126  
    188188        <label>Altitude </label>
    189189                <input type="hidden" size="2"value="0"  name="altRef"  />
     190          <input type="hidden" size="2" value="0" name="altDMS" />
    190191        <input type="text" size="15"value="{$alt}"  name="alt"  /> <label> m </label>         
    191192        </td>
     
    280281<input size=60 id="altRef" name="GPSAltitudeRef" type=\"text\" value="{$altRef}">
    281282        </td>
     283     <input size=60 id="altDMS" name="GPSAltitudeRef" type=\"text\" value="{$altRef}">
    282284        <td>
    283285            Altitude
  • extensions/edit_gmaps/admin/element_set.php

    r8960 r12126  
    1 <?php
     1<?php
    22// +-----------------------------------------------------------------------+
    33// | Piwigo - a PHP based picture gallery                                  |
  • extensions/edit_gmaps/admin/header_2_1.tpl

    r9412 r12126  
    1 {known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.js" now=0}
     1{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.js" now=0}
    22{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"}
    33{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.core.js"}
    44{known_script id="jquery.ui.resizable" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.resizable.js"}
    5 {known_script id="EDIT_RV_script" src=$EDIT_CL_PATH|@cat:"admin/js/JScript.js"} 
    6 {known_script id="fieldset" src=$EDIT_CL_PATH|@cat:"admin/js/fieldset.js"} 
     5{known_script id="EDIT_RV_script" src=$EDIT_CL_PATH|@cat:"admin/js/JScript.js"}
     6{known_script id="fieldset" src=$EDIT_CL_PATH|@cat:"admin/js/fieldset.js"}
  • extensions/edit_gmaps/admin/include/EXIF.php

    r10060 r12126  
    118118function get_EXIF_JPEG( $filename )
    119119{
    120 global $error_message ;
     120global $erreur_message ;
    121121        // Change: Added as of version 1.11
    122122        // Check if a wrapper is being used - these are not currently supported (see notes at top of file)
     
    124124        {
    125125                // A HTTP or FTP wrapper is being used - show a warning and abort
    126                 $error_message .= "HTTP and FTP wrappers are currently not supported with EXIF - See EXIF functionality documentation - a local file must be specified<br>";
    127                 $error_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
    128                 $error_message .= "\$newfilename = tempnam ( \$dir, \"tmpexif\" );<br>\n";
    129                 $error_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
     126                $erreur_message .= "HTTP and FTP wrappers are currently not supported with EXIF - See EXIF functionality documentation - a local file must be specified<br>";
     127                $erreur_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
     128                $erreur_message .= "\$newfilename = tempnam ( \$dir, \"tmpexif\" );<br>\n";
     129                $erreur_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
    130130                return FALSE;
    131131        }
     
    168168        {
    169169                // Could't open the file - exit
    170                 $error_message .= "<p>Could not open file $filename</p>\n";
     170                $erreur_message .= "<p>Could not open file $filename</p>\n";
    171171                return FALSE;
    172172        }
     
    297297function get_Meta_JPEG( $filename )
    298298{
    299 global $error_message ;
     299global $erreur_message ;
    300300        // Change: Added as of version 1.11
    301301        // Check if a wrapper is being used - these are not currently supported (see notes at top of file)
     
    303303        {
    304304                // A HTTP or FTP wrapper is being used - show a warning and abort
    305                 $error_message .= "HTTP and FTP wrappers are currently not supported with Meta - See EXIF/Meta functionality documentation - a local file must be specified<br>";
    306                 $error_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
    307                 $error_message .= "\$newfilename = tempnam ( \$dir, \"tmpmeta\" );<br>\n";
    308                 $error_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
     305                $erreur_message .= "HTTP and FTP wrappers are currently not supported with Meta - See EXIF/Meta functionality documentation - a local file must be specified<br>";
     306                $erreur_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
     307                $erreur_message .= "\$newfilename = tempnam ( \$dir, \"tmpmeta\" );<br>\n";
     308                $erreur_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
    309309                return FALSE;
    310310        }
     
    347347        {
    348348                // Could't open the file - exit
    349                 $error_message .= "<p>Could not open file $filename</p>\n";
     349                $erreur_message .= "<p>Could not open file $filename</p>\n";
    350350                return FALSE;
    351351        }
     
    474474function get_EXIF_TIFF( $filename )
    475475{
    476 global $error_message ;
     476global $erreur_message ;
    477477        // Change: Added as of version 1.11
    478478        // Check if a wrapper is being used - these are not currently supported (see notes at top of file)
     
    480480        {
    481481                // A HTTP or FTP wrapper is being used - show a warning and abort
    482                 $error_message .= "HTTP and FTP wrappers are currently not supported with TIFF - See EXIF/TIFF functionality documentation - a local file must be specified<br>";
    483                 $error_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
    484                 $error_message .= "\$newfilename = tempnam ( \$dir, \"tmptiff\" );<br>\n";
    485                 $error_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
     482                $erreur_message .= "HTTP and FTP wrappers are currently not supported with TIFF - See EXIF/TIFF functionality documentation - a local file must be specified<br>";
     483                $erreur_message .= "To work on an internet file, copy it locally to start with:<br><br>\n";
     484                $erreur_message .= "\$newfilename = tempnam ( \$dir, \"tmptiff\" );<br>\n";
     485                $erreur_message .= "copy ( \"http://whatever.com\", \$newfilename );<br><br>\n";
    486486                return FALSE;
    487487        }
     
    494494        {
    495495                // Could't open the file - exit
    496                 $error_message .= "<p>Could not open file $filename</p>\n";
     496                $erreur_message .= "<p>Could not open file $filename</p>\n";
    497497                return FALSE;
    498498        }
     
    11311131function read_Multiple_IFDs( $filehnd, $Tiff_offset, $Byte_Align, $Tag_Definitions_Name, $local_offsets = FALSE, $read_next_ptr = TRUE )
    11321132{
    1133 global $error_message ;
     1133global $erreur_message ;
    11341134        // Start at the offset of the first IFD
    11351135        $Next_Offset = 0;
     
    11441144                {
    11451145                        // Error seeking to position of next IFD
    1146                         $error_message .= "<p>Error: Corrupted EXIF</p>\n";
     1146                        $erreur_message .= "<p>Error: Corrupted EXIF</p>\n";
    11471147                        return FALSE;
    11481148                }
     
    11931193function read_IFD_universal( $filehnd, $Tiff_offset, $Byte_Align, $Tag_Definitions_Name, $local_offsets = FALSE, $read_next_ptr = TRUE )
    11941194{
    1195 global $error_message ;
    1196 
     1195global $erreur_message ;
     1196        global $nom_fichier;
     1197       
    11971198        if ( ( $filehnd == NULL ) || ( feof( $filehnd ) ) )
    11981199        {
     
    12131214        // If the data is corrupt, the number of entries may be huge, which will cause errors
    12141215        // This is often caused by a lack of a Next-IFD pointer
    1215         if ( $No_Entries> 10000 )
     1216        if ( $No_Entries> 12800 )
    12161217        {
    12171218                // Huge number of entries - abort
    1218                 $error_message .= "<p>".$No_Entries."Error: huge number of EXIF entries - EXIF is probably Corrupted</p>\n";
     1219                $erreur_message .=  $nom_fichier."  Error: huge number  (".$No_Entries.") of EXIF entries - EXIF is probably Corrupted.<br />";
    12191220
    12201221                return array ( FALSE , 0);
     
    12411242        {
    12421243                // Couldn't read the IFD Data properly, Some Casio files have no Next IFD pointer, hence cause this error
    1243                 $error_message .= "<p>Error: EXIF Corrupted</p>\n";
     1244                $erreur_message .= "<p>Error: EXIF Corrupted</p>\n";
    12441245                return array(FALSE, 0);
    12451246        }
     
    12971298                if ( $Data_Count > 100000 )
    12981299                {
    1299                      //   $error_message .= "<p>Error: huge EXIF data count - EXIF is probably Corrupted</p>\n";
     1300                     //   $erreur_message .= "<p>Error: huge EXIF data count - EXIF is probably Corrupted</p>\n";
    13001301
    13011302                        // Some Casio files have no Next IFD pointer, hence cause errors
     
    22092210
    22102211function get_IFD_Data_Type( $input_data, $data_type, $Byte_Align ){
    2211 global $error_message ;
     2212global $erreur_message ;
    22122213        // Check if this is a Unsigned Byte, Unsigned Short or Unsigned Long
    22132214        if (( $data_type == 1 ) || ( $data_type == 3 ) || ( $data_type == 4 ))
     
    22342235                // to return multiple values instead of a single value
    22352236
    2236                 $error_message .= "<p>Error - ASCII Strings should not be processed in get_IFD_Data_Type</p>\n";
     2237                $erreur_message .= "<p>Error - ASCII Strings should not be processed in get_IFD_Data_Type</p>\n";
    22372238                return "Error Should never get here"; //explode( "\x00", $input_data );
    22382239        }
  • extensions/edit_gmaps/admin/include/fonctions.php

    r9412 r12126  
    11<?php
    2   //
    3   // DECIMAL TO FRACTION
    4   //
     2
     3function base_to_meta($image){
     4      $info_meta['lat']=$image['lat'];
     5      $info_meta['lon']=$image['lon'];
     6      $info_meta['alt']=$image['alt'];
     7      //===========================================================================
     8      $info_meta['latRef'] = ($image['lat']<0)? 'S' : "N" ;
     9      $info_meta['GPSLatitudeRef'] = ($image['lat']<0)? 'S' : "N" ;
     10      $p1=dec2dms($image['lat']);
     11 
     12      $info_meta['latDMS']=$p1[0]['Numerator']  . "/" .
     13            $p1[0]['Denominator'] ." ".
     14            $p1[1]['Numerator'] . "/" .
     15            $p1[1]['Denominator'] ." ".
     16            $p1[2]['Numerator'] . "/" .
     17            $p1[2]['Denominator'] ;
     18
     19      $info_meta['GPSLatitude']=array(
     20            $p1[0]['Numerator']  . "/" .
     21            $p1[0]['Denominator'] ,
     22            $p1[1]['Numerator'] . "/" .
     23            $p1[1]['Denominator'] ,
     24            $p1[2]['Numerator'] . "/" .
     25            $p1[2]['Denominator']
     26            );
     27
     28      //===========================================================================
     29      $info_meta['GPSLongitudeRef']  = ($image['lon']<0)? 'W' : "E" ;
     30      $info_meta['lonRef']  = ($image['lon']<0)? 'W' : "E" ;
     31      $p1=dec2dms($image['lon']);
     32      $info_meta['lonDMS']=$p1[0]['Numerator']  . "/" .
     33            $p1[0]['Denominator'] ." ".
     34            $p1[1]['Numerator'] . "/" .
     35            $p1[1]['Denominator'] ." ".
     36            $p1[2]['Numerator'] . "/" .
     37            $p1[2]['Denominator'] ;
     38      $info_meta['GPSLongitude']=array(
     39            $p1[0]['Numerator']  . "/" .
     40            $p1[0]['Denominator'] ,
     41            $p1[1]['Numerator'] . "/" .
     42            $p1[1]['Denominator'] ,
     43            $p1[2]['Numerator'] . "/" .
     44            $p1[2]['Denominator']
     45            );
     46      //===========================================================================
     47        $info_meta['GPSAltitudeRef'] = "0";
     48        $p1= round( $image['alt'] * 5000000000 );
     49        $info_meta['GPSAltitude']= $p1.'/'."500000000000";
     50        $info_meta['altDMS']= $p1.'/'."500000000000";
     51        $info_meta['altRef']= "0";
     52  return $info_meta ;
     53}
     54
     55/**********************************
     56* DECIMAL TO FRACTION             *
     57**********************************/
    558  function dec2frac( $decimal ) {
    659    $decimal = (string)$decimal;
     
    1063
    1164    // find least reduced fractional form of number
    12     for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ )
    13     {
     65    for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ ){
    1466     // build the denominator as we 'shift' the decimal to the right
    1567     if( $dec ) $den *= 10;
     
    4294  }
    4395
    44  
     96/**********************************
     97* Decimal vers Deg Min Sec        *
     98**********************************/
    4599function dec2dms($value) {
    46100        $value= abs($value);
     
    59113        $ret[2]['Denominator']=$sec->Denominator;
    60114  $ret[3]= " Deg: " . $degrees . " Min: " . $minutes . " Sec: " . $seconds."  " ;
    61        
     115        $ret[4]= " " . $degrees . "/1 " . $minutes . "/1 " . $sec->Numerator."/".$sec->Denominator ;
    62116return( $ret);
    63117
    64118}
    65119
    66 
    67 /*
    68 //Array (
    69 [GPSLatitudeRef] => S
    70 [GPSLatitude] =>
    71 Array ( [0] => 41/1
    72 [1] => 54/1
    73 [2] => 26543/3238 )
    74 [GPSLongitudeRef] => E
    75 [GPSLongitude] => Array (
    76 [0] => 146/1
    77 [1] => 21/1
    78 [2] => 61393/1729 ) )
    79 */
    80120
    81121function toFraction($number){
     
    108148return ($denominator > 0) ? $numerator . '/' . $denominator : false;
    109149}
    110 
    111  function Parse_Fract( $f )
    112 {
     150//==============================================
     151 function Parse_Fract( $f ){
    113152  $nd = explode( '/', $f );
    114153  return $nd[0]/$nd[1];
  • extensions/edit_gmaps/admin/js/JScript.js

    r10060 r12126  
    88
    99function onLoad() {
    10     var reg = new RegExp('/', "g");
    11    
    12     if (coordinates.ADRESSE)
    13         coordinates.ADRESSE = coordinates.ADRESSE.replace("/", ", ");
    14 
    15           document.getElementById("match").value = coordinates.ADRESSE;
    16                 geocoder = new google.maps.Geocoder();
    17                     var mapElement = document.getElementById("map");
    18                     if (coordinates.LAT <= 90 && coordinates.LAT != " " && coordinates.LAT != "" ) {
    19 
    20                         } else {
    21                             coordinates.LAT=49 ;coordinates.LON = 3;
    22                             coordinates.ZOOM = coordinates.ZOOM | 18;
    23                             geocoder.geocode({ 'address': coordinates.ADRESSE }, function (results, status) {
    24                                 /* Si l'adresse a pu être géolocalisée */
    25                                 if (status == google.maps.GeocoderStatus.OK) {
    26                                     /* Récupération de sa latitude et de sa longitude */
    27                                     coordinates.LAT = results[0].geometry.location.lat();
    28                                     coordinates.LON = results[0].geometry.location.lng();
    29                                     LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
    30                                     updateMarkerPosition(LatLng);
    31                                     geocodePosition(LatLng);
    32                                 }
    33                             });
    34 
    35                            
    36                         }
     10  var reg = new RegExp('/', "g");
     11
     12  if (coordinates.ADRESSE)
     13    coordinates.ADRESSE = coordinates.ADRESSE.replace("/", ", ");
     14
     15  document.getElementById("match").value = coordinates.ADRESSE;
     16  geocoder = new google.maps.Geocoder();
     17  var mapElement = document.getElementById("map");
     18  if (coordinates.LAT <= 90 && coordinates.LAT != " " && coordinates.LAT != "") {
     19
     20  } else {
     21    coordinates.LAT = 49; coordinates.LON = 3;
     22    coordinates.ZOOM = coordinates.ZOOM | 18;
     23    geocoder.geocode({ 'address': coordinates.ADRESSE }, function (results, status) {
     24      /* Si l'adresse a pu être géolocalisée */
     25      if (status == google.maps.GeocoderStatus.OK) {
     26        /* Récupération de sa latitude et de sa longitude */
     27        coordinates.LAT = results[0].geometry.location.lat();
     28        coordinates.LON = results[0].geometry.location.lng();
     29        LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
     30        updateMarkerPosition(LatLng);
     31        geocodePosition(LatLng);
     32      }
     33    });
     34
     35
     36  }
    3737  zoom = coordinates.ZOOM;
    38    LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
    39  
    40 
    41             /*
    42              MapTypeId.ROADMAP affiche un plan (de type carte routière).
    43              MapTypeId.SATELLITE affiche une vue satellite.
    44              MapTypeId.HYBRID affiche une vue mixte entre les deux précédentes.
    45              MapTypeId.TERRAIN affiche une vue du relief.
    46             */
    47  var mapOpts = {     
    48                     center:LatLng,
    49                     zoom:zoom,
    50                             mapTypeId: google.maps.MapTypeId.SATELLITE
    51                     };
    52        
    53                     map = new google.maps.Map( mapElement, mapOpts );
    54 
    55              
    56 
    57 
    58          if (coordinates)
    59                    marker = new google.maps.Marker( {
    60                             position: map.getCenter(),
    61                             map: map,
    62                     draggable: true
    63                             });
    64 
    65 
    66                 // Add dragging event listeners.   
    67                 google.maps.event.addListener(marker,
     38  LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
     39
     40
     41  /*
     42  MapTypeId.ROADMAP affiche un plan (de type carte routière).
     43  MapTypeId.SATELLITE affiche une vue satellite.
     44  MapTypeId.HYBRID affiche une vue mixte entre les deux précédentes.
     45  MapTypeId.TERRAIN affiche une vue du relief.
     46  */
     47  var mapOpts = {
     48    center: LatLng,
     49    zoom: zoom,
     50    mapTypeId: google.maps.MapTypeId.SATELLITE
     51  };
     52
     53  map = new google.maps.Map(mapElement, mapOpts);
     54
     55
     56
     57
     58  if (coordinates)
     59    marker = new google.maps.Marker({
     60      position: map.getCenter(),
     61      map: map,
     62      draggable: true
     63    });
     64
     65
     66  // Add dragging event listeners.   
     67  google.maps.event.addListener(marker,
    6868        'dragstart',
    6969        function () {
    70             updateMarkerAddress('Dragging...');
     70          updateMarkerAddress('Dragging...');
    7171        });
    7272
    73         google.maps.event.addListener(marker,
     73  google.maps.event.addListener(marker,
    7474            'drag',
    7575            function () {
    76                 updateMarkerStatus('Dragging...');
    77                 updateMarkerPosition(marker.getPosition());
     76              updateMarkerStatus('Dragging...');
     77              updateMarkerPosition(marker.getPosition());
    7878            }
    7979            );
    8080
    81             google.maps.event.addListener(marker,
     81  google.maps.event.addListener(marker,
    8282                                            'dragend',
    8383                                            function () {
    8484
    85                                              
    86                                      
     85
     86
    8787                                              // getElevation({ latLng: marker.getPosition() });
    88                                                 geocodePosition(marker.getPosition());
    89                                                 updateMarkerStatus('Drag ended');
    90                                                 getElevation({ 'latLng': marker.getPosition() });
    91                                                
     88                                              geocodePosition(marker.getPosition());
     89                                              updateMarkerStatus('Drag ended');
     90                                              getElevation({ 'latLng': marker.getPosition() });
     91
    9292
    9393                                            }
    9494        );
    9595
    96        // styleIcon = new StyledIcon(StyledIconTypes.BUBBLE, { color: "#cccccc", text: "Drag Me!" });
    97        // var styleMaker1 = new StyledMarker({ styleIcon: styleIcon, position: new google.maps.LatLng(37.383477473067, -121.880502070713), map: map, draggable: true });
    98 
    99        // google.maps.event.addDomListener(styleMaker1, "dragend", getElevation);
    100                                             // Update current position info.   
    101 
    102                        updateMarkerPosition(LatLng);
    103                        geocodePosition(LatLng);
    104                        getElevation({ 'latLng': marker.getPosition() });
    105                      
    106                   return false;
    107    
    108 
    109  
    110 
    111 
    112  }
    113 
    114        function updateMarkerStatus(str) {   
    115                 document.getElementById('markerStatus').innerHTML = str;
    116         }   
    117        
    118         function updateMarkerPosition(latLng) {   
    119                 document.Envoie.lat.value=latLng.lat() ;
    120                 document.Envoie.lon.value = latLng.lng();
    121                 dms_frac = dec2dms(latLng.lng());
    122                 if (document.Envoie.lon.value < 0) 
    123                 document.Envoie.lonRef.value = "W";
    124                 else                     
    125                 document.Envoie.lonRef.value = "E";
    126                 document.Envoie.lonDMS.value = Math.abs(dms_frac.Degre) +"/1" + " " + dms_frac.Minute +"/1" + " " +    dms_frac.Numerator + "/" + dms_frac.Denominator;
    127                 dms_frac = dec2dms(latLng.lat());
    128                 if (document.Envoie.lat.value < 0)
    129                     document.Envoie.latRef.value = "S";
    130                 else
    131                     document.Envoie.latRef.value = "N";
    132                 document.Envoie.latDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator;
    133               //  update_datas();
    134             }
    135 
    136 
    137                 function update_datas() {
    138                 n= jQuery(document.EditJPEG);
    139 
    140                 jQuery.each(n[0], function (i) {
    141 
    142 
    143                     n00 = this;
    144                     n0 = n00.id;
    145                     n1 = n00.name;
    146                     n2 = jQuery(n00).val();
    147                     try {
    148                         if (n0 == "alt") {
    149                             n3 = dec2frac(document.Envoie[n0].value);
    150                             n3 = n3.Numerator + "/" + n3.Denominator;
    151                             jQuery(this).val(n3);
    152                         }
    153                         else {
    154                             n3 = document.Envoie[n0].value;
    155                             jQuery(this).val(n3);
    156                         }
    157                     }
    158                     catch (e) {
    159                         n3 = n0;
    160                     }
    161 
    162 
    163 
    164                 }
    165                 )
    166 
    167                    
    168 
    169                 }
    170            
    171            function updateMarkerAddress(str) {
    172                document.getElementById('markerAdress').innerHTML = str;
    173        
    174                jQuery("#match").val(str);
    175             }
    176 
    177             function getElevation(event) {
    178                 var elevator = new google.maps.ElevationService();
    179                 var locations = [];
    180 
    181                 // Retrieve the clicked location and push it on the array
    182                 var clickedLocation = event.latLng;
    183                 locations.push(clickedLocation);
    184 
    185                 // Create a LocationElevationRequest object using the array's one value
    186                 var positionalRequest = {
    187                     'locations': locations
    188                 }
    189 
    190                 // Initiate the location request
    191                 if (elevator) {
    192                     elevator.getElevationForLocations(positionalRequest, function (results, status) {
    193                         if (status == google.maps.ElevationStatus.OK) {
    194 
    195                             // Retrieve the first result
    196                             if (results[0]) {
    197                                 coordinates.ALT = results[0].elevation;
    198                                 document.Envoie.alt.value = coordinates.ALT;
    199                                 altDMS = dec2frac(coordinates.ALT);
    200                                 document.Envoie.altRef.value = "0";
    201                                 document.Envoie.altDMS.value =  altDMS.Numerator + "/" +  altDMS.Denominator;
    202                                 //styleIcon.set("text", "Elevation: " + results[0].elevation + "m");
    203                             } else {
    204                                 // alert("No results found");
    205                             }
    206                         } else {
    207                             alert("Elevation service failed due to: " + status);
    208                         }
     96  // styleIcon = new StyledIcon(StyledIconTypes.BUBBLE, { color: "#cccccc", text: "Drag Me!" });
     97  // var styleMaker1 = new StyledMarker({ styleIcon: styleIcon, position: new google.maps.LatLng(37.383477473067, -121.880502070713), map: map, draggable: true });
     98
     99  // google.maps.event.addDomListener(styleMaker1, "dragend", getElevation);
     100  // Update current position info.   
     101
     102  updateMarkerPosition(LatLng);
     103  geocodePosition(LatLng);
     104  getElevation({ 'latLng': marker.getPosition() });
     105
     106  return false;
     107
     108
     109
     110
     111
     112}
     113
     114function updateMarkerStatus(str) {
     115  document.getElementById('markerStatus').innerHTML = str;
     116}
     117
     118function updateMarkerPosition(latLng) {
     119  document.Envoie.lat.value = latLng.lat();
     120  document.Envoie.lon.value = latLng.lng();
     121  dms_frac = dec2dms(latLng.lng());
     122  if (document.Envoie.lon.value < 0)
     123    document.Envoie.lonRef.value = "W";
     124  else
     125    document.Envoie.lonRef.value = "E";
     126  document.Envoie.lonDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator;
     127  dms_frac = dec2dms(latLng.lat());
     128  if (document.Envoie.lat.value < 0)
     129    document.Envoie.latRef.value = "S";
     130  else
     131    document.Envoie.latRef.value = "N";
     132  document.Envoie.latDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator;
     133  //  update_datas();
     134}
     135
     136function update_datas() {
     137  n = jQuery(document.EditJPEG);
     138  jQuery.each(n[0], function (i) {
     139    n00 = this;
     140    n0 = n00.id;
     141    n1 = n00.name;
     142    n2 = jQuery(n00).val();
     143    try {
     144      if (n0 == "alt") {
     145        n3 = dec2frac(document.Envoie[n0].value);
     146        n3 = n3.Numerator + "/" + n3.Denominator;
     147        jQuery(this).val(n3);
     148      }
     149      else {
     150        n3 = document.Envoie[n0].value;
     151        jQuery(this).val(n3);
     152      }
     153    }
     154    catch (e) {
     155      n3 = n0;
     156    }
     157  })
     158}
     159
     160function updateMarkerAddress(str) {
     161  document.getElementById('markerAdress').innerHTML = str;
     162  jQuery("#match").val(str);
     163}
     164
     165function getElevation(event) {
     166  var elevator = new google.maps.ElevationService();
     167  var locations = [];
     168
     169  // Retrieve the clicked location and push it on the array
     170  var clickedLocation = event.latLng;
     171  locations.push(clickedLocation);
     172
     173  // Create a LocationElevationRequest object using the array's one value
     174  var positionalRequest = {
     175    'locations': locations
     176  }
     177
     178  // Initiate the location request
     179  if (elevator) {
     180    elevator.getElevationForLocations(positionalRequest, function (results, status) {
     181      if (status == google.maps.ElevationStatus.OK) {
     182
     183        // Retrieve the first result
     184        if (results[0]) {
     185          coordinates.ALT = results[0].elevation;
     186          document.Envoie.alt.value = coordinates.ALT;
     187          altDMS = dec2frac(coordinates.ALT);
     188          document.Envoie.altRef.value = "0";
     189
     190          document.Envoie.altDMS.value = altDMS.Numerator + "/" + altDMS.Denominator;
     191          //styleIcon.set("text", "Elevation: " + results[0].elevation + "m");
     192        } else {
     193          // alert("No results found");
     194        }
     195      } else {
     196        alert("Elevation service failed due to: " + status);
     197      }
     198    });
     199  }
     200}
     201function geocodePosition(pos) {
     202  geocoder.geocode({ 'latLng': pos },
     203                    function (results, status) {
     204                      /* Si le géocodage inversé a réussi */
     205                      if (status == google.maps.GeocoderStatus.OK) {
     206                        updateMarkerAddress(results[0].formatted_address);
     207                      } else {
     208                        updateMarkerAddress('Cannot determine address at this location.');
     209                      }
    209210                    });
    210                 }
    211             }
    212 
    213 
    214 
    215             function geocodePosition(pos) {
    216                      geocoder.geocode({ 'latLng': pos },
    217                     function (results, status) {
    218                    /* Si le géocodage inversé a réussi */
    219                    if (status == google.maps.GeocoderStatus.OK) {
    220                        updateMarkerAddress(results[0].formatted_address);
    221                    } else {
    222                        updateMarkerAddress('Cannot determine address at this location.');
    223                    }
    224                });
    225         }
    226 
    227  
    228         /* Fonction de géocodage déclenchée en cliquant surle bouton "Geocoder"  */
    229         function codeAddress() {
    230             /* Récupération de la valeur de l'adresse saisie */
    231          
    232             /* Appel au service de geocodage avec l'adresse en paramètre */
    233             if (typeof map == "undefined") onLoad();
    234 
    235             var address = document.getElementById("match").value;
     211}
     212/* Fonction de géocodage déclenchée en cliquant surle bouton "Geocoder"  */
     213function codeAddress() {
     214  /* Récupération de la valeur de l'adresse saisie */
     215
     216  /* Appel au service de geocodage avec l'adresse en paramètre */
     217  if (typeof map == "undefined") onLoad();
     218
     219  var address = document.getElementById("match").value;
    236220
    237221  geocoder.geocode({ 'address': address }, function (results, status) {
    238       /* Si l'adresse a pu être géolocalisée */
    239       if (status == google.maps.GeocoderStatus.OK) {
    240           /* Récupération de sa latitude et de sa longitude */
    241           coordinates.LAT = results[0].geometry.location.lat();
    242           coordinates.LON = results[0].geometry.location.lng();
    243           onLoad();
    244          
    245            
    246 
    247       } else {
    248           alert("Cannot determine location at this adress.: " + status);
    249       }
     222    /* Si l'adresse a pu être géolocalisée */
     223    if (status == google.maps.GeocoderStatus.OK) {
     224      /* Récupération de sa latitude et de sa longitude */
     225      coordinates.LAT = results[0].geometry.location.lat();
     226      coordinates.LON = results[0].geometry.location.lng();
     227      onLoad();
     228    } else {
     229      alert("Cannot determine location at this adress.: " + status);
     230    }
    250231  });
    251232}
     
    253234//=======================================================
    254235function On_Click(a, b, c) {
    255     document.Envoie.lat.value = b;
    256     document.Envoie.lon.value = c;
    257 
    258     coordinates = {LAT:a,
    259      LON : b} ;
    260     LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
    261     updateMarkerPosition(LatLng);
    262 
    263 
     236  document.Envoie.lat.value = b;
     237  document.Envoie.lon.value = c;
     238  coordinates = { LAT: a,
     239    LON: b
     240  };
     241  LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
     242  updateMarkerPosition(LatLng);
    264243}
    265244
    266245jQuery(window).load(
    267 
    268246      function () {
    269 //Récupérer tous les inputs radios appartenant à un même groupe
    270  /*         a = jQuery('input[type=hidden][name=Selectthumbnail]');
    271           b = a.length;
    272           c = jQuery('input[type=hidden]:checked').length;
    273           d = jQuery('input[type=hidden][name="Selectthumbnail"]').attr('value');
    274 */
     247        //Récupérer tous les inputs radios appartenant à un même groupe
     248        /*         a = jQuery('input[type=hidden][name=Selectthumbnail]');
     249        b = a.length;
     250        c = jQuery('input[type=hidden]:checked').length;
     251        d = jQuery('input[type=hidden][name="Selectthumbnail"]').attr('value');
     252        */
    275253
    276254        //  onLoad();
    277       }); 
     255      });
    278256
    279257jQuery(document).ready(function () {
    280258
    281     jQuery('.cluetip').cluetip({
    282         width: 300, height: 100,
    283         splitTitle: '|',
    284         clickThrough: true
    285     }
     259 /*
     260  jQuery('.cluetip').cluetip({
     261    width: 300, height: 100,
     262    splitTitle: '|',
     263    clickThrough: true
     264  }
    286265  );
     266  */
     267  jQuery('.cluetip').tipTip({ maxWidth: '600px', 'delay': 0, 'fadeIn': 200, 'fadeOut': 200 }); 
    287268  jQuery("#search").click(function (e) {
    288269
    289         coordinates = { ADRESSE: jQuery("#match").val(),
    290                         LAT:0,LON:0,ZOOM: 18 ,ALT:0
    291                        };
    292         codeAddress();
    293         return false;
    294     });
    295 
    296     jQuery("#match").keydown(function (e) {
    297         // e.target         pour FireFox
    298         // event.srcElement pour IE
    299         var Obj = e ? e.target : event.srcElement;
    300         if (Obj.tagName != "INPUT") return false;
    301         var Code = e.keyCode || e.which;
    302         if (Code != 13) return true;
    303         coordinates = { ADRESSE: jQuery("#match").val(),
    304             LAT: 0, LON: 0, ZOOM: 18, ALT: 0
    305                        };
    306         codeAddress();
    307         return false;
    308     });
     270    coordinates = { ADRESSE: jQuery("#match").val(),
     271      LAT: 0, LON: 0, ZOOM: 18, ALT: 0
     272    };
     273    codeAddress();
     274    return false;
     275  });
     276
     277  jQuery("#match").keydown(function (e) {
     278    // e.target         pour FireFox
     279    // event.srcElement pour IE
     280    var Obj = e ? e.target : event.srcElement;
     281    if (Obj.tagName != "INPUT") return false;
     282    var Code = e.keyCode || e.which;
     283    if (Code != 13) return true;
     284    coordinates = { ADRESSE: jQuery("#match").val(),
     285      LAT: 0, LON: 0, ZOOM: 18, ALT: 0
     286    };
     287    codeAddress();
     288    return false;
     289  });
    309290
    310291
     
    314295
    315296
    316   // DECIMAL TO FRACTION
    317   //
    318   function dec2frac( valeur_decimal ) {
    319      decimal = valeur_decimal.toString() ;
    320       num = '';
    321       den = 1;
    322       dec = false;
    323 
    324       // find least reduced fractional form of number
    325       for( i = 0, ix =   decimal.length  ; i < ix; i++ )
    326       {
    327       // build the denominator as we 'shift' the decimal to the right
    328       if( dec ) den *= 10;
    329 
    330       // find the decimal place/ build the numberator
    331       if( decimal.charAt(i) == '.' ) dec = true;
    332       else num += decimal.charAt(i);
    333       }
    334       num = parseInt(num);
    335  
    336       // whole number, just return it
    337       if( den == 1 ) return num;
    338 
    339       num2 = num;
    340       den2 = den;
    341       rem  = 1;
    342       // Euclid's Algorithm (to find the gcd)
    343       while( num2 % den2 ) {
    344       rem = num2 % den2;
    345       num2 = den2;
    346       den2 = rem;
    347       }
    348       if( den2 != den ) rem = den2;
    349       ret1 = { Numerator: (num / rem), Denominator: (den / rem) };
    350       // new Array()
    351     // ret1->Numerator =(num / rem ) ;
    352     // ret1->Denominator=(den / rem);
    353 
    354       // now $rem holds the gcd of the numerator and denominator of our fraction
    355       return ret1;
    356      
    357   }
     297// DECIMAL TO FRACTION
     298//
     299function dec2frac(valeur_decimal) {
     300  decimal = valeur_decimal.toString();
     301  num = '';
     302  den = 1;
     303  dec = false;
     304
     305  // find least reduced fractional form of number
     306  for (i = 0, ix = decimal.length; i < ix; i++) {
     307    // build the denominator as we 'shift' the decimal to the right
     308    if (dec) den *= 10;
     309
     310    // find the decimal place/ build the numberator
     311    if (decimal.charAt(i) == '.') dec = true;
     312    else num += decimal.charAt(i);
     313  }
     314  num = parseInt(num);
     315
     316  // whole number, just return it
     317  if (den == 1) return num;
     318
     319  num2 = num;
     320  den2 = den;
     321  rem = 1;
     322  // Euclid's Algorithm (to find the gcd)
     323  while (num2 % den2) {
     324    rem = num2 % den2;
     325    num2 = den2;
     326    den2 = rem;
     327  }
     328  if (den2 != den) rem = den2;
     329  ret1 = { Numerator: (num / rem), Denominator: (den / rem) };
     330  // new Array()
     331  // ret1->Numerator =(num / rem ) ;
     332  // ret1->Denominator=(den / rem);
     333
     334  // now $rem holds the gcd of the numerator and denominator of our fraction
     335  return ret1;
     336
     337}
    358338
    359339function dec2dms(l) {
    360     sign = 1;
    361     if (l < 0) { sign = -1; }
    362     l = Math.abs(Math.round(l * 1000000.))
    363     d = Math.floor(l / 1000000) * sign;
    364     m = Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60);
    365     s = Math.floor(((((l / 1000000) - Math.floor(l / 1000000)) * 60) - Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60)) * 100000) * 60 / 100000;
    366     frac_s = dec2frac(s);
    367     s2 = (frac_s.Numerator / frac_s.Denominator);
    368     return { dms: d + "° " + m + "' " + s + "''",
    369         Degre:d, Minute:m,Sec:s,
    370         Numerator: frac_s.Numerator,
    371         Denominator:frac_s.Denominator};
    372 }
    373 
     340  sign = 1;
     341  if (l < 0) { sign = -1; }
     342  l = Math.abs(Math.round(l * 1000000.))
     343  d = Math.floor(l / 1000000) * sign;
     344  m = Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60);
     345  s = Math.floor(((((l / 1000000) - Math.floor(l / 1000000)) * 60) - Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60)) * 100000) * 60 / 100000;
     346  frac_s = dec2frac(s);
     347  s2 = (frac_s.Numerator / frac_s.Denominator);
     348  return { dms: d + "° " + m + "' " + s + "''",
     349    Degre: d, Minute: m, Sec: s,
     350    Numerator: frac_s.Numerator,
     351    Denominator: frac_s.Denominator
     352  };
     353}
     354
  • extensions/edit_gmaps/edit_gmaps.inc.php

    r9446 r12126  
    6666class cl_edit_controler {
    6767
     68static public  function add_meta_gps($new_ps_file_info_array,$image){
     69            global $nom_fichier,$erreur_message, $info_message; 
     70           
     71
     72 // $exif = @read_exif_data( $exif );
     73//  $exif = @array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
     74 
     75  foreach( $new_ps_file_info_array['selection']  as $filename )   {
     76    //======================================================
     77         if($new_ps_file_info_array['lat']=='') {   
     78            $erreur_message .= "Error - lon or lat = null : $filename <br>\n";
     79            }else{
     80     if($filename!="") {                   
     81            //= $new_ps_file_info_array[ 'filename' ];
     82            // Protect against hackers editing other files
     83            // copy( $filename,  $filename.".bak" );
     84            $path_parts = pathinfo( $filename );     
     85
     86            if ( strcasecmp( $path_parts["extension"], "jpg" ) != 0 ) {
     87              $erreur_message .= $filename ;
     88              $erreur_message .="Incorrect File Type - JPEG Only\n";
     89              $filename="";
     90              return;
     91            }
     92            // Change: removed limitation on file being in current directory - as of version 1.11
     93            // Retrieve the header information
     94
     95            $nom_fichier=$filename;
     96            $jpeg_header_data = get_jpeg_header_data( $filename );
     97            // Retreive the EXIF, XMP and Photoshop IRB information from
     98            // the existing file, so that it can be updated
     99            $Exif_array = get_EXIF_JPEG( $filename );
     100            $XMP_array = read_XMP_array_from_text( get_XMP_text( $jpeg_header_data ) );
     101            $IRB_array = get_Photoshop_IRB( $jpeg_header_data );
     102            // Update the JPEG header information with the new Photoshop File Info
     103
     104            $jpeg_header_data = put_GPS_file_info( $jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array );
     105            // Check if the Update worked
     106            if ( $jpeg_header_data == FALSE ) {
     107              // Update of file info didn''t work - output error message
     108              $erreur_message .= "jpeg_header_data
     109              Error - Failure update Photoshop File Info : $filename <br>\n";
     110              return false;
     111              // Output HTML with the form and data which was
     112              // sent, to allow the user to fix it
     113            }else if ( FALSE == put_jpeg_header_data(  $filename, $filename, $jpeg_header_data ) ) {
     114              // Attempt to write the new JPEG file
     115              // Writing of the new file didn''t work - output error message
     116              $erreur_message .= "Error - Failure to write new JPEG : $filename <br>\n";
     117              return false;
     118              // Output HTML with the form and data which was
     119              // sent, to allow the user to fix it
     120            }else{           
     121              return true;
     122          }
     123     }// test filename}
     124   } //for each
     125
     126  }   
     127
     128
     129}
     130//==========================================================
     131static public function Get_exif_gps($firt_image,$image,$hight_gps) {
     132  global $errors;global $template ;
     133    global $info_message ;
     134    error_reporting ( 1 );
     135    $filename=$firt_image;
     136   
     137    $datas = array();
     138    $errors = array();
     139    $exif = @read_exif_data( $filename );
     140    if ( empty($exif) ) return;
     141
     142 $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
     143 if(count($exif)==0 || $hight_gps ){
     144  $path_parts = pathinfo( $filename );
     145  $exif = @read_exif_data( $path_parts['dirname']."/pwg_high/".$path_parts['basename']);
     146  $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
     147 }
     148 if(count($exif)==0) return ;
     149//====================================================================
     150    $lat = $image['lat'] ;
     151    $lon = $image['lon'] ;
     152    $alt = $image['alt'];
     153   
     154        $p1=base_to_meta($image);
     155       
     156 if($exif['GPSLatitude'][0]=="1/1" && $lat!=""){
     157        $exif['GPSLatitudeRef'] = $p1['GPSLatitudeRef'] ;   
     158        $exif['GPSLatitude']=$p1['GPSLatitude']; 
     159        $exif['GPSLongitudeRef']  = $p1['GPSLongitudeRef'];
     160        $exif['GPSLongitude']=$p1['GPSLongitude'];
     161        $exif['GPSAltitudeRef'] =$p1['GPSAltitudeRef'];       
     162        $exif['GPSAltitude']= $p1['GPSAltitude'];         
     163
     164   }
     165   
     166$is_exif =  is_array($exif['GPSLatitude']) && $exif['GPSLatitude']!=''   ;
     167$is_exif =  is_array($exif['GPSLongitude']) && $exif['GPSLongitude']!=''  & $is_exif  ;
     168
     169 if ($is_exif) { 
     170     $lat_exif = Parse_Lat_Lon( $exif['GPSLatitude'] );
     171     $lon_exif = Parse_Lat_Lon( $exif['GPSLongitude'] );
     172     $alt_exif = Parse_Fract( $exif['GPSAltitude'] );
     173 }
     174
     175$is_exif =    $lat_exif!=0;
     176//==============================
     177if ($lat =="" || $hight_gps){
     178  $lat = Parse_Lat_Lon( $exif['GPSLatitude'] );
     179  if ( $exif['GPSLatitudeRef']=='S' ) $lat = -$lat;
     180}else{
     181      if($lat<0)      $exif['GPSLatitudeRef']='S' ;
     182        else        $exif['GPSLatitudeRef']='N' ;
     183}
     184//==============================
     185          if ($lon =="" || $hight_gps) {
     186             $lon = Parse_Lat_Lon( $exif['GPSLongitude'] );
     187             if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
     188          }else{
     189            if ($lon<0) $exif['GPSLongitudeRef'] ='W' ;
     190            else $exif['GPSLongitudeRef'] ='E' ;
     191          }
     192//=======================================================================
     193           $altref = 0;
     194          if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) ){
     195                  $exif['GPSAltitude']=$alt;
     196                  $exif['GPSAltitudeRef']=0;
     197            }   else {
     198                $alt =       $exif['GPSAltitude'];
     199                $altref = $exif['GPSAltitudeRef'];
     200            }
     201   //========================================================================
     202        $datas[] = array (
     203            'is_exif' =>  $is_exif ,
     204            ' filename=' => $filename ,
     205            'id' =>    $image['id'] ,
     206            'lat' =>   $lat ,
     207            'lon' =>   $lon ,
     208            'latDMS' =>     $exif['GPSLatitude'][0]." ".
     209                            $exif['GPSLatitude'][1]." ".
     210                            $exif['GPSLatitude'][2]." ".
     211                            $exif['GPSLatitudeRef'],
     212            'lonDMS' =>     $exif['GPSLongitude'][0]." ".
     213                            $exif['GPSLongitude'][1]." ".
     214                            $exif['GPSLongitude'][2]." ".
     215                            $exif['GPSLongitudeRef'],
     216            'altref' => $exif['GPSAltitudeRef'],
     217            'alt' =>   $exif['GPSAltitude']
     218            );
     219
     220return $datas[0] ;
     221}
     222//======================================================
     223/*
     224 *
     225 */
     226 static public function add_data_base($sel,$lat,$lon,$alt){
     227    global $page,$info_message,$erreur_message ;
     228
     229    if ( strlen($lat)>0 and strlen($lon)>0 ) {
     230      if ( (double)$lat<=90 and (double)$lat>=-90
     231          and (double)$lon<=180 and (double)$lat>=-180 )
     232        $update_query = 'lat='.$lat.', lon='.$lon;
     233      else
     234        $erreur_message .= 'Invalid lat or lon value';
     235    }
     236    elseif ( strlen($lat)==0 and strlen($lon)==0 )
     237      $update_query = 'lat=NULL, lon=NULL';
     238    else
     239       $erreur_message .= 'Both lat/lon must be empty or not empty';
     240    if ( strlen($alt)==0)
     241          $update_query .= ', alt=NULL';
     242        else
     243          $update_query .= ', alt=' .$alt ;
     244
     245    if (isset($update_query)){
     246        $update_query = '
     247        UPDATE '.IMAGES_TABLE.' SET '.$update_query.'
     248        WHERE id IN ('.implode(',',$sel).')';
     249        pwg_query($update_query) ;
     250        cl_meta_invalidate_cache();
     251        $info_message .=  l10n('update') . " " . implode(',',$sel)  . " ". IMAGES_TABLE . " : " .  l10n('OK') ."<br />";       
     252       }
     253  }
     254//======================================================
    68255     static public function cl_edit_admin_menu($menu)
    69256    {
     
    77264            return $menu;
    78265    }
    79 
    80 
    81 
    82 
    83 
    84 
    85266        /*
    86267        *
  • extensions/edit_gmaps/main.inc.php

    r10060 r12126  
    44Version: auto
    55Description:  Editor for rv gmaps
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=330
     6Plugin URI: http://piwigo.org/ext/extension_view.php
    77Author: rvelices cljosse
    88Author URI: http://cl.josse.free.fr/
Note: See TracChangeset for help on using the changeset viewer.