1 | <?php |
---|
2 | if (!defined('GVIDEO_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | /** |
---|
5 | * replace content on picture page |
---|
6 | */ |
---|
7 | function gvideo_element_content($content, $element_info) |
---|
8 | { |
---|
9 | global $page, $picture, $template, $conf; |
---|
10 | |
---|
11 | $query = ' |
---|
12 | SELECT * |
---|
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&highlight=%23FFC300&background=%23171D1B', |
---|
43 | 'E02C72' => 'foreground=%23E02C72&highlight=%23BF4B78&background=%23260F18', |
---|
44 | '92ADE0' => 'foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226', |
---|
45 | 'E8D9AC' => 'foreground=%23E8D9AC&highlight=%23FFF6D9&background=%23493D27', |
---|
46 | 'C2E165' => 'foreground=%23C2E165&highlight=%23809443&background=%23232912', |
---|
47 | '052880' => 'foreground=%23FF0099&highlight=%23C9A1FF&background=%23052880', |
---|
48 | 'FF0000' => 'foreground=%23FF0000&highlight=%23FFFFFF&background=%23000000', |
---|
49 | '834596' => 'foreground=%23834596&highlight=%23CFCFCF&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 | */ |
---|
62 | function gvideo_delete_elements($ids) |
---|
63 | { |
---|
64 | $query = ' |
---|
65 | DELETE 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 | */ |
---|
74 | function gvideo_photo_edit() |
---|
75 | { |
---|
76 | global $page, $template, $conf; |
---|
77 | |
---|
78 | if ($page['page'] != 'photo') return; |
---|
79 | |
---|
80 | $query = ' |
---|
81 | SELECT * |
---|
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']) ? '&cat_id='.$_GET['cat_id'] : ''; |
---|
111 | |
---|
112 | $template->assign('U_ADD_FILM_FRAME', $admin_url_start.'&add_film_frame=1'); |
---|
113 | $template->set_prefilter('picture_modify', 'gvideo_photo_edit_prefilter'); |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | function 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 | ?> |
---|