source: extensions/rv_gmaps/trunk/main.inc.php @ 12700

Last change on this file since 12700 was 12700, checked in by rvelices, 12 years ago

rv_gmaps towards full maps api v3 migration

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1<?php /*
2Plugin Name: RV Maps&Earth
3Version: 2.3.a
4Description: Extend your gallery with Google Maps and Google Earth ...
5Plugin URI: http://piwigo.org/ext/extension_view.php?eid=122
6Author: rvelices
7Author URI: http://www.modusoptimus.com/
8*/
9define( 'RVM_PLUGIN_VERSION', '2.3.a');
10if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
11
12add_event_handler('loc_end_index', 'rvm_end_index' );
13add_event_handler('loc_begin_index_category_thumbnails', 'rvm_index_cat_thumbs_displayed');
14add_event_handler('loc_begin_index_thumbnails', 'rvm_begin_index_thumbnails');
15
16add_event_handler('picture_pictures_data', 'rvm_picture_pictures_data' );
17add_event_handler('get_admin_plugin_menu_links', 'rvm_plugin_admin_menu' );
18
19global $rvm_dir;
20$rvm_dir = basename( dirname(__FILE__) );
21
22
23function rvm_index_cat_thumbs_displayed()
24{
25        global $page;
26        $page['rvm_cat_thumbs_displayed'] = true;
27}
28
29function 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
42define('RVM_ACTION_MODEL', '<a href="%s" title="%s" rel="nofollow" class="pwg-state-default pwg-button"%s><span class="pwg-icon pwg-icon-%s">&nbsp;</span><span class="pwg-button-text">%s</span></a>');
43
44function rvm_end_index()
45{
46        global $page, $filter, $template, $rvm_dir;
47
48        //if ( !is_admin() ) return; // TEMP
49        if ( isset($page['chronology_field']) || $filter['enabled'] )
50                return;
51
52        if ( 'categories' == @$page['section'])
53        { // flat or no flat ; has subcats or not;  ?
54                if ( ! @$page['rvm_cat_thumbs_displayed'] and empty($page['items']) )
55                        return;
56        }
57        else
58        {
59                if (
60                        !in_array( @$page['section'], array('tags','search','recent_pics','list') )
61                        )
62                        return;
63                if ( empty($page['items']) )
64                        return;
65        }
66
67        include_once( dirname(__FILE__) .'/include/functions.php');
68
69        if ( !empty($page['items']) )
70        {
71                if (!@$page['rvm_items_have_latlon'] and ! rvm_items_have_latlon( $page['items'] ) )
72                        return;
73        }
74        rvm_load_language();
75
76        $map_url = rvm_duplicate_map_index_url( array(), array('start') );
77        if ( !empty($map_url) )
78        {
79                $link_title = sprintf( l10n('displays %s on a map'), strip_tags($page['title']) );
80                $template->concat( 'PLUGIN_INDEX_ACTIONS' , "\n<li>".sprintf(RVM_ACTION_MODEL,
81                        $map_url, $link_title, '', 'map', 'map'
82                        ).'</li>');
83        }
84
85        {
86                $kml_url = rvm_duplicate_kml_index_url( array(), array('start') );
87                $link_title = sprintf( l10n('opens %s in Google Earth'), strip_tags($page['title']) );
88                $template->concat( 'PLUGIN_INDEX_ACTIONS' , "\n<li>".sprintf(RVM_ACTION_MODEL,
89                        $kml_url, $link_title, ' type="application/vnd.google-earth.kml+xml"', 'globe', 'earth'
90                        ).'</li>');
91        }
92}
93
94function rvm_picture_pictures_data($pictures)
95{
96        if ( isset($pictures['current']['lat']) and isset($pictures['current']['lon']) )
97        {
98                global $template;
99                $template->append('head_elements', '<meta name="geo.position" content="'.$pictures['current']['lat'].';'.$pictures['current']['lon'].'">' );
100                include_once( dirname(__FILE__) .'/include/functions.php');
101                rvm_load_language();
102                if ( isset($_GET['map']) )
103                        include_once( dirname(__FILE__) .'/include/picture_map.inc.php');
104                else
105                {
106                        global $rvm_dir;
107                        $map_url = rvm_duplicate_map_picture_url();
108                        $link_title = sprintf( l10n('displays %s on a map'), strip_tags($pictures['current']['name']) );
109                        $template->concat( 'PLUGIN_PICTURE_ACTIONS' , sprintf(RVM_ACTION_MODEL,
110                                        $map_url, $link_title, ' target="_top"', 'map', 'map'
111                                ));
112                }
113        }
114        else
115                if ( isset($_GET['map']) )
116                        redirect( duplicate_picture_url() );
117        return $pictures;
118}
119
120function rvm_plugin_admin_menu($menu)
121{
122        include_once( dirname(__FILE__) .'/include/functions.php');
123        add_event_handler('invalidate_user_cache', 'rvm_invalidate_cache' );
124
125        array_push($menu,
126                        array(
127                                'NAME' => 'Maps & Earth',
128                                'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/admin.php')
129                        )
130                );
131        return $menu;
132}
133
134?>
Note: See TracBrowser for help on using the repository browser.