source: extensions/Histogram/hgram_install.class.inc.php @ 31669

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

First commit for histogram plugin

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : Histogram
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  HGram_Install : classe to manage plugin install
13
14  --------------------------------------------------------------------------- */
15
16  if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
17
18  include_once('hgram_version.inc.php'); // => Don't forget to update this file !!
19  include_once('hgram_root.class.inc.php');
20  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
21
22  /* HGram class for install process */
23  class HGram_Install extends HGram_root
24  {
25    private $tablef;
26
27    public function __construct($prefixeTable, $filelocation)
28    {
29      parent::__construct($prefixeTable, $filelocation);
30      $this->tablef= new GPCTables($this->tables);
31    }
32
33    public function __destruct()
34    {
35      unset($this->tablef);
36      parent::__destruct();
37    }
38
39    /*
40        function for installation process
41        return true if install process is ok, otherwise false
42    */
43    public function install()
44    {
45      if(!file_exists(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY))
46      {
47        mkdir(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY, 0755, true);
48      }
49
50      $this->initConfig();
51      $this->loadConfig();
52      $this->config['installed']=HGRAM_VERSION2;
53      $this->config['newInstall']='y';
54      $this->saveConfig();
55
56      $tables_def=array(
57"CREATE TABLE `".$this->tables['histo']."` (
58  `imageId` INTEGER UNSIGNED NOT NULL DEFAULT 0,
59  `valueL` VARCHAR(1792)  NOT NULL,
60  `valueA` VARCHAR(1792)  NOT NULL,
61  `valueM` VARCHAR(1792)  NOT NULL,
62  `valueR` VARCHAR(1792)  NOT NULL,
63  `valueG` VARCHAR(1792)  NOT NULL,
64  `valueB` VARCHAR(1792)  NOT NULL,
65  `graphFile` VARCHAR(36)  NOT NULL,
66  PRIMARY KEY (`imageId`)
67)
68CHARACTER SET utf8 COLLATE utf8_general_ci",
69      );
70
71      $result=$this->tablef->create($tables_def);
72
73      GPCCore::register($this->getPluginName(), HGRAM_VERSION, HGRAM_GPC_NEEDED);
74
75      return($result);
76    }
77
78
79    /*
80        function for uninstall process
81    */
82    public function uninstall()
83    {
84      GPCCore::unregister($this->getPluginName());
85
86      $this->purgeHistoCache();
87
88      $this->deleteConfig();
89      $this->tablef->drop();
90      return('');
91    }
92
93    public function activate()
94    {
95      global $template;
96
97      $this->initConfig();
98      $this->loadConfig();
99      $this->config['installed']=HGRAM_VERSION2;
100      $this->saveConfig();
101
102      return('');
103    }
104
105    public function deactivate()
106    {
107    }
108
109  } //class
110
111?>
Note: See TracBrowser for help on using the repository browser.