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