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

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

Commit a first release of the plugin for piwigo using the JpegMetaData classe

  • Property svn:executable set to *
File size: 3.6 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    private $exportfile;
29
30    public function AMD_install($prefixeTable, $filelocation)
31    {
32      parent::__construct($prefixeTable, $filelocation);
33      $this->tablef= new manage_tables($this->tables);
34      $this->exportfile=dirname($this->filelocation).'/'.$this->plugin_name_files.'.sql';
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      $tables_def=array(
44"CREATE TABLE `".$this->tables['used_tags']."` (
45  `numId` int(10) unsigned NOT NULL auto_increment,
46  `tagId` varchar(80) NOT NULL default '',
47  `translatable` char(1) NOT NULL default 'n',
48  `name` varchar(200) NOT NULL default '',
49  `numOfImg` int(10) unsigned NOT NULL default '0',
50  PRIMARY KEY  (`numId`),
51  KEY `by_tag` (`tagId`)
52);",
53"CREATE TABLE `".$this->tables['images_tags']."` (
54  `imageId` mediumint(8) unsigned NOT NULL default '0',
55  `numId` int(10) unsigned NOT NULL default '0',
56  `value` varchar(255) default NULL,
57  PRIMARY KEY  USING BTREE (`imageId`,`numId`)
58);",
59"CREATE TABLE `".$this->tables['images']."` (
60  `imageId` MEDIUMINT(8) UNSIGNED NOT NULL,
61  `analyzed` CHAR(1)  NOT NULL DEFAULT 'n',
62  `nbTags` int(10) unsigned NOT NULL default '0',
63  PRIMARY KEY (`imageId`)
64);",
65"CREATE TABLE `".$this->tables['selected_tag']."` (
66  `tagId` VARCHAR(80)  NOT NULL,
67  `order` INTEGER UNSIGNED NOT NULL DEFAULT 0,
68  `groupId` INTEGER  NOT NULL DEFAULT -1,
69  PRIMARY KEY (`tagId`)
70);",
71"CREATE TABLE `".$this->tables['groups_names']."` (
72  `groupId` INTEGER  NOT NULL,
73  `lang` CHAR(5)  NOT NULL,
74  `name` VARCHAR(80)  NOT NULL,
75  PRIMARY KEY (`groupId`, `lang`)
76);",
77"CREATE TABLE `".$this->tables['groups']."` (
78  `groupId` INTEGER  NOT NULL AUTO_INCREMENT,
79  `order` INTEGER UNSIGNED NOT NULL DEFAULT 0,
80  PRIMARY KEY (`groupId`)
81);"
82);
83      //$table_def array
84      $tables_def = create_table_add_character_set($tables_def);
85      $result=$this->tablef->create_tables($tables_def);
86
87      /*
88       * fill the 'used_tags' table with default values
89       */
90      foreach(JpegMetaData::getTagList(Array('filter' => JpegMetaData::TAGFILTER_IMPLEMENTED, 'xmp' => true, 'maker' => true, 'iptc' => true)) as $key => $val)
91      {
92        $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0);";
93        pwg_query($sql);
94      }
95
96      return($result);
97    }
98
99
100    /*
101        function for uninstall process
102    */
103    public function uninstall()
104    {
105      $this->tablef->export($this->exportfile);
106      $this->delete_config();
107      $this->tablef->drop_tables();
108    }
109
110    public function activate()
111    {
112      global $template;
113
114      $this->init_config();
115      $this->load_config();
116      $this->save_config();
117    }
118
119
120    public function deactivate()
121    {
122    }
123
124  } //class
125
126?>
Note: See TracBrowser for help on using the repository browser.