add reddit button

git-svn-id: http://piwigo.org/svn/extensions/SocialButtons@24758 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
mistic100
2013-10-04 22:02:41 +00:00
parent 267f127067
commit 7cd449b5eb
10 changed files with 133 additions and 0 deletions

View File

@@ -38,6 +38,11 @@ if (isset($_POST['submit']))
'layout' => $_POST['pinterest']['layout'],
'img_size' => $_POST['pinterest']['img_size'],
),
'reddit' => array(
'enabled' => isset($_POST['reddit']['enabled']),
'type' => $_POST['reddit']['type'],
'community' => $_POST['reddit']['community'],
),
);
conf_update_param('SocialButtons', serialize($conf['SocialButtons']));

View File

@@ -37,6 +37,11 @@ function socialbutt_install()
'layout' => 'horizontal',
'img_size' => 'Original',
),
'reddit' => array(
'enabled' => true,
'type' => 'interactive',
'community' => null,
),
);
if (isset($conf['TumblrShare']))
@@ -75,6 +80,15 @@ function socialbutt_install()
);
}
if (empty($new_conf['reddit']))
{
$new_conf['reddit'] = array(
'enabled' => false,
'type' => 'interactive',
'community' => null,
);
}
if (!isset($new_conf['on_index']))
{
$new_conf['on_index'] = true;

44
include/reddit.inc.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
defined('SOCIALBUTT_PATH') or die('Hacking attempt!');
function socialbutt_reddit($basename, $root_url, &$tpl_vars, &$buttons)
{
global $conf, $template, $user;
$reddit_langs = array(
'en','ar','be','bg','ca','cs','da','de','el','en-au','en-ca','en-gb','en-us','eo',
'es','es-ar','et','eu','fa','fi','fr','he','hi','hr','hu','hy','id','is','it','ja',
'ko','la','leet','lol','lt','lv','nl','nn','no','pir','pl','pt','pt-pt','ro','ru',
'sk','sl','sr','sr-la','sv','ta','th','tr','uk','vi','zh'
);
// fallback to simple image if JS not enabled
if ($conf['SocialButtons']['light'] && $conf['SocialButtons']['reddit']['type'] == 'interactive')
{
$conf['SocialButtons']['reddit']['type'] = 'spreddit7';
}
// config
$tpl_vars['REDDIT'] = $conf['SocialButtons']['reddit'];
// button language
if ( in_array(str_replace('_','-',strtolower($user['language'])), $reddit_langs) )
{
$tpl_vars['REDDIT']['lang'] = str_replace('_','-',strtolower($user['language']));
}
if ( in_array(substr($user['language'],0,2), $reddit_langs) )
{
$tpl_vars['REDDIT']['lang'] = substr($user['language'],0,2);
}
else
{
$tpl_vars['REDDIT']['lang'] = 'en';
}
$template->set_filename('reddit_button', realpath(SOCIALBUTT_PATH .'template/reddit.tpl'));
$buttons[] = 'reddit_button';
}
?>

View File

@@ -12,6 +12,7 @@ $lang['Top bubble'] = 'Top bubble';
$lang['Display buttons'] = 'Display buttons';
$lang['on photo and album'] = 'on photo and album';
$lang['only on photo'] = 'only on photo';
$lang['Community'] = 'Community';
$lang['Light mode'] = 'Light mode';
$lang['When light mode is activated no external script is loaded, it <b>speeds up the load of the page and disables user tracking</b> but also disables annotations and in-page popups.'] = 'When light mode is activated no external script is loaded, it <b>speeds up the load of the page and disables user tracking</b> but also disables annotations and in-page popups.';
?>

View File

@@ -14,6 +14,7 @@ $lang['Top bubble'] = 'Bulle en haut';
$lang['Display buttons'] = 'Afficher les boutons';
$lang['on photo and album'] = 'sur les photos et les albums';
$lang['only on photo'] = 'uniquement sur les photos';
$lang['Community'] = 'Communauté';
$lang['Light mode'] = 'Mode léger';
$lang['When light mode is activated no external script is loaded, it <b>speeds up the load of the page and disables user tracking</b> but also disables annotations and in-page popups.'] = 'Quand le mode léger est activé aucun script externe n\'est chargé, celà <b>accélère le chargement de la page est désactive le tracking des utilisateurs</b> mais désactive aussi les annotations et les popups détaillés.';
?>

View File

@@ -152,6 +152,11 @@ function socialbutt_add_button()
include_once(SOCIALBUTT_PATH . 'include/pinterest.inc.php');
socialbutt_pinterest($basename, $root_url, $tpl_vars, $buttons);
}
if ($conf['SocialButtons']['reddit']['enabled'])
{
include_once(SOCIALBUTT_PATH . 'include/reddit.inc.php');
socialbutt_reddit($basename, $root_url, $tpl_vars, $buttons);
}
unset_make_full_url();

