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: auto |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable, $conf; |
---|
14 | |
---|
15 | 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 | |
---|
20 | include_once(GVIDEO_PATH . 'include/events.inc.php'); |
---|
21 | |
---|
22 | |
---|
23 | $conf['gvideo'] = safe_unserialize($conf['gvideo']); |
---|
24 | |
---|
25 | |
---|
26 | add_event_handler('picture_pictures_data', 'gvideo_prepare_picture'); |
---|
27 | |
---|
28 | add_event_handler('delete_elements', 'gvideo_delete_elements'); |
---|
29 | |
---|
30 | if (defined('IN_ADMIN')) |
---|
31 | { |
---|
32 | add_event_handler('get_admin_plugin_menu_links', 'gvideo_admin_menu'); |
---|
33 | add_event_handler('tabsheet_before_select','gvideo_tab', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); |
---|
34 | |
---|
35 | add_event_handler('get_batch_manager_prefilters', 'gvideo_add_prefilter'); |
---|
36 | add_event_handler('perform_batch_manager_prefilters', 'gvideo_apply_prefilter', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | /** |
---|
41 | * admin plugins menu |
---|
42 | */ |
---|
43 | function gvideo_admin_menu($menu) |
---|
44 | { |
---|
45 | $menu[] = array( |
---|
46 | 'NAME' => 'Embedded Videos', |
---|
47 | 'URL' => GVIDEO_ADMIN, |
---|
48 | ); |
---|
49 | return $menu; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * special tabs |
---|
54 | */ |
---|
55 | function gvideo_tab($sheets, $id) |
---|
56 | { |
---|
57 | if ($id != 'photo') return $sheets; |
---|
58 | |
---|
59 | $query = ' |
---|
60 | SELECT * |
---|
61 | FROM '.GVIDEO_TABLE.' |
---|
62 | WHERE picture_id = '.$_GET['image_id'].' |
---|
63 | ;'; |
---|
64 | $result = pwg_query($query); |
---|
65 | |
---|
66 | if (!pwg_db_num_rows($result)) return $sheets; |
---|
67 | |
---|
68 | global $gvideo, $page; |
---|
69 | |
---|
70 | load_language('plugin.lang', GVIDEO_PATH); |
---|
71 | |
---|
72 | if ($page['tab'] == 'properties') |
---|
73 | { |
---|
74 | $page['infos'][] = l10n('This element is a video added with "Embedded Video"'); |
---|
75 | } |
---|
76 | |
---|
77 | $gvideo = pwg_db_fetch_assoc($result); |
---|
78 | |
---|
79 | $sheets['gvideo'] = array( |
---|
80 | 'caption' => l10n('Video properties'), |
---|
81 | 'url' => GVIDEO_ADMIN.'-photo&image_id='.$_GET['image_id'], |
---|
82 | ); |
---|
83 | unset($sheets['coi'], $sheets['update']); |
---|
84 | |
---|
85 | return $sheets; |
---|
86 | } |
---|