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

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

Connect the plugin to the RBuilder component + fixe some small bugs

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