source: extensions/gvideo/main.inc.php @ 19056

Last change on this file since 19056 was 19056, checked in by mistic100, 11 years ago

allow to add private dailymotion videos, remove videobb support, add tags support

File size: 2.7 KB
Line 
1<?php 
2/*
3Plugin Name: Embedded Videos
4Version: auto
5Description: Add videos from Dailymotion, Youtube, Vimeo, Wideo, videobb and Wat.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=136
7Author: Mistic & P@t
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14
15define('GVIDEO_PATH',    PHPWG_PLUGINS_PATH . 'gvideo/');
16define('GVIDEO_ADMIN',   get_root_url() . 'admin.php?page=plugin-gvideo');
17define('GVIDEO_TABLE',   $prefixeTable.'image_video');
18define('GVIDEO_VERSION', 'auto');
19
20
21add_event_handler('init', 'gvideo_init');
22add_event_handler('picture_pictures_data', 'gvideo_prepare_picture');
23add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
24
25if (defined('IN_ADMIN'))
26{
27  add_event_handler('delete_elements', 'gvideo_delete_elements');
28  add_event_handler('get_admin_plugin_menu_links', 'gvideo_admin_menu');
29  add_event_handler('tabsheet_before_select','gvideo_tab', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); 
30}
31
32include_once(GVIDEO_PATH . 'include/gvideo.inc.php');
33
34
35/**
36 * update & load language
37 */
38function gvideo_init()
39{
40  global $pwg_loaded_plugins;
41 
42  if (
43    GVIDEO_VERSION == 'auto' or
44    $pwg_loaded_plugins['gvideo']['version'] == 'auto' or
45    version_compare($pwg_loaded_plugins['gvideo']['version'], GVIDEO_VERSION, '<')
46  )
47  {
48    include_once(GVIDEO_PATH . 'include/install.inc.php');
49    gvideo_install();
50   
51    if ( $pwg_loaded_plugins['gvideo']['version'] != 'auto' and GVIDEO_VERSION !='auto' )
52    {
53      $query = '
54UPDATE '. PLUGINS_TABLE .'
55SET version = "'. GVIDEO_VERSION .'"
56WHERE id = "gvideo"';
57      pwg_query($query);
58     
59      $pwg_loaded_plugins['gvideo']['version'] = GVIDEO_VERSION;
60     
61      if (defined('IN_ADMIN'))
62      {
63        $_SESSION['page_infos'][] = 'Embedded Videos updated to version '. GVIDEO_VERSION;
64      }
65    }
66  }
67 
68  load_language('plugin.lang', GVIDEO_PATH);
69}
70
71/**
72 * admin plugins menu
73 */
74function gvideo_admin_menu($menu) 
75{
76  array_push($menu, array(
77    'NAME' => 'Embedded Videos',
78    'URL' => GVIDEO_ADMIN,
79  ));
80  return $menu;
81}
82
83/**
84 * special tabs
85 */
86function gvideo_tab($sheets, $id)
87{
88  if ($id != 'photo') return $sheets;
89 
90  $query = '
91SELECT *
92  FROM '.GVIDEO_TABLE.'
93  WHERE picture_id = '.$_GET['image_id'].'
94;';
95  $result = pwg_query($query);
96
97  if (!pwg_db_num_rows($result)) return $sheets;
98 
99  global $gvideo;
100  $gvideo = pwg_db_fetch_assoc($result);
101 
102  $sheets['gvideo'] = array(
103    'caption' => l10n('Video properties'),
104    'url' => GVIDEO_ADMIN.'-photo&amp;image_id='.$_GET['image_id'],
105    );
106  unset($sheets['coi'], $sheets['update']);
107 
108  return $sheets;
109}
110
111?>
Note: See TracBrowser for help on using the repository browser.