source: extensions/Psli_BingMaps/admin/include/admin_picture.inc.php @ 15448

Last change on this file since 15448 was 15448, checked in by psli, 12 years ago
File size: 3.6 KB
Line 
1<?php
2/*
3Plugin Name: Psli-BingMaps
4Author: psli
5*/
6
7// Chech whether we are indeed included by Piwigo.
8if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
9
10//******* Fetch global data *******
11global $template, $conf, $page, $debug;
12
13$add_js = "";
14
15// Include class files for map, pin and zone
16include_once(PSLI_BINGMAPS_CLASS_PICTURE_PHP);
17
18//******* Get Bing Map Key *******
19$query = '
20        SELECT value
21                FROM '.CONFIG_TABLE.'
22                WHERE param = "'.PSLI_CONF_KEY.'";';
23$result = pwg_query($query);
24$row = pwg_db_fetch_assoc($result);
25$bing_map_key = $row['value'];
26
27//******* Select entity to display *******
28$class_pin = new Psli_Pin();
29if (isset($_POST['open']))
30{
31        if ((isset($_POST['pictureSelected'])) && ($_POST['pictureSelected'] != 0))
32                $class_pin->open($_POST['pictureSelected']);
33        else
34                array_push($page['errors'], l10n('You need to select a picture'));
35}
36else
37{
38        if ((isset($_POST['hiddenpicture'])) && ($_POST['hiddenpicture'] != ""))
39                $class_pin->open($_POST['hiddenpicture']);
40}               
41if ($class_pin->isOpened())
42        $display = 'block';
43else
44        $display = 'none';
45
46
47/************************************************************************************/
48/* Submit - Delete pin **************************************************************/
49if (isset($_POST['delete']))
50{
51        if (isset($_POST['deleteCheck']))
52        {
53                if ((isset($_POST['pictureSelected'])) && ($_POST['pictureSelected'] != 0))
54                {
55                        $class_pin->open($_POST['pictureSelected']);
56                        $class_pin->delete();
57                        $class_pin = new Psli_Pin();
58                        $display = 'none';
59                        array_push($page['infos'], l10n('Information data registered in database'));
60                }
61                else
62                        array_push($page['errors'], l10n('You need to select a picture'));
63        }
64        else
65                array_push($page['errors'], l10n('You need to confirm deletion'));
66}
67/************************************************************************************/
68
69/************************************************************************************/
70/* Submit - Update a pin ************************************************************/
71if (isset($_POST['save']))
72{
73        $class_pin->setTitle($_POST['title']);
74        $class_pin->setZoomMin($_POST['zoommin']);
75        $class_pin->setZoomMax($_POST['zoommax']);
76       
77        $class_pin->clearMaps();
78        if (isset ($_POST['associatedmap']))
79                for ($i = 0; $i < count($_POST['associatedmap']); $i++)
80                        $class_pin->addMap($_POST['associatedmap'][$i]);
81                       
82        $class_pin->save();
83        $display = 'block';
84        array_push($page['infos'], l10n('Information data registered in database'));
85}
86/************************************************************************************/
87
88//******* Generate map list *******
89$query = "
90        SELECT id, title
91                FROM ".PSLI_MAPS_TABLE."
92                ORDER BY title;";
93$result = pwg_query($query);
94$associatedmap = "";
95while ($row = pwg_db_fetch_assoc($result))
96{
97        $status = "";
98        if ($class_pin->isMapAssociated($row['id']))
99                $status = "CHECKED";
100        $associatedmap .= '<tr><td><input type="checkbox" name="associatedmap[]" value="'.$row['id'].'" style="margin-right:10px;" '.$status.' />'.$row['title'].'</td></tr>';
101}
102
103//******* Send configuration data to template *******
104$class_pin->assignData($template, "LAT", "LON", "ZOOMMIN", "ZOOMMAX", "TITLE", "ACTIONPICTURE", "HIDDENPICTURE");
105$class_pin->generatePinList($template, "picture_select");
106       
107//******* Assign data to template *******
108$template->assign(
109  array(
110        'KEY'          => $bing_map_key,
111        'DISPLAY'      => $display,
112        'ASSOCIATEDMAP' => $associatedmap,
113  )
114);
115
116//******* Assign the template contents to ADMIN_CONTENT *******
117$template->set_filenames(array('plugin_admin_content' => PSLI_BINGMAPS_ADMIN_PICTURE_TPL));
118$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
119?>
Note: See TracBrowser for help on using the repository browser.