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

update for Piwigo 2.4
change previews with new G+1 appearance
add Annotation parameter

File:
1 edited

Legend:

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

    r11600 r15121  
    2222  global $conf, $template, $user;
    2323 
    24   $conf['GooglePlusOne'] = explode(',', $conf['GooglePlusOne']);
     24  $conf['GooglePlusOne'] = unserialize($conf['GooglePlusOne']);
    2525  $conf['GooglePlusOne']['lang'] = array(
    26     'ar','bg','ca','hr','cs','da','nl','et','fi','fr','de','el','iw','hi',
    27     'hu','id','it','ja','ko','lv','lt','ms','no','fa','pl','ro','ru','sr',
    28     'sk','sl','es','sv','th','tr','uk','vi'
     26    'ar','bg','ca','zh-CN','zh-TW','hr','cs','da','nl','en-US','en-GB','et','fi','fr','de',
     27    'el','iw','hi','hu','id','it','ja','ko','lv','lt','ms','no','fa','pl','pt-BR','pt-PT',
     28    'ro','ru','sr','sk','sl','es','sv','th','tr','uk','vi',
    2929    );
     30   
     31  $template->assign(array(
     32    'GPLUS1_SIZE' => $conf['GooglePlusOne']['size'],
     33    'GPLUS1_ANNO' => $conf['GooglePlusOne']['annotation'],
     34  ));
    3035 
    3136  if (script_basename() == 'picture')
    3237  {
    33     $template->assign(array(
    34       'GPLUS1_SIZE' => $conf['GooglePlusOne'][0],
    35       'GPLUS1_POSITON' => $conf['GooglePlusOne'][1],
    36     ));
    37        
     38    $template->assign('GPLUS1_POSITON', $conf['GooglePlusOne']['position']);
    3839    $template->set_prefilter('picture', 'gplus1_add_button_prefilter');
    3940  }
    4041  else if (script_basename() == 'index')
    4142  {
    42     $template->assign(array(
    43       'GPLUS1_SIZE' => $conf['GooglePlusOne'][0],
    44       'GPLUS1_POSITON' => 'index',
    45     ));
    46        
     43    $template->assign('GPLUS1_POSITON', 'index');
    4744    $template->set_prefilter('index', 'gplus1_add_button_prefilter');
    4845  }
    4946 
    5047  // if the link is in the toolbar, we must use smallier buttons
    51   if ( script_basename() == 'index' OR  $conf['GooglePlusOne'][1] == 'toolbar')
     48  if ( script_basename() == 'index' OR  $conf['GooglePlusOne']['position'] == 'toolbar')
    5249  {
    53     if ($conf['GooglePlusOne'][0] == 'tall')
     50    if ($conf['GooglePlusOne']['size'] == 'tall' AND $conf['GooglePlusOne']['annotation'] == 'bubble')
    5451    {
    5552        $template->assign('GPLUS1_SIZE', 'standard');
     
    5855 
    5956  // button language
     57  if ( in_array(str_replace('_','-',$user['language']), $conf['GooglePlusOne']['lang']) )
     58  {
     59    $template->assign('GPLUS1_LANG', str_replace('_','-',$user['language']));
     60  }
    6061  if ( in_array(substr($user['language'],0,2), $conf['GooglePlusOne']['lang']) )
    6162  {
     
    7273  global $template;
    7374 
     75  $replace = '{combine_script id=\'google_plusone\' path=\'https://apis.google.com/js/plusone.js\'}
     76<script type="text/javascript">window.___gcfg = {ldelim}lang: \'{$GPLUS1_LANG}\'};</script>
     77<g:plusone size="{$GPLUS1_SIZE}" annotation="{$GPLUS1_ANNO}"></g:plusone>';
     78 
    7479  switch ($template->get_template_vars('GPLUS1_POSITON'))
    7580  {
    7681    case 'top':
    7782      $search = '<div id="theImage">';
    78       $replace = '<div><g:plusone size="{$GPLUS1_SIZE}"></g:plusone></div>';
     83      $replace = '<div>'.$replace.'</div>';
    7984      break;
    8085     
    8186    case 'bottom':
    8287      $search = '{$ELEMENT_CONTENT}';
    83       $replace = '<g:plusone size="{$GPLUS1_SIZE}"></g:plusone>';
    8488      break;
    8589     
    8690    case 'toolbar':
    87       $search = '{*caddie management END*}';
    88       $replace = '<g:plusone size="{$GPLUS1_SIZE}"></g:plusone>';
     91      $search = '<div class="actionButtons">';
    8992      break;
    9093     
    9194    case 'index': 
    9295      $search = '<ul class="categoryActions">';
    93       $replace = '<li><g:plusone size="{$GPLUS1_SIZE}"></g:plusone></li>';
     96      $replace = '<li>'.$replace.'</li>';
    9497      break;
    9598  }
    96   $replace = $search.$replace.'
    97 {combine_script id=\'google_plusone\' path=\'https://apis.google.com/js/plusone.js\'}
    98 <script type="text/javascript">{ldelim}lang: \'{$GPLUS1_LANG}\'}</script>';
    9999
    100   return str_replace($search, $replace, $content);
     100  return str_replace($search, $search.$replace, $content);
    101101}
    102102
     
    108108  function gplus1_plugin_admin_menu($menu)
    109109  {
    110     array_push(
    111       $menu,
    112       array(
    113         'NAME' => 'Google+1',
    114         'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
    115         )
    116       );
    117    
     110    array_push($menu, array(
     111      'NAME' => 'Google+1',
     112      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
     113      ));
    118114    return $menu;
    119115  }
Note: See TracChangeset for help on using the changeset viewer.