1 | <?php |
---|
2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | class header_manager_maintain extends PluginMaintain |
---|
5 | { |
---|
6 | private $installed = false; |
---|
7 | |
---|
8 | private $default_conf = array( |
---|
9 | 'width' => 1000, |
---|
10 | 'height' => 150, |
---|
11 | 'image' => 'random', |
---|
12 | 'display' => 'image_only', |
---|
13 | 'banner_on_picture' => true, |
---|
14 | 'keep_ratio' => true |
---|
15 | ); |
---|
16 | |
---|
17 | function install($plugin_version, &$errors=array()) |
---|
18 | { |
---|
19 | global $conf, $prefixeTable; |
---|
20 | |
---|
21 | // configuration |
---|
22 | if (empty($conf['header_manager'])) |
---|
23 | { |
---|
24 | $conf['header_manager'] = serialize($this->default_conf); |
---|
25 | conf_update_param('header_manager', $conf['header_manager']); |
---|
26 | } |
---|
27 | else |
---|
28 | { |
---|
29 | $new_conf = is_string($conf['header_manager']) ? unserialize($conf['header_manager']) : $conf['header_manager']; |
---|
30 | |
---|
31 | if (!isset($new_conf['banner_on_picture'])) |
---|
32 | { |
---|
33 | $new_conf['banner_on_picture'] = true; |
---|
34 | } |
---|
35 | else if (!isset($new_conf['keep_ratio'])) |
---|
36 | { |
---|
37 | $new_conf['keep_ratio'] = true; |
---|
38 | } |
---|
39 | |
---|
40 | $conf['header_manager'] = serialize($new_conf); |
---|
41 | conf_update_param('header_manager', $conf['header_manager']); |
---|
42 | } |
---|
43 | |
---|
44 | // banners directory |
---|
45 | if (!file_exists(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners')) |
---|
46 | { |
---|
47 | mkdir(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners', 0755); |
---|
48 | } |
---|
49 | |
---|
50 | // banners table |
---|
51 | $query = ' |
---|
52 | CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` ( |
---|
53 | `category_id` smallint(5) unsigned NOT NULL, |
---|
54 | `image` varchar(255) NOT NULL, |
---|
55 | `deep` tinyint(1) DEFAULT 1, |
---|
56 | PRIMARY KEY (`category_id`) |
---|
57 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
---|
58 | ;'; |
---|
59 | pwg_query($query); |
---|
60 | |
---|
61 | $this->installed = true; |
---|
62 | } |
---|
63 | |
---|
64 | function activate($plugin_version, &$errors=array()) |
---|
65 | { |
---|
66 | if (!$this->installed) |
---|
67 | { |
---|
68 | $this->install($plugin_version, $errors); |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | function deactivate() |
---|
73 | { |
---|
74 | } |
---|
75 | |
---|
76 | function uninstall() |
---|
77 | { |
---|
78 | global $prefixeTable; |
---|
79 | |
---|
80 | conf_delete_param('header_manager'); |
---|
81 | |
---|
82 | pwg_query('DROP TABLE `' .$prefixeTable . 'category_banner`;'); |
---|
83 | } |
---|
84 | } |
---|