1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | /** |
---|
25 | * @package functions\menubar |
---|
26 | */ |
---|
27 | |
---|
28 | include_once(PHPWG_ROOT_PATH.'include/block.class.php'); |
---|
29 | |
---|
30 | initialize_menu(); |
---|
31 | |
---|
32 | /** |
---|
33 | * Setups each block the main menubar. |
---|
34 | */ |
---|
35 | function initialize_menu() |
---|
36 | { |
---|
37 | global $page, $conf, $user, $template, $filter; |
---|
38 | |
---|
39 | $menu = new BlockManager("menubar"); |
---|
40 | $menu->load_registered_blocks(); |
---|
41 | $menu->prepare_display(); |
---|
42 | |
---|
43 | if ( $page['section']=='search' and isset($page['qsearch_details']) ) |
---|
44 | { |
---|
45 | $template->assign('QUERY_SEARCH', htmlspecialchars($page['qsearch_details']['q']) ); |
---|
46 | } |
---|
47 | |
---|
48 | //--------------------------------------------------------------- external links |
---|
49 | if ( ($block=$menu->get_block('mbLinks')) and !empty($conf['links']) ) |
---|
50 | { |
---|
51 | $block->data = array(); |
---|
52 | foreach ($conf['links'] as $url => $url_data) |
---|
53 | { |
---|
54 | if (!is_array($url_data)) |
---|
55 | { |
---|
56 | $url_data = array('label' => $url_data); |
---|
57 | } |
---|
58 | |
---|
59 | if |
---|
60 | ( |
---|
61 | (!isset($url_data['eval_visible'])) |
---|
62 | or |
---|
63 | (eval($url_data['eval_visible'])) |
---|
64 | ) |
---|
65 | { |
---|
66 | $tpl_var = array( |
---|
67 | 'URL' => $url, |
---|
68 | 'LABEL' => $url_data['label'] |
---|
69 | ); |
---|
70 | |
---|
71 | if (!isset($url_data['new_window']) or $url_data['new_window']) |
---|
72 | { |
---|
73 | $tpl_var['new_window'] = |
---|
74 | array( |
---|
75 | 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''), |
---|
76 | 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '') |
---|
77 | ); |
---|
78 | } |
---|
79 | $block->data[] = $tpl_var; |
---|
80 | } |
---|
81 | } |
---|
82 | if ( !empty($block->data) ) |
---|
83 | { |
---|
84 | $block->template = 'menubar_links.tpl'; |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | //-------------------------------------------------------------- categories |
---|
89 | $block = $menu->get_block('mbCategories'); |
---|
90 | //------------------------------------------------------------------------ filter |
---|
91 | if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used')) |
---|
92 | { |
---|
93 | if ($filter['enabled']) |
---|
94 | { |
---|
95 | $template->assign( |
---|
96 | 'U_STOP_FILTER', |
---|
97 | add_url_params(make_index_url(array()), array('filter' => 'stop')) |
---|
98 | ); |
---|
99 | } |
---|
100 | else |
---|
101 | { |
---|
102 | $template->assign( |
---|
103 | 'U_START_FILTER', |
---|
104 | add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period'])) |
---|
105 | ); |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | if ( $block!=null ) |
---|
110 | { |
---|
111 | $block->data = array( |
---|
112 | 'NB_PICTURE' => $user['nb_total_images'], |
---|
113 | 'MENU_CATEGORIES' => get_categories_menu(), |
---|
114 | 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), |
---|
115 | ); |
---|
116 | $block->template = 'menubar_categories.tpl'; |
---|
117 | } |
---|
118 | |
---|
119 | //------------------------------------------------------------------------ tags |
---|
120 | $block = $menu->get_block('mbTags'); |
---|
121 | if ( $block!=null and !empty($page['items']) and 'picture' != script_basename() ) |
---|
122 | { |
---|
123 | if ('tags'==@$page['section']) |
---|
124 | { |
---|
125 | $tags = get_common_tags( |
---|
126 | $page['items'], |
---|
127 | $conf['menubar_tag_cloud_items_number'], |
---|
128 | $page['tag_ids'] |
---|
129 | ); |
---|
130 | $tags = add_level_to_tags($tags); |
---|
131 | |
---|
132 | foreach ($tags as $tag) |
---|
133 | { |
---|
134 | $block->data[] = array_merge( |
---|
135 | $tag, |
---|
136 | array( |
---|
137 | 'U_ADD' => make_index_url( |
---|
138 | array( |
---|
139 | 'tags' => array_merge( |
---|
140 | $page['tags'], |
---|
141 | array($tag) |
---|
142 | ) |
---|
143 | ) |
---|
144 | ), |
---|
145 | 'URL' => make_index_url( array( 'tags' => array($tag) ) |
---|
146 | ), |
---|
147 | ) |
---|
148 | ); |
---|
149 | } |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] ); |
---|
154 | $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) ); |
---|
155 | foreach ($tags as $tag) |
---|
156 | { |
---|
157 | $block->data[] = |
---|
158 | array_merge( $tag, |
---|
159 | array( |
---|
160 | 'URL' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
161 | ) |
---|
162 | ); |
---|
163 | } |
---|
164 | } |
---|
165 | if ( !empty($block->data) ) |
---|
166 | { |
---|
167 | $block->template = 'menubar_tags.tpl'; |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | //----------------------------------------------------------- special categories |
---|
172 | if ( ($block = $menu->get_block('mbSpecials')) != null ) |
---|
173 | { |
---|
174 | if ( !is_a_guest() ) |
---|
175 | {// favorites |
---|
176 | $block->data['favorites'] = |
---|
177 | array( |
---|
178 | 'URL' => make_index_url(array('section' => 'favorites')), |
---|
179 | 'TITLE' => l10n('display your favorites photos'), |
---|
180 | 'NAME' => l10n('Your favorites') |
---|
181 | ); |
---|
182 | } |
---|
183 | |
---|
184 | $block->data['most_visited'] = |
---|
185 | array( |
---|
186 | 'URL' => make_index_url(array('section' => 'most_visited')), |
---|
187 | 'TITLE' => l10n('display most visited photos'), |
---|
188 | 'NAME' => l10n('Most visited') |
---|
189 | ); |
---|
190 | |
---|
191 | if ($conf['rate']) |
---|
192 | { |
---|
193 | $block->data['best_rated'] = |
---|
194 | array( |
---|
195 | 'URL' => make_index_url(array('section' => 'best_rated')), |
---|
196 | 'TITLE' => l10n('display best rated photos'), |
---|
197 | 'NAME' => l10n('Best rated') |
---|
198 | ); |
---|
199 | } |
---|
200 | |
---|
201 | $block->data['recent_pics'] = |
---|
202 | array( |
---|
203 | 'URL' => make_index_url(array('section' => 'recent_pics')), |
---|
204 | 'TITLE' => l10n('display most recent photos'), |
---|
205 | 'NAME' => l10n('Recent photos'), |
---|
206 | ); |
---|
207 | |
---|
208 | $block->data['recent_cats'] = |
---|
209 | array( |
---|
210 | 'URL' => make_index_url(array('section' => 'recent_cats')), |
---|
211 | 'TITLE' => l10n('display recently updated albums'), |
---|
212 | 'NAME' => l10n('Recent albums'), |
---|
213 | ); |
---|
214 | |
---|
215 | $block->data['random'] = |
---|
216 | array( |
---|
217 | 'URL' => get_root_url().'random.php', |
---|
218 | 'TITLE' => l10n('display a set of random photos'), |
---|
219 | 'NAME' => l10n('Random photos'), |
---|
220 | 'REL'=> 'rel="nofollow"' |
---|
221 | ); |
---|
222 | |
---|
223 | $block->data['calendar'] = |
---|
224 | array( |
---|
225 | 'URL' => |
---|
226 | make_index_url( |
---|
227 | array( |
---|
228 | 'chronology_field' => ($conf['calendar_datefield']=='date_available' |
---|
229 | ? 'posted' : 'created'), |
---|
230 | 'chronology_style'=> 'monthly', |
---|
231 | 'chronology_view' => 'calendar' |
---|
232 | ) |
---|
233 | ), |
---|
234 | 'TITLE' => l10n('display each day with photos, month per month'), |
---|
235 | 'NAME' => l10n('Calendar'), |
---|
236 | 'REL'=> 'rel="nofollow"' |
---|
237 | ); |
---|
238 | $block->template = 'menubar_specials.tpl'; |
---|
239 | } |
---|
240 | |
---|
241 | |
---|
242 | //---------------------------------------------------------------------- summary |
---|
243 | if ( ($block=$menu->get_block('mbMenu')) != null ) |
---|
244 | { |
---|
245 | // quick search block will be displayed only if data['qsearch'] is set |
---|
246 | // to "yes" |
---|
247 | $block->data['qsearch']=true; |
---|
248 | |
---|
249 | // tags link |
---|
250 | $block->data['tags'] = |
---|
251 | array( |
---|
252 | 'TITLE' => l10n('display available tags'), |
---|
253 | 'NAME' => l10n('Tags'), |
---|
254 | 'URL'=> get_root_url().'tags.php', |
---|
255 | 'COUNTER' => get_nb_available_tags(), |
---|
256 | ); |
---|
257 | |
---|
258 | // search link |
---|
259 | $block->data['search'] = |
---|
260 | array( |
---|
261 | 'TITLE'=>l10n('search'), |
---|
262 | 'NAME'=>l10n('Search'), |
---|
263 | 'URL'=> get_root_url().'search.php', |
---|
264 | 'REL'=> 'rel="search"' |
---|
265 | ); |
---|
266 | |
---|
267 | if ($conf['activate_comments']) |
---|
268 | { |
---|
269 | // comments link |
---|
270 | $block->data['comments'] = |
---|
271 | array( |
---|
272 | 'TITLE'=>l10n('display last user comments'), |
---|
273 | 'NAME'=>l10n('Comments'), |
---|
274 | 'URL'=> get_root_url().'comments.php', |
---|
275 | 'COUNTER' => get_nb_available_comments(), |
---|
276 | ); |
---|
277 | } |
---|
278 | |
---|
279 | // about link |
---|
280 | $block->data['about'] = |
---|
281 | array( |
---|
282 | 'TITLE' => l10n('About Piwigo'), |
---|
283 | 'NAME' => l10n('About'), |
---|
284 | 'URL' => get_root_url().'about.php', |
---|
285 | ); |
---|
286 | |
---|
287 | // notification |
---|
288 | $block->data['rss'] = |
---|
289 | array( |
---|
290 | 'TITLE'=>l10n('RSS feed'), |
---|
291 | 'NAME'=>l10n('Notification'), |
---|
292 | 'URL'=> get_root_url().'notification.php', |
---|
293 | 'REL'=> 'rel="nofollow"' |
---|
294 | ); |
---|
295 | $block->template = 'menubar_menu.tpl'; |
---|
296 | } |
---|
297 | |
---|
298 | |
---|
299 | //--------------------------------------------------------------- identification |
---|
300 | if (is_a_guest()) |
---|
301 | { |
---|
302 | $template->assign( |
---|
303 | array( |
---|
304 | 'U_LOGIN' => get_root_url().'identification.php', |
---|
305 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
---|
306 | 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'] |
---|
307 | ) |
---|
308 | ); |
---|
309 | if ($conf['allow_user_registration']) |
---|
310 | { |
---|
311 | $template->assign( 'U_REGISTER', get_root_url().'register.php'); |
---|
312 | } |
---|
313 | } |
---|
314 | else |
---|
315 | { |
---|
316 | $template->assign('USERNAME', stripslashes($user['username'])); |
---|
317 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
318 | { |
---|
319 | $template->assign('U_PROFILE', get_root_url().'profile.php'); |
---|
320 | } |
---|
321 | |
---|
322 | // the logout link has no meaning with Apache authentication : it is not |
---|
323 | // possible to logout with this kind of authentication. |
---|
324 | if (!$conf['apache_authentication']) |
---|
325 | { |
---|
326 | $template->assign('U_LOGOUT', get_root_url().'?act=logout'); |
---|
327 | } |
---|
328 | if (is_admin()) |
---|
329 | { |
---|
330 | $template->assign('U_ADMIN', get_root_url().'admin.php'); |
---|
331 | } |
---|
332 | } |
---|
333 | if ( ($block=$menu->get_block('mbIdentification')) != null ) |
---|
334 | { |
---|
335 | $block->template = 'menubar_identification.tpl'; |
---|
336 | } |
---|
337 | $menu->apply('MENUBAR', 'menubar.tpl' ); |
---|
338 | } |
---|
339 | |
---|
340 | ?> |
---|