'sharethis')) . '/'); define('SHARETHIS_DIR', PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'sharethis/'); if (!defined('GDTHEME_PATH')): define('GDTHEME_PATH' , PHPWG_THEMES_PATH . 'greydragon/'); endif; // +-----------------------------------------------------------------------+ // | Add event handlers | // +-----------------------------------------------------------------------+ // init the plugin add_event_handler('init', 'sharethis_init'); /* * this is the common way to define event functions: create a new function for each event you want to handle */ if (defined('IN_ADMIN')): // file containing all admin handlers functions $admin_file = SHARETHIS_PATH . 'include/admin_events.inc.php'; // admin plugins menu link add_event_handler('get_admin_plugin_menu_links', 'sharethis_admin_plugin_menu_links', EVENT_HANDLER_PRIORITY_NEUTRAL, $admin_file); endif; function sharethis_init() { global $conf; // prepare plugin configuration $conf['sharethis'] = safe_unserialize($conf['sharethis']); if ($conf['sharethis']['facebook'] || $conf['sharethis']['pinterest'] || $conf['sharethis']['twitter'] || $conf['sharethis']['googleplus'] || $conf['sharethis']['tumblr']): add_event_handler('loc_begin_picture', 'sharethis_picture_handler'); endif; } function sharethis_picture_handler() { global $template, $conf, $current; if ($template->get_themeconf("name") == "greydragon"): add_event_handler('gd_get_metadata', 'sharethis_get_tab_metadata'); else: $template->set_prefilter('picture', 'sharethis_append_content'); endif; load_language('plugin.lang', SHARETHIS_PATH); $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https'; $host = $_SERVER['HTTP_HOST']; $script = $_SERVER['SCRIPT_NAME']; $params = $_SERVER['QUERY_STRING']; $curUrl = $protocol . '://' . $host . $script . '?' . $params; $template->assign( array( 'sharethis_facebook' => $conf['sharethis']['facebook'], 'sharethis_pinterest' => $conf['sharethis']['pinterest'], 'sharethis_twitter' => $conf['sharethis']['twitter'], 'sharethis_googleplus' => $conf['sharethis']['googleplus'], 'sharethis_tumblr' => $conf['sharethis']['tumblr'], 'SHARETHIS_PATH' => SHARETHIS_PATH, 'CUR_PAGE' => $curUrl )); } function sharethis_get_tab_metadata($metadata) { // pinterest &media= $url = '{$CUR_PAGE|escape:\'url\'}'; $image = '{if $current.selected_derivative}{$U_HOME|escape:\'url\'}{"/"|escape:\'url\'}{$current.selected_derivative->get_url()|escape:\'url\'}{/if}'; $title = '{$GALLERY_TITLE|escape:\'url\'}{" | "|escape:\'url\'}{$PAGE_TITLE|escape:\'url\'}{if $current->author}{" | by "|escape:\'url\'}{$current->author|escape:\'url\'}{/if}'; $content = '{$CONTENT_DESCRIPTION|urlencode}'; $metadata[] = array( "id" => "sharethis", "icon_class" => "fa fa-share-alt", "title" => "{'Share This'|@translate}", "content" => '{\'Share This\'|@translate}:' . '{html_head}{"\n"}' . '{"\n"}' . '{"\n"}' . '{"\n"}' . '{if $current.selected_derivative}{"\n"}{/if}' . '{"\n"}' . '{"\n"}' . '{if $sharethis_pinterest}{/if}' . '{/html_head}' . '{if $sharethis_facebook} {\'Facebook\'|@translate}{/if}' . '{if $sharethis_pinterest} {\'Pinterest\'|@translate}{/if}' . '{if $sharethis_twitter} {\'Twitter\'|@translate}{/if}' . '{if $sharethis_googleplus} {\'Google+\'|@translate}{/if}' . '{if $sharethis_tumblr} {\'Tumblr\'|@translate}{/if}', "combine" => '{combine_css id=\'fa\' path=$SHARETHIS_PATH|cat:"/css/font-awesome.min.css"}' . '{combine_css id=\'sharethis\' path=$SHARETHIS_PATH|cat:"/css/styles.css"}', "no_overlay" => TRUE ); return $metadata; } function sharethis_append_content($tpl_source, &$smarty){ $metadata = array(); $metadata = sharethis_get_tab_metadata($metadata); $pattern = '#
#'; if (!preg_match($pattern, $tpl_source)): $pattern = '#
#'; $replacement = '$0
' . $metadata[0]["content"] . '
' . $metadata[0]["combine"] . ' '; else: $replacement = '
' . $metadata[0]["content"] . '
' . $metadata[0]["combine"] . ' $0 '; endif; return preg_replace($pattern, $replacement, $tpl_source, 1); }