source: extensions/gvideo/include/events.inc.php @ 26470

Last change on this file since 26470 was 26470, checked in by mistic100, 10 years ago

Update for Piwigo 2.6
TODO: button on Admin Tools bar

File size: 2.8 KB
Line 
1<?php
2defined('GVIDEO_PATH') or die('Hacking attempt!');
3
4/**
5 * some stuff at the begining of picture.php
6 */
7function gvideo_prepare_picture($picture)
8{
9  if ($picture['current']['is_gvideo'])
10  {
11    // remove default parser
12    remove_event_handler('render_element_content', 'default_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL);
13   
14    // add custom parser
15    add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
16  }
17 
18  return $picture;
19}
20
21/**
22 * replace content on picture page
23 */
24function gvideo_element_content($content, $element_info)
25{
26  if (!$element_info['is_gvideo'])
27  {
28    return $content;
29  }
30 
31  global $page, $picture, $template, $conf;
32 
33  // remove some actions
34  $template->assign('U_SLIDESHOW_START', null);
35  $template->assign('U_METADATA', null);
36  $template->append('current', array('U_DOWNLOAD' => null), true);
37 
38  $query = '
39SELECT *
40  FROM '.GVIDEO_TABLE.'
41  WHERE picture_id = '.$element_info['id'].'
42;';
43  $video = pwg_db_fetch_assoc(pwg_query($query));
44 
45  if (empty($video['width']))
46  {
47    $video['width'] = $conf['gvideo']['width'];
48    $video['height'] = $conf['gvideo']['height'];
49  }
50  if (empty($video['autoplay']))
51  {
52    $video['autoplay'] = $conf['gvideo']['autoplay'];
53  }
54 
55  $video['config'] = $conf['gvideo'];
56  if ($video['type'] == 'dailymotion')
57  {
58    $colors = array(
59      'F7FFFD' => 'foreground=%23F7FFFD&amp;highlight=%23FFC300&amp;background=%23171D1B',
60      'E02C72' => 'foreground=%23E02C72&amp;highlight=%23BF4B78&amp;background=%23260F18',
61      '92ADE0' => 'foreground=%2392ADE0&amp;highlight=%23A2ACBF&amp;background=%23202226',
62      'E8D9AC' => 'foreground=%23E8D9AC&amp;highlight=%23FFF6D9&amp;background=%23493D27',
63      'C2E165' => 'foreground=%23C2E165&amp;highlight=%23809443&amp;background=%23232912',
64      '052880' => 'foreground=%23FF0099&amp;highlight=%23C9A1FF&amp;background=%23052880',
65      'FF0000' => 'foreground=%23FF0000&amp;highlight=%23FFFFFF&amp;background=%23000000',
66      '834596' => 'foreground=%23834596&amp;highlight=%23CFCFCF&amp;background=%23000000',
67      );
68    $video['config']['dailymotion']['color'] = $colors[ $video['config']['dailymotion']['color'] ];
69  }
70 
71  $template->assign('GVIDEO', $video);
72 
73  global $user;
74  // hide stripped overlay preventing to click on video object
75  if (strpos('stripped', $user['theme']) !== false)
76  {
77    $template->block_html_style(null, '.hideTabs{ display:none !important; }');
78  }
79
80  $template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'template/video_'.$video['type'].'.tpl'));
81  return $template->parse('gvideo_content', true);
82}
83
84/**
85 * clean table at element deletion
86 */
87function gvideo_delete_elements($ids)
88{
89  $query = '
90DELETE FROM '.GVIDEO_TABLE.'
91  WHERE picture_id IN ('.implode(',', $ids).')
92;';
93  pwg_query($query);
94}
Note: See TracBrowser for help on using the repository browser.