<%
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.mop.user.UserNavigation;
import org.exoplatform.portal.mop.user.UserNode;
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.platform.component.social.UINavigationComposer;
import org.exoplatform.platform.webui.NavigationURLUtils;

def rcontext = _ctx.getRequestContext() ;
JavascriptManager jsmanager = rcontext.getJavascriptManager();
jsmanager.importJavascript('eXo.portal.UIPortalNavigation') ;
jsmanager.importJavascript('eXo.portal.UIAdminToolbar') ;
jsmanager.addCustomizedOnLoadScript('eXo.portal.UIAdminToolbar.onLoad("' + uicomponent.id + '");');

def user = uicomponent.getUser();

def labelActivities = _ctx.appRes("UIUserPlatformToolBarPortlet.label.activities");
def labelProfile = _ctx.appRes("UIUserPlatformToolBarPortlet.label.profile");
def labelnetwork = _ctx.appRes("UIUserPlatformToolBarPortlet.label.network");
def labelpeople = _ctx.appRes("UIUserPlatformToolBarPortlet.label.find");
def labelaccount = _ctx.appRes("UIUserPlatformToolBarPortlet.label.account");
def labellanguage = _ctx.appRes("UIUserPlatformToolBarPortlet.label.language");
def labellogout = _ctx.appRes("UIUserPlatformToolBarPortlet.label.logout");
def remoteUser = Util.getPortalRequestContext().getRemoteUser();
def activitiesLink = NavigationURLUtils.getURLInCurrentPortal("activities");
def profileLink = NavigationURLUtils.getURLInCurrentPortal("profile") + "/" + remoteUser;
def connectionLink = NavigationURLUtils.getURLInCurrentPortal("connections") + "/network/" + remoteUser;
def directoryLink = NavigationURLUtils.getURLInCurrentPortal("people");
def changeLanguageAction = "if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'ChangeLanguage', true));";
def accountSetting = "javascript:if(document.getElementById('UIMaskWorkspace')) ajaxGet(eXo.env.server.createPortalURL('UIPortal', 'AccountSettings', true));"
String clazz = "";
%>
<ul class="UIUserToolBarPortlet UIHorizontalTabs" id="$uicomponent.id">
	<li id="UserNavigationTabsContainer" class="UITab">
		<a class="TBIcon" href="#">
			   $user.fullName
		</a>
		<ul style="display:none;" class="MenuItemContainer">
			<%if(uicomponent.isSocialPortal()) {%>
				<% uicomponent.renderNavigationComposer() %>
				<li>
					<ul class="ClearFix">
						<li class="MenuItem $clazz">
							<a href="$profileLink" class="ToolBarProfileIcon">$labelProfile</a>
							<a href="$connectionLink" class="ToolBarNetworkIcon">$labelnetwork</a>
						</li>
						<li class="MenuItem $clazz">
							<a href="$activitiesLink" class="ToolBarActivityIcon">$labelActivities</a>
							<a href="$directoryLink" class="FindPeopleIcon">$labelpeople</a>
						</li>
					</ul>
				</li>
			<%}%>
			<li>
				<ul class="ClearFix">
					<li class="MenuItem $clazz">
						<a href="$accountSetting" class="AccountSettingIcon">$labelaccount</a>				
					</li>       
					<li class="MenuItem $clazz" onclick="$changeLanguageAction">
						<a href="#" class="ChangeLanguageIcon">$labellanguage</a>
					</li>
				</ul>
			</li>			
			<li class="MenuItem $clazz" onclick="eXo.portal.logout();">
				<a href="#" class="LogoutIcon">$labellogout</a> 						
			</li>
		</ul>
	</li>
</ul>