001package votorola.a.web.wic; // Copyright 2008-2010, 2012, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. 002 003import org.apache.wicket.markup.html.*; 004import org.apache.wicket.markup.html.link.*; 005import org.apache.wicket.markup.html.panel.*; 006import votorola.a.web.wic.authen.*; 007import votorola.g.lang.*; 008import votorola.g.locale.*; 009import votorola.g.web.wic.*; 010import votorola.s.wic.server.*; 011 012 013/** A header of navigation links and session controls, for the page top. It contains 014 * things like a "login" control and a "home" link. 015 * 016 * @see <a href='../../../../../../a/web/wic/WC_NavigationHead.html' 017 * target='_top'>WC_NavigationHead.html</a> 018 */ 019public @ThreadRestricted("wicket") final class WC_NavigationHead extends Panel 020{ 021 022 023 /** Constructs a WC_NavigationHead. 024 * 025 * @param page the page in which the controls will appear. 026 */ 027 public WC_NavigationHead( final String id, final VPageHTML page, final VRequestCycle cycle ) 028 { 029 super( id ); 030 setRenderBodyOnly( true ); 031 032 // User link 033 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 034 { 035 final VSession.User user = VSession.get().user(); 036 if( user == null ) add( VPage.newNullComponent( "userLink" )); 037 else 038 { 039 final String username = user.username(); 040 final String loc = 041 VOWicket.get().vsRun().voteServer().pollwiki().encodePageSpecifier( 042 "User:" + username ).build().toASCIIString(); 043 final WebMarkupContainer link = new WebMarkupContainer( "userLink" ); 044 link.add( new ExternalLink( "a", loc, username )); 045 add( link ); 046 } 047 } 048 049 // Login link 050 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 051 add( WC_LoginLink.newInOut( "linkLoginLogout", page, cycle )); 052 053 // Home link 054 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 055 { 056 final BookmarkablePageLinkX link = new BookmarkablePageLinkX( "home", WP_Server.class ); 057 link.setBody( cycle.bunW().l( "a.web.wic.WC_NavigationHead.home" )); 058 if( page instanceof WP_Server ) link.setEnabled( false ); 059 060 add( link ); 061 } 062 } 063 064 065}