1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : GMaps |
---|
4 | Author : Grum |
---|
5 | email : grum@piwigo.org |
---|
6 | website : http://photos.grum.fr |
---|
7 | |
---|
8 | << May the Little SpaceFrog be with you ! >> |
---|
9 | ------------------------------------------------------------------------------ |
---|
10 | See main.inc.php for release information |
---|
11 | |
---|
12 | GMaps_Install : classe to manage plugin install |
---|
13 | |
---|
14 | --------------------------------------------------------------------------- */ |
---|
15 | |
---|
16 | include_once('gmaps_version.inc.php'); // => Don't forget to update this file !! |
---|
17 | include_once('gmaps_root.class.inc.php'); |
---|
18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); |
---|
19 | |
---|
20 | /* GMaps class for install process */ |
---|
21 | class GMaps_Install extends GMaps_root |
---|
22 | { |
---|
23 | private $tablef; |
---|
24 | |
---|
25 | public function __construct($prefixeTable, $filelocation) |
---|
26 | { |
---|
27 | parent::__construct($prefixeTable, $filelocation); |
---|
28 | $this->tablef= new GPCTables($this->tables); |
---|
29 | } |
---|
30 | |
---|
31 | public function __destruct() |
---|
32 | { |
---|
33 | unset($this->tablef); |
---|
34 | parent::__destruct(); |
---|
35 | } |
---|
36 | |
---|
37 | /* |
---|
38 | function for installation process |
---|
39 | return true if install process is ok, otherwise false |
---|
40 | */ |
---|
41 | public function install() |
---|
42 | { |
---|
43 | $this->initConfig(); |
---|
44 | $this->loadConfig(); |
---|
45 | $this->config['installed']=GMAPS_VERSION2; |
---|
46 | $this->config['newInstall']='y'; |
---|
47 | $this->saveConfig(); |
---|
48 | |
---|
49 | $tables_def=array( |
---|
50 | "CREATE TABLE `".$this->tables['maps']."` ( |
---|
51 | `id` int(10) unsigned NOT NULL auto_increment, |
---|
52 | `name` varchar(80) NOT NULL, |
---|
53 | `displayType` char(2) NOT NULL, |
---|
54 | `sizeMode` char(1) NOT NULL, |
---|
55 | `width` int(10) unsigned NOT NULL default '470', |
---|
56 | `height` int(10) unsigned NOT NULL default '210', |
---|
57 | `zoomLevel` smallint(6) NOT NULL default '4', |
---|
58 | `mapType` varchar(9) NOT NULL default 'hybrid', |
---|
59 | `mapTypeControl` smallint(6) NOT NULL default '0', |
---|
60 | `navigationControl` smallint(6) NOT NULL default '0', |
---|
61 | `scaleControl` char(1) NOT NULL default 'y', |
---|
62 | `streetViewControl` char(1) NOT NULL default 'n', |
---|
63 | `style` varchar(512) NOT NULL, |
---|
64 | PRIMARY KEY (`id`) |
---|
65 | )", |
---|
66 | "CREATE TABLE `".$this->tables['category_maps']."` ( |
---|
67 | `id` int(10) unsigned NOT NULL auto_increment, |
---|
68 | `categoryId` smallint(5) unsigned NOT NULL, |
---|
69 | `mapId` int(11) NOT NULL, |
---|
70 | `imgSort` smallint(5) unsigned NOT NULL default '0', |
---|
71 | `applySubCat` char(1) NOT NULL default 'y', |
---|
72 | `kmlFileId` int(10) unsigned NOT NULL default '0', |
---|
73 | `kmlFileUrl` varchar(255) NOT NULL, |
---|
74 | `icon` varchar(255) NOT NULL, |
---|
75 | `marker` varchar(255) NOT NULL, |
---|
76 | `title` varchar(200) NOT NULL, |
---|
77 | PRIMARY KEY (`id`), |
---|
78 | KEY `byCategorie` (`categoryId`,`mapId`) |
---|
79 | )", |
---|
80 | "CREATE TABLE `".$this->tables['cache']."` ( |
---|
81 | `userId` smallint(5) NOT NULL, |
---|
82 | `requestId` timestamp NOT NULL default '0000-00-00 00:00:00', |
---|
83 | `imageId` mediumint(8) NOT NULL, |
---|
84 | `latitude` decimal(20,17) NOT NULL default '0.00000000000000000', |
---|
85 | `longitude` decimal(20,17) NOT NULL default '0.00000000000000000', |
---|
86 | `imageName` varchar(255) NOT NULL, |
---|
87 | `imageTnFile` varchar(255) NOT NULL, |
---|
88 | `imageCatsId` varchar(255) NOT NULL, |
---|
89 | `imageCatsNames` varchar(255) NOT NULL, |
---|
90 | `imageCatsPLink` varchar(255) NOT NULL, |
---|
91 | PRIMARY KEY USING BTREE (`userId`,`requestId`,`imageId`) |
---|
92 | )", |
---|
93 | "CREATE TABLE `".$this->tables['kmlfiles']."` ( |
---|
94 | `id` int(10) unsigned NOT NULL auto_increment, |
---|
95 | `file` varchar(255) NOT NULL, |
---|
96 | `name` varchar(255) NOT NULL, |
---|
97 | `fileDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, |
---|
98 | `fileSize` mediumint(8) unsigned NOT NULL, |
---|
99 | PRIMARY KEY (`id`) |
---|
100 | )" |
---|
101 | ); |
---|
102 | |
---|
103 | $tables_def = create_table_add_character_set($tables_def); |
---|
104 | $result=$this->tablef->create($tables_def); |
---|
105 | unset($tables_def); |
---|
106 | |
---|
107 | GPCCore::register($this->getPluginName(), GMAPS_VERSION, GMAPS_GPC_NEEDED); |
---|
108 | return($result); |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | /* |
---|
113 | function for uninstall process |
---|
114 | */ |
---|
115 | public function uninstall() |
---|
116 | { |
---|
117 | $this->deleteConfig(); |
---|
118 | $this->tablef->drop(); |
---|
119 | GPCCore::unregister($this->getPluginName()); |
---|
120 | return(''); |
---|
121 | } |
---|
122 | |
---|
123 | public function activate() |
---|
124 | { |
---|
125 | $this->initConfig(); |
---|
126 | $this->loadConfig(); |
---|
127 | |
---|
128 | /* |
---|
129 | * migration code |
---|
130 | */ |
---|
131 | switch($this->config['installed']) |
---|
132 | { |
---|
133 | // actually, there no migration possible from previous release |
---|
134 | default: |
---|
135 | // nothing to do... |
---|
136 | break; |
---|
137 | } |
---|
138 | |
---|
139 | $this->config['installed']=GMAPS_VERSION2; |
---|
140 | $this->saveConfig(); |
---|
141 | |
---|
142 | GPCCore::register($this->getPluginName(), GMAPS_VERSION, GMAPS_GPC_NEEDED); |
---|
143 | GPCRequestBuilder::register($this->getPluginName(), dirname($this->getFileLocation()).'/gmaps_rb_callback.class.inc.php'); |
---|
144 | return(''); |
---|
145 | } |
---|
146 | |
---|
147 | public function deactivate() |
---|
148 | { |
---|
149 | GPCRequestBuilder::unregister($this->getPluginName()); |
---|
150 | } |
---|
151 | |
---|
152 | } //class |
---|
153 | |
---|
154 | ?> |
---|