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