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

Last change on this file since 17685 was 17685, checked in by mistic100, 12 years ago

next release is 2.4.d

File size: 2.6 KB
RevLine 
[17307]1<?php 
[3609]2/*
[17307]3Plugin Name: Embedded Videos
[3697]4Version: auto
[17307]5Description: Add videos from Dailymotion, Youtube, Vimeo, Wideo, videobb and Wat.
[3609]6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=136
[17307]7Author: Mistic & P@t
8Author URI: http://www.strangeplanet.fr
[3609]9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
[17307]13global $prefixeTable;
[3609]14
[17661]15define('GVIDEO_PATH',    PHPWG_PLUGINS_PATH . 'gvideo/');
16define('GVIDEO_ADMIN',   get_root_url() . 'admin.php?page=plugin-gvideo');
17define('GVIDEO_TABLE',   $prefixeTable.'image_video');
[17685]18define('GVIDEO_VERSION', '2.4.d');
[3609]19
20
[17661]21add_event_handler('init', 'gvideo_init');
[17678]22add_event_handler('picture_pictures_data', 'gvideo_prepare_picture');
[17307]23add_event_handler('render_element_content', 'gvideo_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
[3609]24
[17307]25if (defined('IN_ADMIN'))
[3609]26{
[17307]27  add_event_handler('delete_elements', 'gvideo_delete_elements');
28  add_event_handler('get_admin_plugin_menu_links', 'gvideo_admin_menu');
[17626]29  add_event_handler('tabsheet_before_select','gvideo_tab', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); 
[17661]30}
31
32include_once(GVIDEO_PATH . 'include/gvideo.inc.php');
33
34
35/**
36 * update & load language
37 */
38function gvideo_init()
39{
40  global $pwg_loaded_plugins;
[17383]41 
[17661]42  if (
43    $pwg_loaded_plugins['gvideo']['version'] == 'auto' or
44    version_compare($pwg_loaded_plugins['gvideo']['version'], GVIDEO_VERSION, '<')
45  )
[17383]46  {
[17661]47    include_once(GVIDEO_PATH . 'include/install.inc.php');
48    gvideo_install();
49   
50    if ($pwg_loaded_plugins['gvideo']['version'] != 'auto')
51    {
52      $query = '
53UPDATE '. PLUGINS_TABLE .'
54SET version = "'. GVIDEO_VERSION .'"
55WHERE 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    }
[17383]65  }
[17661]66 
67  load_language('plugin.lang', GVIDEO_PATH);
68}
[3609]69
[17661]70/**
71 * admin plugins menu
72 */
73function 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 */
85function gvideo_tab($sheets, $id)
86{
87  if ($id != 'photo') return $sheets;
[17626]88 
[17661]89  $query = '
[17626]90SELECT *
91  FROM '.GVIDEO_TABLE.'
92  WHERE picture_id = '.$_GET['image_id'].'
93;';
[17661]94  $result = pwg_query($query);
95
96  if (!pwg_db_num_rows($result)) return $sheets;
[17626]97 
[17661]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&amp;image_id='.$_GET['image_id'],
104    );
105  unset($sheets['coi'], $sheets['update']);
106 
107  return $sheets;
[13114]108}
109
[3296]110?>
Note: See TracBrowser for help on using the repository browser.