[1367] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[5196] | 5 | // | Copyright(C) 2008-2010 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 | { |
---|
[2488] | 44 | $data = array(); |
---|
| 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 | } |
---|
| 72 | $data[] = $tpl_var; |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | $block->template = 'menubar_links.tpl'; |
---|
| 76 | $block->data = $data; |
---|
[1728] | 77 | } |
---|
| 78 | |
---|
[2488] | 79 | //-------------------------------------------------------------- categories |
---|
| 80 | $block = $menu->get_block('mbCategories'); |
---|
| 81 | //------------------------------------------------------------------------ filter |
---|
[5293] | 82 | if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used')) |
---|
[1728] | 83 | { |
---|
[2488] | 84 | if ($filter['enabled']) |
---|
[1728] | 85 | { |
---|
[2488] | 86 | $template->assign( |
---|
| 87 | 'U_STOP_FILTER', |
---|
| 88 | add_url_params(make_index_url(array()), array('filter' => 'stop')) |
---|
[1743] | 89 | ); |
---|
[1728] | 90 | } |
---|
[2488] | 91 | else |
---|
| 92 | { |
---|
| 93 | $template->assign( |
---|
| 94 | 'U_START_FILTER', |
---|
| 95 | add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period'])) |
---|
| 96 | ); |
---|
| 97 | } |
---|
[1728] | 98 | } |
---|
[1677] | 99 | |
---|
[2488] | 100 | if ( $block!=null ) |
---|
[1722] | 101 | { |
---|
[2488] | 102 | $block->data = array( |
---|
| 103 | 'NB_PICTURE' => $user['nb_total_images'], |
---|
[3171] | 104 | 'MENU_CATEGORIES' => get_categories_menu(), |
---|
[2488] | 105 | 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), |
---|
| 106 | 'U_UPLOAD' => get_upload_menu_link() |
---|
| 107 | ); |
---|
| 108 | $block->template = 'menubar_categories.tpl'; |
---|
[1722] | 109 | } |
---|
[1677] | 110 | |
---|
[1367] | 111 | //------------------------------------------------------------------------ tags |
---|
[2488] | 112 | $block = $menu->get_block('mbTags'); |
---|
[5752] | 113 | if ( $block!=null and !empty($page['items']) ) |
---|
[1367] | 114 | { |
---|
[5752] | 115 | if ('tags'==@$page['section']) |
---|
| 116 | { |
---|
| 117 | $tags = get_common_tags( |
---|
| 118 | $page['items'], |
---|
| 119 | $conf['menubar_tag_cloud_items_number'], |
---|
| 120 | $page['tag_ids'] |
---|
| 121 | ); |
---|
| 122 | $tags = add_level_to_tags($tags); |
---|
[2488] | 123 | |
---|
[5752] | 124 | foreach ($tags as $tag) |
---|
| 125 | { |
---|
| 126 | $block->data[] = array_merge( |
---|
| 127 | $tag, |
---|
| 128 | array( |
---|
| 129 | 'U_ADD' => make_index_url( |
---|
| 130 | array( |
---|
| 131 | 'tags' => array_merge( |
---|
| 132 | $page['tags'], |
---|
| 133 | array($tag) |
---|
| 134 | ) |
---|
| 135 | ) |
---|
| 136 | ), |
---|
| 137 | 'URL' => make_index_url( array( 'tags' => array($tag) ) |
---|
| 138 | ), |
---|
| 139 | ) |
---|
| 140 | ); |
---|
| 141 | } |
---|
| 142 | } |
---|
| 143 | else |
---|
[2488] | 144 | { |
---|
[5752] | 145 | $selection = array_slice( $page['items'], $page['start'], $page['nb_image_page'] ); |
---|
| 146 | $tags = add_level_to_tags( get_common_tags($selection, 12) ); |
---|
| 147 | foreach ($tags as $tag) |
---|
| 148 | { |
---|
| 149 | $block->data[] = |
---|
| 150 | array_merge( $tag, |
---|
| 151 | array( |
---|
| 152 | 'URL' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
[5703] | 153 | ) |
---|
[2488] | 154 | ); |
---|
[5752] | 155 | } |
---|
[2488] | 156 | } |
---|
[5752] | 157 | if ( !empty($block->data) ) |
---|
| 158 | { |
---|
| 159 | $block->template = 'menubar_tags.tpl'; |
---|
| 160 | } |
---|
[1367] | 161 | } |
---|
| 162 | |
---|
[2488] | 163 | //----------------------------------------------------------- special categories |
---|
| 164 | if ( ($block = $menu->get_block('mbSpecials')) != null ) |
---|
[1367] | 165 | { |
---|
[2488] | 166 | if ( !is_a_guest() ) |
---|
| 167 | {// favorites |
---|
| 168 | $block->data['favorites'] = |
---|
[2409] | 169 | array( |
---|
[2488] | 170 | 'URL' => make_index_url(array('section' => 'favorites')), |
---|
[5021] | 171 | 'TITLE' => l10n('display my favorites pictures'), |
---|
| 172 | 'NAME' => l10n('My favorites') |
---|
[2488] | 173 | ); |
---|
| 174 | } |
---|
[1367] | 175 | |
---|
[2488] | 176 | $block->data['most_visited'] = |
---|
| 177 | array( |
---|
| 178 | 'URL' => make_index_url(array('section' => 'most_visited')), |
---|
[5021] | 179 | 'TITLE' => l10n('display most visited pictures'), |
---|
| 180 | 'NAME' => l10n('Most visited') |
---|
[1367] | 181 | ); |
---|
| 182 | |
---|
[2488] | 183 | if ($conf['rate']) |
---|
| 184 | { |
---|
| 185 | $block->data['best_rated'] = |
---|
[1367] | 186 | array( |
---|
[2488] | 187 | 'URL' => make_index_url(array('section' => 'best_rated')), |
---|
[5021] | 188 | 'TITLE' => l10n('display best rated items'), |
---|
| 189 | 'NAME' => l10n('Best rated') |
---|
[2488] | 190 | ); |
---|
| 191 | } |
---|
[1367] | 192 | |
---|
[2488] | 193 | $block->data['random'] = |
---|
[2231] | 194 | array( |
---|
[2488] | 195 | 'URL' => get_root_url().'random.php', |
---|
[5021] | 196 | 'TITLE' => l10n('display a set of random pictures'), |
---|
| 197 | 'NAME' => l10n('Random pictures'), |
---|
[2488] | 198 | 'REL'=> 'rel="nofollow"' |
---|
| 199 | ); |
---|
[1367] | 200 | |
---|
[2488] | 201 | $block->data['recent_pics'] = |
---|
| 202 | array( |
---|
| 203 | 'URL' => make_index_url(array('section' => 'recent_pics')), |
---|
[5021] | 204 | 'TITLE' => l10n('display most recent pictures'), |
---|
| 205 | 'NAME' => l10n('Recent pictures'), |
---|
[2488] | 206 | ); |
---|
[1367] | 207 | |
---|
[2488] | 208 | $block->data['recent_cats'] = |
---|
| 209 | array( |
---|
| 210 | 'URL' => make_index_url(array('section' => 'recent_cats')), |
---|
[5021] | 211 | 'TITLE' => l10n('display recently updated categories'), |
---|
| 212 | 'NAME' => l10n('Recent categories'), |
---|
[2488] | 213 | ); |
---|
[1367] | 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 | ), |
---|
[5021] | 227 | 'TITLE' => l10n('display each day with pictures, month per month'), |
---|
| 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( |
---|
| 245 | 'TITLE' => l10n('See available tags'), |
---|
| 246 | 'NAME' => l10n('Tags'), |
---|
| 247 | 'URL'=> get_root_url().'tags.php', |
---|
| 248 | ); |
---|
[1367] | 249 | |
---|
[2488] | 250 | // search link |
---|
| 251 | $block->data['search'] = |
---|
| 252 | array( |
---|
[5021] | 253 | 'TITLE'=>l10n('search'), |
---|
[2488] | 254 | 'NAME'=>l10n('Search'), |
---|
| 255 | 'URL'=> get_root_url().'search.php', |
---|
| 256 | 'REL'=> 'rel="search"' |
---|
| 257 | ); |
---|
[1367] | 258 | |
---|
[2488] | 259 | // comments link |
---|
| 260 | $block->data['comments'] = |
---|
| 261 | array( |
---|
[5021] | 262 | 'TITLE'=>l10n('See last users comments'), |
---|
| 263 | 'NAME'=>l10n('Comments'), |
---|
[2488] | 264 | 'URL'=> get_root_url().'comments.php', |
---|
| 265 | ); |
---|
[1367] | 266 | |
---|
[2488] | 267 | // about link |
---|
| 268 | $block->data['about'] = |
---|
| 269 | array( |
---|
[5021] | 270 | 'TITLE' => l10n('About Piwigo'), |
---|
[2488] | 271 | 'NAME' => l10n('About'), |
---|
| 272 | 'URL' => get_root_url().'about.php', |
---|
| 273 | ); |
---|
[1367] | 274 | |
---|
[2488] | 275 | // notification |
---|
| 276 | $block->data['rss'] = |
---|
| 277 | array( |
---|
| 278 | 'TITLE'=>l10n('RSS feed'), |
---|
| 279 | 'NAME'=>l10n('Notification'), |
---|
| 280 | 'URL'=> get_root_url().'notification.php', |
---|
| 281 | 'REL'=> 'rel="nofollow"' |
---|
| 282 | ); |
---|
| 283 | $block->template = 'menubar_menu.tpl'; |
---|
| 284 | } |
---|
[1367] | 285 | |
---|
[1436] | 286 | |
---|
[2488] | 287 | //--------------------------------------------------------------- identification |
---|
| 288 | if (is_a_guest()) |
---|
| 289 | { |
---|
| 290 | $template->assign( |
---|
| 291 | array( |
---|
| 292 | 'U_LOGIN' => get_root_url().'identification.php', |
---|
[2515] | 293 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
---|
[2488] | 294 | 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'] |
---|
| 295 | ) |
---|
| 296 | ); |
---|
| 297 | if ($conf['allow_user_registration']) |
---|
| 298 | { |
---|
| 299 | $template->assign( 'U_REGISTER', get_root_url().'register.php'); |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | else |
---|
| 303 | { |
---|
[4304] | 304 | $template->assign('USERNAME', stripslashes($user['username'])); |
---|
[2488] | 305 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
| 306 | { |
---|
| 307 | $template->assign('U_PROFILE', get_root_url().'profile.php'); |
---|
| 308 | } |
---|
[2325] | 309 | |
---|
[2488] | 310 | // the logout link has no meaning with Apache authentication : it is not |
---|
| 311 | // possible to logout with this kind of authentication. |
---|
| 312 | if (!$conf['apache_authentication']) |
---|
| 313 | { |
---|
| 314 | $template->assign('U_LOGOUT', get_root_url().'?act=logout'); |
---|
| 315 | } |
---|
| 316 | if (is_admin()) |
---|
| 317 | { |
---|
| 318 | $template->assign('U_ADMIN', get_root_url().'admin.php'); |
---|
| 319 | } |
---|
| 320 | } |
---|
| 321 | if ( ($block=$menu->get_block('mbIdentification')) != null ) |
---|
| 322 | { |
---|
| 323 | $block->template = 'menubar_identification.tpl'; |
---|
| 324 | } |
---|
| 325 | $menu->apply('MENUBAR', 'menubar.tpl' ); |
---|
| 326 | } |
---|
[1367] | 327 | ?> |
---|