[1367] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[12922] | 5 | // | Copyright(C) 2008-2012 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'); |
---|
[5752] | 114 | if ( $block!=null and !empty($page['items']) ) |
---|
[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['random'] = |
---|
[2231] | 195 | array( |
---|
[2488] | 196 | 'URL' => get_root_url().'random.php', |
---|
[8665] | 197 | 'TITLE' => l10n('display a set of random photos'), |
---|
| 198 | 'NAME' => l10n('Random photos'), |
---|
[2488] | 199 | 'REL'=> 'rel="nofollow"' |
---|
| 200 | ); |
---|
[1367] | 201 | |
---|
[2488] | 202 | $block->data['recent_pics'] = |
---|
| 203 | array( |
---|
| 204 | 'URL' => make_index_url(array('section' => 'recent_pics')), |
---|
[8665] | 205 | 'TITLE' => l10n('display most recent photos'), |
---|
| 206 | 'NAME' => l10n('Recent photos'), |
---|
[2488] | 207 | ); |
---|
[1367] | 208 | |
---|
[2488] | 209 | $block->data['recent_cats'] = |
---|
| 210 | array( |
---|
| 211 | 'URL' => make_index_url(array('section' => 'recent_cats')), |
---|
[6951] | 212 | 'TITLE' => l10n('display recently updated albums'), |
---|
| 213 | 'NAME' => l10n('Recent albums'), |
---|
[2488] | 214 | ); |
---|
[1367] | 215 | |
---|
[2488] | 216 | |
---|
| 217 | $block->data['calendar'] = |
---|
| 218 | array( |
---|
| 219 | 'URL' => |
---|
| 220 | make_index_url( |
---|
| 221 | array( |
---|
| 222 | 'chronology_field' => ($conf['calendar_datefield']=='date_available' |
---|
| 223 | ? 'posted' : 'created'), |
---|
| 224 | 'chronology_style'=> 'monthly', |
---|
| 225 | 'chronology_view' => 'calendar' |
---|
| 226 | ) |
---|
| 227 | ), |
---|
[8665] | 228 | 'TITLE' => l10n('display each day with photos, month per month'), |
---|
[5021] | 229 | 'NAME' => l10n('Calendar'), |
---|
[2488] | 230 | 'REL'=> 'rel="nofollow"' |
---|
| 231 | ); |
---|
| 232 | $block->template = 'menubar_specials.tpl'; |
---|
[1367] | 233 | } |
---|
| 234 | |
---|
[2488] | 235 | |
---|
| 236 | //---------------------------------------------------------------------- summary |
---|
| 237 | if ( ($block=$menu->get_block('mbMenu')) != null ) |
---|
[1367] | 238 | { |
---|
[2810] | 239 | // quick search block will be displayed only if data['qsearch'] is set |
---|
| 240 | // to "yes" |
---|
[2813] | 241 | $block->data['qsearch']=true; |
---|
[2810] | 242 | |
---|
[2488] | 243 | // tags link |
---|
| 244 | $block->data['tags'] = |
---|
| 245 | array( |
---|
[8665] | 246 | 'TITLE' => l10n('display available tags'), |
---|
[2488] | 247 | 'NAME' => l10n('Tags'), |
---|
| 248 | 'URL'=> get_root_url().'tags.php', |
---|
| 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', |
---|
| 268 | ); |
---|
| 269 | } |
---|
[1367] | 270 | |
---|
[2488] | 271 | // about link |
---|
| 272 | $block->data['about'] = |
---|
| 273 | array( |
---|
[5021] | 274 | 'TITLE' => l10n('About Piwigo'), |
---|
[2488] | 275 | 'NAME' => l10n('About'), |
---|
| 276 | 'URL' => get_root_url().'about.php', |
---|
| 277 | ); |
---|
[1367] | 278 | |
---|
[2488] | 279 | // notification |
---|
| 280 | $block->data['rss'] = |
---|
| 281 | array( |
---|
| 282 | 'TITLE'=>l10n('RSS feed'), |
---|
| 283 | 'NAME'=>l10n('Notification'), |
---|
| 284 | 'URL'=> get_root_url().'notification.php', |
---|
| 285 | 'REL'=> 'rel="nofollow"' |
---|
| 286 | ); |
---|
| 287 | $block->template = 'menubar_menu.tpl'; |
---|
| 288 | } |
---|
[1367] | 289 | |
---|
[1436] | 290 | |
---|
[2488] | 291 | //--------------------------------------------------------------- identification |
---|
| 292 | if (is_a_guest()) |
---|
| 293 | { |
---|
| 294 | $template->assign( |
---|
| 295 | array( |
---|
| 296 | 'U_LOGIN' => get_root_url().'identification.php', |
---|
[2515] | 297 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
---|
[2488] | 298 | 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'] |
---|
| 299 | ) |
---|
| 300 | ); |
---|
| 301 | if ($conf['allow_user_registration']) |
---|
| 302 | { |
---|
| 303 | $template->assign( 'U_REGISTER', get_root_url().'register.php'); |
---|
| 304 | } |
---|
| 305 | } |
---|
| 306 | else |
---|
| 307 | { |
---|
[4304] | 308 | $template->assign('USERNAME', stripslashes($user['username'])); |
---|
[2488] | 309 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
| 310 | { |
---|
| 311 | $template->assign('U_PROFILE', get_root_url().'profile.php'); |
---|
| 312 | } |
---|
[2325] | 313 | |
---|
[2488] | 314 | // the logout link has no meaning with Apache authentication : it is not |
---|
| 315 | // possible to logout with this kind of authentication. |
---|
| 316 | if (!$conf['apache_authentication']) |
---|
| 317 | { |
---|
| 318 | $template->assign('U_LOGOUT', get_root_url().'?act=logout'); |
---|
| 319 | } |
---|
| 320 | if (is_admin()) |
---|
| 321 | { |
---|
| 322 | $template->assign('U_ADMIN', get_root_url().'admin.php'); |
---|
| 323 | } |
---|
| 324 | } |
---|
| 325 | if ( ($block=$menu->get_block('mbIdentification')) != null ) |
---|
| 326 | { |
---|
| 327 | $block->template = 'menubar_identification.tpl'; |
---|
| 328 | } |
---|
| 329 | $menu->apply('MENUBAR', 'menubar.tpl' ); |
---|
| 330 | } |
---|
[6951] | 331 | ?> |
---|