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

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

consolidate upgrade process, cURL compliant with safe_mode

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