Social Buttons instead.'; } function gplus1_add_button() { global $conf, $template, $user; $conf['GooglePlusOne'] = unserialize($conf['GooglePlusOne']); $conf['GooglePlusOne']['lang'] = array( 'ar','bg','ca','zh-CN','zh-TW','hr','cs','da','nl','en-US','en-GB','et','fi','fr','de', 'el','iw','hi','hu','id','it','ja','ko','lv','lt','ms','no','fa','pl','pt-BR','pt-PT', 'ro','ru','sr','sk','sl','es','sv','th','tr','uk','vi', ); // urls and position if (script_basename() == 'picture') { $template->assign('GPLUS1_URL', get_absolute_root_url().ltrim(duplicate_picture_url(), './')); } else if (script_basename() == 'index') { $conf['GooglePlusOne']['position'] = 'index'; $template->assign('GPLUS1_URL', get_absolute_root_url().ltrim(duplicate_index_url(array(), array('start')), './')); } else { return; } // if the link is in the toolbar, we must use smallier buttons if ( script_basename() == 'index' OR $conf['GooglePlusOne']['position'] == 'toolbar') { if ($conf['GooglePlusOne']['size'] == 'tall' AND $conf['GooglePlusOne']['annotation'] == 'bubble') { $conf['GooglePlusOne']['size'] = 'standard'; } } // config $template->assign(array( 'GPLUS1_SIZE' => $conf['GooglePlusOne']['size'], 'GPLUS1_ANNO' => $conf['GooglePlusOne']['annotation'], 'GPLUS1_POSITON' => $conf['GooglePlusOne']['position'], )); // button language if ( in_array(str_replace('_','-',$user['language']), $conf['GooglePlusOne']['lang']) ) { $template->assign('GPLUS1_LANG', str_replace('_','-',$user['language'])); } if ( in_array(substr($user['language'],0,2), $conf['GooglePlusOne']['lang']) ) { $template->assign('GPLUS1_LANG', substr($user['language'],0,2)); } else { $template->assign('GPLUS1_LANG', 'en-GB'); } $template->set_filename('gplus1_button', dirname(__FILE__).'/button.tpl'); $button = $template->parse('gplus1_button', true); switch ($conf['GooglePlusOne']['position']) { case 'index': // $template->add_index_button('
  • '.$button.'
  • ', 100); $template->concat('PLUGIN_INDEX_ACTIONS', '
  • '.$button.'
  • '); break; case 'toolbar': // $template->add_picture_button($button, 100); $template->concat('PLUGIN_PICTURE_ACTIONS', $button); break; default; $template->assign('GPLUS1_BUTTON', $button); $template->set_prefilter('picture', 'gplus1_add_button_prefilter'); } } function gplus1_add_button_prefilter($content, &$smarty) { global $template; switch ($template->get_template_vars('GPLUS1_POSITION')) { case 'top': $search = '
    '; $replace = '
    {$GPLUS1_BUTTON}
    '; break; case 'bottom': $search = '{$ELEMENT_CONTENT}'; $replace = '{$GPLUS1_BUTTON}'; break; } return str_replace($search, $search.$replace, $content); } if (script_basename() == 'admin') { add_event_handler('get_admin_plugin_menu_links', 'gplus1_plugin_admin_menu'); function gplus1_plugin_admin_menu($menu) { array_push($menu, array( 'NAME' => 'Google+1', 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)) )); return $menu; } } ?>