Ignore:
Timestamp:
Feb 10, 2013, 10:12:00 PM (11 years ago)
Author:
mistic100
Message:

get geoloc ig rv_gmaps installed, compatible with safe_mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Google2Piwigo/include/ws_functions.inc.php

    r19834 r20670  
    1313      'pwa_album' => array(),
    1414      'category' => array(),
    15       'fills' => array('default' =>null),
     15      'fills' => array('default' => 'fill_name,fill_author,fill_tags,fill_date,fill_description'),
    1616      ),
    1717    'Used by Picasa Web Albums'
     
    2626  }
    2727 
    28   global $conf;
     28  global $conf, $pwg_loaded_plugins;
    2929 
    3030  include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
     
    5757  $query->setPhotoId($params['id']);
    5858  $query->setImgMax('d');
    59   $photoEntry = $picasa->getPhotoFeed($query);
    60    
     59  $photoEntry = $picasa->getPhotoEntry($query);
     60 
    6161  $photo = array(
    62     'id' => $params['id'],
    63     'url' => $photoEntry->mediaGroup->content[0]->url,
    64     'title' => get_filename_wo_extension($photoEntry->mediagroup->title->text),
    65     'author' => $photoEntry->mediaGroup->credit[0]->text,
    66     'description' => $photoEntry->mediagroup->description->text,
    67     'tags' => $photoEntry->mediagroup->keywords->text,
    68     'timestamp' => substr($photoEntry->gphotoTimestamp->text, 0, -3),
     62    'id' =>           $params['id'],
     63    'url' =>          $photoEntry->getMediaGroup()->content[0]->getUrl(),
     64    'title' =>        get_filename_wo_extension($photoEntry->getMediaGroup()->getTitle()->getText()),
     65    'author' =>       $photoEntry->getMediaGroup()->credit[0]->getText(),
     66    'description' =>  $photoEntry->getMediaGroup()->getDescription()->getText(),
     67    'tags' =>         $photoEntry->getMediaGroup()->getKeywords()->getText(),
     68    'timestamp' =>    substr($photoEntry->getGphotoTimestamp(), 0, -3),
     69    'latlon' =>       null,
    6970    );
     71 
    7072  $photo['path'] = PICASA_WA_CACHE . 'picasa-'.$photo['id'].'.'.get_extension($photo['url']);
    7173 
    72   file_put_contents('dump.txt', print_r($photo, true), FILE_APPEND);
     74  if ($photoEntry->getGeoRssWhere() !== null && !empty($pwg_loaded_plugins['rv_gmaps']))
     75  {
     76    $photo['latlon'] = $photoEntry->getGeoRssWhere()->getPoint()->getPos()->getText();
     77  }
    7378 
    7479  // copy file
     
    128133    $updates = array();
    129134    if (in_array('fill_name', $params['fills']))        $updates['name'] = pwg_db_real_escape_string($photo['title']);
    130     if (in_array('fill_taken', $params['fills']))       $updates['date_creation'] = date('Y-m-d H:i:s', $photo['timestamp']);
     135    if (in_array('fill_date', $params['fills']))        $updates['date_creation'] = date('Y-m-d H:i:s', $photo['timestamp']);
    131136    if (in_array('fill_author', $params['fills']))      $updates['author'] = pwg_db_real_escape_string($photo['author']);
    132137    if (in_array('fill_description', $params['fills'])) $updates['comment'] = pwg_db_real_escape_string($photo['description']);
     138    if (in_array('fill_geotag', $params['fills']) and !empty($photo['latlon']) )
     139    {
     140      $latlon = explode(' ', $photo['latlon']);
     141      if (count($latlon) == 2)
     142      {
     143        $updates['lat'] = pwg_db_real_escape_string($latlon[0]);
     144        $updates['lon'] = pwg_db_real_escape_string($latlon[1]);
     145      }
     146    }
    133147   
    134148    if (count($updates))
Note: See TracChangeset for help on using the changeset viewer.