1 | <?php |
---|
2 | |
---|
3 | function plugin_install() |
---|
4 | { |
---|
5 | global $prefixeTable, $conf; |
---|
6 | |
---|
7 | $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'additionalpages"'; |
---|
8 | $result = pwg_query($query); |
---|
9 | if (!mysql_fetch_row($result)) |
---|
10 | { |
---|
11 | $query = 'CREATE TABLE ' . $prefixeTable . 'additionalpages ( |
---|
12 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
13 | pos SMALLINT( 5 ) UNSIGNED default NULL , |
---|
14 | lang VARCHAR( 255 ) NOT NULL , |
---|
15 | title VARCHAR( 255 ) NOT NULL , |
---|
16 | text LONGTEXT NOT NULL , |
---|
17 | PRIMARY KEY (id) , |
---|
18 | INDEX (pos) , |
---|
19 | INDEX (lang)) |
---|
20 | DEFAULT CHARACTER SET utf8;'; |
---|
21 | pwg_query($query); |
---|
22 | } |
---|
23 | |
---|
24 | if (!isset($conf['additional_pages'])) |
---|
25 | { |
---|
26 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
27 | VALUES ("additional_pages" , "Additional Pages,on,on,off,off,,off,off" , "Parametres du plugin Additional Pages");'; |
---|
28 | pwg_query($query); |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | function plugin_activate() |
---|
33 | { |
---|
34 | global $prefixeTable; |
---|
35 | |
---|
36 | $q = pwg_query('SHOW COLUMNS FROM ' . HISTORY_TABLE . ' LIKE "section"'); |
---|
37 | $section = mysql_fetch_array($q); |
---|
38 | $type = $section['Type']; |
---|
39 | |
---|
40 | // Add additional page section into history table |
---|
41 | if (strpos($type, 'additional_page') === false) |
---|
42 | { |
---|
43 | $type = strtr($type , array(')' => ',\'additional_page\')')); |
---|
44 | pwg_query('ALTER TABLE ' . HISTORY_TABLE . ' CHANGE section section ' . $type . ' DEFAULT NULL'); |
---|
45 | } |
---|
46 | |
---|
47 | // Check if upgrade is needed |
---|
48 | $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'additionalpages;'; |
---|
49 | $result = array_from_query($query, 'Collation'); |
---|
50 | if (strpos($result[4], 'utf8') === false) |
---|
51 | { |
---|
52 | upgrade_ap_from_17(); |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | function plugin_uninstall() |
---|
57 | { |
---|
58 | global $prefixeTable; |
---|
59 | |
---|
60 | $q = 'DROP TABLE ' . $prefixeTable . 'additionalpages;'; |
---|
61 | pwg_query($q); |
---|
62 | |
---|
63 | $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="additional_pages" LIMIT 1;'; |
---|
64 | pwg_query($q); |
---|
65 | } |
---|
66 | |
---|
67 | function upgrade_ap_from_17() |
---|
68 | { |
---|
69 | global $prefixeTable; |
---|
70 | |
---|
71 | $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages |
---|
72 | MODIFY COLUMN lang varchar(255) CHARACTER SET utf8 NOT NULL, |
---|
73 | MODIFY COLUMN title varchar(255) CHARACTER SET utf8 NOT NULL, |
---|
74 | MODIFY COLUMN text longtext CHARACTER SET utf8 NOT NULL, |
---|
75 | DEFAULT CHARACTER SET utf8;'; |
---|
76 | |
---|
77 | pwg_query($query); |
---|
78 | } |
---|
79 | |
---|
80 | ?> |
---|