1 | <?php /* |
---|
2 | Plugin Name: RV Maps&Earth |
---|
3 | Version: 2.0.b |
---|
4 | Description: Extend your gallery with Google Maps and Google Earth ... |
---|
5 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=122 |
---|
6 | Author: rvelices |
---|
7 | Author URI: http://www.modusoptimus.com/ |
---|
8 | */ |
---|
9 | define( 'RVM_PLUGIN_VERSION', '2.0.b'); |
---|
10 | if (!defined('PHPWG_ROOT_PATH')) 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 | add_event_handler('get_admin_plugin_menu_links', 'rvm_plugin_admin_menu' ); |
---|
18 | |
---|
19 | global $rvm_dir; |
---|
20 | $rvm_dir = basename( dirname(__FILE__) ); |
---|
21 | |
---|
22 | |
---|
23 | function rvm_index_cat_thumbs_displayed() |
---|
24 | { |
---|
25 | global $page; |
---|
26 | $page['rvm_cat_thumbs_displayed'] = true; |
---|
27 | } |
---|
28 | |
---|
29 | function rvm_begin_index_thumbnails( $pictures ) |
---|
30 | { |
---|
31 | global $page; |
---|
32 | foreach ($pictures as $picture) |
---|
33 | { |
---|
34 | if ( isset($picture['lat']) ) |
---|
35 | { |
---|
36 | $page['rvm_items_have_latlon'] = true; |
---|
37 | break; |
---|
38 | } |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | function rvm_end_index() |
---|
43 | { |
---|
44 | global $page, $filter, $template, $rvm_dir; |
---|
45 | |
---|
46 | //if ( !is_admin() ) return; // TEMP |
---|
47 | if ( isset($page['chronology_field']) || $filter['enabled'] ) |
---|
48 | return; |
---|
49 | |
---|
50 | if ( 'categories' == @$page['section']) |
---|
51 | { // flat or no flat ; has subcats or not; ? |
---|
52 | if ( ! @$page['rvm_cat_thumbs_displayed'] and empty($page['items']) ) |
---|
53 | return; |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | if ( |
---|
58 | !in_array( @$page['section'], array('tags','search','recent_pics','list') ) |
---|
59 | ) |
---|
60 | return; |
---|
61 | if ( empty($page['items']) ) |
---|
62 | return; |
---|
63 | } |
---|
64 | |
---|
65 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
66 | |
---|
67 | if ( !empty($page['items']) ) |
---|
68 | { |
---|
69 | if (!@$page['rvm_items_have_latlon'] and ! rvm_items_have_latlon( $page['items'] ) ) |
---|
70 | return; |
---|
71 | } |
---|
72 | rvm_load_language(); |
---|
73 | |
---|
74 | $map_url = rvm_duplicate_map_index_url( array(), array('start') ); |
---|
75 | if ( !empty($map_url) ) |
---|
76 | { |
---|
77 | $link_title = sprintf( l10n('displays %s on a map'), strip_tags($page['title']) ); |
---|
78 | $template->concat( 'PLUGIN_INDEX_ACTIONS' ,' |
---|
79 | <li><a href="'.$map_url.'" title="'.$link_title.'" rel="nofollow"><img src="'.get_root_url().'plugins/'.$rvm_dir.'/icons/map_m.png" class="button" alt="map"></a></li> |
---|
80 | '); |
---|
81 | } |
---|
82 | |
---|
83 | // if ( empty($map_url) ) |
---|
84 | { |
---|
85 | $kml_url = rvm_duplicate_kml_index_url( array(), array('start') ); |
---|
86 | $link_title = sprintf( l10n('opens %s in Google Earth'), strip_tags($page['title']) ); |
---|
87 | $template->concat( 'PLUGIN_INDEX_ACTIONS' ,' |
---|
88 | <li><a href="'.$kml_url.'" title="'.$link_title.'" rel="nofollow" type="application/vnd.google-earth.kml+xml"><img src="'.get_root_url().'plugins/'.$rvm_dir.'/icons/earth_m.png" class="button" alt="earth"></a></li> |
---|
89 | '); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | function rvm_picture_pictures_data($pictures) |
---|
94 | { |
---|
95 | if ( isset($pictures['current']['lat']) and isset($pictures['current']['lon']) ) |
---|
96 | { |
---|
97 | global $template; |
---|
98 | $template->append('head_elements', '<meta name="geo.position" content="'.$pictures['current']['lat'].';'.$pictures['current']['lon'].'">' ); |
---|
99 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
100 | rvm_load_language(); |
---|
101 | if ( isset($_GET['map']) ) |
---|
102 | include_once( dirname(__FILE__) .'/include/picture_map.inc.php'); |
---|
103 | else |
---|
104 | { |
---|
105 | global $rvm_dir; |
---|
106 | $map_url = rvm_duplicate_map_picture_url(); |
---|
107 | if (!empty($map_url)) |
---|
108 | { |
---|
109 | $link_title = sprintf( l10n('displays %s on a map'), strip_tags($pictures['current']['name']) ); |
---|
110 | $template->concat('PLUGIN_PICTURE_ACTIONS', ' |
---|
111 | <a href="'.$map_url.'" title="'.$link_title.'" rel="nofollow" target="_top"><img src="'.get_root_url().'plugins/'.$rvm_dir.'/icons/map_m.png" class="button" alt="map"></a> |
---|
112 | '); |
---|
113 | } |
---|
114 | } |
---|
115 | } |
---|
116 | else |
---|
117 | if ( isset($_GET['map']) ) |
---|
118 | redirect( duplicate_picture_url() ); |
---|
119 | return $pictures; |
---|
120 | } |
---|
121 | |
---|
122 | function rvm_plugin_admin_menu($menu) |
---|
123 | { |
---|
124 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
125 | add_event_handler('invalidate_user_cache', 'rvm_invalidate_cache' ); |
---|
126 | |
---|
127 | array_push($menu, |
---|
128 | array( |
---|
129 | 'NAME' => 'Maps & Earth', |
---|
130 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/admin.php') |
---|
131 | ) |
---|
132 | ); |
---|
133 | return $menu; |
---|
134 | } |
---|
135 | |
---|
136 | ?> |
---|