1 | <?php |
---|
2 | if (!defined('GVIDEO_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | /** |
---|
5 | * some stuff at the begining of picture.php |
---|
6 | */ |
---|
7 | function 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_controler; |
---|
16 | |
---|
17 | if ( isset($pwg_loaded_plugins['Autosize']) and isset($autosize_controler) ) |
---|
18 | { |
---|
19 | remove_event_handler('render_element_content', array(&$autosize_controler, 'init'), EVENT_HANDLER_PRIORITY_NEUTRAL); |
---|
20 | remove_event_handler('render_element_content', array(&$autosize_controler, 'autosize_calcContent'), 40); |
---|
21 | remove_event_handler('loc_after_page_header', array(&$autosize_controler, 'cl_autosize_script_1'), EVENT_HANDLER_PRIORITY_NEUTRAL); |
---|
22 | remove_event_handler('loc_after_page_header', array(&$autosize_controler, 'cl_autosize_script_2'), EVENT_HANDLER_PRIORITY_NEUTRAL); |
---|
23 | remove_event_handler('loc_after_page_header', array(&$autosize_controler, 'cl_autosize_script_3'), EVENT_HANDLER_PRIORITY_NEUTRAL); |
---|
24 | remove_event_handler('loc_after_page_header', array(&$autosize_controler, 'cl_autosize_affiche'), EVENT_HANDLER_PRIORITY_NEUTRAL+21); |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | return $picture; |
---|
29 | } |
---|
30 | |
---|
31 | /** |
---|
32 | * replace content on picture page |
---|
33 | */ |
---|
34 | function gvideo_element_content($content, $element_info) |
---|
35 | { |
---|
36 | if (!$element_info['is_gvideo']) |
---|
37 | { |
---|
38 | return $content; |
---|
39 | } |
---|
40 | |
---|
41 | global $page, $picture, $template, $conf; |
---|
42 | |
---|
43 | if (is_string($conf['gvideo'])) |
---|
44 | { |
---|
45 | $conf['gvideo'] = unserialize($conf['gvideo']); |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | $query = ' |
---|
50 | SELECT * |
---|
51 | FROM '.GVIDEO_TABLE.' |
---|
52 | WHERE picture_id = '.$element_info['id'].' |
---|
53 | ;'; |
---|
54 | $video = pwg_db_fetch_assoc(pwg_query($query)); |
---|
55 | |
---|
56 | if (empty($video['width'])) |
---|
57 | { |
---|
58 | $video['width'] = $conf['gvideo']['width']; |
---|
59 | $video['height'] = $conf['gvideo']['height']; |
---|
60 | } |
---|
61 | if (empty($video['autoplay'])) |
---|
62 | { |
---|
63 | $video['autoplay'] = $conf['gvideo']['autoplay']; |
---|
64 | } |
---|
65 | |
---|
66 | $video['config'] = $conf['gvideo']; |
---|
67 | if ($video['type'] == 'dailymotion') |
---|
68 | { |
---|
69 | $colors = array( |
---|
70 | 'F7FFFD' => 'foreground=%23F7FFFD&highlight=%23FFC300&background=%23171D1B', |
---|
71 | 'E02C72' => 'foreground=%23E02C72&highlight=%23BF4B78&background=%23260F18', |
---|
72 | '92ADE0' => 'foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226', |
---|
73 | 'E8D9AC' => 'foreground=%23E8D9AC&highlight=%23FFF6D9&background=%23493D27', |
---|
74 | 'C2E165' => 'foreground=%23C2E165&highlight=%23809443&background=%23232912', |
---|
75 | '052880' => 'foreground=%23FF0099&highlight=%23C9A1FF&background=%23052880', |
---|
76 | 'FF0000' => 'foreground=%23FF0000&highlight=%23FFFFFF&background=%23000000', |
---|
77 | '834596' => 'foreground=%23834596&highlight=%23CFCFCF&background=%23000000', |
---|
78 | ); |
---|
79 | $video['config']['dailymotion']['color'] = $colors[ $video['config']['dailymotion']['color'] ]; |
---|
80 | } |
---|
81 | |
---|
82 | $template->assign('GVIDEO', $video); |
---|
83 | |
---|
84 | global $user; |
---|
85 | if (strpos('stripped', $user['theme']) !== false) |
---|
86 | { |
---|
87 | $template->append('head_elements', '<style type="text/css">.hideTabs{display:none;}</style>'); |
---|
88 | } |
---|
89 | |
---|
90 | $template->set_filename('gvideo_content', dirname(__FILE__).'/../template/video_'.$video['type'].'.tpl'); |
---|
91 | return $template->parse('gvideo_content', true); |
---|
92 | } |
---|
93 | |
---|
94 | /** |
---|
95 | * clean table at element deletion |
---|
96 | */ |
---|
97 | function gvideo_delete_elements($ids) |
---|
98 | { |
---|
99 | $query = ' |
---|
100 | DELETE FROM '.GVIDEO_TABLE.' |
---|
101 | WHERE picture_id IN ('.implode(',', $ids).') |
---|
102 | ;'; |
---|
103 | pwg_query($query); |
---|
104 | } |
---|
105 | |
---|
106 | ?> |
---|