[24677] | 1 | <?php |
---|
| 2 | /*********************************************** |
---|
| 3 | * File : admin_config.php |
---|
| 4 | * Project : piwigo-openstreetmap |
---|
| 5 | * Descr : Install / Uninstall method |
---|
| 6 | * |
---|
| 7 | * Created : 28.05.2013 |
---|
| 8 | * |
---|
| 9 | * Copyright 2013 <xbgmsharp@gmail.com> |
---|
| 10 | * |
---|
| 11 | * This program is free software: you can redistribute it and/or modify |
---|
| 12 | * it under the terms of the GNU General Public License as published by |
---|
| 13 | * the Free Software Foundation, either version 3 of the License, or |
---|
| 14 | * (at your option) any later version. |
---|
| 15 | * |
---|
| 16 | * This program is distributed in the hope that it will be useful, |
---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | * GNU General Public License for more details. |
---|
| 20 | * |
---|
| 21 | * You should have received a copy of the GNU General Public License |
---|
| 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 23 | * |
---|
| 24 | ************************************************/ |
---|
| 25 | |
---|
| 26 | // Check whether we are indeed included by Piwigo. |
---|
| 27 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 28 | |
---|
| 29 | // Check access and exit when user status is not ok |
---|
| 30 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 31 | |
---|
| 32 | // Setup plugin Language |
---|
| 33 | load_language('plugin.lang', OSM_PATH); |
---|
| 34 | |
---|
| 35 | // Fetch the template. |
---|
| 36 | global $template, $conf, $lang; |
---|
| 37 | |
---|
| 38 | // Available baselayer |
---|
| 39 | $available_baselayer = array( |
---|
| 40 | 'mapnik' => 'OpenStreetMap (Mapnik)', |
---|
| 41 | 'mapnikfr' => 'OpenStreetMap FR', |
---|
| 42 | 'mapnikde' => 'OpenStreetMap DE', |
---|
| 43 | 'mapquest' => 'MapQuest', |
---|
| 44 | 'cloudmade' => 'Cloudmade', |
---|
| 45 | 'custom' => 'custom', |
---|
| 46 | ); |
---|
| 47 | |
---|
| 48 | // Available zoom value |
---|
| 49 | $available_zoom = array( |
---|
| 50 | '1' => '1', |
---|
| 51 | '2' => '2', |
---|
| 52 | '3' => '3', |
---|
| 53 | '4' => '4', |
---|
| 54 | '5' => '5', |
---|
| 55 | '6' => '6', |
---|
| 56 | '7' => '7', |
---|
| 57 | '8' => '8', |
---|
| 58 | '9' => '9', |
---|
| 59 | '10' => '10', |
---|
| 60 | '11' => '11', |
---|
| 61 | '12' => '12', |
---|
| 62 | '13' => '13', |
---|
| 63 | '14' => '14', |
---|
| 64 | '15' => '15', |
---|
| 65 | '16' => '16', |
---|
| 66 | '17' => '17', |
---|
| 67 | '18' => '18', |
---|
| 68 | ); |
---|
| 69 | |
---|
| 70 | // Available options |
---|
| 71 | $available_add_before = array( |
---|
| 72 | 'Author' => l10n('Author'), |
---|
| 73 | 'datecreate' => l10n('Created on'), |
---|
| 74 | 'datepost' => l10n('Posted on'), |
---|
| 75 | 'Dimensions' => l10n('Dimensions'), |
---|
| 76 | 'File' => l10n('File'), |
---|
| 77 | 'Filesize' => l10n('Filesize'), |
---|
| 78 | 'Tags' => l10n('Tags'), |
---|
| 79 | 'Categories' => l10n('Albums'), |
---|
| 80 | 'Visits' => l10n('Visits'), |
---|
| 81 | 'Average' => l10n('Rating score'), |
---|
| 82 | 'rating' => l10n('Rate this photo'), |
---|
| 83 | 'Privacy' => l10n('Who can see this photo?'), |
---|
| 84 | ); |
---|
| 85 | |
---|
| 86 | // Available pin |
---|
| 87 | $available_pin = array( |
---|
| 88 | '0' => l10n('NOPIN'), |
---|
| 89 | '1' => l10n('DEFAULTPIN'), |
---|
| 90 | '2' => l10n('LEAFPINGREEN'), |
---|
| 91 | '3' => l10n('LEAFPINORANGE'), |
---|
| 92 | '4' => l10n('LEAFPINRED'), |
---|
| 93 | '5' => l10n('MAPICONSBLEU'), |
---|
| 94 | '6' => l10n('MAPICONSGREEN'), |
---|
| 95 | '7' => l10n('OWNPIN'), |
---|
| 96 | ); |
---|
| 97 | |
---|
| 98 | // Available popup |
---|
| 99 | $available_popup = array( |
---|
| 100 | '0' => l10n('CLICK'), |
---|
| 101 | // '1' => l10n('ALWAYS'), |
---|
| 102 | '2' => l10n('NEVER'), |
---|
| 103 | ); |
---|
| 104 | |
---|
| 105 | $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE `lat` IS NOT NULL and `lon` IS NOT NULL '; |
---|
| 106 | list($nb_geotagged) = pwg_db_fetch_array( pwg_query($query) ); |
---|
| 107 | |
---|
| 108 | // Update conf if submitted in admin site |
---|
| 109 | if (isset($_POST['submit']) && !empty($_POST['osm_height'])) |
---|
| 110 | { |
---|
| 111 | // On post admin form |
---|
| 112 | $conf['osm_conf'] = array( |
---|
| 113 | 'right_panel' => array( |
---|
| 114 | 'enabled' => get_boolean($_POST['osm_right_panel']), |
---|
| 115 | 'add_before' => $_POST['osm_add_before'], |
---|
| 116 | 'height' => $_POST['osm_height'], |
---|
| 117 | 'zoom' => $_POST['osm_zoom'], |
---|
| 118 | 'link' => $_POST['osm_right_link'], |
---|
| 119 | 'linkcss' => $_POST['osm_right_linkcss'], |
---|
| 120 | 'showosm' => get_boolean($_POST['osm_showosm']), |
---|
| 121 | ), |
---|
| 122 | 'left_menu' => array( |
---|
| 123 | 'enabled' => get_boolean($_POST['osm_left_menu']), |
---|
| 124 | 'link' => $_POST['osm_left_link'], |
---|
| 125 | 'popup' => $_POST['osm_left_popup'], |
---|
| 126 | 'popupinfo_name' => isset($_POST['osm_left_popupinfo_name']), |
---|
| 127 | 'popupinfo_img' => isset($_POST['osm_left_popupinfo_img']), |
---|
| 128 | 'popupinfo_link' => isset($_POST['osm_left_popupinfo_link']), |
---|
| 129 | 'popupinfo_comment' => isset($_POST['osm_left_popupinfo_comment']), |
---|
| 130 | 'popupinfo_author' => isset($_POST['osm_left_popupinfo_author']), |
---|
| 131 | ), |
---|
| 132 | 'map' => array( |
---|
| 133 | 'baselayer' => $_POST['osm_baselayer'], |
---|
| 134 | 'custombaselayer' => $_POST['osm_custombaselayer'], |
---|
| 135 | 'custombaselayerurl' => $_POST['osm_custombaselayerurl'], |
---|
| 136 | 'noworldwarp' => get_boolean($_POST['osm_noworldwarp']), |
---|
| 137 | 'attrleaflet' => get_boolean($_POST['osm_attrleaflet']), |
---|
| 138 | 'attrimagery' => get_boolean($_POST['osm_attrimagery']), |
---|
| 139 | 'attrplugin' => get_boolean($_POST['osm_attrplugin']), |
---|
| 140 | ), |
---|
| 141 | 'auto_sync' => get_boolean($_POST['osm_auto_sync']), |
---|
| 142 | 'batch_manager' => get_boolean($_POST['osm_batch_manager']), |
---|
| 143 | ); |
---|
| 144 | |
---|
| 145 | // Update config to DB |
---|
| 146 | conf_update_param('osm_conf', serialize($conf['osm_conf'])); |
---|
| 147 | |
---|
| 148 | // the prefilter changes, we must delete compiled templatess |
---|
| 149 | $template->delete_compiled_templates(); |
---|
| 150 | array_push($page['infos'], l10n('Your configuration settings are saved')); |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | // send value to template |
---|
| 154 | $template->assign($conf['osm_conf']); |
---|
| 155 | $template->assign( |
---|
| 156 | array( |
---|
| 157 | 'AVAILABLE_ADD_BEFORE' => $available_add_before, |
---|
| 158 | 'AVAILABLE_ZOOM' => $available_zoom, |
---|
| 159 | 'AVAILABLE_BASELAYER' => $available_baselayer, |
---|
| 160 | 'AVAILABLE_PIN' => $available_pin, |
---|
| 161 | 'AVAILABLE_POPUP' => $available_popup, |
---|
| 162 | 'NB_GEOTAGGED' => $nb_geotagged, |
---|
| 163 | ) |
---|
| 164 | ); |
---|
| 165 | |
---|
| 166 | ?> |
---|