[1367] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[26461] | 5 | // | Copyright(C) 2008-2014 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 | /** |
---|
[25762] | 25 | * @package functions\menubar |
---|
[1436] | 26 | */ |
---|
[1367] | 27 | |
---|
[2488] | 28 | include_once(PHPWG_ROOT_PATH.'include/block.class.php'); |
---|
[1595] | 29 | |
---|
[2488] | 30 | initialize_menu(); |
---|
[1367] | 31 | |
---|
[25762] | 32 | /** |
---|
| 33 | * Setups each block the main menubar. |
---|
| 34 | */ |
---|
[2488] | 35 | function initialize_menu() |
---|
[1367] | 36 | { |
---|
[2488] | 37 | global $page, $conf, $user, $template, $filter; |
---|
| 38 | |
---|
| 39 | $menu = new BlockManager("menubar"); |
---|
| 40 | $menu->load_registered_blocks(); |
---|
| 41 | $menu->prepare_display(); |
---|
| 42 | |
---|
[28484] | 43 | if ( @$page['section']=='search' and isset($page['qsearch_details']) ) |
---|
[28316] | 44 | { |
---|
| 45 | $template->assign('QUERY_SEARCH', htmlspecialchars($page['qsearch_details']['q']) ); |
---|
| 46 | } |
---|
| 47 | |
---|
[2488] | 48 | //--------------------------------------------------------------- external links |
---|
| 49 | if ( ($block=$menu->get_block('mbLinks')) and !empty($conf['links']) ) |
---|
[1728] | 50 | { |
---|
[8223] | 51 | $block->data = array(); |
---|
[2488] | 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 | } |
---|
[8223] | 79 | $block->data[] = $tpl_var; |
---|
[2488] | 80 | } |
---|
| 81 | } |
---|
[8223] | 82 | if ( !empty($block->data) ) |
---|
| 83 | { |
---|
| 84 | $block->template = 'menubar_links.tpl'; |
---|
| 85 | } |
---|
[1728] | 86 | } |
---|
| 87 | |
---|
[2488] | 88 | //-------------------------------------------------------------- categories |
---|
| 89 | $block = $menu->get_block('mbCategories'); |
---|
| 90 | //------------------------------------------------------------------------ filter |
---|
[5293] | 91 | if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used')) |
---|
[1728] | 92 | { |
---|
[2488] | 93 | if ($filter['enabled']) |
---|
[1728] | 94 | { |
---|
[2488] | 95 | $template->assign( |
---|
| 96 | 'U_STOP_FILTER', |
---|
| 97 | add_url_params(make_index_url(array()), array('filter' => 'stop')) |
---|
[1743] | 98 | ); |
---|
[1728] | 99 | } |
---|
[2488] | 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 | } |
---|
[1728] | 107 | } |
---|
[1677] | 108 | |
---|
[2488] | 109 | if ( $block!=null ) |
---|
[1722] | 110 | { |
---|
[2488] | 111 | $block->data = array( |
---|
| 112 | 'NB_PICTURE' => $user['nb_total_images'], |
---|
[3171] | 113 | 'MENU_CATEGORIES' => get_categories_menu(), |
---|
[2488] | 114 | 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), |
---|
| 115 | ); |
---|
| 116 | $block->template = 'menubar_categories.tpl'; |
---|
[1722] | 117 | } |
---|
[1677] | 118 | |
---|
[1367] | 119 | //------------------------------------------------------------------------ tags |
---|
[2488] | 120 | $block = $menu->get_block('mbTags'); |
---|
[21040] | 121 | if ( $block!=null and !empty($page['items']) and 'picture' != script_basename() ) |
---|
[1367] | 122 | { |
---|
[5752] | 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); |
---|
[2488] | 131 | |
---|
[5752] | 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 |
---|
[2488] | 152 | { |
---|
[5752] | 153 | $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] ); |
---|
[6716] | 154 | $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) ); |
---|
[5752] | 155 | foreach ($tags as $tag) |
---|
| 156 | { |
---|
| 157 | $block->data[] = |
---|
| 158 | array_merge( $tag, |
---|
| 159 | array( |
---|
| 160 | 'URL' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
[5703] | 161 | ) |
---|
[2488] | 162 | ); |
---|
[5752] | 163 | } |
---|
[2488] | 164 | } |
---|
[5752] | 165 | if ( !empty($block->data) ) |
---|
| 166 | { |
---|
| 167 | $block->template = 'menubar_tags.tpl'; |
---|
| 168 | } |
---|
[1367] | 169 | } |
---|
| 170 | |
---|
[2488] | 171 | //----------------------------------------------------------- special categories |
---|
| 172 | if ( ($block = $menu->get_block('mbSpecials')) != null ) |
---|
[1367] | 173 | { |
---|
[2488] | 174 | if ( !is_a_guest() ) |
---|
| 175 | {// favorites |
---|
| 176 | $block->data['favorites'] = |
---|
[2409] | 177 | array( |
---|
[2488] | 178 | 'URL' => make_index_url(array('section' => 'favorites')), |
---|
[8665] | 179 | 'TITLE' => l10n('display your favorites photos'), |
---|
| 180 | 'NAME' => l10n('Your favorites') |
---|
[2488] | 181 | ); |
---|
| 182 | } |
---|
[1367] | 183 | |
---|
[2488] | 184 | $block->data['most_visited'] = |
---|
| 185 | array( |
---|
| 186 | 'URL' => make_index_url(array('section' => 'most_visited')), |
---|
[8665] | 187 | 'TITLE' => l10n('display most visited photos'), |
---|
[5021] | 188 | 'NAME' => l10n('Most visited') |
---|
[1367] | 189 | ); |
---|
| 190 | |
---|
[2488] | 191 | if ($conf['rate']) |
---|
| 192 | { |
---|
| 193 | $block->data['best_rated'] = |
---|
[1367] | 194 | array( |
---|
[2488] | 195 | 'URL' => make_index_url(array('section' => 'best_rated')), |
---|
[8665] | 196 | 'TITLE' => l10n('display best rated photos'), |
---|
[5021] | 197 | 'NAME' => l10n('Best rated') |
---|
[2488] | 198 | ); |
---|
| 199 | } |
---|
[1367] | 200 | |
---|
[2488] | 201 | $block->data['recent_pics'] = |
---|
| 202 | array( |
---|
| 203 | 'URL' => make_index_url(array('section' => 'recent_pics')), |
---|
[8665] | 204 | 'TITLE' => l10n('display most recent photos'), |
---|
| 205 | 'NAME' => l10n('Recent photos'), |
---|
[2488] | 206 | ); |
---|
[1367] | 207 | |
---|
[2488] | 208 | $block->data['recent_cats'] = |
---|
| 209 | array( |
---|
| 210 | 'URL' => make_index_url(array('section' => 'recent_cats')), |
---|
[6951] | 211 | 'TITLE' => l10n('display recently updated albums'), |
---|
| 212 | 'NAME' => l10n('Recent albums'), |
---|
[2488] | 213 | ); |
---|
[1367] | 214 | |
---|
[21817] | 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 | ); |
---|
[2488] | 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 | ), |
---|
[8665] | 234 | 'TITLE' => l10n('display each day with photos, month per month'), |
---|
[5021] | 235 | 'NAME' => l10n('Calendar'), |
---|
[2488] | 236 | 'REL'=> 'rel="nofollow"' |
---|
| 237 | ); |
---|
| 238 | $block->template = 'menubar_specials.tpl'; |
---|
[1367] | 239 | } |
---|
| 240 | |
---|
[2488] | 241 | |
---|
| 242 | //---------------------------------------------------------------------- summary |
---|
| 243 | if ( ($block=$menu->get_block('mbMenu')) != null ) |
---|
[1367] | 244 | { |
---|
[2810] | 245 | // quick search block will be displayed only if data['qsearch'] is set |
---|
| 246 | // to "yes" |
---|
[2813] | 247 | $block->data['qsearch']=true; |
---|
[2810] | 248 | |
---|
[2488] | 249 | // tags link |
---|
| 250 | $block->data['tags'] = |
---|
| 251 | array( |
---|
[8665] | 252 | 'TITLE' => l10n('display available tags'), |
---|
[2488] | 253 | 'NAME' => l10n('Tags'), |
---|
| 254 | 'URL'=> get_root_url().'tags.php', |
---|
[21817] | 255 | 'COUNTER' => get_nb_available_tags(), |
---|
[2488] | 256 | ); |
---|
[1367] | 257 | |
---|
[2488] | 258 | // search link |
---|
| 259 | $block->data['search'] = |
---|
| 260 | array( |
---|
[5021] | 261 | 'TITLE'=>l10n('search'), |
---|
[2488] | 262 | 'NAME'=>l10n('Search'), |
---|
| 263 | 'URL'=> get_root_url().'search.php', |
---|
| 264 | 'REL'=> 'rel="search"' |
---|
| 265 | ); |
---|
[1367] | 266 | |
---|
[12887] | 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', |
---|
[21817] | 275 | 'COUNTER' => get_nb_available_comments(), |
---|
[12887] | 276 | ); |
---|
| 277 | } |
---|
[1367] | 278 | |
---|
[2488] | 279 | // about link |
---|
| 280 | $block->data['about'] = |
---|
| 281 | array( |
---|
[5021] | 282 | 'TITLE' => l10n('About Piwigo'), |
---|
[2488] | 283 | 'NAME' => l10n('About'), |
---|
| 284 | 'URL' => get_root_url().'about.php', |
---|
| 285 | ); |
---|
[1367] | 286 | |
---|
[2488] | 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 | } |
---|
[1367] | 297 | |
---|
[1436] | 298 | |
---|
[2488] | 299 | //--------------------------------------------------------------- identification |
---|
| 300 | if (is_a_guest()) |
---|
| 301 | { |
---|
| 302 | $template->assign( |
---|
| 303 | array( |
---|
| 304 | 'U_LOGIN' => get_root_url().'identification.php', |
---|
[2515] | 305 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
---|
[2488] | 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 | { |
---|
[4304] | 316 | $template->assign('USERNAME', stripslashes($user['username'])); |
---|
[2488] | 317 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
| 318 | { |
---|
| 319 | $template->assign('U_PROFILE', get_root_url().'profile.php'); |
---|
| 320 | } |
---|
[2325] | 321 | |
---|
[2488] | 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 | } |
---|
[25762] | 339 | |
---|
[6951] | 340 | ?> |
---|