1 | <?php /* |
---|
2 | Plugin Name: RV Maps&Earth |
---|
3 | Version: 2.7.a |
---|
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.6.a'); |
---|
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 | add_event_handler('blockmanager_apply', 'rvm_blockmanager_apply'); |
---|
18 | |
---|
19 | add_event_handler('qsearch_pre', 'rvm_qsearch_pre', EVENT_HANDLER_PRIORITY_NEUTRAL, dirname(__FILE__).'/qsearch.inc.php'); |
---|
20 | add_event_handler('qsearch_get_scopes', 'rvm_qsearch_get_scopes', EVENT_HANDLER_PRIORITY_NEUTRAL, dirname(__FILE__).'/qsearch.inc.php'); |
---|
21 | add_event_handler('get_popup_help_content', 'rvm_get_popup_help', EVENT_HANDLER_PRIORITY_NEUTRAL, dirname(__FILE__).'/qsearch.inc.php'); |
---|
22 | |
---|
23 | global $rvm_dir; |
---|
24 | $rvm_dir = basename( dirname(__FILE__) ); |
---|
25 | |
---|
26 | |
---|
27 | function rvm_index_cat_thumbs_displayed() |
---|
28 | { |
---|
29 | global $page; |
---|
30 | $page['rvm_cat_thumbs_displayed'] = true; |
---|
31 | } |
---|
32 | |
---|
33 | function rvm_begin_index_thumbnails( $pictures ) |
---|
34 | { |
---|
35 | global $page; |
---|
36 | foreach ($pictures as $picture) |
---|
37 | { |
---|
38 | if ( isset($picture['latitude']) ) |
---|
39 | { |
---|
40 | $page['rvm_items_have_latlon'] = true; |
---|
41 | break; |
---|
42 | } |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | 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>'); |
---|
47 | |
---|
48 | function rvm_end_index() |
---|
49 | { |
---|
50 | global $page, $filter, $template, $rvm_dir; |
---|
51 | |
---|
52 | if ( isset($page['chronology_field']) || $filter['enabled'] ) |
---|
53 | return; |
---|
54 | |
---|
55 | $geo = @$page['qsearch_details']['geo']; |
---|
56 | if (!empty($geo) && !@$page['start']) |
---|
57 | { |
---|
58 | include_once(dirname(__FILE__).'/qsearch.inc.php'); |
---|
59 | rvm_qsearch_show_alt($geo); |
---|
60 | } |
---|
61 | if ( 'categories' == @$page['section']) |
---|
62 | { // flat or no flat ; has subcats or not; ? |
---|
63 | if ( ! @$page['rvm_cat_thumbs_displayed'] and empty($page['items']) ) |
---|
64 | return; |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | if ( |
---|
69 | !in_array( @$page['section'], array('tags','search','recent_pics','list') ) |
---|
70 | ) |
---|
71 | return; |
---|
72 | if ( empty($page['items']) ) |
---|
73 | return; |
---|
74 | } |
---|
75 | |
---|
76 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
77 | |
---|
78 | if ( !empty($page['items']) ) |
---|
79 | { |
---|
80 | if (!@$page['rvm_items_have_latlon'] and ! rvm_items_have_latlon( $page['items'] ) ) |
---|
81 | return; |
---|
82 | } |
---|
83 | rvm_load_language(); |
---|
84 | |
---|
85 | $map_url = rvm_duplicate_map_index_url( array(), array('start') ); |
---|
86 | $link_title = sprintf( l10n('displays %s on a map'), strip_tags($page['title']) ); |
---|
87 | $template->concat( 'PLUGIN_INDEX_ACTIONS' , "\n<li>".sprintf(RVM_ACTION_MODEL, |
---|
88 | $map_url, $link_title, '', 'map', l10n('Map') |
---|
89 | ).'</li>'); |
---|
90 | } |
---|
91 | |
---|
92 | function rvm_picture_pictures_data($pictures) |
---|
93 | { |
---|
94 | if ( isset($pictures['current']['latitude']) and isset($pictures['current']['longitude']) ) |
---|
95 | { |
---|
96 | global $template; |
---|
97 | $template->append('head_elements', '<meta name=geo.position content='.$pictures['current']['latitude'].';'.$pictures['current']['longitude'].'>' ); |
---|
98 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
99 | rvm_load_language(); |
---|
100 | if ( isset($_GET['map']) ) |
---|
101 | include_once( dirname(__FILE__) .'/include/picture_map.inc.php'); |
---|
102 | else |
---|
103 | { |
---|
104 | global $rvm_dir; |
---|
105 | $map_url = rvm_duplicate_map_picture_url(); |
---|
106 | $link_title = sprintf( l10n('displays %s on a map'), strip_tags($pictures['current']['TITLE']) ); |
---|
107 | $template->concat( 'PLUGIN_PICTURE_ACTIONS' , sprintf(RVM_ACTION_MODEL, |
---|
108 | $map_url, $link_title, ' target="_top"', 'map', l10n('Map') |
---|
109 | )); |
---|
110 | } |
---|
111 | } |
---|
112 | elseif ( isset($_GET['map']) ) |
---|
113 | redirect( duplicate_picture_url() ); |
---|
114 | return $pictures; |
---|
115 | } |
---|
116 | |
---|
117 | function rvm_blockmanager_apply($mb_arr) |
---|
118 | { |
---|
119 | if ($mb_arr[0]->get_id() != 'menubar' ) |
---|
120 | return; |
---|
121 | if ( ($block=$mb_arr[0]->get_block('mbMenu')) != null ) |
---|
122 | { |
---|
123 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
124 | rvm_load_language(); |
---|
125 | global $conf; |
---|
126 | $link_title = sprintf( l10n('displays %s on a map'), strip_tags($conf['gallery_title']) ); |
---|
127 | $block->data['rv_gmaps'] = array( |
---|
128 | 'URL' => rvm_make_map_index_url( array('section'=>'categories') ), |
---|
129 | 'TITLE' => $link_title, |
---|
130 | 'NAME' => l10n('World map'), |
---|
131 | 'REL'=> 'rel=nofollow' |
---|
132 | ); |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | if (defined('IN_ADMIN')) { |
---|
137 | include_once(dirname(__FILE__).'/admin/admin_boot.php'); |
---|
138 | } |
---|
139 | ?> |
---|