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