[14872] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Psli-BingMaps |
---|
| 4 | Author: psli |
---|
| 5 | Description: Admin function for plugin "Psli-BingMaps" |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | // Chech whether we are indeed included by Piwigo. |
---|
| 9 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 10 | |
---|
| 11 | // Fetch the template. |
---|
[14913] | 12 | global $template, $conf, $page, $debug; |
---|
[14872] | 13 | |
---|
[14913] | 14 | $debug .= "PSLIDEBUG - ".$_SERVER['REQUEST_URI']; |
---|
| 15 | |
---|
[14872] | 16 | // Save configuration |
---|
| 17 | if (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 = ' |
---|
| 98 | SELECT id,name,uppercats,global_rank |
---|
| 99 | FROM '.CATEGORIES_TABLE.' |
---|
| 100 | ;'; |
---|
| 101 | $result = pwg_query($query); |
---|
| 102 | $categories = array(); |
---|
| 103 | $selecteds = array(); |
---|
| 104 | array_push($selecteds, "To define"); |
---|
| 105 | if (!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 | } |
---|
| 128 | usort($categories, 'global_rank_compare'); |
---|
| 129 | display_select_categories($categories, $selecteds, 'category_select', true); |
---|
| 130 | |
---|
| 131 | display_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, |
---|
[14891] | 139 | 'ZOOM' => $zoom, |
---|
[14913] | 140 | 'JSPATH' => PSLI_BINGMAPS_JS, |
---|
| 141 | 'VERSION' => " v".PSLI_VERSION_MAJ.".".PSLI_VERSION_MIN |
---|
[14872] | 142 | ) |
---|
| 143 | ); |
---|
| 144 | |
---|
| 145 | // Language data |
---|
[14891] | 146 | load_language('plugin.lang', PSLI_BINGMAPS_TEMPLATE_PATH); |
---|
[14872] | 147 | |
---|
| 148 | // Assign the template contents to ADMIN_CONTENT |
---|
[14891] | 149 | $template->set_filenames(array('plugin_admin_content' => PSLI_BINGMAPS_ADMIN_TPL)); |
---|
[14872] | 150 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 151 | |
---|
| 152 | ?> |
---|