| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | FacebookPlug - a Piwigo Plugin | |
|---|
| 4 | // | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org | |
|---|
| 5 | // +-----------------------------------------------------------------------+ |
|---|
| 6 | // | This program is free software; you can redistribute it and/or modify | |
|---|
| 7 | // | it under the terms of the GNU General Public License as published by | |
|---|
| 8 | // | the Free Software Foundation | |
|---|
| 9 | // | | |
|---|
| 10 | // | This program is distributed in the hope that it will be useful, but | |
|---|
| 11 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
|---|
| 12 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
|---|
| 13 | // | General Public License for more details. | |
|---|
| 14 | // | | |
|---|
| 15 | // | You should have received a copy of the GNU General Public License | |
|---|
| 16 | // | along with this program; if not, write to the Free Software | |
|---|
| 17 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
|---|
| 18 | // | USA. | |
|---|
| 19 | // +-----------------------------------------------------------------------+ |
|---|
| 20 | |
|---|
| 21 | if (!defined('PHPWG_ROOT_PATH')) |
|---|
| 22 | { |
|---|
| 23 | die('Hacking attempt!'); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | function fbp_render_element_content($content, $current_picture) |
|---|
| 27 | { |
|---|
| 28 | global $template, $user, $page, $conf, $picture; |
|---|
| 29 | |
|---|
| 30 | if ($page['fbp']['do_facebook_init']) |
|---|
| 31 | { |
|---|
| 32 | // Header for each page |
|---|
| 33 | //~ $tpls[] = 'picture.header'; |
|---|
| 34 | |
|---|
| 35 | // Specific |
|---|
| 36 | if ($page['slideshow'] and $conf['fbp']['social_plugin_facepile']['enabled']) |
|---|
| 37 | { |
|---|
| 38 | $tpls[] = 'social.plugin.facepile'; |
|---|
| 39 | } |
|---|
| 40 | else if (! $page['slideshow']) |
|---|
| 41 | { |
|---|
| 42 | if ($conf['fbp']['social_plugin_like_button']['enabled']) |
|---|
| 43 | { |
|---|
| 44 | $tpls[] = 'social.plugin.like.button'; |
|---|
| 45 | } |
|---|
| 46 | else if ($conf['fbp']['social_plugin_comments']['enabled']) |
|---|
| 47 | { |
|---|
| 48 | $tpls[] = 'social.plugin.comments'; |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | // define picture FB link |
|---|
| 53 | // Always use full url for FB social plugin |
|---|
| 54 | set_make_full_url(); |
|---|
| 55 | if ($conf['fbp']['picture_url_type'] == 'image') |
|---|
| 56 | { |
|---|
| 57 | $page['fbp']['url'] = get_element_url($current_picture); |
|---|
| 58 | } |
|---|
| 59 | else |
|---|
| 60 | { |
|---|
| 61 | $page['fbp']['url'] = make_picture_url(array('image_id' => $page['image_id'])); |
|---|
| 62 | } |
|---|
| 63 | $page['fbp']['url_image'] = get_thumbnail_url($current_picture); |
|---|
| 64 | unset_make_full_url(); |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | // Assign template |
|---|
| 68 | $template->assign('fbp_page', $page['fbp']); |
|---|
| 69 | |
|---|
| 70 | // Parse TPL |
|---|
| 71 | foreach($tpls as $tpl) |
|---|
| 72 | { |
|---|
| 73 | // XFBML implementation |
|---|
| 74 | $template->set_filename('fbp_'.$tpl, FBP_DIR.'/tpl/'.$tpl.'.tpl'); |
|---|
| 75 | $content .= $template->parse('fbp_'.$tpl, true); |
|---|
| 76 | } |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | return $content; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | function fbp_loc_end_picture() |
|---|
| 83 | { |
|---|
| 84 | global $template; |
|---|
| 85 | |
|---|
| 86 | $template->assign('FBP_SHARE_LI', false); |
|---|
| 87 | |
|---|
| 88 | $tpl = 'share'; |
|---|
| 89 | $template->set_filename('fbp_'.$tpl, FBP_DIR.'/tpl/'.$tpl.'.tpl'); |
|---|
| 90 | $template->concat( |
|---|
| 91 | 'PLUGIN_PICTURE_ACTIONS', |
|---|
| 92 | $template->parse('fbp_'.$tpl, true) |
|---|
| 93 | ); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | add_event_handler('render_element_content', 'fbp_render_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL+1 /*in order to have picture content*/, 2); |
|---|
| 97 | |
|---|
| 98 | if ($conf['fbp']['share_picture']) |
|---|
| 99 | { |
|---|
| 100 | add_event_handler('loc_end_picture', 'fbp_loc_end_picture', EVENT_HANDLER_PRIORITY_NEUTRAL+1 /* In order to be on right */); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | ?> |
|---|