commit 5a4902235e9f0d9827374d5f3daca55b5ec10562 Author: mistic100 Date: Thu Jan 24 18:38:46 2013 +0000 create plugin SocialButtons git-svn-id: http://piwigo.org/svn/extensions/SocialButtons@20358 68402e56-0260-453c-a942-63ccdbb3a9ee diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..822a307 --- /dev/null +++ b/admin.php @@ -0,0 +1,53 @@ + $_POST['position'], + 'twitter' => array( + 'enabled' => isset($_POST['twitter']['enabled']), + 'size' => $_POST['twitter']['size'], + 'count' => $_POST['twitter']['count'], + 'via' => trim($_POST['twitter']['via']), + ), + 'google' => array( + 'enabled' => isset($_POST['google']['enabled']), + 'size' => $_POST['google']['size'], + 'annotation' => $_POST['google']['annotation'], + ), + 'tumblr' => array( + 'enabled' => isset($_POST['tumblr']['enabled']), + 'type' => $_POST['tumblr']['type'], + 'img_size' => $_POST['tumblr']['img_size'], + ), + 'facebook' => array( + 'enabled' => isset($_POST['facebook']['enabled']), + 'color' => $_POST['facebook']['color'], + 'layout' => $_POST['facebook']['layout'], + ), + ); + + conf_update_param('SocialButtons', serialize($conf['SocialButtons'])); + array_push($page['infos'], l10n('Information data registered in database')); + + // the prefilter changes, we must delete compiled templatess + $template->delete_compiled_templates(); +} + + +$template->assign($conf['SocialButtons']); +$template->assign(array( + 'SOCIALBUTT_PATH' => SOCIALBUTT_PATH, + 'img_sizes' => array_merge(ImageStdParams::get_all_types(), array('Original')), + )); + +$template->set_filename('socialbutt_content', realpath(SOCIALBUTT_PATH . 'template/admin.tpl')); +$template->assign_var_from_handle('ADMIN_CONTENT', 'socialbutt_content'); + +?> \ No newline at end of file diff --git a/include/facebook.inc.php b/include/facebook.inc.php new file mode 100644 index 0000000..5b89826 --- /dev/null +++ b/include/facebook.inc.php @@ -0,0 +1,47 @@ +set_filename('facebook_button', realpath(SOCIALBUTT_PATH .'template/facebook.tpl')); + return 'facebook_button'; +} + +?> \ No newline at end of file diff --git a/include/google.inc.php b/include/google.inc.php new file mode 100644 index 0000000..a67a9ba --- /dev/null +++ b/include/google.inc.php @@ -0,0 +1,48 @@ +set_filename('google_button', realpath(SOCIALBUTT_PATH .'template/google.tpl')); + return 'google_button'; +} + +?> \ No newline at end of file diff --git a/include/index.php b/include/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/include/index.php @@ -0,0 +1,7 @@ + diff --git a/include/install.inc.php b/include/install.inc.php new file mode 100644 index 0000000..2fae8b9 --- /dev/null +++ b/include/install.inc.php @@ -0,0 +1,61 @@ + 'toolbar', + 'twitter' => array( + 'enabled' => true, + 'size' => 'small', + 'count' => 'bubble', + 'via' => null, + ), + 'google' => array( + 'enabled' => true, + 'size' => 'medium', + 'annotation' => 'bubble', + ), + 'tumblr' => array( + 'enabled' => true, + 'type' => 'share_1', + 'img_size' => 'Original', + ), + 'facebook' => array( + 'enabled' => true, + 'color' => 'light', + 'layout' => 'button_count', + ), + ); + + if (isset($conf['TumblrShare'])) + { + $temp = is_string($conf['TumblrShare']) ? unserialize($conf['TumblrShare']) : $conf['TumblrShare']; + $default_config['tumblr']['type'] = $temp['type']; + $default_config['tumblr']['img_size'] = $temp['img_size']; + } + if (isset($conf['TweetThis'])) + { + $temp = is_string($conf['TweetThis']) ? unserialize($conf['TweetThis']) : $conf['TweetThis']; + $default_config['twitter']['size'] = $temp['size']; + $default_config['twitter']['count'] = $temp['count'] ? 'bubble' : 'none'; + $default_config['twitter']['via'] = $temp['via']; + } + if (isset($conf['GooglePlusOne'])) + { + $temp = is_string($conf['GooglePlusOne']) ? unserialize($conf['GooglePlusOne']) : $conf['GooglePlusOne']; + $default_config['google']['size'] = $temp['size']; + $default_config['google']['annotation'] = $temp['annotation']; + } + + + $conf['SocialButtons'] = serialize($default_config); + conf_update_param('SocialButtons', $conf['SocialButtons']); + } +} + +?> \ No newline at end of file diff --git a/include/tumblr.inc.php b/include/tumblr.inc.php new file mode 100644 index 0000000..c9af3e7 --- /dev/null +++ b/include/tumblr.inc.php @@ -0,0 +1,56 @@ + 'width:81px; height:20px;', + 'share_2' => 'width:61px; height:20px;', + 'share_3' => 'width:129px; height:20px;', + 'share_4' => 'width:20px; height:20px;', + 'share_1T' => 'width:81px; height:20px;', + 'share_2T' => 'width:61px; height:20px;', + 'share_3T' => 'width:129px; height:20px;', + 'share_4T' => 'width:20px; height:20px;', + ); + + + // config + $tpl_vars['TUMBLR'] = $conf['SocialButtons']['tumblr']; + $tpl_vars['TUMBLR']['css'] = $tumblr_css[ $conf['SocialButtons']['tumblr']['type'] ]; + $tpl_vars['TUMBLR']['copyright'] = ' (from '.$conf['gallery_title'].')'; + + // button on piture page + if ($basename == 'picture') + { + global $picture; + + $tpl_vars['TUMBLR']['mode'] = 'photo'; + $tpl_vars['TUMBLR']['title'] = $picture['current']['TITLE']; + + if ($conf['SocialButtons']['tumblr']['img_size'] == 'Original') + { + $tpl_vars['TUMBLR']['source'] = $root_url.ltrim($picture['current']['src_image']->get_url(), './'); + } + else + { + $tpl_vars['TUMBLR']['source'] = $root_url.ltrim(DerivativeImage::url($conf['SocialButtons']['tumblr']['img_size'], $picture['current']['src_image']), './'); + } + } + // button on other pages + else if ($basename == 'index') + { + global $page; + + $tpl_vars['TUMBLR']['mode'] = 'link'; + $tpl_vars['TUMBLR']['title'] = strip_tags($page['title']); + } + + + $template->set_filename('tumblr_button', realpath(SOCIALBUTT_PATH .'template/tumblr.tpl')); + return 'tumblr_button'; +} + +?> \ No newline at end of file diff --git a/include/twitter.inc.php b/include/twitter.inc.php new file mode 100644 index 0000000..83f0327 --- /dev/null +++ b/include/twitter.inc.php @@ -0,0 +1,36 @@ +set_filename('twitter_button', realpath(SOCIALBUTT_PATH .'template/twitter.tpl')); + return 'twitter_button'; +} + +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/index.php @@ -0,0 +1,7 @@ + diff --git a/language/af_ZA/index.php b/language/af_ZA/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/af_ZA/index.php @@ -0,0 +1,7 @@ + diff --git a/language/af_ZA/plugin.lang.php b/language/af_ZA/plugin.lang.php new file mode 100644 index 0000000..7935dfd --- /dev/null +++ b/language/af_ZA/plugin.lang.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/language/bg_BG/index.php b/language/bg_BG/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/bg_BG/index.php @@ -0,0 +1,7 @@ + diff --git a/language/bg_BG/plugin.lang.php b/language/bg_BG/plugin.lang.php new file mode 100644 index 0000000..d9e9716 --- /dev/null +++ b/language/bg_BG/plugin.lang.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/language/ca_ES/index.php b/language/ca_ES/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/ca_ES/index.php @@ -0,0 +1,7 @@ + diff --git a/language/ca_ES/plugin.lang.php b/language/ca_ES/plugin.lang.php new file mode 100644 index 0000000..5a0f368 --- /dev/null +++ b/language/ca_ES/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/cs_CZ/index.php b/language/cs_CZ/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/cs_CZ/index.php @@ -0,0 +1,7 @@ + diff --git a/language/cs_CZ/plugin.lang.php b/language/cs_CZ/plugin.lang.php new file mode 100644 index 0000000..09fb6e5 --- /dev/null +++ b/language/cs_CZ/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/da_DK/index.php b/language/da_DK/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/da_DK/index.php @@ -0,0 +1,7 @@ + diff --git a/language/da_DK/plugin.lang.php b/language/da_DK/plugin.lang.php new file mode 100644 index 0000000..7b51e2c --- /dev/null +++ b/language/da_DK/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/de_DE/index.php b/language/de_DE/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/de_DE/index.php @@ -0,0 +1,7 @@ + diff --git a/language/de_DE/plugin.lang.php b/language/de_DE/plugin.lang.php new file mode 100644 index 0000000..c6f6b86 --- /dev/null +++ b/language/de_DE/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/el_GR/index.php b/language/el_GR/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/el_GR/index.php @@ -0,0 +1,7 @@ + diff --git a/language/el_GR/plugin.lang.php b/language/el_GR/plugin.lang.php new file mode 100644 index 0000000..2cff13b --- /dev/null +++ b/language/el_GR/plugin.lang.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/language/en_UK/description.txt b/language/en_UK/description.txt new file mode 100644 index 0000000..28a6198 --- /dev/null +++ b/language/en_UK/description.txt @@ -0,0 +1 @@ +Sharing functions for Facebook, Twitter, Google+ and Tumblr \ No newline at end of file diff --git a/language/en_UK/index.php b/language/en_UK/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/en_UK/index.php @@ -0,0 +1,7 @@ + diff --git a/language/en_UK/plugin.lang.php b/language/en_UK/plugin.lang.php new file mode 100644 index 0000000..8824b51 --- /dev/null +++ b/language/en_UK/plugin.lang.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/language/es_ES/index.php b/language/es_ES/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/es_ES/index.php @@ -0,0 +1,7 @@ + diff --git a/language/es_ES/plugin.lang.php b/language/es_ES/plugin.lang.php new file mode 100644 index 0000000..671f094 --- /dev/null +++ b/language/es_ES/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/et_EE/index.php b/language/et_EE/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/et_EE/index.php @@ -0,0 +1,7 @@ + diff --git a/language/et_EE/plugin.lang.php b/language/et_EE/plugin.lang.php new file mode 100644 index 0000000..c339f9e --- /dev/null +++ b/language/et_EE/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/fa_IR/index.php b/language/fa_IR/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/fa_IR/index.php @@ -0,0 +1,7 @@ + diff --git a/language/fa_IR/plugin.lang.php b/language/fa_IR/plugin.lang.php new file mode 100644 index 0000000..b145610 --- /dev/null +++ b/language/fa_IR/plugin.lang.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/language/fi_FI/index.php b/language/fi_FI/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/fi_FI/index.php @@ -0,0 +1,7 @@ + diff --git a/language/fi_FI/plugin.lang.php b/language/fi_FI/plugin.lang.php new file mode 100644 index 0000000..3a0641b --- /dev/null +++ b/language/fi_FI/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/fr_FR/description.txt b/language/fr_FR/description.txt new file mode 100644 index 0000000..bc53c88 --- /dev/null +++ b/language/fr_FR/description.txt @@ -0,0 +1 @@ +Functions de partage pour Facebook, Twitter, Google+ et Tumblr \ No newline at end of file diff --git a/language/fr_FR/index.php b/language/fr_FR/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/fr_FR/index.php @@ -0,0 +1,7 @@ + diff --git a/language/fr_FR/plugin.lang.php b/language/fr_FR/plugin.lang.php new file mode 100644 index 0000000..c353e3e --- /dev/null +++ b/language/fr_FR/plugin.lang.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/language/hu_HU/index.php b/language/hu_HU/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/hu_HU/index.php @@ -0,0 +1,7 @@ + diff --git a/language/hu_HU/plugin.lang.php b/language/hu_HU/plugin.lang.php new file mode 100644 index 0000000..9822f54 --- /dev/null +++ b/language/hu_HU/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/index.php b/language/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/index.php @@ -0,0 +1,7 @@ + diff --git a/language/it_IT/index.php b/language/it_IT/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/it_IT/index.php @@ -0,0 +1,7 @@ + diff --git a/language/it_IT/plugin.lang.php b/language/it_IT/plugin.lang.php new file mode 100644 index 0000000..d3114cb --- /dev/null +++ b/language/it_IT/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/lv_LV/index.php b/language/lv_LV/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/lv_LV/index.php @@ -0,0 +1,7 @@ + diff --git a/language/lv_LV/plugin.lang.php b/language/lv_LV/plugin.lang.php new file mode 100644 index 0000000..d786e8a --- /dev/null +++ b/language/lv_LV/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/nb_NO/plugin.lang.php b/language/nb_NO/plugin.lang.php new file mode 100644 index 0000000..db4727f --- /dev/null +++ b/language/nb_NO/plugin.lang.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/language/nl_NL/index.php b/language/nl_NL/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/nl_NL/index.php @@ -0,0 +1,7 @@ + diff --git a/language/nl_NL/plugin.lang.php b/language/nl_NL/plugin.lang.php new file mode 100644 index 0000000..5651e56 --- /dev/null +++ b/language/nl_NL/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/pl_PL/index.php b/language/pl_PL/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/pl_PL/index.php @@ -0,0 +1,7 @@ + diff --git a/language/pl_PL/plugin.lang.php b/language/pl_PL/plugin.lang.php new file mode 100644 index 0000000..5b9e893 --- /dev/null +++ b/language/pl_PL/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/pt_BR/index.php b/language/pt_BR/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/pt_BR/index.php @@ -0,0 +1,7 @@ + diff --git a/language/pt_BR/plugin.lang.php b/language/pt_BR/plugin.lang.php new file mode 100644 index 0000000..988d0a8 --- /dev/null +++ b/language/pt_BR/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/pt_PT/index.php b/language/pt_PT/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/pt_PT/index.php @@ -0,0 +1,7 @@ + diff --git a/language/pt_PT/plugin.lang.php b/language/pt_PT/plugin.lang.php new file mode 100644 index 0000000..0689a73 --- /dev/null +++ b/language/pt_PT/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/ro_RO/index.php b/language/ro_RO/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/ro_RO/index.php @@ -0,0 +1,7 @@ + diff --git a/language/ro_RO/plugin.lang.php b/language/ro_RO/plugin.lang.php new file mode 100644 index 0000000..7271bc7 --- /dev/null +++ b/language/ro_RO/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/language/ru_RU/index.php b/language/ru_RU/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/ru_RU/index.php @@ -0,0 +1,7 @@ + diff --git a/language/ru_RU/plugin.lang.php b/language/ru_RU/plugin.lang.php new file mode 100644 index 0000000..00b846f --- /dev/null +++ b/language/ru_RU/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/sh_RS/index.php b/language/sh_RS/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/sh_RS/index.php @@ -0,0 +1,7 @@ + diff --git a/language/sh_RS/plugin.lang.php b/language/sh_RS/plugin.lang.php new file mode 100644 index 0000000..64f5061 --- /dev/null +++ b/language/sh_RS/plugin.lang.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/language/sk_SK/index.php b/language/sk_SK/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/sk_SK/index.php @@ -0,0 +1,7 @@ + diff --git a/language/sk_SK/plugin.lang.php b/language/sk_SK/plugin.lang.php new file mode 100644 index 0000000..6803bf8 --- /dev/null +++ b/language/sk_SK/plugin.lang.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/language/sv_SE/index.php b/language/sv_SE/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/sv_SE/index.php @@ -0,0 +1,7 @@ + diff --git a/language/sv_SE/plugin.lang.php b/language/sv_SE/plugin.lang.php new file mode 100644 index 0000000..72f4563 --- /dev/null +++ b/language/sv_SE/plugin.lang.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/language/th_TH/index.php b/language/th_TH/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/th_TH/index.php @@ -0,0 +1,7 @@ + diff --git a/language/th_TH/plugin.lang.php b/language/th_TH/plugin.lang.php new file mode 100644 index 0000000..f017284 --- /dev/null +++ b/language/th_TH/plugin.lang.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/language/tr_TR/index.php b/language/tr_TR/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/tr_TR/index.php @@ -0,0 +1,7 @@ + diff --git a/language/tr_TR/plugin.lang.php b/language/tr_TR/plugin.lang.php new file mode 100644 index 0000000..3211371 --- /dev/null +++ b/language/tr_TR/plugin.lang.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/language/uk_UA/index.php b/language/uk_UA/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/uk_UA/index.php @@ -0,0 +1,7 @@ + diff --git a/language/uk_UA/plugin.lang.php b/language/uk_UA/plugin.lang.php new file mode 100644 index 0000000..10dd923 --- /dev/null +++ b/language/uk_UA/plugin.lang.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/language/vi_VN/index.php b/language/vi_VN/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/vi_VN/index.php @@ -0,0 +1,7 @@ + diff --git a/language/vi_VN/plugin.lang.php b/language/vi_VN/plugin.lang.php new file mode 100644 index 0000000..995c4eb --- /dev/null +++ b/language/vi_VN/plugin.lang.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/language/zh_CN/index.php b/language/zh_CN/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/language/zh_CN/index.php @@ -0,0 +1,7 @@ + diff --git a/language/zh_CN/plugin.lang.php b/language/zh_CN/plugin.lang.php new file mode 100644 index 0000000..12c383e --- /dev/null +++ b/language/zh_CN/plugin.lang.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/main.inc.php b/main.inc.php new file mode 100644 index 0000000..a7ebb54 --- /dev/null +++ b/main.inc.php @@ -0,0 +1,198 @@ + 'Social Buttons', + 'URL' => SOCIALBUTT_ADMIN, + )); + return $menu; + } +} +else +{ + add_event_handler('loc_end_picture', 'socialbutt_add_button'); + add_event_handler('loc_end_index', 'socialbutt_add_button'); +} + + +/** + * plugin initialization + */ +function socialbutt_init() +{ + global $conf, $pwg_loaded_plugins; + + // apply upgrade if needed + if ( + SOCIALBUTT_VERSION == 'auto' or + $pwg_loaded_plugins[SOCIALBUTT_ID]['version'] == 'auto' or + version_compare($pwg_loaded_plugins[SOCIALBUTT_ID]['version'], SOCIALBUTT_VERSION, '<') + ) + { + // call install function + include_once(SOCIALBUTT_PATH . 'include/install.inc.php'); + socialbutt_install(); + + // update plugin version in database + if ( $pwg_loaded_plugins[SOCIALBUTT_ID]['version'] != 'auto' and SOCIALBUTT_VERSION != 'auto' ) + { + $query = ' +UPDATE '. PLUGINS_TABLE .' +SET version = "'. SOCIALBUTT_VERSION .'" +WHERE id = "'. SOCIALBUTT_ID .'"'; + pwg_query($query); + + $pwg_loaded_plugins[SOCIALBUTT_ID]['version'] = SOCIALBUTT_VERSION; + + if (defined('IN_ADMIN')) + { + $_SESSION['page_infos'][] = 'Social Buttons updated to version '. SOCIALBUTT_VERSION; + } + } + } + + // prepare plugin configuration + $conf['SocialButtons'] = unserialize($conf['SocialButtons']); +} + + +/** + * add buttons + */ +function socialbutt_add_button() +{ + global $conf, $template; + + $basename = script_basename(); + $root_url = get_absolute_root_url(); + + if ($basename == 'picture') + { + $share_url = $root_url.ltrim(duplicate_picture_url(), './'); + } + else if ($basename == 'index') + { + $conf['SocialButtons']['position'] = 'index'; + $share_url = $root_url.ltrim(duplicate_index_url(array(), array('start')), './'); + } + else + { + return; + } + + + define('SOCIALBUTT_POSITION', $conf['SocialButtons']['position']); + $tpl_vars = array( + 'share_url' => $share_url, + 'position' => $conf['SocialButtons']['position'], + ); + $buttons = array(); + + + if ($conf['SocialButtons']['google']['enabled']) + { + include_once(SOCIALBUTT_PATH . 'include/google.inc.php'); + $buttons[] = socialbutt_google($basename, $root_url, $tpl_vars); + } + if ($conf['SocialButtons']['twitter']['enabled']) + { + include_once(SOCIALBUTT_PATH . 'include/twitter.inc.php'); + $buttons[] = socialbutt_twitter($basename, $root_url, $tpl_vars); + } + if ($conf['SocialButtons']['facebook']['enabled']) + { + include_once(SOCIALBUTT_PATH . 'include/facebook.inc.php'); + $buttons[] = socialbutt_facebook($basename, $root_url, $tpl_vars); + } + if ($conf['SocialButtons']['tumblr']['enabled']) + { + include_once(SOCIALBUTT_PATH . 'include/tumblr.inc.php'); + $buttons[] = socialbutt_tumblr($basename, $root_url, $tpl_vars); + } + + if (empty($buttons)) + { + return; + } + + + $template->assign('SOCIALBUTT', $tpl_vars); + + // parse buttons + foreach ($buttons as &$button) + { + $button = $template->parse($button, true); + } + unset($button); + + switch ($conf['SocialButtons']['position']) + { + case 'index': + foreach ($buttons as $button) { + // $template->add_index_button('
  • '.$button.'
  • ', 100); + $template->concat('PLUGIN_INDEX_ACTIONS', "\n
  • ".$button."
  • "); + } + break; + case 'toolbar': + foreach ($buttons as $button) { + // $template->add_picture_button($button, 100); + $template->concat('PLUGIN_PICTURE_ACTIONS', "\n".$button); + } + break; + default; + $template->assign('SOCIALBUTT_BUTTONS', $buttons); + $template->set_prefilter('picture', 'socialbutt_add_button_prefilter'); + } +} + +function socialbutt_add_button_prefilter($content) +{ + switch (SOCIALBUTT_POSITION) + { + case 'top': + $search = '
    '; + $add = '
    {foreach from=$SOCIALBUTT_BUTTONS item=BUTTON}{$BUTTON}{/foreach}
    '; + break; + + case 'bottom': + $search = '{$ELEMENT_CONTENT}'; + $add = '
    {foreach from=$SOCIALBUTT_BUTTONS item=BUTTON}{$BUTTON}{/foreach}
    '; + break; + } + + return str_replace($search, $search.$add, $content); +} + +?> \ No newline at end of file diff --git a/maintain.inc.php b/maintain.inc.php new file mode 100644 index 0000000..e046803 --- /dev/null +++ b/maintain.inc.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/template/admin.tpl b/template/admin.tpl new file mode 100644 index 0000000..c745770 --- /dev/null +++ b/template/admin.tpl @@ -0,0 +1,275 @@ +{combine_css path=$SOCIALBUTT_PATH|@cat:"template/style.css"} + +{html_style}{literal} +img.grayscale { + filter: url("data:image/svg+xml;utf8,#grayscale"); /* Firefox 10+ */ + filter: gray; /* IE6-9 */ + -webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */ +} +{/literal}{/html_style} + +{footer_script}{literal} +jQuery("input.enable").change(function() { + $parent = $(this).closest("table"); + if (!$(this).is(":checked")) { + $parent.find("thead label").attr("title", "{/literal}{'Enable'|@translate|escape:javascript}{literal}"); + $parent.find("thead img").addClass('grayscale'); + $parent.find("tbody").hide(); + } + else { + $parent.find("thead label").attr("title", "{/literal}{'Disable'|@translate|escape:javascript}{literal}"); + $parent.find("thead img").removeClass('grayscale'); + $parent.find("tbody").show(); + } +}); +{/literal}{/footer_script} + + +
    +

    Social Buttons

    +
    + + +
    + +
    + + + + + +
    + {'Button position on picture page'|@translate} + + + + +
    +
    + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + {'Button type'|@translate} +
    + {'Shared picture size'|@translate} + + {html_options name="tumblr[img_size]" values=$img_sizes output=$img_sizes|translate selected=$tumblr.img_size} +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + {'Button type'|@translate} +
    + {'Annotation'|@translate} + +
    +
    + +
    +
    + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + {'Button type'|@translate} +
    + {'Annotation'|@translate} + +
    +
    +
    + + + @ +
    +
    + +
    + + + + + + + + + + + + + + + + + + +
    + +
    + {'Button type'|@translate} +
    + {'Annotation'|@translate} + +
    +
    + +
    +
    + +
    + +
    + +
    + +
    \ No newline at end of file diff --git a/template/facebook.tpl b/template/facebook.tpl new file mode 100644 index 0000000..7fe427f --- /dev/null +++ b/template/facebook.tpl @@ -0,0 +1,7 @@ +{strip} +{footer_script}jQuery('body').prepend('
    ');{/footer_script} +{combine_script id='facebook_jssdk' load='async' path='https://connect.facebook.net/'|cat:$SOCIALBUTT.FACEBOOK.lang|cat:'/all.js#xfbml=1'} + +
    +{/strip} \ No newline at end of file diff --git a/template/google.tpl b/template/google.tpl new file mode 100644 index 0000000..3d9f3f9 --- /dev/null +++ b/template/google.tpl @@ -0,0 +1,6 @@ +{strip} +{combine_script id='google_plusone' load='footer' path='https://apis.google.com/js/plusone.js'} + + +
    +{/strip} \ No newline at end of file diff --git a/template/images/facebook_dark.png b/template/images/facebook_dark.png new file mode 100644 index 0000000..b9a884b Binary files /dev/null and b/template/images/facebook_dark.png differ diff --git a/template/images/facebook_light.png b/template/images/facebook_light.png new file mode 100644 index 0000000..5722afd Binary files /dev/null and b/template/images/facebook_light.png differ diff --git a/template/images/facebook_logo.png b/template/images/facebook_logo.png new file mode 100644 index 0000000..926932c Binary files /dev/null and b/template/images/facebook_logo.png differ diff --git a/template/images/google_logo.png b/template/images/google_logo.png new file mode 100644 index 0000000..0cdbea4 Binary files /dev/null and b/template/images/google_logo.png differ diff --git a/template/images/google_medium.png b/template/images/google_medium.png new file mode 100644 index 0000000..2e7422f Binary files /dev/null and b/template/images/google_medium.png differ diff --git a/template/images/google_small.png b/template/images/google_small.png new file mode 100644 index 0000000..d5fb3b7 Binary files /dev/null and b/template/images/google_small.png differ diff --git a/template/images/google_standard.png b/template/images/google_standard.png new file mode 100644 index 0000000..c349469 Binary files /dev/null and b/template/images/google_standard.png differ diff --git a/template/images/google_tall.png b/template/images/google_tall.png new file mode 100644 index 0000000..4003450 Binary files /dev/null and b/template/images/google_tall.png differ diff --git a/template/images/index.php b/template/images/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/template/images/index.php @@ -0,0 +1,7 @@ + diff --git a/template/images/tumblr_logo.png b/template/images/tumblr_logo.png new file mode 100644 index 0000000..fb20c8f Binary files /dev/null and b/template/images/tumblr_logo.png differ diff --git a/template/images/twitter_large.png b/template/images/twitter_large.png new file mode 100644 index 0000000..7af6b27 Binary files /dev/null and b/template/images/twitter_large.png differ diff --git a/template/images/twitter_logo.png b/template/images/twitter_logo.png new file mode 100644 index 0000000..365b702 Binary files /dev/null and b/template/images/twitter_logo.png differ diff --git a/template/images/twitter_small.png b/template/images/twitter_small.png new file mode 100644 index 0000000..0baf190 Binary files /dev/null and b/template/images/twitter_small.png differ diff --git a/template/index.php b/template/index.php new file mode 100644 index 0000000..ec66053 --- /dev/null +++ b/template/index.php @@ -0,0 +1,7 @@ + diff --git a/template/style.css b/template/style.css new file mode 100644 index 0000000..3129822 --- /dev/null +++ b/template/style.css @@ -0,0 +1,95 @@ +.socialbutt { + display:inline-block; + vertical-align:top; + margin:10px; + width:500px; + border:10px solid #f9f9f9; + border-radius:10px; + box-shadow:0 0 5px rgba(0,0,0,0.2); +} +.socialbutt table { + border-spacing: 0px; + width:100%; +} + +.socialbutt td { + width:50%; + padding:10px 5px; + background-color:#ECF6FA; + border:1px solid #fff; + border-right-color:#CDE8F4; + border-bottom-color:#CDE8F4; + text-align:center; + vertical-align:center; + font-weight:normal; +} +.socialbutt thead td { + border-top:none; +} +.socialbutt tr td:last-child { + border-right:none; +} +.socialbutt tbody tr:last-child td { + border-bottom:none; +} +.socialbutt tr.button td { + padding:10px 20px; +} +.socialbutt tr.button td:hover { + background-color:#D0E7F2; +} +.socialbutt tr.property td:first-child { + font-weight:bold; +} +.socialbutt tbody tr td:first-child { + text-align:right; +} +.socialbutt tbody tr td:last-child { + text-align:left; +} + +.socialbutt img { + vertical-align:bottom; +} + +.socialbutt input[type='text'], .socialbutt select { + background:#eee; + color:#888; + border:1px solid #aaa; + border-radius:4px; + box-shadow:inset 0 1px 0 rgba(0,0,0,0.05); + padding:5px; +} +.socialbutt input[type='text']:focus, .socialbutt select:focus { + background:#fff; + border-color:#3399ff; +} + +.submit { + display:inline-block; + margin:10px; +} +.submit input { + background: #33bbee; + background: -moz-linear-gradient(top, #33bbee 0%, #339dde 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#33bbee), color-stop(100%,#339dde)); + background: -webkit-linear-gradient(top, #33bbee 0%,#339dde 100%); + background: -o-linear-gradient(top, #33bbee 0%,#339dde 100%); + background: -ms-linear-gradient(top, #33bbee 0%,#339dde 100%); + background: linear-gradient(to bottom, #33bbee 0%,#339dde 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#33bbee', endColorstr='#339dde',GradientType=0 ); + + border-color: #3399DD #3399DD #2288CC; + color: #FFFFFF !important; + font-size: 14px; + text-shadow: -1px -1px 0 #3399DD; + border-radius: 5px; + border-style: solid; + border-width: 1px; + padding: 5px 9px !important; + letter-spacing:0.1em; +} +.submit input:hover { + box-shadow: 0 0 5px #2288CC; + border-color: #3399DD #3399DD #2288CC; +} \ No newline at end of file diff --git a/template/tumblr.tpl b/template/tumblr.tpl new file mode 100644 index 0000000..998fb70 --- /dev/null +++ b/template/tumblr.tpl @@ -0,0 +1,11 @@ +{strip} +{combine_script id='tumblr_share' load='footer' path='http://platform.tumblr.com/v1/share.js'} + +{if $SOCIALBUTT.TUMBLR.mode=='photo'} +{capture assign="inline_tags"}{foreach from=$related_tags item=tag name=tag_loop}{if !$smarty.foreach.tag_loop.first},{/if}{$tag.name}{/foreach}{/capture} +Tumblr +{/strip} \ No newline at end of file diff --git a/template/twitter.tpl b/template/twitter.tpl new file mode 100644 index 0000000..438f1f1 --- /dev/null +++ b/template/twitter.tpl @@ -0,0 +1,7 @@ +{strip} +{combine_script id='twitter_widgets' load='footer' path='http://platform.twitter.com/widgets.js'} + + +{/strip} \ No newline at end of file