1 | <?php /* |
---|
2 | Plugin Name: RV Maps&Earth |
---|
3 | Version: 2.4.c |
---|
4 | Description: Extend your gallery with Google Maps and Google Earth ... |
---|
5 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=122 |
---|
6 | Author: rvelices |
---|
7 | Author URI: http://www.modusoptimus.com/ |
---|
8 | */ |
---|
9 | define( 'RVM_PLUGIN_VERSION', '2.4.b'); |
---|
10 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
11 | |
---|
12 | add_event_handler('loc_end_index', 'rvm_end_index' ); |
---|
13 | add_event_handler('loc_begin_index_category_thumbnails', 'rvm_index_cat_thumbs_displayed'); |
---|
14 | add_event_handler('loc_begin_index_thumbnails', 'rvm_begin_index_thumbnails'); |
---|
15 | |
---|
16 | add_event_handler('picture_pictures_data', 'rvm_picture_pictures_data' ); |
---|
17 | |
---|
18 | global $rvm_dir; |
---|
19 | $rvm_dir = basename( dirname(__FILE__) ); |
---|
20 | |
---|
21 | global $conf; |
---|
22 | if (@$conf['gmaps_auto_sync']) |
---|
23 | { |
---|
24 | $conf['use_exif_mapping']['lat'] = 'lat'; |
---|
25 | $conf['use_exif_mapping']['lon'] = 'lon'; |
---|
26 | add_event_handler('format_exif_data', 'rvm_format_exif', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
27 | } |
---|
28 | |
---|
29 | function rvm_index_cat_thumbs_displayed() |
---|
30 | { |
---|
31 | global $page; |
---|
32 | $page['rvm_cat_thumbs_displayed'] = true; |
---|
33 | } |
---|
34 | |
---|
35 | function rvm_begin_index_thumbnails( $pictures ) |
---|
36 | { |
---|
37 | global $page; |
---|
38 | foreach ($pictures as $picture) |
---|
39 | { |
---|
40 | if ( isset($picture['lat']) ) |
---|
41 | { |
---|
42 | $page['rvm_items_have_latlon'] = true; |
---|
43 | break; |
---|
44 | } |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | define('RVM_ACTION_MODEL', '<a href="%s" title="%s" rel="nofollow" class="pwg-state-default pwg-button"%s><span class="pwg-icon pwg-icon-%s"> </span><span class="pwg-button-text">%s</span></a>'); |
---|
49 | |
---|
50 | function rvm_end_index() |
---|
51 | { |
---|
52 | global $page, $filter, $template, $rvm_dir; |
---|
53 | |
---|
54 | //if ( !is_admin() ) return; // TEMP |
---|
55 | if ( isset($page['chronology_field']) || $filter['enabled'] ) |
---|
56 | return; |
---|
57 | |
---|
58 | if ( 'categories' == @$page['section']) |
---|
59 | { // flat or no flat ; has subcats or not; ? |
---|
60 | if ( ! @$page['rvm_cat_thumbs_displayed'] and empty($page['items']) ) |
---|
61 | return; |
---|
62 | } |
---|
63 | else |
---|
64 | { |
---|
65 | if ( |
---|
66 | !in_array( @$page['section'], array('tags','search','recent_pics','list') ) |
---|
67 | ) |
---|
68 | return; |
---|
69 | if ( empty($page['items']) ) |
---|
70 | return; |
---|
71 | } |
---|
72 | |
---|
73 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
74 | |
---|
75 | if ( !empty($page['items']) ) |
---|
76 | { |
---|
77 | if (!@$page['rvm_items_have_latlon'] and ! rvm_items_have_latlon( $page['items'] ) ) |
---|
78 | return; |
---|
79 | } |
---|
80 | rvm_load_language(); |
---|
81 | |
---|
82 | $map_url = rvm_duplicate_map_index_url( array(), array('start') ); |
---|
83 | if ( !empty($map_url) ) |
---|
84 | { |
---|
85 | $link_title = sprintf( l10n('displays %s on a map'), strip_tags($page['title']) ); |
---|
86 | $template->concat( 'PLUGIN_INDEX_ACTIONS' , "\n<li>".sprintf(RVM_ACTION_MODEL, |
---|
87 | $map_url, $link_title, '', 'map', 'map' |
---|
88 | ).'</li>'); |
---|
89 | } |
---|
90 | |
---|
91 | { |
---|
92 | $kml_url = rvm_duplicate_kml_index_url( array(), array('start') ); |
---|
93 | $link_title = sprintf( l10n('opens %s in Google Earth'), strip_tags($page['title']) ); |
---|
94 | $template->concat( 'PLUGIN_INDEX_ACTIONS' , "\n<li>".sprintf(RVM_ACTION_MODEL, |
---|
95 | $kml_url, $link_title, ' type="application/vnd.google-earth.kml+xml"', 'globe', 'earth' |
---|
96 | ).'</li>'); |
---|
97 | } |
---|
98 | } |
---|
99 | |
---|
100 | function rvm_picture_pictures_data($pictures) |
---|
101 | { |
---|
102 | if ( isset($pictures['current']['lat']) and isset($pictures['current']['lon']) ) |
---|
103 | { |
---|
104 | global $template; |
---|
105 | $template->append('head_elements', '<meta name=geo.position content='.$pictures['current']['lat'].';'.$pictures['current']['lon'].'>' ); |
---|
106 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
107 | rvm_load_language(); |
---|
108 | if ( isset($_GET['map']) ) |
---|
109 | include_once( dirname(__FILE__) .'/include/picture_map.inc.php'); |
---|
110 | else |
---|
111 | { |
---|
112 | global $rvm_dir; |
---|
113 | $map_url = rvm_duplicate_map_picture_url(); |
---|
114 | $link_title = sprintf( l10n('displays %s on a map'), strip_tags($pictures['current']['name']) ); |
---|
115 | $template->concat( 'PLUGIN_PICTURE_ACTIONS' , sprintf(RVM_ACTION_MODEL, |
---|
116 | $map_url, $link_title, ' target="_top"', 'map', 'map' |
---|
117 | )); |
---|
118 | } |
---|
119 | } |
---|
120 | else |
---|
121 | if ( isset($_GET['map']) ) |
---|
122 | redirect( duplicate_picture_url() ); |
---|
123 | return $pictures; |
---|
124 | } |
---|
125 | |
---|
126 | function rvm_format_exif($exif, $file, $map) |
---|
127 | { |
---|
128 | if (isset($map['lat'])) |
---|
129 | { |
---|
130 | include_once( dirname(__FILE__) .'/include/functions_metadata.php'); |
---|
131 | $ll = exif_to_lat_lon($exif); |
---|
132 | if (is_array($ll)) |
---|
133 | { |
---|
134 | $exif[$map['lat']] = $ll[0]; |
---|
135 | $exif[$map['lon']] = $ll[1]; |
---|
136 | } |
---|
137 | } |
---|
138 | return $exif; |
---|
139 | } |
---|
140 | |
---|
141 | if (defined('IN_ADMIN')) { |
---|
142 | include_once(dirname(__FILE__).'/admin/admin_boot.php'); |
---|
143 | } |
---|
144 | ?> |
---|