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