source: extensions/piwigo-openstreetmap/main.inc.php @ 30323

Last change on this file since 30323 was 24677, checked in by ddtddt, 11 years ago

[extensions] - piwigo-openstreetmap - add file for translate

File size: 2.7 KB
Line 
1<?php
2/*
3Plugin Name: OpenStreetMap
4Version: 0.6
5Description: OpenStreetMap integration for piwigo
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=701
7Author: xbmgsharp
8Author URI: https://github.com/xbgmsharp/piwigo-openstreetmap
9*/
10
11// Chech whether we are indeed included by Piwigo.
12if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
13
14// Define the path to our plugin.
15define('OSM_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)).'/');
16
17global $conf;
18
19// Prepare configuration
20$conf['osm_conf'] = unserialize($conf['osm_conf']);
21
22// Plugin on picture page
23if (script_basename() == 'picture')
24{
25        include_once(dirname(__FILE__).'/picture.inc.php');
26}
27
28// Do we have to show a link on the left menu
29if ($conf['osm_conf']['left_menu']['enabled'])
30{
31        // Hook to add link on the left menu
32        add_event_handler('blockmanager_apply', 'osm_blockmanager_apply');
33}
34
35// Hook to sync geotag metadata on updload
36if ($conf['osm_conf']['auto_sync'])
37{
38        $conf['use_exif_mapping']['lat'] = 'lat';
39        $conf['use_exif_mapping']['lon'] = 'lon';
40        add_event_handler('format_exif_data', 'osm_format_exif_data', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
41}
42
43// If admin do the init
44if (defined('IN_ADMIN')) {
45        include_once(OSM_PATH.'/admin/admin_boot.php');
46}
47
48function osm_format_exif_data($exif, $file, $map)
49{
50        if (isset($map['lat']))
51        {
52                include_once( dirname(__FILE__) .'/include/functions_metadata.php');
53                $ll = osm_exif_to_lat_lon($exif);
54                if (is_array($ll))
55                {
56                        $exif[$map['lat']] = $ll[0];
57                        $exif[$map['lon']] = $ll[1];
58                }
59        }
60        return $exif;
61}
62
63function osm_blockmanager_apply($mb_arr)
64{
65        if ($mb_arr[0]->get_id() != 'menubar' )
66                return;
67        if ( ($block=$mb_arr[0]->get_block('mbMenu')) != null )
68        {
69                include_once( dirname(__FILE__) .'/include/functions.php');
70                load_language('plugin.lang', OSM_PATH);
71                global $conf;
72                $linkname = isset($conf['osm_conf']['left_menu']['link']) ? $conf['osm_conf']['left_menu']['link'] : 'OS World Map';
73                $link_title = sprintf( l10n('displays %s on a map'), strip_tags($conf['gallery_title']) );
74                $block->data['osm'] = array(
75                        'URL' => osm_make_map_index_url( array('section'=>'categories') ),
76                        'TITLE' => $link_title,
77                        'NAME' => $linkname,
78                        'REL'=> 'rel=nofollow'
79                );
80        }
81}
82
83function osm_strbool($value)
84{
85        return $value ? 'true' : 'false';
86}
87
88function imagery($bl, $style){
89        $return = "";
90        if     ($bl == 'mapnik')        $return = "OSM.org (CC BY-SA)";
91        else if($bl == 'mapnikfr')      $return = "Openstreetmap.fr (CC BY-SA)";
92        else if($bl == 'mapnikde')      $return = "Openstreetmap.de (CC BY-SA)";
93        else if($bl == 'cloudmade')     $return = "Cloudmade (CC BY-SA)";
94        else if($bl == 'mapquest')      $return = "Mapquest (CC BY-SA)";
95        else if($bl == 'custom')        $return = $style;
96        return $return;
97}
98
99?>
Note: See TracBrowser for help on using the repository browser.