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

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

compatibility with Lightbox

File size: 4.0 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  if (!$element_info['is_gvideo'])
10  {
11    return $content;
12  }
13 
14  global $page, $picture, $template, $conf;
15 
16  $conf['gvideo'] = unserialize($conf['gvideo']);
17 
18  remove_event_handler('render_element_content', 'default_picture_content', EVENT_HANDLER_PRIORITY_NEUTRAL);
19 
20  $query = '
21SELECT *
22  FROM '.GVIDEO_TABLE.'
23  WHERE picture_id = '.$element_info['id'].'
24;';
25  $video = pwg_db_fetch_assoc(pwg_query($query));
26 
27  if (empty($video['width']))
28  {
29    $video['width'] = $conf['gvideo']['width'];
30    $video['height'] = $conf['gvideo']['height'];
31  }
32  if (empty($video['autoplay']))
33  {
34    $video['autoplay'] = $conf['gvideo']['autoplay'];
35  }
36 
37  $video['config'] = $conf['gvideo'];
38  if ($video['type'] == 'dailymotion')
39  {
40    $colors = array(
41      'F7FFFD' => 'foreground=%23F7FFFD&amp;highlight=%23FFC300&amp;background=%23171D1B',
42      'E02C72' => 'foreground=%23E02C72&amp;highlight=%23BF4B78&amp;background=%23260F18',
43      '92ADE0' => 'foreground=%2392ADE0&amp;highlight=%23A2ACBF&amp;background=%23202226',
44      'E8D9AC' => 'foreground=%23E8D9AC&amp;highlight=%23FFF6D9&amp;background=%23493D27',
45      'C2E165' => 'foreground=%23C2E165&amp;highlight=%23809443&amp;background=%23232912',
46      '052880' => 'foreground=%23FF0099&amp;highlight=%23C9A1FF&amp;background=%23052880',
47      'FF0000' => 'foreground=%23FF0000&amp;highlight=%23FFFFFF&amp;background=%23000000',
48      '834596' => 'foreground=%23834596&amp;highlight=%23CFCFCF&amp;background=%23000000',
49      );
50    $video['config']['dailymotion']['color'] = $colors[ $video['config']['dailymotion']['color'] ];
51  }
52  $template->assign('GVIDEO', $video);
53
54  $template->set_filename('gvideo_content', dirname(__FILE__).'/../template/video_'.$video['type'].'.tpl');
55  return $template->parse('gvideo_content', true);
56}
57
58/**
59 * clean table at element deletion
60 */
61function gvideo_delete_elements($ids)
62{
63  $query = '
64DELETE FROM '.GVIDEO_TABLE.'
65  WHERE picture_id IN ('.implode(',', $ids).')
66;';
67  pwg_query($query);
68}
69
70/**
71 * add message and link on edition page
72 */
73function gvideo_photo_edit()
74{
75  global $page, $template, $conf;
76 
77  if ($page['page'] != 'photo') return;
78 
79  $query = '
80SELECT *
81  FROM '.GVIDEO_TABLE.'
82  WHERE picture_id = '.$_GET['image_id'].'
83;';
84  $result = pwg_query($query);
85 
86  if (!pwg_db_num_rows($result)) return;
87   
88  $video = pwg_db_fetch_assoc($result);
89   
90  array_push($page['warnings'], l10n('This element is a video added with "Embedded Video"'));
91 
92  if (function_exists('imagecreatetruecolor'))
93  {
94    if (isset($_GET['add_film_frame']))
95    {
96      include_once(GVIDEO_PATH . '/include/functions.inc.php');
97      include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
98     
99      $image_infos = pwg_db_fetch_assoc(pwg_query('SELECT path, file FROM '.IMAGES_TABLE.' WHERE id = '.$_GET['image_id'].';'));
100      $thumb_source = $conf['data_location'].$image_infos['file'];
101     
102      add_film_frame($image_infos['path'], $thumb_source);
103      add_uploaded_file($thumb_source, $image_infos['file'], null, null, $_GET['image_id']);
104      $template->assign('TN_UPDATE', true);
105    }
106   
107    $admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
108    $admin_url_start = $admin_photo_base_url.'-properties';
109    $admin_url_start.= isset($_GET['cat_id']) ? '&amp;cat_id='.$_GET['cat_id'] : '';
110   
111    $template->assign('U_ADD_FILM_FRAME', $admin_url_start.'&amp;add_film_frame=1');
112    $template->set_prefilter('picture_modify', 'gvideo_photo_edit_prefilter');
113  }
114}
115
116function gvideo_photo_edit_prefilter($content)
117{
118  $search[0] = '{if !url_is_remote($PATH)}';
119  $replace[0] = '<li><a href="{$U_ADD_FILM_FRAME}" id="refresh_video">{\'Add film effect\'|@translate}</a></li>'.$search[0];
120 
121  $search[1] = '{$TN_SRC}';
122  $replace[1] = $search[1].'{if $TN_UPDATE}?'.time().'{/if}';
123 
124  return str_replace($search, $replace, $content);
125}
126
127?>
Note: See TracBrowser for help on using the repository browser.