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

Last change on this file since 17430 was 17383, checked in by mistic100, 12 years ago
  • simplify add page
  • simplify migration task
  • add option to add film effect on element edition page
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  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 and link on edition page
73 */
74function gvideo_photo_edit()
75{
76  global $page, $template, $conf;
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)) return;
88   
89  $video = pwg_db_fetch_assoc($result);
90   
91  array_push($page['warnings'], l10n('This element is a video added with "Embedded Video"'));
92 
93  if (function_exists('imagecreatetruecolor'))
94  {
95    if (isset($_GET['add_film_frame']))
96    {
97      include_once(GVIDEO_PATH . '/include/functions.inc.php');
98      include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
99     
100      $image_infos = pwg_db_fetch_assoc(pwg_query('SELECT path, file FROM '.IMAGES_TABLE.' WHERE id = '.$_GET['image_id'].';'));
101      $thumb_source = $conf['data_location'].$image_infos['file'];
102     
103      add_film_frame($image_infos['path'], $thumb_source);
104      add_uploaded_file($thumb_source, $image_infos['file'], null, null, $_GET['image_id']);
105      $template->assign('TN_UPDATE', true);
106    }
107   
108    $admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
109    $admin_url_start = $admin_photo_base_url.'-properties';
110    $admin_url_start.= isset($_GET['cat_id']) ? '&amp;cat_id='.$_GET['cat_id'] : '';
111   
112    $template->assign('U_ADD_FILM_FRAME', $admin_url_start.'&amp;add_film_frame=1');
113    $template->set_prefilter('picture_modify', 'gvideo_photo_edit_prefilter');
114  }
115}
116
117function gvideo_photo_edit_prefilter($content)
118{
119  $search[0] = '{if !url_is_remote($PATH)}';
120  $replace[0] = '<li><a href="{$U_ADD_FILM_FRAME}" id="refresh_video">{\'Add film effect\'|@translate}</a></li>'.$search[0];
121 
122  $search[1] = '{$TN_SRC}';
123  $replace[1] = $search[1].'{if $TN_UPDATE}?'.time().'{/if}';
124 
125  return str_replace($search, $replace, $content);
126}
127
128?>
Note: See TracBrowser for help on using the repository browser.