source: extensions/Psli_BingMaps/include/admin.php @ 14913

Last change on this file since 14913 was 14913, checked in by psli, 12 years ago

Version 1.3 :

  • correction de l'upgrade
  • correction des chemins d'accès
File size: 3.5 KB
Line 
1<?php
2/*
3Plugin Name: Psli-BingMaps
4Author: psli
5Description: Admin function for plugin "Psli-BingMaps"
6*/
7
8// Chech whether we are indeed included by Piwigo.
9if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
10
11// Fetch the template.
12global $template, $conf, $page, $debug;
13
14$debug .= "PSLIDEBUG - ".$_SERVER['REQUEST_URI'];
15
16// Save configuration
17if (isset($_POST['submit']))
18{
19        $query = '
20                UPDATE '.CONFIG_TABLE.'
21                        SET value="' . addslashes($_POST['key']) . '"
22                        WHERE param="'.PSLI_CONF_KEY.'"
23                        LIMIT 1';
24    pwg_query($query);
25    $query = '
26                UPDATE '.CONFIG_TABLE.'
27                        SET value="' . addslashes($_POST['lat']) . '"
28                        WHERE param="'.PSLI_CONF_LAT.'"
29                        LIMIT 1';
30    pwg_query($query);
31        $query = '
32                UPDATE '.CONFIG_TABLE.'
33                        SET value="' . addslashes($_POST['lon']) . '"
34                        WHERE param="'.PSLI_CONF_LON.'"
35                        LIMIT 1';
36    pwg_query($query);
37        $query = '
38                UPDATE '.CONFIG_TABLE.'
39                        SET value="' . addslashes($_POST['zoom']) . '"
40                        WHERE param="'.PSLI_CONF_ZOOM.'"
41                        LIMIT 1';
42    pwg_query($query);
43       
44        if ($_POST['catSelected'] != 0)
45        {
46                $query = '
47                        UPDATE '.CONFIG_TABLE.'
48                                SET value="' . addslashes($_POST['catSelected']) . '"
49                                WHERE param="'.PSLI_CONF_CATEGORY.'"
50                                LIMIT 1';
51                pwg_query($query);
52        }
53    array_push($page['infos'], l10n('Information data registered in database'));
54}
55
56// Get configuration
57$query = '
58        SELECT value
59                FROM '.CONFIG_TABLE.'
60                WHERE param = "'.PSLI_CONF_KEY.'";';
61$result = pwg_query($query);
62$row = pwg_db_fetch_assoc($result);
63$key = $row['value'];
64
65$query = '
66        SELECT value
67                FROM '.CONFIG_TABLE.'
68                WHERE param = "'.PSLI_CONF_LAT.'";';
69$result = pwg_query($query);
70$row = pwg_db_fetch_assoc($result);
71$lat = $row['value'];
72
73$query = '
74        SELECT value
75                FROM '.CONFIG_TABLE.'
76                WHERE param = "'.PSLI_CONF_LON.'";';
77$result = pwg_query($query);
78$row = pwg_db_fetch_assoc($result);
79$lon = $row['value'];
80
81$query = '
82        SELECT value
83                FROM '.CONFIG_TABLE.'
84                WHERE param = "'.PSLI_CONF_ZOOM.'";';
85$result = pwg_query($query);
86$row = pwg_db_fetch_assoc($result);
87$zoom = $row['value'];
88
89$query = '
90        SELECT value
91                FROM '.CONFIG_TABLE.'
92                WHERE param = "'.PSLI_CONF_CATEGORY.'";';
93$result = pwg_query($query);
94$row = pwg_db_fetch_assoc($result);
95$category = $row['value'];
96
97$query = '
98SELECT id,name,uppercats,global_rank
99  FROM '.CATEGORIES_TABLE.'
100;';
101$result = pwg_query($query);
102$categories = array();
103$selecteds = array();
104array_push($selecteds, "To define");
105if (!empty($result))
106{
107        while ($row = pwg_db_fetch_assoc($result))
108        {
109                if ($row['id'] == $category)
110                {
111                        $option = strip_tags(
112                                get_cat_display_name_cache(
113                                        $row['uppercats'],
114                                        null,
115                                        false
116                                        )
117                                );
118                        $selecteds = array();
119                        array_push($selecteds, $option);
120                        array_push($categories, $row);
121                }
122                else
123                {
124                        array_push($categories, $row);
125                }
126        }
127}
128usort($categories, 'global_rank_compare');
129display_select_categories($categories, $selecteds, 'category_select', true);
130
131display_select_categories($categories, null, 'zone', true);
132
133// Send configuration data to template
134$template->assign(
135  array(
136        'KEY'          => $key,
137        'LAT'          => $lat,
138        'LON'          => $lon,
139        'ZOOM'         => $zoom,
140        'JSPATH'           => PSLI_BINGMAPS_JS,
141        'VERSION'          => " v".PSLI_VERSION_MAJ.".".PSLI_VERSION_MIN
142  )
143);
144
145// Language data
146load_language('plugin.lang', PSLI_BINGMAPS_TEMPLATE_PATH);
147
148// Assign the template contents to ADMIN_CONTENT
149$template->set_filenames(array('plugin_admin_content' => PSLI_BINGMAPS_ADMIN_TPL));
150$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
151
152?>
Note: See TracBrowser for help on using the repository browser.