1 | <?php |
---|
2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | class SocialButtons_maintain extends PluginMaintain |
---|
5 | { |
---|
6 | private $installed = false; |
---|
7 | |
---|
8 | private $default_config = array( |
---|
9 | 'position' => 'toolbar', |
---|
10 | 'on_index' => true, |
---|
11 | 'img_size' => 'Original', |
---|
12 | 'light' => false, |
---|
13 | 'twitter' => array( |
---|
14 | 'enabled' => true, |
---|
15 | 'size' => 'small', |
---|
16 | 'count' => 'bubble', |
---|
17 | 'via' => null, |
---|
18 | ), |
---|
19 | 'google' => array( |
---|
20 | 'enabled' => true, |
---|
21 | 'size' => 'medium', |
---|
22 | 'annotation' => 'bubble', |
---|
23 | ), |
---|
24 | 'tumblr' => array( |
---|
25 | 'enabled' => true, |
---|
26 | 'type' => 'share_1', |
---|
27 | ), |
---|
28 | 'facebook' => array( |
---|
29 | 'enabled' => true, |
---|
30 | 'color' => 'light', |
---|
31 | 'layout' => 'button_count', |
---|
32 | ), |
---|
33 | 'pinterest' => array( |
---|
34 | 'enabled' => true, |
---|
35 | 'layout' => 'horizontal', |
---|
36 | ), |
---|
37 | 'reddit' => array( |
---|
38 | 'enabled' => true, |
---|
39 | 'type' => 'interactive', |
---|
40 | 'community' => null, |
---|
41 | ), |
---|
42 | 'linkedin' => array( |
---|
43 | 'enabled' => true, |
---|
44 | 'counter' => 'right', |
---|
45 | ), |
---|
46 | ); |
---|
47 | |
---|
48 | function install($plugin_version, &$errors=array()) |
---|
49 | { |
---|
50 | if (empty($conf['SocialButtons'])) |
---|
51 | { |
---|
52 | if (isset($conf['TumblrShare'])) |
---|
53 | { |
---|
54 | $temp = is_string($conf['TumblrShare']) ? unserialize($conf['TumblrShare']) : $conf['TumblrShare']; |
---|
55 | if (!empty($temp['type'])) $this->default_config['tumblr']['type'] = $temp['type']; |
---|
56 | if (!empty($temp['img_size'])) $this->default_config['img_size'] = $temp['img_size']; |
---|
57 | } |
---|
58 | if (isset($conf['TweetThis'])) |
---|
59 | { |
---|
60 | $temp = is_string($conf['TweetThis']) ? unserialize($conf['TweetThis']) : $conf['TweetThis']; |
---|
61 | if (!empty($temp['type'])) $this->default_config['twitter']['size'] = $temp['size']; |
---|
62 | if (!empty($temp['count'])) $this->default_config['twitter']['count'] = $temp['count'] ? 'bubble' : 'none'; |
---|
63 | if (!empty($temp['via'])) $this->default_config['twitter']['via'] = $temp['via']; |
---|
64 | } |
---|
65 | if (isset($conf['GooglePlusOne'])) |
---|
66 | { |
---|
67 | $temp = is_string($conf['GooglePlusOne']) ? unserialize($conf['GooglePlusOne']) : $conf['GooglePlusOne']; |
---|
68 | if (!empty($temp['size'])) $this->default_config['google']['size'] = $temp['size']; |
---|
69 | if (!empty($temp['annotation'])) $this->default_config['google']['annotation'] = $temp['annotation']; |
---|
70 | } |
---|
71 | |
---|
72 | $conf['SocialButtons'] = serialize($this->default_config); |
---|
73 | conf_update_param('SocialButtons', $conf['SocialButtons']); |
---|
74 | } |
---|
75 | else |
---|
76 | { |
---|
77 | $new_conf = is_string($conf['SocialButtons']) ? unserialize($conf['SocialButtons']) : $conf['SocialButtons']; |
---|
78 | |
---|
79 | if (empty($new_conf['pinterest'])) |
---|
80 | { |
---|
81 | $new_conf['pinterest'] = array( |
---|
82 | 'enabled' => true, |
---|
83 | 'layout' => 'horizontal', |
---|
84 | ); |
---|
85 | } |
---|
86 | |
---|
87 | if (empty($new_conf['reddit'])) |
---|
88 | { |
---|
89 | $new_conf['reddit'] = array( |
---|
90 | 'enabled' => false, |
---|
91 | 'type' => 'interactive', |
---|
92 | 'community' => null, |
---|
93 | ); |
---|
94 | } |
---|
95 | |
---|
96 | if (empty($new_conf['linkedin'])) |
---|
97 | { |
---|
98 | $new_conf['linkedin'] = array( |
---|
99 | 'enabled' => false, |
---|
100 | 'counter' => 'right', |
---|
101 | ); |
---|
102 | } |
---|
103 | |
---|
104 | if (!isset($new_conf['on_index'])) |
---|
105 | { |
---|
106 | $new_conf['on_index'] = true; |
---|
107 | } |
---|
108 | |
---|
109 | if ($new_conf['facebook']['layout'] == 'none') |
---|
110 | { |
---|
111 | $new_conf['facebook']['layout'] = 'button_count'; |
---|
112 | } |
---|
113 | |
---|
114 | if (!isset($new_conf['light'])) |
---|
115 | { |
---|
116 | $new_conf['light'] = false; |
---|
117 | } |
---|
118 | |
---|
119 | if (!isset($new_conf['img_size'])) |
---|
120 | { |
---|
121 | $new_conf['img_size'] = isset($new_conf['tumblr']['img_size']) ? $new_conf['tumblr']['img_size'] : 'Original'; |
---|
122 | unset($new_conf['tumblr']['img_size'], $new_conf['pinterest']['img_size']); |
---|
123 | } |
---|
124 | |
---|
125 | $conf['SocialButtons'] = serialize($new_conf); |
---|
126 | conf_update_param('SocialButtons', $conf['SocialButtons']); |
---|
127 | } |
---|
128 | |
---|
129 | $this->installed = true; |
---|
130 | } |
---|
131 | |
---|
132 | function activate($plugin_version, &$errors=array()) |
---|
133 | { |
---|
134 | if (!$this->installed) |
---|
135 | { |
---|
136 | $this->install($plugin_version, $errors); |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | function deactivate() |
---|
141 | { |
---|
142 | } |
---|
143 | |
---|
144 | function uninstall() |
---|
145 | { |
---|
146 | conf_delete_param('SocialButtons'); |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | ?> |
---|