<%
  import org.exoplatform.container.PortalContainer;
  import org.exoplatform.web.application.JavascriptManager;
  import org.exoplatform.portal.webui.util.Util;
  import org.exoplatform.services.wcm.navigation.NavigationUtils;
  import javax.servlet.http.HttpSession;

  def rcontext = _ctx.getRequestContext() ;
  def userName = rcontext.getRemoteUser();
  def portalName = Util.getPortalRequestContext().getPortalOwner();
  
  def selectedNodeUri = Util.getUIPortal().getSelectedUserNode().getURI();
  def session = _ctx.getRequestContext().getRequest().getSession();
  def previousURI = session.getAttribute("previousURI");
  
  NavigationUtils.removeNavigationAsJson(portalName, userName);
  
  session.setAttribute("previousURI", selectedNodeUri);
  if (userName==null && session.getMaxInactiveInterval()>60) {
    session.setAttribute("DefaultMaxInactiveInterval", new Integer(session.getMaxInactiveInterval()));
    session.setMaxInactiveInterval(60);  
  } else if (userName!=null && session.getMaxInactiveInterval()==60) {
    Integer interval = (Integer) session.getAttribute("DefaultMaxInactiveInterval");
    if (interval != null) {
      session.setMaxInactiveInterval(interval.intValue());
    }
  }
		String language = rcontext.getLocale().getLanguage();
		String country = rcontext.getLocale().getCountry();
		if (country != null && country.length() > 0) {
    language += "_" + country;
  }   
%>
<script type="text/javascript">
  eXo.env.portal.userName='<%= userName %>';
  eXo.env.portal.language='<%= language %>'
  eXo.env.portal.selectedNodeUri = '<%= selectedNodeUri %>';
  eXo.env.portal.wcmContentTitle = '<%= _ctx.getRequestContext().getRequest().getAttribute("WCM.Content.Title") %>';
  eXo.env.portal.previousURI = '<%= previousURI %>';
  eXo.env.portal.rest = '<%= PortalContainer.getCurrentRestContextName() %>';
</script>
    
<div id="UIWorkingWorkspace" class="UIWorkingWorkspace" style="position: relative; z-index: 0;">
  <%uicomponent.renderChildren()%>
</div>