View File

@@ -336,6 +336,55 @@ jQuery(".showInfo").tipTip({
</table>
</div> {* <!-- tumblr --> *}
<div class="socialbutt {if not $reddit.enabled}disabled{else}enabled{/if}"> {* <!-- reddit --> *}
<table>
<thead>
<tr><td colspan="2">
<label title="{if $reddit.enabled}{'Disable'|@translate}{else}{'Enable'|@translate}{/if}">
<img src="{$SOCIALBUTT_PATH}template/images/reddit_logo.png"/>
<input class="enable" style="display:none;" type="checkbox" name="reddit[enabled]" {if $reddit.enabled}checked="checked"{/if}/>
</label>
</td></tr>
</thead>
<tbody>
<tr class="property">
<td>
{'Button type'|@translate}
</td>
<td></td>
</tr>
<tr class="button">
<td><label>
<img src="http://fr.reddit.com/static/spreddit7.gif"/>
<input type="radio" name="reddit[type]" value="spreddit7" {if $reddit.type=='spreddit7'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="reddit[type]" value="spreddit6" {if $reddit.type=='spreddit6'}checked="checked"{/if}/>
<img src="http://fr.reddit.com/static/spreddit6.gif"/>
</label></td>
</tr>
<tr class="button">
<td><label>
<img src="http://fr.reddit.com/static/spreddit1.gif"/>
<input type="radio" name="reddit[type]" value="spreddit1" {if $reddit.type=='spreddit1'}checked="checked"{/if}/>
</label></td>
<td><label>
<input type="radio" name="reddit[type]" value="interactive" {if $reddit.type=='interactive'}checked="checked"{/if}/>
<img src="{$SOCIALBUTT_PATH}template/images/reddit_interactive.png"/>
</label></td>
</tr>
<tr class="property">
<td>
<label for="reddit_community">{'Community'|@translate}</label>
</td>
<td>
<input type="text" id="reddit_community" name="reddit[community]" value="{$reddit.community}"/>
</td>
</tr>
</tbody>
</table>
</div> {* <!-- tumblr --> *}
<br>
<div class="submit">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

14
template/reddit.tpl Normal file
View File

@@ -0,0 +1,14 @@
{strip}
{if not $SOCIALBUTT.light && $SOCIALBUTT.REDDIT.type == 'interactive'}
<script type="text/javascript">
reddit_url = "{$SOCIALBUTT.share_url|escape:javascript}";
reddit_title = "{$PAGE_TITLE|cat:' | '|cat:$GALLERY_TITLE|escape:javascript}";
reddit_target = "{$SOCIALBUTT.REDDIT.community|escape:javascript}";
reddit_newwindow = 1;
</script>
<script type="text/javascript" src="http://{$SOCIALBUTT.REDDIT.lang}.reddit.com/static/button/button1.js"></script>
{else}
<a href="http://{$SOCIALBUTT.REDDIT.lang}.reddit.com/submit?url={$SOCIALBUTT.share_url|urlencode}&title={$PAGE_TITLE|cat:' | '|cat:$GALLERY_TITLE|urlencode}&target={$SOCIALBUTT.REDDIT.community|urlencode}" rel="nofollow" target="_blank">
<img src="http://www.reddit.com/static/{$SOCIALBUTT.REDDIT.type}.gif" alt="Submit to reddit"></a>
{/if}
{/strip}