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 | return($result); |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | /* |
---|
90 | function for uninstall process |
---|
91 | */ |
---|
92 | public function uninstall() |
---|
93 | { |
---|
94 | $this->delete_config(); |
---|
95 | $this->tablef->drop_tables(); |
---|
96 | } |
---|
97 | |
---|
98 | public function activate() |
---|
99 | { |
---|
100 | global $template; |
---|
101 | |
---|
102 | |
---|
103 | pwg_query("DELETE FROM ".$this->tables['used_tags']); |
---|
104 | pwg_query("DELETE FROM ".$this->tables['images_tags']); |
---|
105 | pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0;"); |
---|
106 | /* |
---|
107 | * fill the 'used_tags' table with default values |
---|
108 | */ |
---|
109 | foreach(JpegMetaData::getTagList(Array('filter' => JpegMetaData::TAGFILTER_IMPLEMENTED, 'xmp' => true, 'maker' => true, 'iptc' => true)) as $key => $val) |
---|
110 | { |
---|
111 | $sql="INSERT INTO ".$this->tables['used_tags']." VALUES('', '".$key."', '".(($val['translatable'])?'y':'n')."', '".$val['name']."', 0);"; |
---|
112 | pwg_query($sql); |
---|
113 | } |
---|
114 | |
---|
115 | $this->init_config(); |
---|
116 | $this->load_config(); |
---|
117 | $this->save_config(); |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | public function deactivate() |
---|
122 | { |
---|
123 | } |
---|
124 | |
---|
125 | } //class |
---|
126 | |
---|
127 | ?> |
---|