source: extensions/header_manager/main.inc.php @ 17644

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

improve upgrade process (for manual upgrades and piwigo.com upgrades)
improve delete button visibility

File size: 2.8 KB
Line 
1<?php 
2/*
3Plugin Name: Header Manager
4Version: auto
5Description: Header Manager allows to simply manage gallery banners. You can upload a picture from your computer or use a picture already in the gallery.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=608
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14define('HEADER_MANAGER_PATH',    PHPWG_PLUGINS_PATH . 'header_manager/');
15define('HEADER_MANAGER_ADMIN',   get_root_url() . 'admin.php?page=plugin-header_manager');
16define('HEADER_MANAGER_DIR',     PWG_LOCAL_DIR . 'banners/');
17define('HEADER_MANAGER_TABLE',   $prefixeTable . 'category_banner');
18define('HEADER_MANAGER_VERSION', '1.0.3');
19
20add_event_handler('init', 'header_manager_init');
21
22function header_manager_init()
23{
24  if (defined('PWG_HELP')) return;
25 
26  global $conf;
27  $conf['header_manager'] = unserialize($conf['header_manager']);
28   
29  include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php');
30  include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
31 
32  if (!defined('IN_ADMIN'))
33  {
34    add_event_handler('render_page_banner', 'header_manager_render');
35  }
36  else
37  {
38    add_event_handler('loc_begin_admin_page', 'header_manager_check_version');
39    add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
40    add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
41    add_event_handler('delete_categories', 'header_manager_delete_categories');
42  }
43}
44
45/**
46 * Header Manager admin link
47 */
48function header_manager_admin_menu($menu) 
49{
50  array_push($menu, array(
51    'NAME' => 'Header Manager',
52    'URL' => HEADER_MANAGER_ADMIN,
53  ));
54  return $menu;
55}
56
57/**
58 * tab on album edition page
59 */
60function header_manager_tab($sheets, $id)
61{
62  if ($id == 'album')
63  {
64    load_language('plugin.lang', HEADER_MANAGER_PATH);
65   
66    $sheets['headermanager'] = array(
67      'caption' => l10n('Banner'),
68      'url' => HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
69      );
70  }
71 
72  return $sheets;
73}
74
75/**
76 * updating the plugin
77 */
78function header_manager_check_version()
79{
80  global $pwg_loaded_plugins, $page;
81 
82  if (
83    ( 
84      @$page['page'] == 'intro' or 
85      @$_GET['section'] == 'header_manager/admin.php' 
86    )
87    and 
88    (
89      $pwg_loaded_plugins['header_manager']['version'] == 'auto' or
90      version_compare($pwg_loaded_plugins['header_manager']['version'], HEADER_MANAGER_VERSION, '<')
91    ) 
92  )
93  {
94    include_once(HEADER_MANAGER_PATH . 'include/install.inc.php');
95    header_manager_install();
96   
97    if ($pwg_loaded_plugins['header_manager']['version'] != 'auto')
98    {
99      $query = '
100UPDATE '. PLUGINS_TABLE .'
101SET version = "'. HEADER_MANAGER_VERSION .'"
102WHERE id = "header_manager"';
103      pwg_query($query);
104    }
105  }
106}
107
108?>
Note: See TracBrowser for help on using the repository browser.