source: extensions/SocialButtons/maintain.class.php @ 30939

Last change on this file since 30939 was 29781, checked in by mistic100, 10 years ago

fix maintain class + facebook url

File size: 3.6 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4class SocialButtons_maintain extends PluginMaintain
5{
6  private $default_config = array(
7    'position' => 'toolbar',
8    'on_index' => true,
9    'img_size' => 'Original',
10    'light' => false,
11    'twitter' => array(
12      'enabled' => true,
13      'size' => 'small',
14      'count' => 'bubble',
15      'via' => null,
16      ),
17    'google' => array(
18      'enabled' => true,
19      'size' => 'medium',
20      'annotation' => 'bubble',
21      ),
22    'tumblr' => array(
23      'enabled' => true,
24      'type' => 'share_1',
25      ),
26    'facebook' => array(
27      'enabled' => true,
28      'color' => 'light',
29      'layout' => 'button_count',
30      ),
31    'pinterest' => array(
32      'enabled' => true,
33      'layout' => 'horizontal',
34      ),
35    'reddit' => array(
36      'enabled' => false,
37      'type' => 'interactive',
38      'community' => null,
39      ),
40    'linkedin' => array(
41      'enabled' => false,
42      'counter' => 'right',
43      ),
44    );
45
46  function install($plugin_version, &$errors=array())
47  {
48    global $conf;
49
50    if (empty($conf['SocialButtons']))
51    {
52      if (isset($conf['TumblrShare']))
53      {
54        $temp = safe_unserialize($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 = safe_unserialize($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 = safe_unserialize($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_update_param('SocialButtons', $this->default_config, true);
73    }
74    else
75    {
76      $new_conf = safe_unserialize($conf['SocialButtons']);
77
78      if (empty($new_conf['pinterest']))
79      {
80        $new_conf['pinterest'] = array(
81          'enabled' => true,
82          'layout' => 'horizontal',
83          );
84      }
85
86      if (empty($new_conf['reddit']))
87      {
88        $new_conf['reddit'] = array(
89          'enabled' => false,
90          'type' => 'interactive',
91          'community' => null,
92          );
93      }
94
95      if (empty($new_conf['linkedin']))
96      {
97        $new_conf['linkedin'] = array(
98          'enabled' => false,
99          'counter' => 'right',
100          );
101      }
102
103      if (!isset($new_conf['on_index']))
104      {
105        $new_conf['on_index'] = true;
106      }
107
108      if ($new_conf['facebook']['layout'] == 'none')
109      {
110        $new_conf['facebook']['layout'] = 'button_count';
111      }
112
113      if (!isset($new_conf['light']))
114      {
115        $new_conf['light'] = false;
116      }
117
118      if (!isset($new_conf['img_size']))
119      {
120        $new_conf['img_size'] = isset($new_conf['tumblr']['img_size']) ? $new_conf['tumblr']['img_size'] : 'Original';
121        unset($new_conf['tumblr']['img_size'], $new_conf['pinterest']['img_size']);
122      }
123
124      conf_update_param('SocialButtons', $new_conf, true);
125    }
126  }
127
128  function update($old_version, $new_version, &$errors=array())
129  {
130    $this->install($new_version, $errors);
131  }
132
133  function uninstall()
134  {
135    conf_delete_param('SocialButtons');
136  }
137}
Note: See TracBrowser for help on using the repository browser.