source: extensions/gvideo/include/events.inc.php @ 26524

Last change on this file since 26524 was 26524, checked in by mistic100, 10 years ago

add link in Admin Tools 'Edit' menu if available

File size: 3.5 KB
Line 
1<?php
2defined('GVIDEO_PATH') or die('Hacking attempt!');
3
4/**
5 * some stuff at the begining of picture.php
6 */
7function 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' => GVIDEO_ADMIN.'-photo&amp;image_id='.$picture['current']['id'],
26        ));
27
28      $template->set_prefilter('ato_public_controller', 'gvideo_admintools');
29    }
30  }
31 
32  return $picture;
33}
34
35function 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 */
51function 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 = '
66SELECT *
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&amp;highlight=%23FFC300&amp;background=%23171D1B',
87      'E02C72' => 'foreground=%23E02C72&amp;highlight=%23BF4B78&amp;background=%23260F18',
88      '92ADE0' => 'foreground=%2392ADE0&amp;highlight=%23A2ACBF&amp;background=%23202226',
89      'E8D9AC' => 'foreground=%23E8D9AC&amp;highlight=%23FFF6D9&amp;background=%23493D27',
90      'C2E165' => 'foreground=%23C2E165&amp;highlight=%23809443&amp;background=%23232912',
91      '052880' => 'foreground=%23FF0099&amp;highlight=%23C9A1FF&amp;background=%23052880',
92      'FF0000' => 'foreground=%23FF0000&amp;highlight=%23FFFFFF&amp;background=%23000000',
93      '834596' => 'foreground=%23834596&amp;highlight=%23CFCFCF&amp;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  $template->set_filename('gvideo_content', realpath(GVIDEO_PATH . 'template/video_'.$video['type'].'.tpl'));
108  return $template->parse('gvideo_content', true);
109}
110
111/**
112 * clean table at element deletion
113 */
114function gvideo_delete_elements($ids)
115{
116  $query = '
117DELETE FROM '.GVIDEO_TABLE.'
118  WHERE picture_id IN ('.implode(',', $ids).')
119;';
120  pwg_query($query);
121}
Note: See TracBrowser for help on using the repository browser.