1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Header Manager |
---|
4 | Version: auto |
---|
5 | Description: Header Manager allows to simply manage gallery banners. You can upload a picture from your computer or use a picture already in the gallery. |
---|
6 | Plugin URI: auto |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable; |
---|
14 | define('HEADER_MANAGER_PATH', PHPWG_PLUGINS_PATH . 'header_manager/'); |
---|
15 | define('HEADER_MANAGER_ADMIN', get_root_url() . 'admin.php?page=plugin-header_manager'); |
---|
16 | define('HEADER_MANAGER_DIR', PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners/'); |
---|
17 | define('HEADER_MANAGER_TABLE', $prefixeTable . 'category_banner'); |
---|
18 | define('HEADER_MANAGER_VERSION', 'auto'); |
---|
19 | |
---|
20 | |
---|
21 | add_event_handler('init', 'header_manager_init'); |
---|
22 | |
---|
23 | if (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 | } |
---|
29 | else if (!defined('PWG_HELP')) |
---|
30 | { |
---|
31 | add_event_handler('render_page_banner', 'header_manager_render'); |
---|
32 | } |
---|
33 | |
---|
34 | include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php'); |
---|
35 | include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php'); |
---|
36 | |
---|
37 | |
---|
38 | /** |
---|
39 | * initialization |
---|
40 | */ |
---|
41 | function header_manager_init() |
---|
42 | { |
---|
43 | global $conf, $pwg_loaded_plugins, $page; |
---|
44 | |
---|
45 | include_once(HEADER_MANAGER_PATH . 'maintain.inc.php'); |
---|
46 | $maintain = new header_manager_maintain('header_manager'); |
---|
47 | $maintain->autoUpdate(HEADER_MANAGER_VERSION, 'install'); |
---|
48 | |
---|
49 | $conf['header_manager'] = unserialize($conf['header_manager']); |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * Header Manager admin link |
---|
54 | */ |
---|
55 | function header_manager_admin_menu($menu) |
---|
56 | { |
---|
57 | $menu[] = array( |
---|
58 | 'NAME' => 'Header Manager', |
---|
59 | 'URL' => HEADER_MANAGER_ADMIN, |
---|
60 | ); |
---|
61 | return $menu; |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * tab on album edition page |
---|
66 | */ |
---|
67 | function header_manager_tab($sheets, $id) |
---|
68 | { |
---|
69 | if ($id == 'album') |
---|
70 | { |
---|
71 | load_language('plugin.lang', HEADER_MANAGER_PATH); |
---|
72 | |
---|
73 | $sheets['headermanager'] = array( |
---|
74 | 'caption' => l10n('Banner'), |
---|
75 | 'url' => HEADER_MANAGER_ADMIN.'-album&cat_id='.$_GET['cat_id'], |
---|
76 | ); |
---|
77 | } |
---|
78 | |
---|
79 | return $sheets; |
---|
80 | } |
---|
81 | |
---|
82 | /** |
---|
83 | * clean table when categories are deleted |
---|
84 | */ |
---|
85 | function header_manager_delete_categories($ids) |
---|
86 | { |
---|
87 | $query = ' |
---|
88 | DELETE FROM '.HEADER_MANAGER_TABLE.' |
---|
89 | WHERE category_id IN('.implode(',', $ids).') |
---|
90 | ;'; |
---|
91 | pwg_query($query); |
---|
92 | } |
---|