1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | FacebookPlug - a Piwigo Plugin | |
---|
4 | // | Copyright (C) 2010 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 | include_once(FBP_DIR.'/include/common.inc.php'); |
---|
27 | include_once(FBP_DIR.'/include/header.inc.php'); |
---|
28 | |
---|
29 | function fbp_render_element_content($content, $current_picture) |
---|
30 | { |
---|
31 | global $template, $user, $page, $conf, $picture; |
---|
32 | |
---|
33 | if ($page['slideshow'] and $conf['fbp']['social_plugin_facepile']['enabled']) |
---|
34 | { |
---|
35 | $tpl = 'social.plugin.facepile'; |
---|
36 | } |
---|
37 | else if (! $page['slideshow']) |
---|
38 | { |
---|
39 | if ($conf['fbp']['social_plugin_like_button']['enabled']) |
---|
40 | { |
---|
41 | $tpl = 'social.plugin.like.button'; |
---|
42 | } |
---|
43 | else if ($conf['fbp']['social_plugin_comments']['enabled']) |
---|
44 | { |
---|
45 | $tpl = 'social.plugin.comments'; |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | if (empty($tpl)) |
---|
50 | { |
---|
51 | // nothing to do |
---|
52 | return $content; |
---|
53 | } |
---|
54 | |
---|
55 | // define picture FB link |
---|
56 | // Always use full url for FB social plugin |
---|
57 | set_make_full_url(); |
---|
58 | if ($conf['fbp']['picture_url_type'] == 'image') |
---|
59 | { |
---|
60 | $fbp_url_picture = get_element_url($current_picture); |
---|
61 | } |
---|
62 | else |
---|
63 | { |
---|
64 | $fbp_url_picture = make_picture_url(array('image_id' => $page['image_id'])); |
---|
65 | } |
---|
66 | unset_make_full_url(); |
---|
67 | $template->assign('fbp_url_picture', $fbp_url_picture); |
---|
68 | $template->assign('fbp_urlencode_picture', urlencode($fbp_url_picture)); |
---|
69 | |
---|
70 | // XFBML implementation |
---|
71 | $template->set_filename($tpl, FBP_DIR.'/tpl/'.$tpl.'.tpl'); |
---|
72 | $content .= $template->parse($tpl, true); |
---|
73 | |
---|
74 | return $content; |
---|
75 | } |
---|
76 | |
---|
77 | function ftp_loc_end_section_init() |
---|
78 | { |
---|
79 | global $conf; |
---|
80 | |
---|
81 | if ($conf['fbp']['social_plugin_like_button']['enabled'] or $conf['fbp']['social_plugin_comments']['enabled']) |
---|
82 | { |
---|
83 | if ($conf['fbp']['allow_fb_access_private_page']) |
---|
84 | { |
---|
85 | global $user, $page; |
---|
86 | |
---|
87 | // No restristion for facebook user |
---|
88 | if (preg_match('/'.FBP_IP_FB. '/', $_SERVER["REMOTE_ADDR"])) |
---|
89 | { |
---|
90 | //Allow guest access |
---|
91 | $conf['guest_access'] = true; |
---|
92 | // No forbidden categorie |
---|
93 | $user['forbidden_categories'] = ''; |
---|
94 | $user['level'] = max($conf['available_permission_levels']); |
---|
95 | $page['rank_of'][$page['image_id']] = 0; |
---|
96 | $page['items'] = array_flip($page['rank_of']); |
---|
97 | } |
---|
98 | } |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | if ($conf['fbp']['social_plugin_like_button']['enabled'] or $conf['fbp']['social_plugin_facepile']['enabled'] or $conf['fbp']['social_plugin_comments']['enabled']) |
---|
103 | { |
---|
104 | //~ add_event_handler('loc_begin_picture', 'fbp_loc_begin_picture'); |
---|
105 | add_event_handler('render_element_content', 'fbp_render_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL+1 /*in order to have picture content*/, 2); |
---|
106 | //~ add_event_handler('loc_end_picture', 'fbp_loc_end_picture'); |
---|
107 | add_event_handler('loc_end_section_init', 'ftp_loc_end_section_init'); |
---|
108 | } |
---|
109 | |
---|
110 | ?> |
---|