source: extensions/SocialButtons/include/tumblr.inc.php @ 20358

Last change on this file since 20358 was 20358, checked in by mistic100, 11 years ago

create plugin SocialButtons

File size: 1.7 KB
Line 
1<?php
2defined('SOCIALBUTT_PATH') or die('Hacking attempt!');
3
4function socialbutt_tumblr($basename, $root_url, &$tpl_vars)
5{
6  global $conf, $template, $user;
7 
8  $tumblr_css = array(
9    'share_1' => 'width:81px; height:20px;',
10    'share_2' => 'width:61px; height:20px;',
11    'share_3' => 'width:129px; height:20px;',
12    'share_4' => 'width:20px; height:20px;',
13    'share_1T' => 'width:81px; height:20px;',
14    'share_2T' => 'width:61px; height:20px;',
15    'share_3T' => 'width:129px; height:20px;',
16    'share_4T' => 'width:20px; height:20px;',
17    );
18 
19 
20  // config
21  $tpl_vars['TUMBLR'] = $conf['SocialButtons']['tumblr'];
22  $tpl_vars['TUMBLR']['css'] = $tumblr_css[ $conf['SocialButtons']['tumblr']['type'] ];
23  $tpl_vars['TUMBLR']['copyright'] = ' (from <a href="'.$root_url.'">'.$conf['gallery_title'].'</a>)';
24 
25  // button on piture page
26  if ($basename == 'picture')
27  {
28    global $picture;
29   
30    $tpl_vars['TUMBLR']['mode'] = 'photo';
31    $tpl_vars['TUMBLR']['title'] = $picture['current']['TITLE'];
32   
33    if ($conf['SocialButtons']['tumblr']['img_size'] == 'Original')
34    {
35      $tpl_vars['TUMBLR']['source'] = $root_url.ltrim($picture['current']['src_image']->get_url(), './');
36    }
37    else
38    {
39      $tpl_vars['TUMBLR']['source'] = $root_url.ltrim(DerivativeImage::url($conf['SocialButtons']['tumblr']['img_size'], $picture['current']['src_image']), './');
40    }
41  }
42  // button on other pages
43  else if ($basename == 'index')
44  {
45    global $page;
46   
47    $tpl_vars['TUMBLR']['mode'] = 'link';
48    $tpl_vars['TUMBLR']['title'] = strip_tags($page['title']);
49  }
50 
51 
52  $template->set_filename('tumblr_button', realpath(SOCIALBUTT_PATH .'template/tumblr.tpl'));
53  return 'tumblr_button';
54}
55
56?> 
Note: See TracBrowser for help on using the repository browser.