diff --git a/admin.php b/admin.php index 80042f2..6616307 100644 --- a/admin.php +++ b/admin.php @@ -30,7 +30,6 @@ if (isset($_POST['submit'])) ), 'facebook' => array( 'enabled' => isset($_POST['facebook']['enabled']), - 'color' => $_POST['facebook']['color'], 'layout' => $_POST['facebook']['layout'], ), 'pinterest' => array( @@ -49,7 +48,7 @@ if (isset($_POST['submit'])) ); conf_update_param('SocialButtons', serialize($conf['SocialButtons'])); - array_push($page['infos'], l10n('Information data registered in database')); + $page['infos'][] = l10n('Information data registered in database'); // the prefilter changes, we must delete compiled templatess $template->delete_compiled_templates(); diff --git a/main.inc.php b/main.inc.php index e275aaa..f7b13ff 100644 --- a/main.inc.php +++ b/main.inc.php @@ -10,12 +10,10 @@ Author URI: http://www.strangeplanet.fr defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); -global $prefixeTable; - // +-----------------------------------------------------------------------+ // | Define plugin constants | // +-----------------------------------------------------------------------+ -defined('SOCIALBUTT_ID') or define('SOCIALBUTT_ID', basename(dirname(__FILE__))); +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'); @@ -33,10 +31,10 @@ if (defined('IN_ADMIN')) function socialbutt_admin_plugin_menu_links($menu) { - array_push($menu, array( + $menu[] = array( 'NAME' => 'Social Buttons', 'URL' => SOCIALBUTT_ADMIN, - )); + ); return $menu; } } @@ -53,37 +51,11 @@ else function socialbutt_init() { global $conf, $pwg_loaded_plugins; - - // apply upgrade if needed - if ( - SOCIALBUTT_VERSION == 'auto' or - $pwg_loaded_plugins[SOCIALBUTT_ID]['version'] == 'auto' or - version_compare($pwg_loaded_plugins[SOCIALBUTT_ID]['version'], SOCIALBUTT_VERSION, '<') - ) - { - // call install function - include_once(SOCIALBUTT_PATH . 'include/install.inc.php'); - socialbutt_install(); - - // update plugin version in database - if ( $pwg_loaded_plugins[SOCIALBUTT_ID]['version'] != 'auto' and SOCIALBUTT_VERSION != 'auto' ) - { - $query = ' -UPDATE '. PLUGINS_TABLE .' -SET version = "'. SOCIALBUTT_VERSION .'" -WHERE id = "'. SOCIALBUTT_ID .'"'; - pwg_query($query); - - $pwg_loaded_plugins[SOCIALBUTT_ID]['version'] = SOCIALBUTT_VERSION; - - if (defined('IN_ADMIN')) - { - $_SESSION['page_infos'][] = 'Social Buttons updated to version '. SOCIALBUTT_VERSION; - } - } - } - - // prepare plugin configuration + + include_once(SOCIALBUTT_PATH . 'maintain.inc.php'); + $maintain = new SocialButtons_maintain(SOCIALBUTT_ID); + $maintain->autoUpdate(SOCIALBUTT_VERSION, 'install'); + $conf['SocialButtons'] = unserialize($conf['SocialButtons']); } @@ -146,6 +118,10 @@ function socialbutt_add_button() { if ($conf['SocialButtons'][$service]['enabled']) { + if ($service=='pinterest' && $basename!='picture') + { + continue; + } include_once(SOCIALBUTT_PATH . 'include/'. $service .'.inc.php'); call_user_func_array('socialbutt_'.$service, array($basename, $root_url, &$tpl_vars, &$buttons)); } diff --git a/maintain.inc.php b/maintain.inc.php index 32a5be1..bfe7fa8 100644 --- a/maintain.inc.php +++ b/maintain.inc.php @@ -1,32 +1,150 @@ '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', + ), + ); - -function plugin_activate() -{ - if (!defined('socialbutt_installed')) + function install($plugin_version, &$errors=array()) { - socialbutt_install(); + if (empty($conf['SocialButtons'])) + { + if (isset($conf['TumblrShare'])) + { + $temp = is_string($conf['TumblrShare']) ? unserialize($conf['TumblrShare']) : $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']; + 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']; + 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']); + } + 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']); + } + + $this->installed = true; + } + + function activate($plugin_version, &$errors=array()) + { + if (!$this->installed) + { + $this->install($plugin_version, $errors); + } + } + + function deactivate() + { + } + + function uninstall() + { + conf_delete_param('SocialButtons'); } } - -function plugin_uninstall() -{ - global $conf; - - pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "SocialButtons";'); - unset($conf['SocialButtons']); -} - ?> \ No newline at end of file diff --git a/template/admin.tpl b/template/admin.tpl index aa54ad9..4615d29 100644 --- a/template/admin.tpl +++ b/template/admin.tpl @@ -1,27 +1,26 @@ {combine_css path=$SOCIALBUTT_PATH|@cat:"template/style.css"} -{html_style}{literal} +{html_style} .socialbutt.disabled thead img { -webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */ filter: url("data:image/svg+xml;utf8,#grayscale"); /* Firefox 10+ */ filter: gray; /* IE6-9 */ } -{/literal} {if $light} -.not-light {ldelim} display:none; } +.not-light { display:none; } {/if} {/html_style} -{footer_script}{literal} +{footer_script} jQuery("input.enable").change(function() { $parent = $(this).closest("div.socialbutt"); if (!$(this).is(":checked")) { - $parent.find("thead label").attr("title", "{/literal}{'Enable'|@translate|escape:javascript}{literal}"); + $parent.find("thead label").attr("title", "{'Enable'|translate|escape:javascript}"); $parent.addClass('disabled'); $parent.removeClass('enabled'); } else { - $parent.find("thead label").attr("title", "{/literal}{'Disable'|@translate|escape:javascript}{literal}"); + $parent.find("thead label").attr("title", "{'Disable'|translate|escape:javascript}"); $parent.addClass('enabled'); $parent.removeClass('disabled'); } @@ -43,7 +42,7 @@ jQuery(".showInfo").tipTip({ maxWidth: '300px', defaultPosition: 'bottom' }); -{/literal}{/footer_script} +{/footer_script}
| - {'Button position on picture page'|@translate} + {'Button position on picture page'|translate} | - - - + + + |
| - {'Display buttons'|@translate} + {'Display buttons'|translate} |
- - + + |
| - {'Shared picture size'|@translate} + {'Shared picture size'|translate} | {html_options name="img_size" values=$img_sizes output=$img_sizes|translate selected=$img_size} @@ -84,11 +83,11 @@ jQuery(".showInfo").tipTip({ |
| - + | - i + |
| - |