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 AUTO_INCREMENT, |
---|
13 | pos SMALLINT( 5 ) NULL default NULL , |
---|
14 | lang VARCHAR( 255 ) NULL default NULL , |
---|
15 | title VARCHAR( 255 ) NOT NULL , |
---|
16 | content LONGTEXT NOT NULL , |
---|
17 | users VARCHAR( 255 ) NULL DEFAULT NULL , |
---|
18 | groups VARCHAR( 255 ) NULL DEFAULT NULL , |
---|
19 | permalink VARCHAR( 64 ) NULL DEFAULT NULL , |
---|
20 | PRIMARY KEY (id) , |
---|
21 | INDEX (pos) , |
---|
22 | INDEX (lang)) |
---|
23 | DEFAULT CHARACTER SET utf8;'; |
---|
24 | pwg_query($query); |
---|
25 | } |
---|
26 | |
---|
27 | if (!isset($conf['additional_pages'])) |
---|
28 | { |
---|
29 | $config = array( |
---|
30 | 'languages' => array('default' => 'Additional Pages'), |
---|
31 | 'show_home' => true, |
---|
32 | 'group_perm' => false, |
---|
33 | 'user_perm' => false, |
---|
34 | 'homepage' => null, |
---|
35 | ); |
---|
36 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
37 | VALUES ("additional_pages" , "'.addslashes(serialize($config)).'" , "Additional Pages config configuration");'; |
---|
38 | pwg_query($query); |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | function plugin_activate() |
---|
43 | { |
---|
44 | global $prefixeTable; |
---|
45 | |
---|
46 | $q = pwg_query('SHOW COLUMNS FROM ' . HISTORY_TABLE . ' LIKE "section"'); |
---|
47 | $section = mysql_fetch_array($q); |
---|
48 | $type = $section['Type']; |
---|
49 | |
---|
50 | // Add additional page section into history table |
---|
51 | if (strpos($type, 'additional_page') === false) |
---|
52 | { |
---|
53 | $type = strtr($type , array(')' => ',\'additional_page\')')); |
---|
54 | pwg_query('ALTER TABLE ' . HISTORY_TABLE . ' CHANGE section section ' . $type . ' DEFAULT NULL'); |
---|
55 | } |
---|
56 | |
---|
57 | // Check if upgrade is needed |
---|
58 | $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'additionalpages;'; |
---|
59 | $result = array_from_query($query, 'Collation'); |
---|
60 | if (strpos($result[4], 'utf8') === false) |
---|
61 | { |
---|
62 | upgrade_ap_from_17(); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | function plugin_uninstall() |
---|
67 | { |
---|
68 | global $prefixeTable; |
---|
69 | |
---|
70 | $q = 'DROP TABLE ' . $prefixeTable . 'additionalpages;'; |
---|
71 | pwg_query($q); |
---|
72 | |
---|
73 | $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="additional_pages" LIMIT 1;'; |
---|
74 | pwg_query($q); |
---|
75 | } |
---|
76 | |
---|
77 | function upgrade_ap_from_17() |
---|
78 | { |
---|
79 | global $prefixeTable; |
---|
80 | |
---|
81 | $query = 'ALTER TABLE ' . $prefixeTable . 'additionalpages |
---|
82 | MODIFY COLUMN lang varchar(255) CHARACTER SET utf8 NOT NULL, |
---|
83 | MODIFY COLUMN title varchar(255) CHARACTER SET utf8 NOT NULL, |
---|
84 | MODIFY COLUMN text longtext CHARACTER SET utf8 NOT NULL, |
---|
85 | DEFAULT CHARACTER SET utf8;'; |
---|
86 | |
---|
87 | pwg_query($query); |
---|
88 | } |
---|
89 | |
---|
90 | ?> |
---|