1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2013 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 | //--------------------------------------------------------------- external links |
---|
44 | if ( ($block=$menu->get_block('mbLinks')) and !empty($conf['links']) ) |
---|
45 | { |
---|
46 | $block->data = array(); |
---|
47 | foreach ($conf['links'] as $url => $url_data) |
---|
48 | { |
---|
49 | if (!is_array($url_data)) |
---|
50 | { |
---|
51 | $url_data = array('label' => $url_data); |
---|
52 | } |
---|
53 | |
---|
54 | if |
---|
55 | ( |
---|
56 | (!isset($url_data['eval_visible'])) |
---|
57 | or |
---|
58 | (eval($url_data['eval_visible'])) |
---|
59 | ) |
---|
60 | { |
---|
61 | $tpl_var = array( |
---|
62 | 'URL' => $url, |
---|
63 | 'LABEL' => $url_data['label'] |
---|
64 | ); |
---|
65 | |
---|
66 | if (!isset($url_data['new_window']) or $url_data['new_window']) |
---|
67 | { |
---|
68 | $tpl_var['new_window'] = |
---|
69 | array( |
---|
70 | 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''), |
---|
71 | 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '') |
---|
72 | ); |
---|
73 | } |
---|
74 | $block->data[] = $tpl_var; |
---|
75 | } |
---|
76 | } |
---|
77 | if ( !empty($block->data) ) |
---|
78 | { |
---|
79 | $block->template = 'menubar_links.tpl'; |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | //-------------------------------------------------------------- categories |
---|
84 | $block = $menu->get_block('mbCategories'); |
---|
85 | //------------------------------------------------------------------------ filter |
---|
86 | if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used')) |
---|
87 | { |
---|
88 | if ($filter['enabled']) |
---|
89 | { |
---|
90 | $template->assign( |
---|
91 | 'U_STOP_FILTER', |
---|
92 | add_url_params(make_index_url(array()), array('filter' => 'stop')) |
---|
93 | ); |
---|
94 | } |
---|
95 | else |
---|
96 | { |
---|
97 | $template->assign( |
---|
98 | 'U_START_FILTER', |
---|
99 | add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period'])) |
---|
100 | ); |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | if ( $block!=null ) |
---|
105 | { |
---|
106 | $block->data = array( |
---|
107 | 'NB_PICTURE' => $user['nb_total_images'], |
---|
108 | 'MENU_CATEGORIES' => get_categories_menu(), |
---|
109 | 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), |
---|
110 | ); |
---|
111 | $block->template = 'menubar_categories.tpl'; |
---|
112 | } |
---|
113 | |
---|
114 | //------------------------------------------------------------------------ tags |
---|
115 | $block = $menu->get_block('mbTags'); |
---|
116 | if ( $block!=null and !empty($page['items']) and 'picture' != script_basename() ) |
---|
117 | { |
---|
118 | if ('tags'==@$page['section']) |
---|
119 | { |
---|
120 | $tags = get_common_tags( |
---|
121 | $page['items'], |
---|
122 | $conf['menubar_tag_cloud_items_number'], |
---|
123 | $page['tag_ids'] |
---|
124 | ); |
---|
125 | $tags = add_level_to_tags($tags); |
---|
126 | |
---|
127 | foreach ($tags as $tag) |
---|
128 | { |
---|
129 | $block->data[] = array_merge( |
---|
130 | $tag, |
---|
131 | array( |
---|
132 | 'U_ADD' => make_index_url( |
---|
133 | array( |
---|
134 | 'tags' => array_merge( |
---|
135 | $page['tags'], |
---|
136 | array($tag) |
---|
137 | ) |
---|
138 | ) |
---|
139 | ), |
---|
140 | 'URL' => make_index_url( array( 'tags' => array($tag) ) |
---|
141 | ), |
---|
142 | ) |
---|
143 | ); |
---|
144 | } |
---|
145 | } |
---|
146 | else |
---|
147 | { |
---|
148 | $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] ); |
---|
149 | $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) ); |
---|
150 | foreach ($tags as $tag) |
---|
151 | { |
---|
152 | $block->data[] = |
---|
153 | array_merge( $tag, |
---|
154 | array( |
---|
155 | 'URL' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
156 | ) |
---|
157 | ); |
---|
158 | } |
---|
159 | } |
---|
160 | if ( !empty($block->data) ) |
---|
161 | { |
---|
162 | $block->template = 'menubar_tags.tpl'; |
---|
163 | } |
---|
164 | } |
---|
165 | |
---|
166 | //----------------------------------------------------------- special categories |
---|
167 | if ( ($block = $menu->get_block('mbSpecials')) != null ) |
---|
168 | { |
---|
169 | if ( !is_a_guest() ) |
---|
170 | {// favorites |
---|
171 | $block->data['favorites'] = |
---|
172 | array( |
---|
173 | 'URL' => make_index_url(array('section' => 'favorites')), |
---|
174 | 'TITLE' => l10n('display your favorites photos'), |
---|
175 | 'NAME' => l10n('Your favorites') |
---|
176 | ); |
---|
177 | } |
---|
178 | |
---|
179 | $block->data['most_visited'] = |
---|
180 | array( |
---|
181 | 'URL' => make_index_url(array('section' => 'most_visited')), |
---|
182 | 'TITLE' => l10n('display most visited photos'), |
---|
183 | 'NAME' => l10n('Most visited') |
---|
184 | ); |
---|
185 | |
---|
186 | if ($conf['rate']) |
---|
187 | { |
---|
188 | $block->data['best_rated'] = |
---|
189 | array( |
---|
190 | 'URL' => make_index_url(array('section' => 'best_rated')), |
---|
191 | 'TITLE' => l10n('display best rated photos'), |
---|
192 | 'NAME' => l10n('Best rated') |
---|
193 | ); |
---|
194 | } |
---|
195 | |
---|
196 | $block->data['recent_pics'] = |
---|
197 | array( |
---|
198 | 'URL' => make_index_url(array('section' => 'recent_pics')), |
---|
199 | 'TITLE' => l10n('display most recent photos'), |
---|
200 | 'NAME' => l10n('Recent photos'), |
---|
201 | ); |
---|
202 | |
---|
203 | $block->data['recent_cats'] = |
---|
204 | array( |
---|
205 | 'URL' => make_index_url(array('section' => 'recent_cats')), |
---|
206 | 'TITLE' => l10n('display recently updated albums'), |
---|
207 | 'NAME' => l10n('Recent albums'), |
---|
208 | ); |
---|
209 | |
---|
210 | $block->data['random'] = |
---|
211 | array( |
---|
212 | 'URL' => get_root_url().'random.php', |
---|
213 | 'TITLE' => l10n('display a set of random photos'), |
---|
214 | 'NAME' => l10n('Random photos'), |
---|
215 | 'REL'=> 'rel="nofollow"' |
---|
216 | ); |
---|
217 | |
---|
218 | $block->data['calendar'] = |
---|
219 | array( |
---|
220 | 'URL' => |
---|
221 | make_index_url( |
---|
222 | array( |
---|
223 | 'chronology_field' => ($conf['calendar_datefield']=='date_available' |
---|
224 | ? 'posted' : 'created'), |
---|
225 | 'chronology_style'=> 'monthly', |
---|
226 | 'chronology_view' => 'calendar' |
---|
227 | ) |
---|
228 | ), |
---|
229 | 'TITLE' => l10n('display each day with photos, month per month'), |
---|
230 | 'NAME' => l10n('Calendar'), |
---|
231 | 'REL'=> 'rel="nofollow"' |
---|
232 | ); |
---|
233 | $block->template = 'menubar_specials.tpl'; |
---|
234 | } |
---|
235 | |
---|
236 | |
---|
237 | //---------------------------------------------------------------------- summary |
---|
238 | if ( ($block=$menu->get_block('mbMenu')) != null ) |
---|
239 | { |
---|
240 | // quick search block will be displayed only if data['qsearch'] is set |
---|
241 | // to "yes" |
---|
242 | $block->data['qsearch']=true; |
---|
243 | |
---|
244 | // tags link |
---|
245 | $block->data['tags'] = |
---|
246 | array( |
---|
247 | 'TITLE' => l10n('display available tags'), |
---|
248 | 'NAME' => l10n('Tags'), |
---|
249 | 'URL'=> get_root_url().'tags.php', |
---|
250 | 'COUNTER' => get_nb_available_tags(), |
---|
251 | ); |
---|
252 | |
---|
253 | // search link |
---|
254 | $block->data['search'] = |
---|
255 | array( |
---|
256 | 'TITLE'=>l10n('search'), |
---|
257 | 'NAME'=>l10n('Search'), |
---|
258 | 'URL'=> get_root_url().'search.php', |
---|
259 | 'REL'=> 'rel="search"' |
---|
260 | ); |
---|
261 | |
---|
262 | if ($conf['activate_comments']) |
---|
263 | { |
---|
264 | // comments link |
---|
265 | $block->data['comments'] = |
---|
266 | array( |
---|
267 | 'TITLE'=>l10n('display last user comments'), |
---|
268 | 'NAME'=>l10n('Comments'), |
---|
269 | 'URL'=> get_root_url().'comments.php', |
---|
270 | 'COUNTER' => get_nb_available_comments(), |
---|
271 | ); |
---|
272 | } |
---|
273 | |
---|
274 | // about link |
---|
275 | $block->data['about'] = |
---|
276 | array( |
---|
277 | 'TITLE' => l10n('About Piwigo'), |
---|
278 | 'NAME' => l10n('About'), |
---|
279 | 'URL' => get_root_url().'about.php', |
---|
280 | ); |
---|
281 | |
---|
282 | // notification |
---|
283 | $block->data['rss'] = |
---|
284 | array( |
---|
285 | 'TITLE'=>l10n('RSS feed'), |
---|
286 | 'NAME'=>l10n('Notification'), |
---|
287 | 'URL'=> get_root_url().'notification.php', |
---|
288 | 'REL'=> 'rel="nofollow"' |
---|
289 | ); |
---|
290 | $block->template = 'menubar_menu.tpl'; |
---|
291 | } |
---|
292 | |
---|
293 | |
---|
294 | //--------------------------------------------------------------- identification |
---|
295 | if (is_a_guest()) |
---|
296 | { |
---|
297 | $template->assign( |
---|
298 | array( |
---|
299 | 'U_LOGIN' => get_root_url().'identification.php', |
---|
300 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
---|
301 | 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'] |
---|
302 | ) |
---|
303 | ); |
---|
304 | if ($conf['allow_user_registration']) |
---|
305 | { |
---|
306 | $template->assign( 'U_REGISTER', get_root_url().'register.php'); |
---|
307 | } |
---|
308 | } |
---|
309 | else |
---|
310 | { |
---|
311 | $template->assign('USERNAME', stripslashes($user['username'])); |
---|
312 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
313 | { |
---|
314 | $template->assign('U_PROFILE', get_root_url().'profile.php'); |
---|
315 | } |
---|
316 | |
---|
317 | // the logout link has no meaning with Apache authentication : it is not |
---|
318 | // possible to logout with this kind of authentication. |
---|
319 | if (!$conf['apache_authentication']) |
---|
320 | { |
---|
321 | $template->assign('U_LOGOUT', get_root_url().'?act=logout'); |
---|
322 | } |
---|
323 | if (is_admin()) |
---|
324 | { |
---|
325 | $template->assign('U_ADMIN', get_root_url().'admin.php'); |
---|
326 | } |
---|
327 | } |
---|
328 | if ( ($block=$menu->get_block('mbIdentification')) != null ) |
---|
329 | { |
---|
330 | $block->template = 'menubar_identification.tpl'; |
---|
331 | } |
---|
332 | $menu->apply('MENUBAR', 'menubar.tpl' ); |
---|
333 | } |
---|
334 | |
---|
335 | ?> |
---|