source: extensions/gvideo/include/gvideo.inc.php @ 17307

Last change on this file since 17307 was 17307, checked in by mistic100, 12 years ago

new version for Piwigo 2.4 (renamed into 'Embedded Videos')

File size: 2.5 KB
Line 
1<?php
2if (!defined('GVIDEO_PATH')) die('Hacking attempt!');
3
4/**
5 * replace content on picture page
6 */
7function gvideo_element_content($content, $element_info)
8{
9  global $page, $picture, $template, $conf;
10 
11  $query = '
12SELECT *
13  FROM '.GVIDEO_TABLE.'
14  WHERE picture_id = '.$element_info['id'].'
15;';
16  $result = pwg_query($query);
17 
18  if (!pwg_db_num_rows($result))
19  {
20    return $content;
21  }
22 
23  remove_event_handler('render_element_content', 'default_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL);
24 
25  $conf['gvideo'] = unserialize($conf['gvideo']);
26 
27  $video = pwg_db_fetch_assoc($result); 
28  if (empty($video['width']))
29  {
30    $video['width'] = $conf['gvideo']['width'];
31    $video['height'] = $conf['gvideo']['height'];
32  }
33  if (empty($video['autoplay']))
34  {
35    $video['autoplay'] = $conf['gvideo']['autoplay'];
36  }
37 
38  $video['config'] = $conf['gvideo'];
39  if ($video['type'] == 'dailymotion')
40  {
41    $colors = array(
42      'F7FFFD' => 'foreground=%23F7FFFD&amp;highlight=%23FFC300&amp;background=%23171D1B',
43      'E02C72' => 'foreground=%23E02C72&amp;highlight=%23BF4B78&amp;background=%23260F18',
44      '92ADE0' => 'foreground=%2392ADE0&amp;highlight=%23A2ACBF&amp;background=%23202226',
45      'E8D9AC' => 'foreground=%23E8D9AC&amp;highlight=%23FFF6D9&amp;background=%23493D27',
46      'C2E165' => 'foreground=%23C2E165&amp;highlight=%23809443&amp;background=%23232912',
47      '052880' => 'foreground=%23FF0099&amp;highlight=%23C9A1FF&amp;background=%23052880',
48      'FF0000' => 'foreground=%23FF0000&amp;highlight=%23FFFFFF&amp;background=%23000000',
49      '834596' => 'foreground=%23834596&amp;highlight=%23CFCFCF&amp;background=%23000000',
50      );
51    $video['config']['dailymotion']['color'] = $colors[ $video['config']['dailymotion']['color'] ];
52  }
53  $template->assign('GVIDEO', $video);
54
55  $template->set_filename('gvideo_content', dirname(__FILE__).'/../template/video_'.$video['type'].'.tpl');
56  return $template->parse('gvideo_content', true);
57}
58
59/**
60 * clean table at element deletion
61 */
62function gvideo_delete_elements($ids)
63{
64  $query = '
65DELETE FROM '.GVIDEO_TABLE.'
66  WHERE picture_id IN ('.implode(',', $ids).')
67;';
68  pwg_query($query);
69}
70
71/**
72 * add message on edition page
73 */
74function gvideo_photo_edit()
75{
76  global $page;
77 
78  if ($page['page'] != 'photo') return;
79 
80  $query = '
81SELECT *
82  FROM '.GVIDEO_TABLE.'
83  WHERE picture_id = '.$_GET['image_id'].'
84;';
85  $result = pwg_query($query);
86 
87  if (pwg_db_num_rows($result))
88  {
89    array_push($page['warnings'], l10n('This element is a video added with "Embedded Video"'));
90  }
91}
92
93?>
Note: See TracBrowser for help on using the repository browser.