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