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

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

allow to add any video with direct embed code + add batch manager filter

File size: 2.2 KB
Line 
1<?php 
2/*
3Plugin Name: Embedded Videos
4Version: auto
5Description: Add videos from Dailymotion, Youtube, Vimeo, Wideo and Wat.
6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
12
13global $prefixeTable;
14
15define('GVIDEO_ID',      basename(dirname(__FILE__)));
16define('GVIDEO_PATH',    PHPWG_PLUGINS_PATH . GVIDEO_ID . '/');
17define('GVIDEO_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . GVIDEO_ID);
18define('GVIDEO_TABLE',   $prefixeTable.'image_video');
19define('GVIDEO_VERSION', 'auto');
20
21
22add_event_handler('init', 'gvideo_init');
23add_event_handler('picture_pictures_data', 'gvideo_prepare_picture');
24
25if (defined('IN_ADMIN'))
26{
27  add_event_handler('get_admin_plugin_menu_links', 'gvideo_admin_menu');
28  add_event_handler('tabsheet_before_select','gvideo_tab', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2);
29 
30  add_event_handler('get_batch_manager_prefilters', 'gvideo_add_prefilter');
31  add_event_handler('perform_batch_manager_prefilters', 'gvideo_apply_prefilter');
32}
33
34add_event_handler('delete_elements', 'gvideo_delete_elements');
35
36include_once(GVIDEO_PATH . 'include/events.inc.php');
37
38
39/**
40 * init
41 */
42function gvideo_init()
43{
44  global $conf;
45 
46  include_once(GVIDEO_PATH . 'maintain.inc.php');
47  $maintain = new gvideo_maintain(GVIDEO_ID);
48  $maintain->autoUpdate(GVIDEO_VERSION, 'install');
49 
50  $conf['gvideo'] = unserialize($conf['gvideo']);
51}
52
53/**
54 * admin plugins menu
55 */
56function gvideo_admin_menu($menu) 
57{
58  $menu[] = array(
59    'NAME' => 'Embedded Videos',
60    'URL' => GVIDEO_ADMIN,
61    );
62  return $menu;
63}
64
65/**
66 * special tabs
67 */
68function gvideo_tab($sheets, $id)
69{
70  if ($id != 'photo') return $sheets;
71 
72  $query = '
73SELECT *
74  FROM '.GVIDEO_TABLE.'
75  WHERE picture_id = '.$_GET['image_id'].'
76;';
77  $result = pwg_query($query);
78
79  if (!pwg_db_num_rows($result)) return $sheets;
80 
81  global $gvideo, $page;
82
83  if ($page['tab'] == 'properties')
84  {
85    $page['infos'][] = 'This element is a video added with "Embedded Video"';
86  }
87 
88  $gvideo = pwg_db_fetch_assoc($result);
89 
90  $sheets['gvideo'] = array(
91    'caption' => l10n('Video properties'),
92    'url' => GVIDEO_ADMIN.'-photo&amp;image_id='.$_GET['image_id'],
93    );
94  unset($sheets['coi'], $sheets['update']);
95 
96  return $sheets;
97}
Note: See TracBrowser for help on using the repository browser.