[14872] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Psli-BingMaps |
---|
| 4 | Author: psli |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | // Chech whether we are indeed included by Piwigo. |
---|
| 8 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 9 | |
---|
| 10 | // Include define data |
---|
| 11 | include_once(dirname(__FILE__).'/include/const.inc.php'); |
---|
| 12 | |
---|
| 13 | /********************************************************************************************/ |
---|
[15432] | 14 | // Plugin installation |
---|
[14872] | 15 | // Create all needed tables and parameters ( with value by default) in CONFIG_TABLE |
---|
| 16 | /********************************************************************************************/ |
---|
[14913] | 17 | function plugin_install($plugin_id, $plugin_version, &$errors) |
---|
[14872] | 18 | { |
---|
| 19 | global $prefixeTable; |
---|
| 20 | |
---|
| 21 | $sql = ' |
---|
[15432] | 22 | CREATE TABLE IF NOT EXISTS `'.PSLI_MAPS_TABLE."` ( |
---|
| 23 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
---|
| 24 | `id_category` smallint(5) unsigned DEFAULT NULL, |
---|
| 25 | `title` text, |
---|
| 26 | `lat` decimal(15,12) DEFAULT '0.000000000000', |
---|
| 27 | `lon` decimal(15,12) DEFAULT '0.000000000000', |
---|
| 28 | `zoom` smallint(6) DEFAULT NULL, |
---|
| 29 | PRIMARY KEY (`id`) |
---|
| 30 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; |
---|
| 31 | pwg_query($sql); |
---|
| 32 | |
---|
| 33 | $sql = ' |
---|
[14872] | 34 | CREATE TABLE IF NOT EXISTS `'.PSLI_ENTITIES_TABLE."` ( |
---|
| 35 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
---|
| 36 | `lat` decimal(15,12) DEFAULT '0.000000000000', |
---|
| 37 | `lon` decimal(15,12) DEFAULT '0.000000000000', |
---|
| 38 | `title` text, |
---|
| 39 | `zoomMin` smallint(6) DEFAULT NULL, |
---|
| 40 | `zoomMax` smallint(6) DEFAULT NULL, |
---|
| 41 | `action` smallint(6) DEFAULT NULL, |
---|
[15432] | 42 | `id_action` smallint(5) unsigned DEFAULT NULL, |
---|
| 43 | `type` smallint(1) default 1, |
---|
| 44 | PRIMARY KEY (`id`) |
---|
[14872] | 45 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; |
---|
| 46 | pwg_query($sql); |
---|
| 47 | |
---|
| 48 | $sql = ' |
---|
[15432] | 49 | CREATE TABLE IF NOT EXISTS `'.PSLI_ENTITIES_MAPS_TABLE."` ( |
---|
| 50 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
---|
| 51 | `id_entity` smallint(5) unsigned DEFAULT NULL, |
---|
| 52 | `id_map` smallint(5) unsigned DEFAULT NULL, |
---|
| 53 | PRIMARY KEY (`id`), |
---|
| 54 | UNIQUE `psli_entity_map_1` (`id_entity`, `id_map`), |
---|
| 55 | INDEX `psli_entity_map_2` (`id_entity`), |
---|
| 56 | INDEX `psli_entity_map_3` (`id_map`) |
---|
| 57 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; |
---|
| 58 | pwg_query($sql); |
---|
| 59 | |
---|
| 60 | $sql = ' |
---|
[14872] | 61 | CREATE TABLE IF NOT EXISTS `'.PSLI_DATAPOINT_TABLE.'` ( |
---|
| 62 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
---|
| 63 | `id_entity` smallint(5) unsigned, |
---|
| 64 | `lat` decimal(20,17) DEFAULT NULL, |
---|
| 65 | `lon` decimal(20,17) DEFAULT NULL, |
---|
| 66 | PRIMARY KEY (`id`) |
---|
| 67 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;'; |
---|
| 68 | pwg_query($sql); |
---|
[15432] | 69 | |
---|
[14872] | 70 | $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_KEY."', 'to define');"; |
---|
[14913] | 71 | pwg_query($sql); |
---|
[14872] | 72 | |
---|
| 73 | $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_VERSION_MAJ."', '".PSLI_VERSION_MAJ."');"; |
---|
[14913] | 74 | pwg_query($sql); |
---|
[14872] | 75 | |
---|
| 76 | $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_VERSION_MIN."', '".PSLI_VERSION_MIN."');"; |
---|
[14913] | 77 | pwg_query($sql); |
---|
| 78 | |
---|
| 79 | $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_PATH."', 'http://".$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],"/"))."/');"; |
---|
| 80 | pwg_query($sql); |
---|
| 81 | |
---|
[15432] | 82 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[14872] | 83 | } |
---|
| 84 | |
---|
| 85 | /********************************************************************************************/ |
---|
| 86 | // Plugin deactivation |
---|
| 87 | // Destroy tables and parameters created by plugin |
---|
| 88 | /********************************************************************************************/ |
---|
[14913] | 89 | function plugin_uninstall($plugin_id) |
---|
[14872] | 90 | { |
---|
| 91 | global $prefixeTable; |
---|
[15432] | 92 | $sql = 'DROP TABLE `'.PSLI_MAPS_TABLE.'`;'; |
---|
| 93 | pwg_query($sql); |
---|
[14872] | 94 | $sql = 'DROP TABLE `'.PSLI_ENTITIES_TABLE.'`;'; |
---|
| 95 | pwg_query($sql); |
---|
[15432] | 96 | $sql = 'DROP TABLE `'.PSLI_ENTITIES_MAPS_TABLE.'`;'; |
---|
| 97 | pwg_query($sql); |
---|
[14872] | 98 | $sql = 'DROP TABLE `'.PSLI_DATAPOINT_TABLE.'`;'; |
---|
| 99 | pwg_query($sql); |
---|
| 100 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_KEY."';"; |
---|
| 101 | pwg_query($sql); |
---|
| 102 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_VERSION_MAJ."';"; |
---|
| 103 | pwg_query($sql); |
---|
| 104 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_VERSION_MIN."';"; |
---|
| 105 | pwg_query($sql); |
---|
[15432] | 106 | $sql = 'DELETE FROM `'.CONFIG_TABLE."` WHERE param = '".PSLI_CONF_PATH."';"; |
---|
| 107 | pwg_query($sql); |
---|
| 108 | |
---|
| 109 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[14872] | 110 | } |
---|
| 111 | |
---|
| 112 | ?> |
---|