add pinterest, option to hide counter on facebook button

git-svn-id: http://piwigo.org/svn/extensions/SocialButtons@20374 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
mistic100
2013-01-25 15:51:02 +00:00
parent 6a8b22d7f3
commit 8fc870d23f
12 changed files with 279 additions and 165 deletions
+5
View File
@@ -31,6 +31,11 @@ if (isset($_POST['submit']))
'color' => $_POST['facebook']['color'],
'layout' => $_POST['facebook']['layout'],
),
'pinterest' => array(
'enabled' => isset($_POST['pinterest']['enabled']),
'layout' => $_POST['pinterest']['layout'],
'img_size' => $_POST['pinterest']['img_size'],
),
);
conf_update_param('SocialButtons', serialize($conf['SocialButtons']));
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
defined('SOCIALBUTT_PATH') or die('Hacking attempt!');
function socialbutt_facebook($basename, $root_url, &$tpl_vars)
function socialbutt_facebook($basename, $root_url, &$tpl_vars, &$buttons)
{
global $conf, $template, $user;
@@ -41,7 +41,7 @@ function socialbutt_facebook($basename, $root_url, &$tpl_vars)
$template->set_filename('facebook_button', realpath(SOCIALBUTT_PATH .'template/facebook.tpl'));
return 'facebook_button';
$buttons[] = 'facebook_button';
}
?>
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
defined('SOCIALBUTT_PATH') or die('Hacking attempt!');
function socialbutt_google($basename, $root_url, &$tpl_vars)
function socialbutt_google($basename, $root_url, &$tpl_vars, &$buttons)
{
global $conf, $template, $user;
@@ -42,7 +42,7 @@ function socialbutt_google($basename, $root_url, &$tpl_vars)
$template->set_filename('google_button', realpath(SOCIALBUTT_PATH .'template/google.tpl'));
return 'google_button';
$buttons[] = 'google_button';
}
?>
+19 -1
View File
@@ -30,6 +30,11 @@ function socialbutt_install()
'color' => 'light',
'layout' => 'button_count',
),
'pinterest' => array(
'enabled' => true,
'layout' => 'horizontal',
'img_size' => 'Original',
),
);
if (isset($conf['TumblrShare']))
@@ -52,10 +57,23 @@ function socialbutt_install()
$default_config['google']['annotation'] = $temp['annotation'];
}
$conf['SocialButtons'] = serialize($default_config);
conf_update_param('SocialButtons', $conf['SocialButtons']);
}
else
{
$new_conf = unserialize($conf['SocialButtons']);
if (empty($new_conf['pinterest']))
{
$new_conf['pinterest'] = array(
'enabled' => true,
'layout' => 'horizontal',
'img_size' => 'Original',
);
$conf['SocialButtons'] = serialize($new_conf);
conf_update_param('SocialButtons', $conf['SocialButtons']);
}
}
}
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
defined('SOCIALBUTT_PATH') or die('Hacking attempt!');
function socialbutt_pinterest($basename, $root_url, &$tpl_vars, &$buttons)
{
// only on piture page
if ($basename != 'picture')
{
return;
}
global $conf, $template, $picture;
// config
$tpl_vars['PINTEREST'] = $conf['SocialButtons']['pinterest'];
$tpl_vars['PINTEREST']['copyright'] = ' (from <a href="'.$root_url.'">'.$conf['gallery_title'].'</a>)';
$tpl_vars['PINTEREST']['title'] = $picture['current']['TITLE'];
if ($conf['SocialButtons']['pinterest']['img_size'] == 'Original')
{
$tpl_vars['PINTEREST']['source'] = $root_url.ltrim($picture['current']['src_image']->get_url(), './');
}
else
{
$tpl_vars['PINTEREST']['source'] = $root_url.ltrim(DerivativeImage::url($conf['SocialButtons']['pinterest']['img_size'], $picture['current']['src_image']), './');
}
$template->set_filename('pinterest_button', realpath(SOCIALBUTT_PATH .'template/pinterest.tpl'));
$buttons[] = 'pinterest_button';
}
?>
+3 -3
View File
@@ -1,9 +1,9 @@
<?php
defined('SOCIALBUTT_PATH') or die('Hacking attempt!');
function socialbutt_tumblr($basename, $root_url, &$tpl_vars)
function socialbutt_tumblr($basename, $root_url, &$tpl_vars, &$buttons)
{
global $conf, $template, $user;
global $conf, $template;
$tumblr_css = array(
'share_1' => 'width:81px; height:20px;',
@@ -50,7 +50,7 @@ function socialbutt_tumblr($basename, $root_url, &$tpl_vars)
$template->set_filename('tumblr_button', realpath(SOCIALBUTT_PATH .'template/tumblr.tpl'));
return 'tumblr_button';
$buttons[] = 'tumblr_button';
}
?>
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
defined('SOCIALBUTT_PATH') or die('Hacking attempt!');
function socialbutt_twitter($basename, $root_url, &$tpl_vars)
function socialbutt_twitter($basename, $root_url, &$tpl_vars, &$buttons)
{
global $conf, $template, $user;
@@ -30,7 +30,7 @@ function socialbutt_twitter($basename, $root_url, &$tpl_vars)
$template->set_filename('twitter_button', realpath(SOCIALBUTT_PATH .'template/twitter.tpl'));
return 'twitter_button';
$buttons[] = 'twitter_button';
}
?>
+9 -4
View File
@@ -124,22 +124,27 @@ function socialbutt_add_button()
if ($conf['SocialButtons']['google']['enabled'])
{
include_once(SOCIALBUTT_PATH . 'include/google.inc.php');
$buttons[] = socialbutt_google($basename, $root_url, $tpl_vars);
socialbutt_google($basename, $root_url, $tpl_vars, $buttons);
}
if ($conf['SocialButtons']['twitter']['enabled'])
{
include_once(SOCIALBUTT_PATH . 'include/twitter.inc.php');
$buttons[] = socialbutt_twitter($basename, $root_url, $tpl_vars);
socialbutt_twitter($basename, $root_url, $tpl_vars, $buttons);
}
if ($conf['SocialButtons']['facebook']['enabled'])
{
include_once(SOCIALBUTT_PATH . 'include/facebook.inc.php');
$buttons[] = socialbutt_facebook($basename, $root_url, $tpl_vars);
socialbutt_facebook($basename, $root_url, $tpl_vars, $buttons);
}
if ($conf['SocialButtons']['tumblr']['enabled'])
{
include_once(SOCIALBUTT_PATH . 'include/tumblr.inc.php');
$buttons[] = socialbutt_tumblr($basename, $root_url, $tpl_vars);
socialbutt_tumblr($basename, $root_url, $tpl_vars, $buttons);
}
if ($conf['SocialButtons']['pinterest']['enabled'] and $basename=='picture')
{
include_once(SOCIALBUTT_PATH . 'include/pinterest.inc.php');
socialbutt_pinterest($basename, $root_url, $tpl_vars, $buttons);
}
if (empty($buttons))
+187 -150
View File
@@ -49,7 +49,192 @@ jQuery("input.enable").change(function() {
<br>
<div class="socialbutt">
<div class="socialbutt"> {* <!-- twitter --> *}
<table>
<thead>
<tr><td colspan="2">
<label title="{if $twitter.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img {if not $twitter.enabled}class="grayscale"{/if} src="{$SOCIALBUTT_PATH}template/images/twitter_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="twitter[enabled]" {if $twitter.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody {if not $twitter.enabled}style="display:none;"{/if}>
<tr class="property">
<td>
{'Button type'|@translate}
</td>
<td></td>
</tr>
<tr class="button">
<td><label>
20px
<img src="{$SOCIALBUTT_PATH}template/images/twitter_small.png"/>
<input type="radio" name="twitter[size]" value="small" {if $twitter.size=='small'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="twitter[size]" value="large" {if $twitter.size=='large'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/twitter_large.png"/>
28px
</label></td>
</tr>
<tr class="property">
<td>
{'Annotation'|@translate}
</td>
<td>
<label><input type="radio" name="twitter[count]" value="none" {if $twitter.count=='none'}checked="checked"{/if}/> {'None'|@translate}</label><br>
<label><input type="radio" name="twitter[count]" value="bubble" {if $twitter.count=='bubble'}checked="checked"{/if}/> {'Bubble'|@translate}</label><br>
</td>
</tr>
<tr class="property">
<td>
<label for="twitter_via">{'Via'|@translate}</label>
</td>
<td>
@ <input type="text" id="twitter_via" name="twitter[via]" value="{$twitter.via}"/>
</td>
</tr>
</tbody>
</table>
</div> {* <!-- twitter --> *}
<div class="socialbutt"> {* <!-- google --> *}
<table>
<thead>
<tr><td colspan="2">
<label title="{if $google.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img {if not $google.enabled}class="grayscale"{/if} src="{$SOCIALBUTT_PATH}template/images/google_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="google[enabled]" {if $google.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody {if not $google.enabled}style="display:none;"{/if}>
<tr class="property">
<td>
{'Button type'|@translate}
</td>
<td></td>
</tr>
<tr class="button">
<td><label>
15px
<img src="{$SOCIALBUTT_PATH}template/images/google_small.png"/>
<input type="radio" name="google[size]" value="small" {if $google.size=='small'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="google[size]" value="medium" {if $google.size=='medium'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/google_medium.png"/>
20px
</label></td>
</tr>
<tr class="button">
<td><label>
24px
<img src="{$SOCIALBUTT_PATH}template/images/google_standard.png"/>
<input type="radio" name="google[size]" value="standard" {if $google.size=='standard'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="google[size]" value="tall" {if $google.size=='tall'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/google_tall.png"/>
60px
</label></td>
</tr>
<tr class="property">
<td>
{'Annotation'|@translate}
</td>
<td>
<label><input type="radio" name="google[annotation]" value="none" {if $google.annotation=='none'}checked="checked"{/if}/> {'None'|@translate}</label><br>
<label><input type="radio" name="google[annotation]" value="bubble" {if $google.annotation=='bubble'}checked="checked"{/if}/> {'Bubble'|@translate}</label><br>
<label><input type="radio" name="google[annotation]" value="inline" {if $google.annotation=='inline'}checked="checked"{/if}/> {'Inline text'|@translate}</label>
</td>
</tr>
</tbody>
</table>
</div> {* <!-- google --> *}
<br>
<div class="socialbutt"> {* <!-- pinterest --> *}
<table>
<thead>
<tr><td colspan="2">
<label title="{if $pinterest.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img {if not $pinterest.enabled}class="grayscale"{/if} src="{$SOCIALBUTT_PATH}template/images/pinterest_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="pinterest[enabled]" {if $pinterest.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody {if not $pinterest.enabled}style="display:none;"{/if}>
<tr class="property">
<td>
{'Shared picture size'|@translate}
</td>
<td>
{html_options name="pinterest[img_size]" values=$img_sizes output=$img_sizes|translate selected=$pinterest.img_size}
</td>
</tr>
<tr class="property">
<td>
{'Annotation'|@translate}
</td>
<td>
<label><input type="radio" name="pinterest[layout]" value="none" {if $pinterest.layout=='none'}checked="checked"{/if}/> {'None'|@translate}</label><br>
<label><input type="radio" name="pinterest[layout]" value="horizontal" {if $pinterest.layout=='horizontal'}checked="checked"{/if}/> {'Right bubble'|@translate}</label><br>
<label><input type="radio" name="pinterest[layout]" value="vertical" {if $pinterest.layout=='vertical'}checked="checked"{/if}/> {'Top bubble'|@translate}</label>
</td>
</tr>
</tbody>
</table>
</div> {* <!-- pinterest --> *}
<div class="socialbutt"> {* <!-- facebook --> *}
<table>
<thead>
<tr><td colspan="2">
<label title="{if $facebook.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img {if not $facebook.enabled}class="grayscale"{/if} src="{$SOCIALBUTT_PATH}template/images/facebook_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="facebook[enabled]" {if $facebook.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody {if not $facebook.enabled}style="display:none;"{/if}>
<tr class="property">
<td>
{'Button type'|@translate}
</td>
<td></td>
</tr>
<tr class="button">
<td><label>
<img src="{$SOCIALBUTT_PATH}template/images/facebook_light.png"/>
<input type="radio" name="facebook[color]" value="light" {if $facebook.color=='light'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="facebook[color]" value="dark" {if $facebook.color=='dark'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/facebook_dark.png"/>
</label></td>
</tr>
<tr class="property">
<td>
{'Annotation'|@translate}
</td>
<td>
<label><input type="radio" name="facebook[layout]" value="none" {if $facebook.layout=='none'}checked="checked"{/if}/> {'None'|@translate}</label><br>
<label><input type="radio" name="facebook[layout]" value="button_count" {if $facebook.layout=='button_count'}checked="checked"{/if}/> {'Right bubble'|@translate}</label><br>
<label><input type="radio" name="facebook[layout]" value="box_count" {if $facebook.layout=='box_count'}checked="checked"{/if}/> {'Top bubble'|@translate}</label><br>
<label><input type="radio" name="facebook[layout]" value="standard" {if $facebook.layout=='standard'}checked="checked"{/if}/> {'Inline text'|@translate}</label>
</td>
</tr>
</tbody>
</table>
</div> {* <!-- facebook --> *}
<br>
<div class="socialbutt"> {* <!-- tumblr --> *}
<table>
<thead>
<tr><td colspan="2">
@@ -116,155 +301,7 @@ jQuery("input.enable").change(function() {
</tr>
</tbody>
</table>
</div>
<div class="socialbutt">
<table>
<thead>
<tr><td colspan="2">
<label title="{if $google.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img {if not $google.enabled}class="grayscale"{/if} src="{$SOCIALBUTT_PATH}template/images/google_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="google[enabled]" {if $google.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody {if not $google.enabled}style="display:none;"{/if}>
<tr class="property">
<td>
{'Button type'|@translate}
</td>
<td></td>
</tr>
<tr class="button">
<td><label>
15px
<img src="{$SOCIALBUTT_PATH}template/images/google_small.png"/>
<input type="radio" name="google[size]" value="small" {if $google.size=='small'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="google[size]" value="medium" {if $google.size=='medium'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/google_medium.png"/>
20px
</label></td>
</tr>
<tr class="button">
<td><label>
24px
<img src="{$SOCIALBUTT_PATH}template/images/google_standard.png"/>
<input type="radio" name="google[size]" value="standard" {if $google.size=='standard'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="google[size]" value="tall" {if $google.size=='tall'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/google_tall.png"/>
60px
</label></td>
</tr>
<tr class="property">
<td>
{'Annotation'|@translate}
</td>
<td>
<label><input type="radio" name="google[annotation]" value="none" {if $google.annotation=='none'}checked="checked"{/if}/> {'None'|@translate}</label><br>
<label><input type="radio" name="google[annotation]" value="bubble" {if $google.annotation=='bubble'}checked="checked"{/if}/> {'Bubble'|@translate}</label><br>
<label><input type="radio" name="google[annotation]" value="inline" {if $google.annotation=='inline'}checked="checked"{/if}/> {'Inline text'|@translate}</label>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<div class="socialbutt">
<table>
<thead>
<tr><td colspan="2">
<label title="{if $twitter.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img {if not $twitter.enabled}class="grayscale"{/if} src="{$SOCIALBUTT_PATH}template/images/twitter_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="twitter[enabled]" {if $twitter.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody {if not $twitter.enabled}style="display:none;"{/if}>
<tr class="property">
<td>
{'Button type'|@translate}
</td>
<td></td>
</tr>
<tr class="button">
<td><label>
20px
<img src="{$SOCIALBUTT_PATH}template/images/twitter_small.png"/>
<input type="radio" name="twitter[size]" value="small" {if $twitter.size=='small'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="twitter[size]" value="large" {if $twitter.size=='large'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/twitter_large.png"/>
28px
</label></td>
</tr>
<tr class="property">
<td>
{'Annotation'|@translate}
</td>
<td>
<label><input type="radio" name="twitter[count]" value="none" {if $twitter.count=='none'}checked="checked"{/if}/> {'None'|@translate}</label><br>
<label><input type="radio" name="twitter[count]" value="bubble" {if $twitter.count=='bubble'}checked="checked"{/if}/> {'Bubble'|@translate}</label><br>
</td>
</tr>
<tr class="property">
<td>
<label for="twitter_via">{'Via'|@translate}</label>
</td>
<td>
@ <input type="text" id="twitter_via" name="twitter[via]" value="{$twitter.via}"/>
</td>
</tr>
</tbody>
</table>
</div>
<div class="socialbutt">
<table>
<thead>
<tr><td colspan="2">
<label title="{if $facebook.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img {if not $facebook.enabled}class="grayscale"{/if} src="{$SOCIALBUTT_PATH}template/images/facebook_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="facebook[enabled]" {if $facebook.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody {if not $facebook.enabled}style="display:none;"{/if}>
<tr class="property">
<td>
{'Button type'|@translate}
</td>
<td></td>
</tr>
<tr class="button">
<td><label>
<img src="{$SOCIALBUTT_PATH}template/images/facebook_light.png"/>
<input type="radio" name="facebook[color]" value="light" {if $facebook.color=='light'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="facebook[color]" value="dark" {if $facebook.color=='dark'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/facebook_dark.png"/>
</label></td>
</tr>
<tr class="property">
<td>
{'Annotation'|@translate}
</td>
<td>
<label><input type="radio" name="facebook[layout]" value="button_count" {if $facebook.layout=='button_count'}checked="checked"{/if}/> {'Right bubble'|@translate}</label><br>
<label><input type="radio" name="facebook[layout]" value="box_count" {if $facebook.layout=='box_count'}checked="checked"{/if}/> {'Top bubble'|@translate}</label><br>
<label><input type="radio" name="facebook[layout]" value="standard" {if $facebook.layout=='standard'}checked="checked"{/if}/> {'Inline text'|@translate}</label>
</td>
</tr>
</tbody>
</table>
</div>
</div> {* <!-- tumblr --> *}
<br>
+11 -1
View File
@@ -2,6 +2,16 @@
{footer_script}jQuery('body').prepend('<div id="fb-root"></div>');{/footer_script}
{combine_script id='facebook_jssdk' load='async' path='https://connect.facebook.net/'|cat:$SOCIALBUTT.FACEBOOK.lang|cat:'/all.js#xfbml=1'}
{if $SOCIALBUTT.FACEBOOK.layout=='none'}
{html_style}{literal}
.fb-like span { height: 22px !important; overflow: hidden; margin-right:10px; }
.fb-like iframe { top: -41px; }
{/literal}{/html_style}
{assign var=facebook_layout value='box_count'}
{else}
{assign var=facebook_layout value=$SOCIALBUTT.FACEBOOK.layout}
{/if}
<div style="display:inline-block;" class="fb-like" data-send="false" data-show-faces="false"
data-href="{$SOCIALBUTT.share_url}" data-layout="{$SOCIALBUTT.FACEBOOK.layout}" data-colorscheme="{$SOCIALBUTT.FACEBOOK.color}"></div>
data-href="{$SOCIALBUTT.share_url}" data-layout="{$facebook_layout}" data-colorscheme="{$SOCIALBUTT.FACEBOOK.color}"></div>
{/strip}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+6
View File
@@ -0,0 +1,6 @@
{strip}
{combine_script id='pinterest_pinit' path='http://assets.pinterest.com/js/pinit.js'}
<a href="http://pinterest.com/pin/create/button/?url={$SOCIALBUTT.share_url|urlencode}&media={$SOCIALBUTT.PINTEREST.source|urlencode}&description={$SOCIALBUTT.PINTEREST.title|urlencode}{$SOCIALBUTT.PINTEREST.copyright|urlencode}"
class="pin-it-button" count-layout="{$SOCIALBUTT.PINTEREST.layout}"><img border="0" src="http://assets.pinterest.com/images/PinExt.png" title="Pin It"/></a>
{/strip}