1 | <?php |
---|
2 | defined('GVIDEO_PATH') or 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 | // add custom parser |
---|
15 | add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2); |
---|
16 | |
---|
17 | if (defined('ADMINTOOLS_ID')) |
---|
18 | { |
---|
19 | global $template; |
---|
20 | |
---|
21 | load_language('plugin.lang', GVIDEO_PATH); |
---|
22 | |
---|
23 | $template->assign(array( |
---|
24 | 'GVIDEO_PATH' => GVIDEO_PATH, |
---|
25 | 'U_GVIDEO_EDIT' => get_root_url().GVIDEO_ADMIN.'-photo&image_id='.$picture['current']['id'], |
---|
26 | )); |
---|
27 | |
---|
28 | $template->set_prefilter('ato_public_controller', 'gvideo_admintools'); |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | return $picture; |
---|
33 | } |
---|
34 | |
---|
35 | function gvideo_admintools($content) |
---|
36 | { |
---|
37 | $search = '{if isset($ato.U_DELETE)}'; |
---|
38 | $replace = ' |
---|
39 | {if isset($U_GVIDEO_EDIT)} |
---|
40 | {combine_css path=$GVIDEO_PATH|cat:\'template/fontello/css/gvideo.css\'} |
---|
41 | <li><a class="icon-gvideo-movie" href="{$U_GVIDEO_EDIT}">{\'Video properties\'|translate}</a></li> |
---|
42 | {/if} |
---|
43 | {if isset($ato.U_DELETE)}'; |
---|
44 | |
---|
45 | return str_replace($search, $replace, $content); |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * replace content on picture page |
---|
50 | */ |
---|
51 | function gvideo_element_content($content, $element_info) |
---|
52 | { |
---|
53 | if (!$element_info['is_gvideo']) |
---|
54 | { |
---|
55 | return $content; |
---|
56 | } |
---|
57 | |
---|
58 | global $page, $picture, $template, $conf; |
---|
59 | |
---|
60 | // remove some actions |
---|
61 | $template->assign('U_SLIDESHOW_START', null); |
---|
62 | $template->assign('U_METADATA', null); |
---|
63 | $template->append('current', array('U_DOWNLOAD' => null), true); |
---|
64 | |
---|
65 | $query = ' |
---|
66 | SELECT * |
---|
67 | FROM '.GVIDEO_TABLE.' |
---|
68 | WHERE picture_id = '.$element_info['id'].' |
---|
69 | ;'; |
---|
70 | $video = pwg_db_fetch_assoc(pwg_query($query)); |
---|
71 | |
---|
72 | if (empty($video['width'])) |
---|
73 | { |
---|
74 | $video['width'] = $conf['gvideo']['width']; |
---|
75 | $video['height'] = $conf['gvideo']['height']; |
---|
76 | } |
---|
77 | if (empty($video['autoplay'])) |
---|
78 | { |
---|
79 | $video['autoplay'] = $conf['gvideo']['autoplay']; |
---|
80 | } |
---|
81 | |
---|
82 | $video['config'] = $conf['gvideo']; |
---|
83 | if ($video['type'] == 'dailymotion') |
---|
84 | { |
---|
85 | $colors = array( |
---|
86 | 'F7FFFD' => 'foreground=%23F7FFFD&highlight=%23FFC300&background=%23171D1B', |
---|
87 | 'E02C72' => 'foreground=%23E02C72&highlight=%23BF4B78&background=%23260F18', |
---|
88 | '92ADE0' => 'foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226', |
---|
89 | 'E8D9AC' => 'foreground=%23E8D9AC&highlight=%23FFF6D9&background=%23493D27', |
---|
90 | 'C2E165' => 'foreground=%23C2E165&highlight=%23809443&background=%23232912', |
---|
91 | '052880' => 'foreground=%23FF0099&highlight=%23C9A1FF&background=%23052880', |
---|
92 | 'FF0000' => 'foreground=%23FF0000&highlight=%23FFFFFF&background=%23000000', |
---|
93 | '834596' => 'foreground=%23834596&highlight=%23CFCFCF&background=%23000000', |
---|
94 | ); |
---|
95 | $video['config']['dailymotion']['color'] = $colors[ $video['config']['dailymotion']['color'] ]; |
---|
96 | } |
---|
97 | |
---|
98 | $template->assign('GVIDEO', $video); |
---|
99 | |
---|
100 | global $user; |
---|
101 | // hide stripped overlay preventing to click on video object |
---|
102 | if (strpos('stripped', $user['theme']) !== false) |
---|
103 | { |
---|
104 | $template->block_html_style(null, '.hideTabs{ display:none !important; }'); |
---|
105 | } |
---|
106 | |
---|
107 | if ($video['type'] == 'embed') |
---|
108 | { |
---|
109 | return $video['embed']; |
---|
110 | } |
---|
111 | else |
---|
112 | { |
---|
113 | $template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'template/video_'.$video['type'].'.tpl')); |
---|
114 | return $template->parse('gvideo_content', true); |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * clean table at element deletion |
---|
120 | */ |
---|
121 | function gvideo_delete_elements($ids) |
---|
122 | { |
---|
123 | $query = ' |
---|
124 | DELETE FROM '.GVIDEO_TABLE.' |
---|
125 | WHERE picture_id IN ('.implode(',', $ids).') |
---|
126 | ;'; |
---|
127 | pwg_query($query); |
---|
128 | } |
---|
129 | |
---|
130 | /** |
---|
131 | * add a prefilter to the Batch Downloader |
---|
132 | */ |
---|
133 | function gvideo_add_prefilter($prefilters) |
---|
134 | { |
---|
135 | $prefilters[] = array( |
---|
136 | 'ID' => 'gvideo', |
---|
137 | 'NAME' => l10n('Videos'), |
---|
138 | ); |
---|
139 | |
---|
140 | return $prefilters; |
---|
141 | } |
---|
142 | |
---|
143 | /** |
---|
144 | * perform added prefilter |
---|
145 | */ |
---|
146 | function gvideo_apply_prefilter($filter_sets, $prefilter) |
---|
147 | { |
---|
148 | if ($prefilter == 'gvideo') |
---|
149 | { |
---|
150 | $query = 'SELECT picture_id FROM '.GVIDEO_TABLE.';'; |
---|
151 | $filter_sets[] = query2array($query, null, 'picture_id'); |
---|
152 | } |
---|
153 | |
---|
154 | return $filter_sets; |
---|
155 | } |
---|