| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | Piwigo - a PHP based picture gallery | |
|---|
| 4 | // +-----------------------------------------------------------------------+ |
|---|
| 5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
|---|
| 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 | // +-----------------------------------------------------------------------+ |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * This file is included by the main page to show the menu bar |
|---|
| 26 | * |
|---|
| 27 | */ |
|---|
| 28 | |
|---|
| 29 | include_once(PHPWG_ROOT_PATH.'include/block.class.php'); |
|---|
| 30 | |
|---|
| 31 | initialize_menu(); |
|---|
| 32 | |
|---|
| 33 | function initialize_menu() |
|---|
| 34 | { |
|---|
| 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']) ) |
|---|
| 43 | { |
|---|
| 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; |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | //-------------------------------------------------------------- categories |
|---|
| 80 | $block = $menu->get_block('mbCategories'); |
|---|
| 81 | //------------------------------------------------------------------------ filter |
|---|
| 82 | if (!empty($conf['filter_pages']) and get_filter_page_value('used')) |
|---|
| 83 | { |
|---|
| 84 | if ($filter['enabled']) |
|---|
| 85 | { |
|---|
| 86 | $template->assign( |
|---|
| 87 | 'U_STOP_FILTER', |
|---|
| 88 | add_url_params(make_index_url(array()), array('filter' => 'stop')) |
|---|
| 89 | ); |
|---|
| 90 | } |
|---|
| 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 | } |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | if ( $block!=null ) |
|---|
| 101 | { |
|---|
| 102 | $block->data = array( |
|---|
| 103 | 'NB_PICTURE' => $user['nb_total_images'], |
|---|
| 104 | 'MENU_CATEGORIES_CONTENT' => get_categories_menu(), |
|---|
| 105 | 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), |
|---|
| 106 | 'U_UPLOAD' => get_upload_menu_link() |
|---|
| 107 | ); |
|---|
| 108 | $block->template = 'menubar_categories.tpl'; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | //------------------------------------------------------------------------ tags |
|---|
| 112 | $block = $menu->get_block('mbTags'); |
|---|
| 113 | if ( $block!=null and 'tags'==@$page['section'] and !empty($page['items']) ) |
|---|
| 114 | { |
|---|
| 115 | $tags = get_common_tags($page['items'], |
|---|
| 116 | $conf['menubar_tag_cloud_items_number'], $page['tag_ids']); |
|---|
| 117 | $tags = add_level_to_tags($tags); |
|---|
| 118 | |
|---|
| 119 | foreach ($tags as $tag) |
|---|
| 120 | { |
|---|
| 121 | $block->data[] = |
|---|
| 122 | array_merge( $tag, |
|---|
| 123 | array( |
|---|
| 124 | 'URL' => make_index_url( |
|---|
| 125 | array( |
|---|
| 126 | 'tags' => array($tag) |
|---|
| 127 | ) |
|---|
| 128 | ), |
|---|
| 129 | 'U_ADD' => make_index_url( |
|---|
| 130 | array( |
|---|
| 131 | 'tags' => array_merge( |
|---|
| 132 | $page['tags'], |
|---|
| 133 | array($tag) |
|---|
| 134 | ) |
|---|
| 135 | ) |
|---|
| 136 | ), |
|---|
| 137 | ) |
|---|
| 138 | ); |
|---|
| 139 | } |
|---|
| 140 | $block->template = 'menubar_tags.tpl'; |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | //----------------------------------------------------------- special categories |
|---|
| 144 | if ( ($block = $menu->get_block('mbSpecials')) != null ) |
|---|
| 145 | { |
|---|
| 146 | if ( !is_a_guest() ) |
|---|
| 147 | {// favorites |
|---|
| 148 | $block->data['favorites'] = |
|---|
| 149 | array( |
|---|
| 150 | 'URL' => make_index_url(array('section' => 'favorites')), |
|---|
| 151 | 'TITLE' => l10n('favorite_cat_hint'), |
|---|
| 152 | 'NAME' => l10n('favorite_cat') |
|---|
| 153 | ); |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | $block->data['most_visited'] = |
|---|
| 157 | array( |
|---|
| 158 | 'URL' => make_index_url(array('section' => 'most_visited')), |
|---|
| 159 | 'TITLE' => l10n('most_visited_cat_hint'), |
|---|
| 160 | 'NAME' => l10n('most_visited_cat') |
|---|
| 161 | ); |
|---|
| 162 | |
|---|
| 163 | if ($conf['rate']) |
|---|
| 164 | { |
|---|
| 165 | $block->data['best_rated'] = |
|---|
| 166 | array( |
|---|
| 167 | 'URL' => make_index_url(array('section' => 'best_rated')), |
|---|
| 168 | 'TITLE' => l10n('best_rated_cat_hint'), |
|---|
| 169 | 'NAME' => l10n('best_rated_cat') |
|---|
| 170 | ); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | $block->data['random'] = |
|---|
| 174 | array( |
|---|
| 175 | 'URL' => get_root_url().'random.php', |
|---|
| 176 | 'TITLE' => l10n('random_cat_hint'), |
|---|
| 177 | 'NAME' => l10n('random_cat'), |
|---|
| 178 | 'REL'=> 'rel="nofollow"' |
|---|
| 179 | ); |
|---|
| 180 | |
|---|
| 181 | $block->data['recent_pics'] = |
|---|
| 182 | array( |
|---|
| 183 | 'URL' => make_index_url(array('section' => 'recent_pics')), |
|---|
| 184 | 'TITLE' => l10n('recent_pics_cat_hint'), |
|---|
| 185 | 'NAME' => l10n('recent_pics_cat'), |
|---|
| 186 | ); |
|---|
| 187 | |
|---|
| 188 | $block->data['recent_cats'] = |
|---|
| 189 | array( |
|---|
| 190 | 'URL' => make_index_url(array('section' => 'recent_cats')), |
|---|
| 191 | 'TITLE' => l10n('recent_cats_cat_hint'), |
|---|
| 192 | 'NAME' => l10n('recent_cats_cat'), |
|---|
| 193 | ); |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | $block->data['calendar'] = |
|---|
| 197 | array( |
|---|
| 198 | 'URL' => |
|---|
| 199 | make_index_url( |
|---|
| 200 | array( |
|---|
| 201 | 'chronology_field' => ($conf['calendar_datefield']=='date_available' |
|---|
| 202 | ? 'posted' : 'created'), |
|---|
| 203 | 'chronology_style'=> 'monthly', |
|---|
| 204 | 'chronology_view' => 'calendar' |
|---|
| 205 | ) |
|---|
| 206 | ), |
|---|
| 207 | 'TITLE' => l10n('calendar_hint'), |
|---|
| 208 | 'NAME' => l10n('calendar'), |
|---|
| 209 | 'REL'=> 'rel="nofollow"' |
|---|
| 210 | ); |
|---|
| 211 | $block->template = 'menubar_specials.tpl'; |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | //---------------------------------------------------------------------- summary |
|---|
| 216 | if ( ($block=$menu->get_block('mbMenu')) != null ) |
|---|
| 217 | { |
|---|
| 218 | // quick search block will be displayed only if data['qsearch'] is set |
|---|
| 219 | // to "yes" |
|---|
| 220 | $block->data['qsearch']=true; |
|---|
| 221 | |
|---|
| 222 | // tags link |
|---|
| 223 | $block->data['tags'] = |
|---|
| 224 | array( |
|---|
| 225 | 'TITLE' => l10n('See available tags'), |
|---|
| 226 | 'NAME' => l10n('Tags'), |
|---|
| 227 | 'URL'=> get_root_url().'tags.php', |
|---|
| 228 | ); |
|---|
| 229 | |
|---|
| 230 | // search link |
|---|
| 231 | $block->data['search'] = |
|---|
| 232 | array( |
|---|
| 233 | 'TITLE'=>l10n('hint_search'), |
|---|
| 234 | 'NAME'=>l10n('Search'), |
|---|
| 235 | 'URL'=> get_root_url().'search.php', |
|---|
| 236 | 'REL'=> 'rel="search"' |
|---|
| 237 | ); |
|---|
| 238 | |
|---|
| 239 | // comments link |
|---|
| 240 | $block->data['comments'] = |
|---|
| 241 | array( |
|---|
| 242 | 'TITLE'=>l10n('hint_comments'), |
|---|
| 243 | 'NAME'=>l10n('comments'), |
|---|
| 244 | 'URL'=> get_root_url().'comments.php', |
|---|
| 245 | ); |
|---|
| 246 | |
|---|
| 247 | // about link |
|---|
| 248 | $block->data['about'] = |
|---|
| 249 | array( |
|---|
| 250 | 'TITLE' => l10n('about_page_title'), |
|---|
| 251 | 'NAME' => l10n('About'), |
|---|
| 252 | 'URL' => get_root_url().'about.php', |
|---|
| 253 | ); |
|---|
| 254 | |
|---|
| 255 | // notification |
|---|
| 256 | $block->data['rss'] = |
|---|
| 257 | array( |
|---|
| 258 | 'TITLE'=>l10n('RSS feed'), |
|---|
| 259 | 'NAME'=>l10n('Notification'), |
|---|
| 260 | 'URL'=> get_root_url().'notification.php', |
|---|
| 261 | 'REL'=> 'rel="nofollow"' |
|---|
| 262 | ); |
|---|
| 263 | $block->template = 'menubar_menu.tpl'; |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | |
|---|
| 267 | //--------------------------------------------------------------- identification |
|---|
| 268 | if (is_a_guest()) |
|---|
| 269 | { |
|---|
| 270 | $template->assign( |
|---|
| 271 | array( |
|---|
| 272 | 'U_LOGIN' => get_root_url().'identification.php', |
|---|
| 273 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
|---|
| 274 | 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'] |
|---|
| 275 | ) |
|---|
| 276 | ); |
|---|
| 277 | if ($conf['allow_user_registration']) |
|---|
| 278 | { |
|---|
| 279 | $template->assign( 'U_REGISTER', get_root_url().'register.php'); |
|---|
| 280 | } |
|---|
| 281 | } |
|---|
| 282 | else |
|---|
| 283 | { |
|---|
| 284 | $template->assign('USERNAME', $user['username']); |
|---|
| 285 | if (is_autorize_status(ACCESS_CLASSIC)) |
|---|
| 286 | { |
|---|
| 287 | $template->assign('U_PROFILE', get_root_url().'profile.php'); |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | // the logout link has no meaning with Apache authentication : it is not |
|---|
| 291 | // possible to logout with this kind of authentication. |
|---|
| 292 | if (!$conf['apache_authentication']) |
|---|
| 293 | { |
|---|
| 294 | $template->assign('U_LOGOUT', get_root_url().'?act=logout'); |
|---|
| 295 | } |
|---|
| 296 | if (is_admin()) |
|---|
| 297 | { |
|---|
| 298 | $template->assign('U_ADMIN', get_root_url().'admin.php'); |
|---|
| 299 | } |
|---|
| 300 | } |
|---|
| 301 | if ( ($block=$menu->get_block('mbIdentification')) != null ) |
|---|
| 302 | { |
|---|
| 303 | $block->template = 'menubar_identification.tpl'; |
|---|
| 304 | } |
|---|
| 305 | $menu->apply('MENUBAR', 'menubar.tpl' ); |
|---|
| 306 | } |
|---|
| 307 | ?> |
|---|