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

Last change on this file since 25973 was 20804, checked in by mistic100, 11 years ago
  • add support for semi-private Vimeo videos
  • escape tags
  • compatible with safe_mode=On
  • deactivate autosize
File size: 2.7 KB
Line 
1<?php 
2/*
3Plugin Name: Embedded Videos
4Version: auto
5Description: Add videos from Dailymotion, Youtube, Vimeo, Wideo 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
15defined('GVIDEO_ID') or define('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');
24add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
25
26if (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
33include_once(GVIDEO_PATH . 'include/gvideo.inc.php');
34
35
36/**
37 * update & load language
38 */
39function 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 = '
55UPDATE '. PLUGINS_TABLE .'
56SET version = "'. GVIDEO_VERSION .'"
57WHERE 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 */
75function 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 */
87function gvideo_tab($sheets, $id)
88{
89  if ($id != 'photo') return $sheets;
90 
91  $query = '
92SELECT *
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&amp;image_id='.$_GET['image_id'],
106    );
107  unset($sheets['coi'], $sheets['update']);
108 
109  return $sheets;
110}
111
112?>
Note: See TracBrowser for help on using the repository browser.