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

Last change on this file since 20804 was 20804, checked in by mistic100, 11 years ago
  • add support for semi-private Vimeo videos
  • escape tags
  • compatible with safe_mode=On
  • deactivate autosize
File size: 3.8 KB
Line 
1<?php
2if (!defined('GVIDEO_PATH')) 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    // remove autosize
15    global $pwg_loaded_plugins, $autosize_ctrl;
16   
17    if ( isset($pwg_loaded_plugins['Autosize']) and isset($autosize_ctrl) )
18    {
19      remove_event_handler('render_element_content', array(&$autosize_ctrl, 'autosize_calcContent'), EVENT_HANDLER_PRIORITY_NEUTRAL-11, 2); 
20      remove_event_handler('render_element_content', array(&$autosize_ctrl, 'init_1'), EVENT_HANDLER_PRIORITY_NEUTRAL-9, 2); 
21      remove_event_handler('render_element_content', array(&$autosize_ctrl, 'init'), EVENT_HANDLER_PRIORITY_NEUTRAL-1, 2);
22      remove_event_handler('render_element_content', array(&$autosize_ctrl, 'init2'), EVENT_HANDLER_PRIORITY_NEUTRAL+1, 2);
23      remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_1'));
24      remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_2'));
25      remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_3'));
26      remove_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_affiche'), EVENT_HANDLER_PRIORITY_NEUTRAL+21);
27    }
28  }
29 
30  return $picture;
31}
32
33/**
34 * replace content on picture page
35 */
36function gvideo_element_content($content, $element_info)
37{
38  if (!$element_info['is_gvideo'])
39  {
40    return $content;
41  }
42 
43  global $page, $picture, $template, $conf;
44 
45  if (is_string($conf['gvideo']))
46  {
47    $conf['gvideo'] = unserialize($conf['gvideo']);
48  }
49 
50  // remove some actions
51  $template->assign('U_SLIDESHOW_START', null);
52  $template->assign('U_METADATA', null);
53  $template->append('current', array('U_DOWNLOAD' => null), true);
54 
55  $query = '
56SELECT *
57  FROM '.GVIDEO_TABLE.'
58  WHERE picture_id = '.$element_info['id'].'
59;';
60  $video = pwg_db_fetch_assoc(pwg_query($query));
61 
62  if (empty($video['width']))
63  {
64    $video['width'] = $conf['gvideo']['width'];
65    $video['height'] = $conf['gvideo']['height'];
66  }
67  if (empty($video['autoplay']))
68  {
69    $video['autoplay'] = $conf['gvideo']['autoplay'];
70  }
71 
72  $video['config'] = $conf['gvideo'];
73  if ($video['type'] == 'dailymotion')
74  {
75    $colors = array(
76      'F7FFFD' => 'foreground=%23F7FFFD&amp;highlight=%23FFC300&amp;background=%23171D1B',
77      'E02C72' => 'foreground=%23E02C72&amp;highlight=%23BF4B78&amp;background=%23260F18',
78      '92ADE0' => 'foreground=%2392ADE0&amp;highlight=%23A2ACBF&amp;background=%23202226',
79      'E8D9AC' => 'foreground=%23E8D9AC&amp;highlight=%23FFF6D9&amp;background=%23493D27',
80      'C2E165' => 'foreground=%23C2E165&amp;highlight=%23809443&amp;background=%23232912',
81      '052880' => 'foreground=%23FF0099&amp;highlight=%23C9A1FF&amp;background=%23052880',
82      'FF0000' => 'foreground=%23FF0000&amp;highlight=%23FFFFFF&amp;background=%23000000',
83      '834596' => 'foreground=%23834596&amp;highlight=%23CFCFCF&amp;background=%23000000',
84      );
85    $video['config']['dailymotion']['color'] = $colors[ $video['config']['dailymotion']['color'] ];
86  }
87 
88  $template->assign('GVIDEO', $video);
89 
90  global $user;
91  if (strpos('stripped', $user['theme']) !== false)
92  {
93    $template->append('head_elements', '<style type="text/css">.hideTabs{display:none;}</style>');
94  }
95
96  $template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'template/video_'.$video['type'].'.tpl'));
97  return $template->parse('gvideo_content', true);
98}
99
100/**
101 * clean table at element deletion
102 */
103function gvideo_delete_elements($ids)
104{
105  $query = '
106DELETE FROM '.GVIDEO_TABLE.'
107  WHERE picture_id IN ('.implode(',', $ids).')
108;';
109  pwg_query($query);
110}
111
112?>
Note: See TracBrowser for help on using the repository browser.