1 | <?php |
---|
2 | defined('HEADER_MANAGER_PATH') or 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 | if (script_basename() == 'picture' and !$conf['header_manager']['banner_on_picture']) |
---|
12 | { |
---|
13 | return ''; |
---|
14 | } |
---|
15 | |
---|
16 | // no support for Kardon (not enough space) |
---|
17 | if ($user['theme'] == 'kardon') |
---|
18 | { |
---|
19 | return $page_banner; |
---|
20 | } |
---|
21 | |
---|
22 | // search banner for a specific category |
---|
23 | if (isset($page['category'])) |
---|
24 | { |
---|
25 | // we use the banner configured for this category |
---|
26 | // if no banner is configured we use the banner of the first parent category with a "deep" banner |
---|
27 | // if nothing found we use the default banner |
---|
28 | $query = ' |
---|
29 | SELECT * |
---|
30 | FROM '.HEADER_MANAGER_TABLE.' |
---|
31 | WHERE |
---|
32 | category_id IN ('.$page['category']['uppercats'].') |
---|
33 | AND (category_id = '.$page['category']['id'].' OR deep = 1) |
---|
34 | ;'; |
---|
35 | $cat_banners = hash_from_query($query, 'category_id'); |
---|
36 | |
---|
37 | if (count($cat_banners)) |
---|
38 | { |
---|
39 | usort($cat_banners, 'hm_uppercats_sort'); |
---|
40 | |
---|
41 | foreach ($cat_banners as $cat_banner) |
---|
42 | { |
---|
43 | $cat_banner = get_banner($cat_banner['image']); |
---|
44 | if ($cat_banner !== false) |
---|
45 | { |
---|
46 | $banner = $cat_banner; |
---|
47 | break; |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | // use default banner |
---|
54 | if (!isset($banner)) |
---|
55 | { |
---|
56 | if (empty($conf['header_manager']['image']) or $conf['header_manager']['image'] == 'random') |
---|
57 | { |
---|
58 | $banners = array_values(list_banners()); |
---|
59 | if (!count($banners)) |
---|
60 | { |
---|
61 | return $page_banner; |
---|
62 | } |
---|
63 | $banner = $banners[ mt_rand(0, count($banners)-1) ]; |
---|
64 | } |
---|
65 | else |
---|
66 | { |
---|
67 | $banner = get_banner($conf['header_manager']['image']); |
---|
68 | if ($banner === false) |
---|
69 | { |
---|
70 | return $page_banner; |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | // for MontBlancXL and BlancMontXL the banner is displayed as background of the header |
---|
76 | if (in_array($user['theme'], array('blancmontxl','montblancxl'))) |
---|
77 | { |
---|
78 | $template->block_html_style(null, |
---|
79 | '#theHeader { background: transparent url('.$banner['PATH'].') center bottom no-repeat; }' |
---|
80 | ); |
---|
81 | |
---|
82 | if ($conf['header_manager']['display'] == 'image_only') |
---|
83 | { |
---|
84 | $page_banner = ''; |
---|
85 | } |
---|
86 | else |
---|
87 | { |
---|
88 | $page_banner = str_replace('%header_manager%', '', $page_banner); |
---|
89 | } |
---|
90 | } |
---|
91 | else |
---|
92 | { |
---|
93 | $template->block_html_style(null, |
---|
94 | '#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; text-align:center; }' |
---|
95 | ); |
---|
96 | |
---|
97 | $banner_img = '<div class="banner">'. ($conf['header_manager']['display']=='with_title' ? $conf['gallery_title'] : ' ') .'</div>'; |
---|
98 | |
---|
99 | if ($conf['header_manager']['display'] == 'with_text') |
---|
100 | { |
---|
101 | $page_banner = str_replace('%header_manager%', $banner_img, $page_banner); |
---|
102 | } |
---|
103 | else |
---|
104 | { |
---|
105 | $page_banner = '<a href="'. get_gallery_home_url() .'">'. $banner_img .'</a>'; |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | return $page_banner; |
---|
110 | } |
---|
111 | |
---|
112 | function hm_uppercats_sort($a, $b) |
---|
113 | { |
---|
114 | global $page; |
---|
115 | $ids = explode(',', $page['category']['uppercats']); |
---|
116 | return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids); |
---|
117 | } |
---|