1 | <?php |
---|
2 | if (!defined('HEADER_MANAGER_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | /** |
---|
5 | * add personal banner to page banner |
---|
6 | */ |
---|
7 | function header_manager_render($page_banner) |
---|
8 | { |
---|
9 | global $conf, $user, $template, $page; |
---|
10 | |
---|
11 | // search banner for a specific category |
---|
12 | if (isset($page['category'])) |
---|
13 | { |
---|
14 | // we use the banner configured for this category |
---|
15 | // if no banner is configured we use the banner of the first parent category with a "deep" banner |
---|
16 | // if nothing found we use the default banner |
---|
17 | $query = ' |
---|
18 | SELECT * |
---|
19 | FROM '.HEADER_MANAGER_TABLE.' |
---|
20 | WHERE |
---|
21 | category_id IN ('.$page['category']['uppercats'].') |
---|
22 | AND (category_id = '.$page['category']['id'].' OR deep = 1) |
---|
23 | ;'; |
---|
24 | $cat_banners = hash_from_query($query, 'category_id'); |
---|
25 | |
---|
26 | if (count($cat_banners)) |
---|
27 | { |
---|
28 | function uppercats_sort($a, $b) |
---|
29 | { |
---|
30 | global $page; |
---|
31 | $ids = explode(',', $page['category']['uppercats']); |
---|
32 | return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids); |
---|
33 | } |
---|
34 | usort($cat_banners, 'uppercats_sort'); |
---|
35 | |
---|
36 | foreach ($cat_banners as $cat_banner) |
---|
37 | { |
---|
38 | $cat_banner = get_banner($cat_banner['image']); |
---|
39 | if ($cat_banner !== false) |
---|
40 | { |
---|
41 | $banner = $cat_banner; |
---|
42 | break; |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | // use default banner |
---|
49 | if (!isset($banner)) |
---|
50 | { |
---|
51 | if ($conf['header_manager']['image'] == 'random') |
---|
52 | { |
---|
53 | $banners = list_banners(); |
---|
54 | if (!count($banners)) return $page_banner; |
---|
55 | $banner = $banners[ mt_rand(0, count($banners)-1) ]; |
---|
56 | } |
---|
57 | else |
---|
58 | { |
---|
59 | $banner = get_banner($conf['header_manager']['image']); |
---|
60 | if ($banner === false) return $page_banner; |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | // for MontBlancXL and BlancMontXL the banner is displayed as background of the header |
---|
65 | if ( in_array($user['theme'], array('blancmontxl','montblancxl')) ) |
---|
66 | { |
---|
67 | $template->append('head_elements', |
---|
68 | '<style type="text/css"> |
---|
69 | #theHeader { background: transparent url('.$banner['PATH'].') center bottom no-repeat; } |
---|
70 | </style>' |
---|
71 | ); |
---|
72 | |
---|
73 | if ($conf['header_manager']['display'] == 'image_only') |
---|
74 | { |
---|
75 | $page_banner = null; |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | $page_banner = str_replace('%header_manager%', null, $page_banner); |
---|
80 | } |
---|
81 | } |
---|
82 | // no support for Kardon (not enough space) |
---|
83 | else if ($user['theme'] != 'kardon') |
---|
84 | { |
---|
85 | $template->append('head_elements', |
---|
86 | '<style type="text/css"> |
---|
87 | #theHeader div.banner { background:transparent url(\''.$banner['PATH'].'\') center center no-repeat;height:'.$banner['SIZE'][1].'px;line-height:'.($banner['SIZE'][1]-12).'px;font-size:2.5em;color:#fff;text-shadow:0 0 5px #000; } |
---|
88 | </style>' |
---|
89 | ); |
---|
90 | |
---|
91 | $banner_img = '<div class="banner">'.($conf['header_manager']['display']=='with_title' ? $conf['gallery_title'] : ' ').'</div>'; |
---|
92 | |
---|
93 | if ($conf['header_manager']['display'] == 'with_text') |
---|
94 | { |
---|
95 | $page_banner = str_replace('%header_manager%', $banner_img, $page_banner); |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | $page_banner = '<a href="'.get_gallery_home_url().'">'.$banner_img.'</a>'; |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | return $page_banner; |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * Header Manager admin link |
---|
108 | */ |
---|
109 | function header_manager_admin_menu($menu) |
---|
110 | { |
---|
111 | array_push($menu, array( |
---|
112 | 'NAME' => 'Header Manager', |
---|
113 | 'URL' => HEADER_MANAGER_ADMIN, |
---|
114 | )); |
---|
115 | return $menu; |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * tab on album edition page |
---|
120 | */ |
---|
121 | function header_manager_tab($sheets, $id) |
---|
122 | { |
---|
123 | if ($id == 'album') |
---|
124 | { |
---|
125 | load_language('plugin.lang', HEADER_MANAGER_PATH); |
---|
126 | |
---|
127 | $sheets['headermanager'] = array( |
---|
128 | 'caption' => l10n('Banner'), |
---|
129 | 'url' => HEADER_MANAGER_ADMIN.'-album&cat_id='.$_GET['cat_id'], |
---|
130 | ); |
---|
131 | } |
---|
132 | |
---|
133 | return $sheets; |
---|
134 | } |
---|
135 | |
---|
136 | ?> |
---|