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

Last change on this file since 24728 was 24010, checked in by mistic100, 11 years ago

"Add banner" in album page make the user redirected to the same page after cropping

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: auto
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',     PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners/');
17define('HEADER_MANAGER_TABLE',   $prefixeTable . 'category_banner');
18define('HEADER_MANAGER_VERSION', 'auto');
19
20
21add_event_handler('init', 'header_manager_init');
22 
23if (defined('IN_ADMIN'))
24{
25  add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu');
26  add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
27  add_event_handler('delete_categories', 'header_manager_delete_categories');
28}
29else if (!defined('PWG_HELP'))
30{
31  add_event_handler('render_page_banner', 'header_manager_render');
32}
33
34include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php');
35include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php');
36
37
38/**
39 * update plugin & unserialize conf
40 */
41function header_manager_init()
42{
43  global $conf, $pwg_loaded_plugins, $page;
44 
45  if (
46    HEADER_MANAGER_VERSION == 'auto' or
47    $pwg_loaded_plugins['header_manager']['version'] == 'auto' or
48    version_compare($pwg_loaded_plugins['header_manager']['version'], HEADER_MANAGER_VERSION, '<')
49  )
50  {
51    include_once(HEADER_MANAGER_PATH . 'include/install.inc.php');
52    header_manager_install();
53   
54    if ( $pwg_loaded_plugins['header_manager']['version'] != 'auto' and HEADER_MANAGER_VERSION != 'auto' )
55    {
56      $query = '
57UPDATE '. PLUGINS_TABLE .'
58SET version = "'. HEADER_MANAGER_VERSION .'"
59WHERE id = "header_manager"';
60      pwg_query($query);
61     
62      $pwg_loaded_plugins['header_manager']['version'] = HEADER_MANAGER_VERSION;
63     
64      if (defined('IN_ADMIN'))
65      {
66        $_SESSION['page_infos'][] = 'Header Manager updated to version '. HEADER_MANAGER_VERSION;
67      }
68    }
69  }
70 
71  $conf['header_manager'] = unserialize($conf['header_manager']);
72}
73
74/**
75 * Header Manager admin link
76 */
77function header_manager_admin_menu($menu) 
78{
79  array_push($menu, array(
80    'NAME' => 'Header Manager',
81    'URL' => HEADER_MANAGER_ADMIN,
82  ));
83  return $menu;
84}
85
86/**
87 * tab on album edition page
88 */
89function header_manager_tab($sheets, $id)
90{
91  if ($id == 'album')
92  {
93    load_language('plugin.lang', HEADER_MANAGER_PATH);
94   
95    $sheets['headermanager'] = array(
96      'caption' => l10n('Banner'),
97      'url' => HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
98      );
99  }
100 
101  return $sheets;
102}
103
104?>
Note: See TracBrowser for help on using the repository browser.