source: extensions/SocialButtons/include/install.inc.php @ 24788

Last change on this file since 24788 was 24788, checked in by mistic100, 11 years ago

improve facebook light link and clean code & conf

File size: 3.4 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4function socialbutt_install() 
5{
6  global $conf;
7 
8  if (empty($conf['SocialButtons']))
9  {
10    $default_config = array(
11      'position' => 'toolbar',
12      'on_index' => true,
13      'img_size' => 'Original',
14      'light' => false,
15      'twitter' => array(
16        'enabled' => true,
17        'size' => 'small',
18        'count' => 'bubble',
19        'via' => null,
20        ),
21      'google' => array(
22        'enabled' => true,
23        'size' => 'medium',
24        'annotation' => 'bubble',
25        ),
26      'tumblr' => array(
27        'enabled' => true,
28        'type' => 'share_1',
29        ),
30      'facebook' => array(
31        'enabled' => true,
32        'color' => 'light',
33        'layout' => 'button_count',
34        ),
35      'pinterest' => array(
36        'enabled' => true,
37        'layout' => 'horizontal',
38        ),
39      'reddit' => array(
40        'enabled' => true,
41        'type' => 'interactive',
42        'community' => null,
43        ),
44      );
45   
46    if (isset($conf['TumblrShare']))
47    {
48      $temp = is_string($conf['TumblrShare']) ? unserialize($conf['TumblrShare']) : $conf['TumblrShare'];
49      if (!empty($temp['type']))      $default_config['tumblr']['type'] = $temp['type'];
50      if (!empty($temp['img_size']))  $default_config['img_size'] =       $temp['img_size'];
51    }
52    if (isset($conf['TweetThis']))
53    {
54      $temp = is_string($conf['TweetThis']) ? unserialize($conf['TweetThis']) : $conf['TweetThis'];
55      if (!empty($temp['type']))  $default_config['twitter']['size'] =  $temp['size'];
56      if (!empty($temp['count'])) $default_config['twitter']['count'] = $temp['count'] ? 'bubble' : 'none';
57      if (!empty($temp['via']))   $default_config['twitter']['via'] =   $temp['via'];
58    }
59    if (isset($conf['GooglePlusOne']))
60    {
61      $temp = is_string($conf['GooglePlusOne']) ? unserialize($conf['GooglePlusOne']) : $conf['GooglePlusOne'];
62      if (!empty($temp['size']))        $default_config['google']['size'] =       $temp['size'];
63      if (!empty($temp['annotation']))  $default_config['google']['annotation'] = $temp['annotation'];
64    }
65   
66    $conf['SocialButtons'] = serialize($default_config);
67    conf_update_param('SocialButtons', $conf['SocialButtons']);
68  }
69  else
70  {
71    $new_conf = is_string($conf['SocialButtons']) ? unserialize($conf['SocialButtons']) : $conf['SocialButtons'];
72   
73    if (empty($new_conf['pinterest']))
74    {
75      $new_conf['pinterest'] = array(
76        'enabled' => true,
77        'layout' => 'horizontal',
78        );
79    }
80   
81    if (empty($new_conf['reddit']))
82    {
83      $new_conf['reddit'] = array(
84        'enabled' => false,
85        'type' => 'interactive',
86        'community' => null,
87        );
88    }
89   
90    if (!isset($new_conf['on_index']))
91    {
92      $new_conf['on_index'] = true;
93    }
94   
95    if ($new_conf['facebook']['layout'] == 'none')
96    {
97      $new_conf['facebook']['layout'] = 'button_count';
98    }
99   
100    if (!isset($new_conf['light']))
101    {
102      $new_conf['light'] = false;
103    }
104   
105    if (!isset($new_conf['img_size']))
106    {
107      $new_conf['img_size'] = isset($new_conf['tumblr']['img_size']) ? $new_conf['tumblr']['img_size'] : 'Original';
108      unset($new_conf['tumblr']['img_size'], $new_conf['pinterest']['img_size']);
109    }
110   
111    $conf['SocialButtons'] = serialize($new_conf);
112    conf_update_param('SocialButtons', $conf['SocialButtons']);
113  }
114}
115
116?>
Note: See TracBrowser for help on using the repository browser.