source: extensions/FacebookPlug/Plugin/include/index.inc.php @ 8436

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

Add share icon on picture and album page

Rename footer.lang.php to common.lang.php
Remove use of target to open a new window

  • Property svn:eol-style set to LF
File size: 4.8 KB
Line 
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
21if (!defined('PHPWG_ROOT_PATH'))
22{
23  die('Hacking attempt!');
24}
25
26function fbp_blockmanager_register_blocks( $menu_ref_arr )
27{
28  global $conf;
29 
30  $menu = & $menu_ref_arr[0];
31  if ($menu->get_id() != 'menubar')
32    return;
33
34  if ($conf['fbp']['social_plugin_activity_feed']['enabled'])
35  {
36    $menu->register_block(new RegisteredBlock('mbFBP_activity_feed', 'social.plugin.activity.feed', 'FacebookPlug'));
37  }
38  if ($conf['fbp']['social_plugin_like_box']['enabled'])
39  {
40    $menu->register_block(new RegisteredBlock('mbFBP_like_box', 'social.plugin.like.box', 'FacebookPlug'));
41  }
42}
43
44function fbp_blockmanager_apply($menu_ref_arr)
45{
46  global $template;
47
48  $menu = & $menu_ref_arr[0];
49
50  foreach (array('mbFBP_activity_feed', 'mbFBP_like_box') as $mbFBPId)
51  {
52    if ($block = $menu->get_block($mbFBPId))
53    {
54      $template->set_template_dir(FBP_DIR.'/tpl/');
55      $block->template = $block->get_block()->get_name().'.tpl';
56    }
57  }
58}
59
60function fbp_loc_begin_index()
61{
62  global $page;
63
64  set_make_full_url();
65  $page['fbp']['url'] = duplicate_index_url(array(''), array('start', 'flat', 'chronology_date', 'chronology_field', 'chronology_style', 'chronology_view'));
66  unset_make_full_url();
67}
68
69function fbp_loc_begin_index_category_thumbnails($categories)
70{
71  global $page;
72
73  $C = count($categories);
74  if ($C > 0)
75  {
76    include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
77    //~ $category = reset($categories);
78    $category = $categories[rand(0, $C-1)];
79    if (is_numeric($category['representative_picture_id']))
80    {
81      $query = '
82SELECT id, path, tn_ext
83FROM '.IMAGES_TABLE.'
84WHERE id = '.$category['representative_picture_id'].'
85;';
86      $result = pwg_query($query);
87      if($row = pwg_db_fetch_assoc($result))
88      {
89        set_make_full_url();
90        $page['fbp']['url_image'] = get_thumbnail_url($row);
91        unset_make_full_url();
92      }
93    }
94  }
95}
96
97function fbp_loc_begin_index_thumbnails($pictures)
98{
99  global $page;
100
101  if (isset($page['category']['representative_picture_id']))
102  {
103    fbp_loc_begin_index_category_thumbnails(array($page['category']));
104  }
105  else
106  {
107    $C = count($pictures);
108    if ($C > 0)
109    {
110      include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
111      $picture = reset($pictures);
112      $picture = $pictures[rand(0, $C-1)];
113      set_make_full_url();
114      $page['fbp']['url_image'] = get_thumbnail_url($picture);
115      unset_make_full_url();
116    }
117  }
118}
119
120function fbp_loc_end_index()
121{
122  global $template;
123
124  $template->assign('FBP_SHARE_LI', true);
125
126  $tpl = 'share';
127  $template->set_filename('fbp_'.$tpl, FBP_DIR.'/tpl/'.$tpl.'.tpl');
128  $template->concat(
129        'PLUGIN_INDEX_ACTIONS',
130        $template->parse('fbp_'.$tpl, true)
131        );
132}
133
134if ($conf['fbp']['social_plugin_activity_feed']['enabled'] or $conf['fbp']['social_plugin_like_box']['enabled'])
135{
136  add_event_handler('blockmanager_register_blocks', 'fbp_blockmanager_register_blocks', EVENT_HANDLER_PRIORITY_NEUTRAL);
137  add_event_handler('blockmanager_apply', 'fbp_blockmanager_apply');
138}
139
140add_event_handler('loc_begin_index', 'fbp_loc_begin_index');
141add_event_handler('loc_begin_index_category_thumbnails', 'fbp_loc_begin_index_category_thumbnails', EVENT_HANDLER_PRIORITY_NEUTRAL, 1);
142add_event_handler('loc_begin_index_thumbnails', 'fbp_loc_begin_index_thumbnails', EVENT_HANDLER_PRIORITY_NEUTRAL, 1);
143
144if ($conf['fbp']['share_album'])
145{
146  add_event_handler('loc_end_index', 'fbp_loc_end_index', EVENT_HANDLER_PRIORITY_NEUTRAL+999 /* In order to be last*/);
147}
148
149?>
Note: See TracBrowser for help on using the repository browser.