Ignore:
Timestamp:
May 19, 2012, 1:12:51 PM (12 years ago)
Author:
mistic100
Message:

update for Piwigo 2.4
change previews with new Twitter appearance
remove all custom buttons, keep only official
new options: display counter and via

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/TweetThis/main.inc.php

    r12388 r15122  
    2020function tweet_add_button()
    2121{
    22   global $conf, $template;
    23   $conf['TweetThis'] = explode(',', $conf['TweetThis']);
     22  global $conf, $template, $user;
     23 
     24  $conf['TweetThis'] = unserialize($conf['TweetThis']);
     25  $conf['TweetThis']['lang'] = array(
     26    'no','de','zh-cn','en','pl','sv','zh-tw','tr','es','th','fa','hu','pt','it','ar','he',
     27    'ko','id','ru','ja','da','fi','hi','ur','fr','nl',
     28    );
     29 
     30  $template->assign(array(
     31    'TWEET_SIZE' => $conf['TweetThis']['size'],
     32    'TWEET_COUNT' => $conf['TweetThis']['count'],
     33    'TWEET_VIA' => $conf['TweetThis']['via'],
     34  ));
    2435 
    2536  if (script_basename() == 'picture')
    2637  {
    27     $template->assign(array(
    28       'TWEET_IMAGE' => $conf['TweetThis'][0],
    29       'TWEET_POSITON' => $conf['TweetThis'][1],
    30     ));
    31        
     38    $template->assign('TWEET_POSITON', $conf['TweetThis']['position']);
    3239    $template->set_prefilter('picture', 'tweet_add_button_prefilter');
    3340  }
    3441  else if (script_basename() == 'index')
    3542  {
    36     $template->assign(array(
    37       'TWEET_IMAGE' => $conf['TweetThis'][0],
    38       'TWEET_POSITON' => 'index',
    39     ));
    40        
     43    $template->assign('TWEET_POSITON', 'index');
    4144    $template->set_prefilter('index', 'tweet_add_button_prefilter');
    4245  }
    4346 
    44   // html change a bit if we use custom button, or official with counter
    45   if ( in_array( $conf['TweetThis'][0], array('none','horizontal','vertical') ) )
     47  // button language
     48  if ( in_array(str_replace('_','-',strtolower($user['language'])), $conf['TweetThis']['lang']) )
    4649  {
    47     $template->assign(array(
    48       'TWEET_IFRAME' => true,
    49       'TWEET_COUNTER' => $conf['TweetThis'][0],
    50     ));
     50    $template->assign('TWEET_LANG', str_replace('_','-',strtolower($user['language'])));
     51  }
     52  if ( in_array(substr($user['language'],0,2), $conf['TweetThis']['lang']) )
     53  {
     54    $template->assign('TWEET_LANG', substr($user['language'],0,2));
    5155  }
    5256  else
    5357  {
    54     $template->assign(array(
    55       'TWEET_IFRAME' => false,
    56       'TWEET_COUNTER' => 'none',
    57     ));
    58   }
    59  
    60   // if the link is in the toolbar, we must use smallier buttons
    61   if ( script_basename() == 'index' OR  $conf['TweetThis'][1] == 'toolbar')
    62   {
    63     switch ($conf['TweetThis'][0])
    64     {
    65       case 'vertical':
    66         $template->assign('TWEET_COUNTER', 'horizontal'); break;
    67       case 't_logo-a':
    68         $template->assign('TWEET_IMAGE', 't_small-a'); break;
    69       case 't_logo-b':
    70         $template->assign('TWEET_IMAGE', 't_small-b'); break;
    71       case 't_logo-c':
    72         $template->assign('TWEET_IMAGE', 't_small-c'); break;
    73     }
     58    $template->assign('TWEET_LANG', 'en');
    7459  }
    7560}
     
    7964  global $template;
    8065 
     66  $replace = '{combine_script id=\'twitter_widgets\' path=\'http://platform.twitter.com/widgets.js}
     67  <a href="https://twitter.com/share" class="twitter-share-button" data-lang="{$TWEET_LANG}" {if not empty($TWEET_VIA)}data-via="{$TWEET_VIA}"{/if} {if $TWEET_SIZE=="large"}data-size="large"{/if} {if not $TWEET_COUNT}data-count="none"{/if}>Tweet</a>';
     68 
    8169  switch ($template->get_template_vars('TWEET_POSITON'))
    8270  {
    8371    case 'top':
    8472      $search = '<div id="theImage">';
    85       $replace = '
    86 <div><a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')"
    87         class="{if $TWEET_IFRAME}twitter-share-button{/if}" title="{\'Share on Twitter\'|@translate}">
    88   {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
    89 </a></div>
    90 ';
     73      $replace = '<div>'.$replace.'</div>';
    9174      break;
    9275     
    9376    case 'bottom':
    9477      $search = '{$ELEMENT_CONTENT}';
    95       $replace = '
    96 <a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')"
    97     class="{if $TWEET_IFRAME}twitter-share-button{/if}" title="{\'Share on Twitter\'|@translate}">
    98   {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
    99 </a>
    100 ';
    10178      break;
    10279     
    10380    case 'toolbar':
    104       $search = '{*caddie management END*}';
    105       $replace = '
    106 <a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')"
    107     class="{if $TWEET_IFRAME}twitter-share-button{/if} pwg-button" title="{\'Share on Twitter\'|@translate}">
    108   {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
    109 </a>
    110 ';
     81      $search = '<div class="actionButtons">';
    11182      break;
    11283     
    11384    case 'index': 
    11485      $search = '<ul class="categoryActions">';
    115       $replace = '
    116 {combine_script id=\'scripts\' path=\'themes/default/js/scripts.js\'}
    117 <li><a href="javascript:phpWGOpenWindow(\'http://twitter.com/share?count={$TWEET_COUNTER}\', \'{\'Share on Twitter\'|@translate}\', \'scrollbars=yes,width=550,height=370\')"
    118         class="{if $TWEET_IFRAME}twitter-share-button{/if} pwg-button" title="{\'Share on Twitter\'|@translate}">
    119   {if $TWEET_IFRAME}Tweet{else}<img src="http://twitter-badges.s3.amazonaws.com/{$TWEET_IMAGE}.png"/>{/if}
    120 </a></li>
    121 ';
     86      $replace = '<li>'.$replace.'</li>';
    12287      break;
    12388  }
    12489 
    125   $replace = $search . $replace . '{if $TWEET_IFRAME}{combine_script id=\'twitter_widgets\' path=\'http://platform.twitter.com/widgets.js}{/if}';
    126 
    127   return str_replace($search, $replace, $content);
     90  return str_replace($search, $search.$replace, $content);
    12891}
    12992
     
    13598  function tweet_plugin_admin_menu($menu)
    13699  {
    137     array_push(
    138       $menu,
    139       array(
    140         'NAME' => 'TweetThis',
    141         'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
    142         )
    143       );
    144    
     100    array_push($menu, array(
     101      'NAME' => 'TweetThis',
     102      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
     103      ));
    145104    return $menu;
    146105  }
Note: See TracChangeset for help on using the changeset viewer.