From 1c57dbef2c95da522b46d46b6a4f0e3057b9c7f2 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Sun, 22 Dec 2013 23:44:02 +0000 Subject: [PATCH] update for Piwigo 2.6 and update Facebook options git-svn-id: http://piwigo.org/svn/extensions/SocialButtons@26100 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin.php | 3 +- main.inc.php | 48 ++------ maintain.inc.php | 162 +++++++++++++++++++++---- template/admin.tpl | 189 +++++++++++++---------------- template/facebook.tpl | 6 +- template/images/facebook.png | Bin 0 -> 1888 bytes template/images/facebook_dark.png | Bin 624 -> 0 bytes template/images/facebook_light.png | Bin 693 -> 0 bytes template/linkedin.tpl | 2 +- template/style.css | 11 -- 10 files changed, 243 insertions(+), 178 deletions(-) create mode 100644 template/images/facebook.png delete mode 100644 template/images/facebook_dark.png delete mode 100644 template/images/facebook_light.png 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}
@@ -57,26 +56,26 @@ jQuery(".showInfo").tipTip({
- {'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 +
@@ -101,7 +100,7 @@ jQuery(".showInfo").tipTip({ @@ -126,16 +125,16 @@ jQuery(".showInfo").tipTip({
-
- {'Button type'|@translate} + {'Button type'|translate}
- {'Annotation'|@translate} + {'Annotation'|translate} -
-
+
+
- + @ @@ -149,7 +148,7 @@ jQuery(".showInfo").tipTip({ @@ -184,12 +183,12 @@ jQuery(".showInfo").tipTip({ @@ -202,92 +201,52 @@ jQuery(".showInfo").tipTip({
-
- {'Button type'|@translate} + {'Button type'|translate}
- {'Annotation'|@translate} + {'Annotation'|translate} -
-
- +
+
+
- - - - - - - -
-
- {'Button type'|@translate} -
- {'Annotation'|@translate} + {'Annotation'|translate} - -
-
- + +
+
+
{* *} -
{* *} +
{* *} - + - - - - - - - - - - - -
-
- {'Button type'|@translate} -
- + {'Annotation'|translate} - +
+
+
-
{* *} +
{* *}
@@ -295,7 +254,7 @@ jQuery(".showInfo").tipTip({ @@ -352,36 +311,60 @@ jQuery(".showInfo").tipTip({
-
- {'Button type'|@translate} + {'Button type'|translate}
{* *} -
{* *} +
{* *} - + + + + + + + + + + + + +
-
- {'Annotation'|@translate} + {'Button type'|translate} +
+ -
-
- +
-
{* *} +
{* *}
{* *} @@ -405,7 +388,7 @@ jQuery(".showInfo").tipTip({
- +
\ No newline at end of file diff --git a/template/facebook.tpl b/template/facebook.tpl index 0fcf0a8..a709d40 100644 --- a/template/facebook.tpl +++ b/template/facebook.tpl @@ -7,11 +7,11 @@ &p[summary]={$CONTENT_DESCRIPTION|cat:$SOCIALBUTT.copyright|urlencode}" {/if} onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=500');return false;" target="_blank" rel="nofollow"> - Facebook + Facebook {else} - {footer_script}jQuery('body').prepend('
');{/footer_script} + {footer_script require='jquery'}jQuery('body').prepend('
');{/footer_script} {combine_script id='facebook_jssdk' load='footer' path='https://connect.facebook.net/'|cat:$SOCIALBUTT.FACEBOOK.lang|cat:'/all.js#xfbml=1'}
+ data-href="{$SOCIALBUTT.share_url}" data-layout="{$SOCIALBUTT.FACEBOOK.layout}"> {/if} {/strip} \ No newline at end of file diff --git a/template/images/facebook.png b/template/images/facebook.png new file mode 100644 index 0000000000000000000000000000000000000000..07763efaa133effdb219053c458a3efc64f56220 GIT binary patch literal 1888 zcmaJ?dsNeQ7_IVBN*&5@2!bI9f}`{y6k1zcOUvki0u~g6=@!}m0h+`#*p^M49#LUb z!N-_$pmS_fk+BK7X?gf&IHvR9m<|Pp;Dah0M5Z9ZQUu)}V>wBFk8|(+zTfxVoaDzw zzss<9wWrZ&40(i9NsS!pd2@y>^5)6a?`E++bkh0;y<( zI#r;QhEK$zRw6K+ByjQ6i0Jh~wlR$;y|DhVqE3}qW!msoF zP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H-yH=7u8g zrLxBMk~NW>%Z%#WNMv*9NO^(x)%8!$FS4`uptEVN10&B5#ispY`RB=H(bDfEA8h&u DGOzb# literal 0 HcmV?d00001 diff --git a/template/images/facebook_dark.png b/template/images/facebook_dark.png deleted file mode 100644 index b9a884bf145999dfbe01096c99b2e05183bca3d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 624 zcmV-$0+0QPP)Tx0vGR~e?XyAmI%59A(M-sxag9pgM+h+!xbC_g@Wi0a7nc7B!Fs*Mxyx?1V>X*1o6Ryzu~<}nJ|FykKb%hI z*~2fFODKwh$z*~Hx7%$Qa1wE{EQ`fr0o!J?u?)B_hr8los#558P3 zqu1+MbLU5+(e^o=PQO3-sf9wJg{S`k-|2J^3WdH8XcDxpi$f;W>-Be*A@7sI;V@FE z)aMhuQ3%58B2ErZzSiwwlo8z6jzl8+;c4gZfxA0H->?Q=QV}#L* zKzIU=#bVobv)MF1Kxr`&z*PkVFhq@i#Gh(aYwHVbAt*%QJ=8Yi@%S{ULT(_RztzB# zZ?KP0&_$Q;8eY1^Gr7%7&zmAP4({dwQf-K8GO+6t_w2N(KdEDN85O`mLZPMQAMX{e zwbS@JJW;lxfFx0xOe7M!c+f?+(+}3*8#@bd;?;+529g~5d>#de5X86^usnFf>FhfR zMv^2o7z}p7g7pR`KfK|5OnM{Ux5nuqT!Qpfl9zafSLB6y%xN3=CCM zeHqLd9xzPE{=^V5H5SN*dGrEevqq4}oxh z_F^PO@(fRbqzpCFJXL_SE<=^kV}`Z`4;VHkD8R+0;t6SzOB*Ie+Ev2R9=;4!42KyC zcf1E?W&s9yU~H_pK*iGL-~WFo84?6Q#iYN3CWDQMJc?R*paU?HM)qZR5~!--!!X}G z!It58_7;Xh1|Nq08eL$9UCiK*6g&80g7MUq=l_+Y_=qZPwoQux)2A*yXV`!G4#UB- z4^bRGz1D|rsqWshPxu`_m;uP~BezvK>Uc^V59-hYJKjUe(ZF8RKVWa_7vue>AJ2aM z_De%lkdq74y&3`z|NrL0kC*Ih%$FGd{rk`R;MvFh??3%82K5VvK>zhOKM(tUB^iMV bfB*vk!EEpiIl-es00000NkvXXu0mjf3xz)6 diff --git a/template/linkedin.tpl b/template/linkedin.tpl index 336c61a..361388d 100644 --- a/template/linkedin.tpl +++ b/template/linkedin.tpl @@ -5,7 +5,7 @@ LinkedIn {else} {combine_script id='linkedin_share' load='footer' path='https://platform.linkedin.com/in.js'} - + {/if} {/strip} \ No newline at end of file diff --git a/template/style.css b/template/style.css index 70c9a55..0afe336 100644 --- a/template/style.css +++ b/template/style.css @@ -115,15 +115,4 @@ } .socialbutt.enabled thead label:before { content:"\2611"; -} - - -.showInfo { - position:static; - display:inline-block; - padding:1px 6px; - width:4px; - height:14px; - line-height:14px; - font-size:0.8em; } \ No newline at end of file
-
- {'Annotation'|@translate} + {'Annotation'|translate} -
-
- +
+
+