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, $conf; |
---|
14 | |
---|
15 | define('HEADER_MANAGER_PATH', PHPWG_PLUGINS_PATH . 'header_manager/'); |
---|
16 | define('HEADER_MANAGER_ADMIN', get_root_url() . 'admin.php?page=plugin-header_manager'); |
---|
17 | define('HEADER_MANAGER_DIR', PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners/'); |
---|
18 | define('HEADER_MANAGER_TABLE', $prefixeTable . 'category_banner'); |
---|
19 | |
---|
20 | include_once(HEADER_MANAGER_PATH . 'include/functions.inc.php'); |
---|
21 | include_once(HEADER_MANAGER_PATH . 'include/header_manager.inc.php'); |
---|
22 | |
---|
23 | |
---|
24 | $conf['header_manager'] = safe_unserialize($conf['header_manager']); |
---|
25 | |
---|
26 | |
---|
27 | if (defined('IN_ADMIN')) |
---|
28 | { |
---|
29 | add_event_handler('get_admin_plugin_menu_links', 'header_manager_admin_menu'); |
---|
30 | add_event_handler('tabsheet_before_select', 'header_manager_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
31 | add_event_handler('delete_categories', 'header_manager_delete_categories'); |
---|
32 | } |
---|
33 | else if (!defined('PWG_HELP')) |
---|
34 | { |
---|
35 | add_event_handler('render_page_banner', 'header_manager_render'); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | /** |
---|
40 | * Header Manager admin link |
---|
41 | */ |
---|
42 | function header_manager_admin_menu($menu) |
---|
43 | { |
---|
44 | $menu[] = array( |
---|
45 | 'NAME' => 'Header Manager', |
---|
46 | 'URL' => HEADER_MANAGER_ADMIN, |
---|
47 | ); |
---|
48 | return $menu; |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * tab on album edition page |
---|
53 | */ |
---|
54 | function header_manager_tab($sheets, $id) |
---|
55 | { |
---|
56 | if ($id == 'album') |
---|
57 | { |
---|
58 | load_language('plugin.lang', HEADER_MANAGER_PATH); |
---|
59 | |
---|
60 | $sheets['headermanager'] = array( |
---|
61 | 'caption' => l10n('Banner'), |
---|
62 | 'url' => HEADER_MANAGER_ADMIN.'-album&cat_id='.$_GET['cat_id'], |
---|
63 | ); |
---|
64 | } |
---|
65 | |
---|
66 | return $sheets; |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | * clean table when categories are deleted |
---|
71 | */ |
---|
72 | function header_manager_delete_categories($ids) |
---|
73 | { |
---|
74 | $query = ' |
---|
75 | DELETE FROM '.HEADER_MANAGER_TABLE.' |
---|
76 | WHERE category_id IN('.implode(',', $ids).') |
---|
77 | ;'; |
---|
78 | pwg_query($query); |
---|
79 | } |
---|