source: extensions/GMaps/gmaps_install.class.inc.php @ 7139

Last change on this file since 7139 was 7139, checked in by grum, 14 years ago

add marker style management + minor bugs fixed

  • Property svn:executable set to *
File size: 4.6 KB
Line 
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  `style` varchar(512) NOT NULL,
63  PRIMARY KEY  (`id`)
64)",
65"CREATE TABLE `".$this->tables['category_maps']."` (
66  `id` int(10) unsigned NOT NULL auto_increment,
67  `categoryId` smallint(5) unsigned NOT NULL,
68  `mapId` int(11) NOT NULL,
69  `imgSort` smallint(5) unsigned NOT NULL default '0',
70  `applySubCat` char(1) NOT NULL default 'y',
71  `kmlFileId` int(10) unsigned NOT NULL default '0',
72  `kmlFileUrl` varchar(255) NOT NULL,
73  `icon` varchar(255) NOT NULL,
74  `marker` varchar(255) NOT NULL,
75  `title` varchar(200) NOT NULL,
76  PRIMARY KEY  (`id`),
77  KEY `byCategorie` (`categoryId`,`mapId`)
78)",
79"CREATE TABLE `".$this->tables['cache']."` (
80  `userId` smallint(5) NOT NULL,
81  `requestId` timestamp NOT NULL default '0000-00-00 00:00:00',
82  `imageId` mediumint(8) NOT NULL,
83  `latitude` decimal(20,17) NOT NULL default '0.00000000000000000',
84  `longitude` decimal(20,17) NOT NULL default '0.00000000000000000',
85  `imageName` varchar(255) NOT NULL,
86  `imageTnFile` varchar(255) NOT NULL,
87  `imageCatsId` varchar(255) NOT NULL,
88  `imageCatsNames` varchar(255) NOT NULL,
89  `imageCatsPLink` varchar(255) NOT NULL,
90  PRIMARY KEY  USING BTREE (`userId`,`requestId`,`imageId`)
91)",
92"CREATE TABLE `".$this->tables['kmlfiles']."` (
93  `id` int(10) unsigned NOT NULL auto_increment,
94  `file` varchar(255) NOT NULL,
95  `name` varchar(255) NOT NULL,
96  `fileDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
97  `fileSize` mediumint(8) unsigned NOT NULL,
98  PRIMARY KEY  (`id`)
99)"
100      );
101
102      $tables_def = create_table_add_character_set($tables_def);
103      $result=$this->tablef->create($tables_def);
104      unset($tables_def);
105
106      GPCCore::register($this->getPluginName(), GMAPS_VERSION, GMAPS_GPC_NEEDED);
107      return($result);
108    }
109
110
111    /*
112        function for uninstall process
113    */
114    public function uninstall()
115    {
116      $this->deleteConfig();
117      $this->tablef->drop();
118      GPCCore::unregister($this->getPluginName());
119      return('');
120    }
121
122    public function activate()
123    {
124      $this->initConfig();
125      $this->loadConfig();
126
127      /*
128       * migration code
129       */
130      switch($this->config['installed'])
131      {
132        // actually, there no migration possible from previous release
133        default:
134          // nothing to do...
135          break;
136      }
137
138      $this->config['installed']=GMAPS_VERSION2;
139      $this->saveConfig();
140
141      GPCCore::register($this->getPluginName(), GMAPS_VERSION, GMAPS_GPC_NEEDED);
142      GPCRequestBuilder::register($this->getPluginName(), dirname($this->getFileLocation()).'/gmaps_rb_callback.class.inc.php');
143      return('');
144    }
145
146    public function deactivate()
147    {
148      GPCRequestBuilder::unregister($this->getPluginName());
149    }
150
151  } //class
152
153?>
Note: See TracBrowser for help on using the repository browser.