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

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

use new maintain class

File size: 3.7 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    if (empty($conf['SocialButtons']))
49    {
50      if (isset($conf['TumblrShare']))
51      {
52        $temp = safe_unserialize($conf['TumblrShare']);
53        if (!empty($temp['type']))      $this->default_config['tumblr']['type'] = $temp['type'];
54        if (!empty($temp['img_size']))  $this->default_config['img_size'] =       $temp['img_size'];
55      }
56      if (isset($conf['TweetThis']))
57      {
58        $temp = safe_unserialize($conf['TweetThis']);
59        if (!empty($temp['type']))  $this->default_config['twitter']['size'] =  $temp['size'];
60        if (!empty($temp['count'])) $this->default_config['twitter']['count'] = $temp['count'] ? 'bubble' : 'none';
61        if (!empty($temp['via']))   $this->default_config['twitter']['via'] =   $temp['via'];
62      }
63      if (isset($conf['GooglePlusOne']))
64      {
65        $temp = safe_unserialize($conf['GooglePlusOne']);
66        if (!empty($temp['size']))        $this->default_config['google']['size'] =       $temp['size'];
67        if (!empty($temp['annotation']))  $this->default_config['google']['annotation'] = $temp['annotation'];
68      }
69     
70      conf_update_param('SocialButtons', $this->default_config, true);
71    }
72    else
73    {
74      $new_conf = safe_unserialize($conf['SocialButtons']);
75     
76      if (empty($new_conf['pinterest']))
77      {
78        $new_conf['pinterest'] = array(
79          'enabled' => true,
80          'layout' => 'horizontal',
81          );
82      }
83     
84      if (empty($new_conf['reddit']))
85      {
86        $new_conf['reddit'] = array(
87          'enabled' => false,
88          'type' => 'interactive',
89          'community' => null,
90          );
91      }
92     
93      if (empty($new_conf['linkedin']))
94      {
95        $new_conf['linkedin'] = array(
96          'enabled' => false,
97          'counter' => 'right',
98          );
99      }
100     
101      if (!isset($new_conf['on_index']))
102      {
103        $new_conf['on_index'] = true;
104      }
105     
106      if ($new_conf['facebook']['layout'] == 'none')
107      {
108        $new_conf['facebook']['layout'] = 'button_count';
109      }
110     
111      if (!isset($new_conf['light']))
112      {
113        $new_conf['light'] = false;
114      }
115     
116      if (!isset($new_conf['img_size']))
117      {
118        $new_conf['img_size'] = isset($new_conf['tumblr']['img_size']) ? $new_conf['tumblr']['img_size'] : 'Original';
119        unset($new_conf['tumblr']['img_size'], $new_conf['pinterest']['img_size']);
120      }
121     
122      conf_update_param('SocialButtons', $new_conf, true);
123    }
124  }
125
126  function update($old_version, $new_version, &$errors=array())
127  {
128    $this->install($new_version, $errors);
129  }
130
131  function uninstall()
132  {
133    conf_delete_param('SocialButtons');
134  }
135}
Note: See TracBrowser for help on using the repository browser.