[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 | /** |
---|
[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 | |
---|
| 43 | //--------------------------------------------------------------- external links |
---|
| 44 | if ( ($block=$menu->get_block('mbLinks')) and !empty($conf['links']) ) |
---|
[1728] | 45 | { |
---|
[8223] | 46 | $block->data = array(); |
---|
[2488] | 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 | } |
---|
[8223] | 74 | $block->data[] = $tpl_var; |
---|
[2488] | 75 | } |
---|
| 76 | } |
---|
[8223] | 77 | if ( !empty($block->data) ) |
---|
| 78 | { |
---|
| 79 | $block->template = 'menubar_links.tpl'; |
---|
| 80 | } |
---|
[1728] | 81 | } |
---|
| 82 | |
---|
[2488] | 83 | //-------------------------------------------------------------- categories |
---|
| 84 | $block = $menu->get_block('mbCategories'); |
---|
| 85 | //------------------------------------------------------------------------ filter |
---|
[5293] | 86 | if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used')) |
---|
[1728] | 87 | { |
---|
[2488] | 88 | if ($filter['enabled']) |
---|
[1728] | 89 | { |
---|
[2488] | 90 | $template->assign( |
---|
| 91 | 'U_STOP_FILTER', |
---|
| 92 | add_url_params(make_index_url(array()), array('filter' => 'stop')) |
---|
[1743] | 93 | ); |
---|
[1728] | 94 | } |
---|
[2488] | 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 | } |
---|
[1728] | 102 | } |
---|
[1677] | 103 | |
---|
[2488] | 104 | if ( $block!=null ) |
---|
[1722] | 105 | { |
---|
[2488] | 106 | $block->data = array( |
---|
| 107 | 'NB_PICTURE' => $user['nb_total_images'], |
---|
[3171] | 108 | 'MENU_CATEGORIES' => get_categories_menu(), |
---|
[2488] | 109 | 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), |
---|
| 110 | ); |
---|
| 111 | $block->template = 'menubar_categories.tpl'; |
---|
[1722] | 112 | } |
---|
[1677] | 113 | |
---|
[1367] | 114 | //------------------------------------------------------------------------ tags |
---|
[2488] | 115 | $block = $menu->get_block('mbTags'); |
---|
[21040] | 116 | if ( $block!=null and !empty($page['items']) and 'picture' != script_basename() ) |
---|
[1367] | 117 | { |
---|
[5752] | 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); |
---|
[2488] | 126 | |
---|
[5752] | 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 |
---|
[2488] | 147 | { |
---|
[5752] | 148 | $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] ); |
---|
[6716] | 149 | $tags = add_level_to_tags( get_common_tags($selection, $conf['content_tag_cloud_items_number']) ); |
---|
[5752] | 150 | foreach ($tags as $tag) |
---|
| 151 | { |
---|
| 152 | $block->data[] = |
---|
| 153 | array_merge( $tag, |
---|
| 154 | array( |
---|
| 155 | 'URL' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
[5703] | 156 | ) |
---|
[2488] | 157 | ); |
---|
[5752] | 158 | } |
---|
[2488] | 159 | } |
---|
[5752] | 160 | if ( !empty($block->data) ) |
---|
| 161 | { |
---|
| 162 | $block->template = 'menubar_tags.tpl'; |
---|
| 163 | } |
---|
[1367] | 164 | } |
---|
| 165 | |
---|
[2488] | 166 | //----------------------------------------------------------- special categories |
---|
| 167 | if ( ($block = $menu->get_block('mbSpecials')) != null ) |
---|
[1367] | 168 | { |
---|
[2488] | 169 | if ( !is_a_guest() ) |
---|
| 170 | {// favorites |
---|
| 171 | $block->data['favorites'] = |
---|
[2409] | 172 | array( |
---|
[2488] | 173 | 'URL' => make_index_url(array('section' => 'favorites')), |
---|
[8665] | 174 | 'TITLE' => l10n('display your favorites photos'), |
---|
| 175 | 'NAME' => l10n('Your favorites') |
---|
[2488] | 176 | ); |
---|
| 177 | } |
---|
[1367] | 178 | |
---|
[2488] | 179 | $block->data['most_visited'] = |
---|
| 180 | array( |
---|
| 181 | 'URL' => make_index_url(array('section' => 'most_visited')), |
---|
[8665] | 182 | 'TITLE' => l10n('display most visited photos'), |
---|
[5021] | 183 | 'NAME' => l10n('Most visited') |
---|
[1367] | 184 | ); |
---|
| 185 | |
---|
[2488] | 186 | if ($conf['rate']) |
---|
| 187 | { |
---|
| 188 | $block->data['best_rated'] = |
---|
[1367] | 189 | array( |
---|
[2488] | 190 | 'URL' => make_index_url(array('section' => 'best_rated')), |
---|
[8665] | 191 | 'TITLE' => l10n('display best rated photos'), |
---|
[5021] | 192 | 'NAME' => l10n('Best rated') |
---|
[2488] | 193 | ); |
---|
| 194 | } |
---|
[1367] | 195 | |
---|
[2488] | 196 | $block->data['recent_pics'] = |
---|
| 197 | array( |
---|
| 198 | 'URL' => make_index_url(array('section' => 'recent_pics')), |
---|
[8665] | 199 | 'TITLE' => l10n('display most recent photos'), |
---|
| 200 | 'NAME' => l10n('Recent photos'), |
---|
[2488] | 201 | ); |
---|
[1367] | 202 | |
---|
[2488] | 203 | $block->data['recent_cats'] = |
---|
| 204 | array( |
---|
| 205 | 'URL' => make_index_url(array('section' => 'recent_cats')), |
---|
[6951] | 206 | 'TITLE' => l10n('display recently updated albums'), |
---|
| 207 | 'NAME' => l10n('Recent albums'), |
---|
[2488] | 208 | ); |
---|
[1367] | 209 | |
---|
[21817] | 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 | ); |
---|
[2488] | 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 | ), |
---|
[8665] | 229 | 'TITLE' => l10n('display each day with photos, month per month'), |
---|
[5021] | 230 | 'NAME' => l10n('Calendar'), |
---|
[2488] | 231 | 'REL'=> 'rel="nofollow"' |
---|
| 232 | ); |
---|
| 233 | $block->template = 'menubar_specials.tpl'; |
---|
[1367] | 234 | } |
---|
| 235 | |
---|
[2488] | 236 | |
---|
| 237 | //---------------------------------------------------------------------- summary |
---|
| 238 | if ( ($block=$menu->get_block('mbMenu')) != null ) |
---|
[1367] | 239 | { |
---|
[2810] | 240 | // quick search block will be displayed only if data['qsearch'] is set |
---|
| 241 | // to "yes" |
---|
[2813] | 242 | $block->data['qsearch']=true; |
---|
[2810] | 243 | |
---|
[2488] | 244 | // tags link |
---|
| 245 | $block->data['tags'] = |
---|
| 246 | array( |
---|
[8665] | 247 | 'TITLE' => l10n('display available tags'), |
---|
[2488] | 248 | 'NAME' => l10n('Tags'), |
---|
| 249 | 'URL'=> get_root_url().'tags.php', |
---|
[21817] | 250 | 'COUNTER' => get_nb_available_tags(), |
---|
[2488] | 251 | ); |
---|
[1367] | 252 | |
---|
[2488] | 253 | // search link |
---|
| 254 | $block->data['search'] = |
---|
| 255 | array( |
---|
[5021] | 256 | 'TITLE'=>l10n('search'), |
---|
[2488] | 257 | 'NAME'=>l10n('Search'), |
---|
| 258 | 'URL'=> get_root_url().'search.php', |
---|
| 259 | 'REL'=> 'rel="search"' |
---|
| 260 | ); |
---|
[1367] | 261 | |
---|
[12887] | 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', |
---|
[21817] | 270 | 'COUNTER' => get_nb_available_comments(), |
---|
[12887] | 271 | ); |
---|
| 272 | } |
---|
[1367] | 273 | |
---|
[2488] | 274 | // about link |
---|
| 275 | $block->data['about'] = |
---|
| 276 | array( |
---|
[5021] | 277 | 'TITLE' => l10n('About Piwigo'), |
---|
[2488] | 278 | 'NAME' => l10n('About'), |
---|
| 279 | 'URL' => get_root_url().'about.php', |
---|
| 280 | ); |
---|
[1367] | 281 | |
---|
[2488] | 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 | } |
---|
[1367] | 292 | |
---|
[1436] | 293 | |
---|
[2488] | 294 | //--------------------------------------------------------------- identification |
---|
| 295 | if (is_a_guest()) |
---|
| 296 | { |
---|
| 297 | $template->assign( |
---|
| 298 | array( |
---|
| 299 | 'U_LOGIN' => get_root_url().'identification.php', |
---|
[2515] | 300 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
---|
[2488] | 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 | { |
---|
[4304] | 311 | $template->assign('USERNAME', stripslashes($user['username'])); |
---|
[2488] | 312 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
| 313 | { |
---|
| 314 | $template->assign('U_PROFILE', get_root_url().'profile.php'); |
---|
| 315 | } |
---|
[2325] | 316 | |
---|
[2488] | 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 | } |
---|
[25762] | 334 | |
---|
[6951] | 335 | ?> |
---|