1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | define('header_dir', PWG_LOCAL_DIR . 'banners/'); |
---|
5 | |
---|
6 | define( |
---|
7 | 'header_manager_default_config', |
---|
8 | serialize(array( |
---|
9 | 'width' => 1000, |
---|
10 | 'height' => 150, |
---|
11 | 'image' => 'random', |
---|
12 | 'display' => 'image_only' |
---|
13 | )) |
---|
14 | ); |
---|
15 | |
---|
16 | |
---|
17 | function plugin_install() |
---|
18 | { |
---|
19 | global $prefixeTable; |
---|
20 | |
---|
21 | pwg_query( |
---|
22 | 'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` ( |
---|
23 | `category_id` smallint(5) unsigned NOT NULL, |
---|
24 | `image` varchar(255) NOT NULL, |
---|
25 | `deep` tinyint(1) DEFAULT 1, |
---|
26 | PRIMARY KEY (`category_id`) |
---|
27 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
---|
28 | ;'); |
---|
29 | |
---|
30 | conf_update_param('header_manager', header_manager_default_config); |
---|
31 | mkdir(header_dir, 0755); |
---|
32 | } |
---|
33 | |
---|
34 | function plugin_activate() |
---|
35 | { |
---|
36 | global $conf, $prefixeTable; |
---|
37 | |
---|
38 | if (empty($conf['header_manager'])) |
---|
39 | { |
---|
40 | conf_update_param('header_manager', header_manager_default_config); |
---|
41 | } |
---|
42 | if (!file_exists(header_dir)) |
---|
43 | { |
---|
44 | mkdir(header_dir, 0755); |
---|
45 | } |
---|
46 | |
---|
47 | pwg_query( |
---|
48 | 'CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` ( |
---|
49 | `category_id` smallint(5) unsigned NOT NULL, |
---|
50 | `image` varchar(255) NOT NULL, |
---|
51 | `deep` tinyint(1) DEFAULT 1, |
---|
52 | PRIMARY KEY (`category_id`) |
---|
53 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
---|
54 | ;'); |
---|
55 | } |
---|
56 | |
---|
57 | function plugin_uninstall() |
---|
58 | { |
---|
59 | global $prefixeTable; |
---|
60 | |
---|
61 | pwg_query('DROP TABLE `' .$prefixeTable . 'category_banner`;'); |
---|
62 | pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "header_manager" LIMIT 1;'); |
---|
63 | } |
---|
64 | |
---|
65 | ?> |
---|