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

Last change on this file since 22591 was 22591, checked in by ddtddt, 11 years ago

[extensions] - FacebookPlug - Checked compatibility with Piwigo 2.5

  • Property svn:eol-style set to LF
File size: 4.7 KB
RevLine 
[8275]1<?php
2// +-----------------------------------------------------------------------+
3// | FacebookPlug - a Piwigo Plugin                                        |
[8425]4// | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org                 |
[8275]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
[8386]26function fbp_blockmanager_register_blocks( $menu_ref_arr )
[8275]27{
[8386]28  global $conf;
[8275]29 
30  $menu = & $menu_ref_arr[0];
31  if ($menu->get_id() != 'menubar')
32    return;
[8386]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  }
[8275]42}
43
[8395]44function fbp_blockmanager_apply($menu_ref_arr)
[8275]45{
46  global $template;
47
48  $menu = & $menu_ref_arr[0];
[8386]49
50  foreach (array('mbFBP_activity_feed', 'mbFBP_like_box') as $mbFBPId)
[8275]51  {
[8386]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    }
[8275]57  }
58}
59
[8395]60function fbp_loc_begin_index()
61{
62  global $page;
[8275]63
[8395]64  set_make_full_url();
[8402]65  $page['fbp']['url'] = duplicate_index_url(array(''), array('start', 'flat', 'chronology_date', 'chronology_field', 'chronology_style', 'chronology_view'));
[8395]66  unset_make_full_url();
67}
68
69function fbp_loc_begin_index_category_thumbnails($categories)
70{
71  global $page;
72
[8420]73  $C = count($categories);
74  if ($C > 0)
[8395]75  {
76    include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
[8420]77    //~ $category = reset($categories);
78    $category = $categories[rand(0, $C-1)];
79    if (is_numeric($category['representative_picture_id']))
80    {
81      $query = '
[16246]82SELECT id, path
[8395]83FROM '.IMAGES_TABLE.'
84WHERE id = '.$category['representative_picture_id'].'
85;';
[8420]86      $result = pwg_query($query);
87      if($row = pwg_db_fetch_assoc($result))
88      {
89        set_make_full_url();
[8440]90        $page['fbp']['url_image'] = get_element_url($row);
[22577]91        $page['fbp']['url_thumbnail_image'] = DerivativeImage::thumb_url($row);
[8420]92        unset_make_full_url();
93      }
[8395]94    }
95  }
96}
97
98function fbp_loc_begin_index_thumbnails($pictures)
99{
100  global $page;
101
[8420]102  if (isset($page['category']['representative_picture_id']))
[8395]103  {
[8420]104    fbp_loc_begin_index_category_thumbnails(array($page['category']));
[8395]105  }
[8420]106  else
107  {
108    $C = count($pictures);
109    if ($C > 0)
110    {
111      include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
112      $picture = reset($pictures);
113      $picture = $pictures[rand(0, $C-1)];
114      set_make_full_url();
[8440]115      $page['fbp']['url_image'] = get_element_url($picture);
[22591]116      $page['fbp']['url_thumbnail_image'] = DerivativeImage::thumb_url($picture);
[8420]117      unset_make_full_url();
118    }
119  }
[8395]120}
121
[8386]122if ($conf['fbp']['social_plugin_activity_feed']['enabled'] or $conf['fbp']['social_plugin_like_box']['enabled'])
[8275]123{
124  add_event_handler('blockmanager_register_blocks', 'fbp_blockmanager_register_blocks', EVENT_HANDLER_PRIORITY_NEUTRAL);
[8395]125  add_event_handler('blockmanager_apply', 'fbp_blockmanager_apply');
[8275]126}
127
[8395]128add_event_handler('loc_begin_index', 'fbp_loc_begin_index');
129add_event_handler('loc_begin_index_category_thumbnails', 'fbp_loc_begin_index_category_thumbnails', EVENT_HANDLER_PRIORITY_NEUTRAL, 1);
130add_event_handler('loc_begin_index_thumbnails', 'fbp_loc_begin_index_thumbnails', EVENT_HANDLER_PRIORITY_NEUTRAL, 1);
131
[8436]132if ($conf['fbp']['share_album'])
133{
[8440]134  add_event_handler('loc_end_index', 'fbp_add_bar_button', EVENT_HANDLER_PRIORITY_NEUTRAL+1 /* In order to be on right */);
[8436]135}
136
[8275]137?>
Note: See TracBrowser for help on using the repository browser.