source: extensions/AMetaData/amd_install.class.inc.php @ 4926

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

Unable to analyze the gallery : bug fixed !
and other little bugs fixed

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1<?php
2/*
3 * -----------------------------------------------------------------------------
4 * Plugin Name: Advanced MetaData
5 * -----------------------------------------------------------------------------
6 * Author     : Grum
7 *   email    : grum@piwigo.org
8 *   website  : http://photos.grum.fr
9 *   PWG user : http://forum.piwigo.org/profile.php?id=3706
10 *
11 *   << May the Little SpaceFrog be with you ! >>
12 *
13 * -----------------------------------------------------------------------------
14 *
15 * See main.inc.php for release information
16 *
17 * AMD_install : classe to manage plugin install
18 * ---------------------------------------------------------------------------
19 */
20
21  @include_once('amd_root.class.inc.php');
22  include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/tables.class.inc.php');
23
24
25  class AMD_install extends AMD_root
26  {
27    private $tablef;
28
29    public function AMD_install($prefixeTable, $filelocation)
30    {
31      parent::__construct($prefixeTable, $filelocation);
32      $this->tablef= new manage_tables($this->tables);
33    }
34
35    /*
36     * function for installation process
37     * return true if install process is ok, otherwise false
38     */
39    public function install()
40    {
41      $tables_def=array(
42"CREATE TABLE `".$this->tables['used_tags']."` (
43  `numId` int(10) unsigned NOT NULL auto_increment,
44  `tagId` varchar(80) NOT NULL default '',
45  `translatable` char(1) NOT NULL default 'n',
46  `name` varchar(200) NOT NULL default '',
47  `numOfImg` int(10) unsigned NOT NULL default '0',
48  PRIMARY KEY  (`numId`),
49  KEY `by_tag` (`tagId`)
50);",
51"CREATE TABLE `".$this->tables['images_tags']."` (
52  `imageId` mediumint(8) unsigned NOT NULL default '0',
53  `numId` int(10) unsigned NOT NULL default '0',
54  `value` varchar(255) default NULL,
55  PRIMARY KEY  USING BTREE (`imageId`,`numId`)
56);",
57"CREATE TABLE `".$this->tables['images']."` (
58  `imageId` MEDIUMINT(8) UNSIGNED NOT NULL,
59  `analyzed` CHAR(1)  NOT NULL DEFAULT 'n',
60  `nbTags` int(10) unsigned NOT NULL default '0',
61  PRIMARY KEY (`imageId`)
62);",
63"CREATE TABLE `".$this->tables['selected_tags']."` (
64  `tagId` VARCHAR(80)  NOT NULL,
65  `order` INTEGER UNSIGNED NOT NULL DEFAULT 0,
66  `groupId` INTEGER  NOT NULL DEFAULT -1,
67  PRIMARY KEY (`tagId`)
68);",
69"CREATE TABLE `".$this->tables['groups_names']."` (
70  `groupId` INTEGER  NOT NULL,
71  `lang` CHAR(5)  NOT NULL,
72  `name` VARCHAR(80)  NOT NULL,
73  PRIMARY KEY (`groupId`, `lang`)
74);",
75"CREATE TABLE `".$this->tables['groups']."` (
76  `groupId` INTEGER  NOT NULL AUTO_INCREMENT,
77  `order` INTEGER UNSIGNED NOT NULL DEFAULT 0,
78  PRIMARY KEY (`groupId`)
79);"
80);
81      //$table_def array
82      $tables_def = create_table_add_character_set($tables_def);
83      $result=$this->tablef->create_tables($tables_def);
84
85      /*
86       * fill the 'used_tags' table with default values
87       */
88      foreach(JpegMetaData::getTagList(Array('filter' => JpegMetaData::TAGFILTER_IMPLEMENTED, 'xmp' => true, 'maker' => true, 'iptc' => true)) as $key => $val)
89      {
90        $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0);";
91        pwg_query($sql);
92      }
93
94      return($result);
95    }
96
97
98    /*
99        function for uninstall process
100    */
101    public function uninstall()
102    {
103      $this->delete_config();
104      $this->tablef->drop_tables();
105    }
106
107    public function activate()
108    {
109      global $template;
110
111      $this->init_config();
112      $this->load_config();
113      $this->save_config();
114    }
115
116
117    public function deactivate()
118    {
119    }
120
121  } //class
122
123?>
Note: See TracBrowser for help on using the repository browser.