mirror of
https://github.com/Piwigo/Piwigo-Social-Buttons.git
synced 2026-08-07 17:32:57 +02:00
use new maintain class
git-svn-id: http://piwigo.org/svn/extensions/SocialButtons@28850 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -47,7 +47,7 @@ if (isset($_POST['submit']))
|
||||
),
|
||||
);
|
||||
|
||||
conf_update_param('SocialButtons', serialize($conf['SocialButtons']));
|
||||
conf_update_param('SocialButtons', $conf['SocialButtons']);
|
||||
$page['infos'][] = l10n('Information data registered in database');
|
||||
|
||||
// the prefilter changes, we must delete compiled templatess
|
||||
@@ -63,5 +63,3 @@ $template->assign(array(
|
||||
|
||||
$template->set_filename('socialbutt_content', realpath(SOCIALBUTT_PATH . 'template/admin.tpl'));
|
||||
$template->assign_var_from_handle('ADMIN_CONTENT', 'socialbutt_content');
|
||||
|
||||
?>
|
||||
@@ -1,128 +0,0 @@
|
||||
<?php
|
||||
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
|
||||
|
||||
function socialbutt_install()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (empty($conf['SocialButtons']))
|
||||
{
|
||||
$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' => true,
|
||||
'type' => 'interactive',
|
||||
'community' => null,
|
||||
),
|
||||
'linkedin' => array(
|
||||
'enabled' => true,
|
||||
'counter' => 'right',
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($conf['TumblrShare']))
|
||||
{
|
||||
$temp = is_string($conf['TumblrShare']) ? unserialize($conf['TumblrShare']) : $conf['TumblrShare'];
|
||||
if (!empty($temp['type'])) $default_config['tumblr']['type'] = $temp['type'];
|
||||
if (!empty($temp['img_size'])) $default_config['img_size'] = $temp['img_size'];
|
||||
}
|
||||
if (isset($conf['TweetThis']))
|
||||
{
|
||||
$temp = is_string($conf['TweetThis']) ? unserialize($conf['TweetThis']) : $conf['TweetThis'];
|
||||
if (!empty($temp['type'])) $default_config['twitter']['size'] = $temp['size'];
|
||||
if (!empty($temp['count'])) $default_config['twitter']['count'] = $temp['count'] ? 'bubble' : 'none';
|
||||
if (!empty($temp['via'])) $default_config['twitter']['via'] = $temp['via'];
|
||||
}
|
||||
if (isset($conf['GooglePlusOne']))
|
||||
{
|
||||
$temp = is_string($conf['GooglePlusOne']) ? unserialize($conf['GooglePlusOne']) : $conf['GooglePlusOne'];
|
||||
if (!empty($temp['size'])) $default_config['google']['size'] = $temp['size'];
|
||||
if (!empty($temp['annotation'])) $default_config['google']['annotation'] = $temp['annotation'];
|
||||
}
|
||||
|
||||
$conf['SocialButtons'] = serialize($default_config);
|
||||
conf_update_param('SocialButtons', $conf['SocialButtons']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_conf = is_string($conf['SocialButtons']) ? unserialize($conf['SocialButtons']) : $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['SocialButtons'] = serialize($new_conf);
|
||||
conf_update_param('SocialButtons', $conf['SocialButtons']);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+7
-29
@@ -10,20 +10,15 @@ Author URI: http://www.strangeplanet.fr
|
||||
|
||||
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Define plugin constants |
|
||||
// +-----------------------------------------------------------------------+
|
||||
define('SOCIALBUTT_ID', basename(dirname(__FILE__)));
|
||||
define('SOCIALBUTT_PATH' , PHPWG_PLUGINS_PATH . SOCIALBUTT_ID . '/');
|
||||
define('SOCIALBUTT_ADMIN', get_root_url() . 'admin.php?page=plugin-' . SOCIALBUTT_ID);
|
||||
define('SOCIALBUTT_VERSION', 'auto');
|
||||
global $conf;
|
||||
|
||||
define('SOCIALBUTT_ID', basename(dirname(__FILE__)));
|
||||
define('SOCIALBUTT_PATH' , PHPWG_PLUGINS_PATH . SOCIALBUTT_ID . '/');
|
||||
define('SOCIALBUTT_ADMIN', get_root_url() . 'admin.php?page=plugin-' . SOCIALBUTT_ID);
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Add event handlers |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// init the plugin
|
||||
add_event_handler('init', 'socialbutt_init');
|
||||
$conf['SocialButtons'] = safe_unserialize($conf['SocialButtons']);
|
||||
|
||||
|
||||
if (defined('IN_ADMIN'))
|
||||
{
|
||||
@@ -45,21 +40,6 @@ else
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* plugin initialization
|
||||
*/
|
||||
function socialbutt_init()
|
||||
{
|
||||
global $conf, $pwg_loaded_plugins;
|
||||
|
||||
include_once(SOCIALBUTT_PATH . 'maintain.inc.php');
|
||||
$maintain = new SocialButtons_maintain(SOCIALBUTT_ID);
|
||||
$maintain->autoUpdate(SOCIALBUTT_VERSION, 'install');
|
||||
|
||||
$conf['SocialButtons'] = unserialize($conf['SocialButtons']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add buttons
|
||||
*/
|
||||
@@ -185,5 +165,3 @@ function socialbutt_add_button_prefilter($content)
|
||||
|
||||
return str_replace($search, $search.$add, $content);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -3,8 +3,6 @@ defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
|
||||
|
||||
class SocialButtons_maintain extends PluginMaintain
|
||||
{
|
||||
private $installed = false;
|
||||
|
||||
private $default_config = array(
|
||||
'position' => 'toolbar',
|
||||
'on_index' => true,
|
||||
@@ -51,30 +49,29 @@ class SocialButtons_maintain extends PluginMaintain
|
||||
{
|
||||
if (isset($conf['TumblrShare']))
|
||||
{
|
||||
$temp = is_string($conf['TumblrShare']) ? unserialize($conf['TumblrShare']) : $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 = is_string($conf['TweetThis']) ? unserialize($conf['TweetThis']) : $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 = is_string($conf['GooglePlusOne']) ? unserialize($conf['GooglePlusOne']) : $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['SocialButtons'] = serialize($this->default_config);
|
||||
conf_update_param('SocialButtons', $conf['SocialButtons']);
|
||||
conf_update_param('SocialButtons', $this->default_config, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_conf = is_string($conf['SocialButtons']) ? unserialize($conf['SocialButtons']) : $conf['SocialButtons'];
|
||||
$new_conf = safe_unserialize($conf['SocialButtons']);
|
||||
|
||||
if (empty($new_conf['pinterest']))
|
||||
{
|
||||
@@ -122,23 +119,13 @@ class SocialButtons_maintain extends PluginMaintain
|
||||
unset($new_conf['tumblr']['img_size'], $new_conf['pinterest']['img_size']);
|
||||
}
|
||||
|
||||
$conf['SocialButtons'] = serialize($new_conf);
|
||||
conf_update_param('SocialButtons', $conf['SocialButtons']);
|
||||
}
|
||||
|
||||
$this->installed = true;
|
||||
}
|
||||
|
||||
function activate($plugin_version, &$errors=array())
|
||||
{
|
||||
if (!$this->installed)
|
||||
{
|
||||
$this->install($plugin_version, $errors);
|
||||
conf_update_param('SocialButtons', $new_conf, true);
|
||||
}
|
||||
}
|
||||
|
||||
function deactivate()
|
||||
function update($old_version, $new_version, &$errors=array())
|
||||
{
|
||||
$this->install($new_version, $errors);
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
@@ -146,5 +133,3 @@ class SocialButtons_maintain extends PluginMaintain
|
||||
conf_delete_param('SocialButtons');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user