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

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

Version 1.2 : Mise a jour de la page Admin pour simplifier le paramétrage

File size: 3.3 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;
13
14// Save configuration
15if (isset($_POST['submit']))
16{
17        $query = '
18                UPDATE '.CONFIG_TABLE.'
19                        SET value="' . addslashes($_POST['key']) . '"
20                        WHERE param="'.PSLI_CONF_KEY.'"
21                        LIMIT 1';
22    pwg_query($query);
23    $query = '
24                UPDATE '.CONFIG_TABLE.'
25                        SET value="' . addslashes($_POST['lat']) . '"
26                        WHERE param="'.PSLI_CONF_LAT.'"
27                        LIMIT 1';
28    pwg_query($query);
29        $query = '
30                UPDATE '.CONFIG_TABLE.'
31                        SET value="' . addslashes($_POST['lon']) . '"
32                        WHERE param="'.PSLI_CONF_LON.'"
33                        LIMIT 1';
34    pwg_query($query);
35        $query = '
36                UPDATE '.CONFIG_TABLE.'
37                        SET value="' . addslashes($_POST['zoom']) . '"
38                        WHERE param="'.PSLI_CONF_ZOOM.'"
39                        LIMIT 1';
40    pwg_query($query);
41       
42        if ($_POST['catSelected'] != 0)
43        {
44                $query = '
45                        UPDATE '.CONFIG_TABLE.'
46                                SET value="' . addslashes($_POST['catSelected']) . '"
47                                WHERE param="'.PSLI_CONF_CATEGORY.'"
48                                LIMIT 1';
49                pwg_query($query);
50        }
51    array_push($page['infos'], l10n('Information data registered in database'));
52}
53
54// Get configuration
55$query = '
56        SELECT value
57                FROM '.CONFIG_TABLE.'
58                WHERE param = "'.PSLI_CONF_KEY.'";';
59$result = pwg_query($query);
60$row = pwg_db_fetch_assoc($result);
61$key = $row['value'];
62
63$query = '
64        SELECT value
65                FROM '.CONFIG_TABLE.'
66                WHERE param = "'.PSLI_CONF_LAT.'";';
67$result = pwg_query($query);
68$row = pwg_db_fetch_assoc($result);
69$lat = $row['value'];
70
71$query = '
72        SELECT value
73                FROM '.CONFIG_TABLE.'
74                WHERE param = "'.PSLI_CONF_LON.'";';
75$result = pwg_query($query);
76$row = pwg_db_fetch_assoc($result);
77$lon = $row['value'];
78
79$query = '
80        SELECT value
81                FROM '.CONFIG_TABLE.'
82                WHERE param = "'.PSLI_CONF_ZOOM.'";';
83$result = pwg_query($query);
84$row = pwg_db_fetch_assoc($result);
85$zoom = $row['value'];
86
87$query = '
88        SELECT value
89                FROM '.CONFIG_TABLE.'
90                WHERE param = "'.PSLI_CONF_CATEGORY.'";';
91$result = pwg_query($query);
92$row = pwg_db_fetch_assoc($result);
93$category = $row['value'];
94
95$query = '
96SELECT id,name,uppercats,global_rank
97  FROM '.CATEGORIES_TABLE.'
98;';
99$result = pwg_query($query);
100$categories = array();
101$selecteds = array();
102array_push($selecteds, "To define");
103if (!empty($result))
104{
105        while ($row = pwg_db_fetch_assoc($result))
106        {
107                if ($row['id'] == $category)
108                {
109                        $option = strip_tags(
110                                get_cat_display_name_cache(
111                                        $row['uppercats'],
112                                        null,
113                                        false
114                                        )
115                                );
116                        $selecteds = array();
117                        array_push($selecteds, $option);
118                        array_push($categories, $row);
119                }
120                else
121                {
122                        array_push($categories, $row);
123                }
124        }
125}
126usort($categories, 'global_rank_compare');
127display_select_categories($categories, $selecteds, 'category_select', true);
128
129display_select_categories($categories, null, 'zone', true);
130
131// Send configuration data to template
132$template->assign(
133  array(
134        'KEY'          => $key,
135        'LAT'          => $lat,
136        'LON'          => $lon,
137        'ZOOM'         => $zoom,
138        'JSPATH'           => PSLI_BINGMAPS_JS
139  )
140);
141
142// Language data
143load_language('plugin.lang', PSLI_BINGMAPS_TEMPLATE_PATH);
144
145// Assign the template contents to ADMIN_CONTENT
146$template->set_filenames(array('plugin_admin_content' => PSLI_BINGMAPS_ADMIN_TPL));
147$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
148
149?>
Note: See TracBrowser for help on using the repository browser.