source: extensions/FacebookPlug/Plugin/include/picture.inc.php @ 8275

Last change on this file since 8275 was 8275, checked in by rub, 13 years ago

Add css
Fix translations
Finish like box integration

  • Property svn:eol-style set to LF
File size: 5.0 KB
Line 
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
21if (!defined('PHPWG_ROOT_PATH'))
22{
23  die('Hacking attempt!');
24}
25
26include_once(FBP_DIR.'/include/common.inc.php');
27include_once(FBP_DIR.'/include/header.inc.php');
28
29/*function fbp_header($content, &$smarty)
30{
31  global $conf;
32
33  // replace tag html
34  $search = '<html ';
35  $replacement = '<html xmlns:fb="http://www.facebook.com/2008/fbml" ';
36
37  //~ $content = preg_replace('#'.$search.'#', $replacement, $content);
38  return preg_replace('#'.$search.'#', $replacement, $content);
39  //~ $fbp_content = file_get_contents(FBP_DIR.'/tpl/init.fb.tpl');
40
41  $search = '<div id="the_page">';
42  return preg_replace('#'.$search.'#', $fbp_content.$search, $content);
43}*/
44
45/*function fbp_loc_begin_picture()
46{
47  global $template, $user, $page, $conf, $picture;
48
49  // set prefilter
50  $template->set_prefilter('header', 'fbp_header');
51
52  $template->assign('FACEBOOK_APP_ID', FACEBOOK_APP_ID);
53  // define language
54  $template->assign('LANGUAGE', $user['language']);
55  $template->assign('fbp', $conf['fbp']);
56  $template->smarty->register_modifier('boolean_to_string', 'boolean_to_string');
57
58  $template->set_filename('init.fb', FBP_DIR.'/tpl/init.fb.tpl');
59  $template->append('head_elements', $template->parse('init.fb', true));
60}*/
61
62function fbp_render_element_content($content, $current_picture)
63{
64  global $template, $user, $page, $conf, $picture;
65
66  if ($page['slideshow'])
67  {
68    // nothing to do on slideshow other media aren't usable
69    return $content;
70  }
71
72  // define picture FB link
73  // Always use full url for FB social plugin
74  set_make_full_url();
75  if ($conf['fbp']['social_plugin_like_button']['url_type'] == 'image')
76  {
77    $fbp_url_picture = get_element_url($current_picture);
78  }
79  else
80  {
81    $fbp_url_picture = make_picture_url(array('image_id' => $page['image_id']));
82  }
83  unset_make_full_url();
84  $template->assign('fbp_url_picture', $fbp_url_picture);
85
86  // XFBML implementation
87  //~ $content .= '
88//~ <div id="fb-xfbml">';
89  if ($conf['fbp']['social_plugin_like_button']['enabled'])
90  {
91    //~ $content .= '
92//~ <div id="fb-xfbml">
93//~ <fb:like href="'.$fbp_url_picture.'" layout="'.$conf['fbp']['social_plugin_like_button']['layout'].'" show_faces="'.boolean_to_string($conf['fbp']['social_plugin_like_button']['show_faces']).'" width="'.@$current_picture['scaled_width'].'" action="'.$conf['fbp']['social_plugin_like_button']['action'].'" colorscheme="'.$conf['fbp']['social_plugin_like_button']['colorscheme'].'"></fb:like>
94//~ </div>';
95    $template->set_filename('social.plugin.like.button', FBP_DIR.'/tpl/social.plugin.like.button.tpl');
96    $content .= $template->parse('social.plugin.like.button', true);
97  }
98
99  return $content;
100}
101
102function ftp_loc_end_section_init()
103{
104  global $conf;
105
106  if ($conf['fbp']['social_plugin_like_button']['enabled'])
107  {
108    if ($conf['fbp']['allow_fb_access_private_page'])
109    {
110      global $user, $page;
111
112      // No restristion for facebook user
113      if (preg_match('/'.FBP_IP_FB. '/', $_SERVER["REMOTE_ADDR"]))
114      {
115        //Allow guest access
116        $conf['guest_access'] = true;
117        // No forbidden categorie
118        $user['forbidden_categories'] = '';
119        $user['level'] = max($conf['available_permission_levels']);
120        $page['rank_of'][$page['image_id']] = 0;
121        $page['items'] = array_flip($page['rank_of']);
122      }
123    }
124  }
125}
126
127if ($conf['fbp']['social_plugin_like_button']['enabled'])
128{
129  //~ add_event_handler('loc_begin_picture', 'fbp_loc_begin_picture');
130  add_event_handler('render_element_content', 'fbp_render_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL+1 /*in order to have picture content*/, 2);
131  //~ add_event_handler('loc_end_picture', 'fbp_loc_end_picture');
132  add_event_handler('loc_end_section_init', 'ftp_loc_end_section_init');
133}
134
135?>
Note: See TracBrowser for help on using the repository browser.