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

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

First commit

  • Property svn:executable set to *
File size: 3.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  `mapId` char(12) NOT NULL,
53  `name` varchar(80) NOT NULL,
54  `width` int(10) unsigned NOT NULL default '470',
55  `height` int(10) unsigned NOT NULL default '210',
56  `zoomLevel` smallint(6) NOT NULL default '4',
57  `mapType` varchar(9) NOT NULL default 'hybrid',
58  `mapTypeControl` smallint(6) NOT NULL default '0',
59  `navigationControl` smallint(6) NOT NULL default '0',
60  `scaleControl` char(1) NOT NULL default 'y',
61  `style` varchar(512) NOT NULL,
62  PRIMARY KEY  (`id`),
63  KEY `byMapId` (`mapId`)
64)",
65"CREATE TABLE   `".$this->tables['category_maps']."` (
66  `id` int(10) unsigned NOT NULL auto_increment,
67  `target` char(1) NOT NULL default 'P',
68  `category_id` smallint(5) unsigned NOT NULL,
69  `map_id` int(11) NOT NULL,
70  `sort` smallint(5) unsigned NOT NULL default '0',
71  `applySubCat` char(1) NOT NULL default 'y',
72  `kmlFileUrl` varchar(255) NOT NULL,
73  `marker` varchar(1) NOT NULL,
74  PRIMARY KEY  (`id`),
75  KEY `byTarget` USING BTREE (`target`,`category_id`,`sort`),
76  KEY `byCategorie` (`category_id`,`target`)
77)"
78      );
79
80      $tables_def = create_table_add_character_set($tables_def);
81      $result=$this->tablef->create($tables_def);
82      unset($tables_def);
83
84      GPCCore::register($this->getPluginName(), GMAPS_VERSION, GMAPS_GPC_NEEDED);
85      return($result);
86    }
87
88
89    /*
90        function for uninstall process
91    */
92    public function uninstall()
93    {
94      $this->deleteConfig();
95      $this->tablef->drop();
96      GPCCore::unregister($this->getPluginName());
97      return('');
98    }
99
100    public function activate()
101    {
102      $this->initConfig();
103      $this->loadConfig();
104
105      /*
106       * migration code
107       */
108      switch($this->config['installed'])
109      {
110        // actually, there no migration possible from previous release
111        default:
112          // nothing to do...
113          break;
114      }
115
116      $this->config['installed']=GMAPS_VERSION2;
117      $this->saveConfig();
118
119      GPCCore::register($this->getPluginName(), GMAPS_VERSION, GMAPS_GPC_NEEDED);
120      return('');
121    }
122
123    public function deactivate()
124    {
125      GPCRequestBuilder::unregister($this->getPluginName());
126    }
127
128  } //class
129
130?>
Note: See TracBrowser for help on using the repository browser.