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

Last change on this file since 27153 was 26717, checked in by rvelices, 10 years ago

rv_gmaps compatible with new latitude/longitude fields in piwigo core 2.6

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