<%
  import org.exoplatform.web.application.Parameter ;
  def rcontext = _ctx.getRequestContext();
  rcontext.getJavascriptManager().addOnLoadJavascript("eXo.ecm.UIListView.setHeight()");
%>
<div class="SideBarContent">
  <div class="BarContent">
    <div class="BarContentL">
      <div class="BarContentR">
        <div class="BarContentM">
          <div class="Title"><%=_ctx.appRes("UIViewRelationList.label.languages-list")%></div>
          <div class="ClearLeft"><span></span></div>
        </div>
      </div>
    </div>
  </div>
  <div class="SideContent">
    <div class="UIViewRelationList">
      <div class="FrameContent">
      <%def languages = uicomponent.getLanguages()
        if(languages.isEmpty()) { %>                        
          <%=_ctx.appRes("UIViewRelationList.label.no-related-document")%>
      <%} else {
          String actionLink ;
          for (rel in languages) {
            String preferenceWS = rel.getSession().getWorkspace().getName() ;
            String path = rel.getPath() ;
            actionLink = uicomponent.event("ChangeNode", path, new Parameter("workspaceName", preferenceWS)) ;
            String relName = path.substring(path.lastIndexOf("/") + 1, path.length()) ;
            String relLang = rel.hasProperty("exo:language")?rel.getProperty("exo:language").getString():"";
            String relTitle;
            if (rel.hasProperty("exo:title")) {
             relTitle = rel.hasProperty("exo:title")?rel.getProperty("exo:title").getString():"";
            } else {
             relTitle = rel.getName(); 
            }            
            if (relTitle!=null && !"".equals(relTitle)) relName = relTitle; 
        %>
            <div> - <a href="$actionLink">$relLang ($relName)</a></div>
        <% 
          }
        }
        %>
      </div>
    </div>
  </div>
  <div class="BarContent">
  	<div class="BarContentL">
  		<div class="BarContentR">
  			<div class="BarContentM">
			    <div class="Title"><%=_ctx.appRes("UIViewRelationList.label.relation-list")%></div>
			  	<div class="ClearLeft"><span></span></div>
			  </div>
			</div>
		</div>
	</div>
  <div class="SideContent">
		<div class="UIViewRelationList">
			<div class="FrameContent">
			<%def relations = uicomponent.getRelations()
				if(relations.isEmpty()) { %>  			    			    	
				  <%=_ctx.appRes("UIViewRelationList.label.no-related-document")%>
			<%} else {
					String actionLink ;
					for (rel in relations) {
					  String preferenceWS = rel.getSession().getWorkspace().getName() ;
					  String path = rel.getPath() ;
					  actionLink = uicomponent.event("ChangeNode", path, new Parameter("workspaceName", preferenceWS)) ;
					  String relName = path.substring(path.lastIndexOf("/") + 1, path.length()) ; 
       String relTitle;
       if (rel.hasProperty("exo:title")) {
        relTitle = rel.getProperty("exo:title").getString();
       } else {
        relTitle = rel.getName(); 
       }       
            if (relTitle!=null && !"".equals(relTitle)) relName = relTitle; 
				%>
				 	  <div> - <a href="$actionLink">$relName</a></div>
				<% 
				  }
				}
				%>
			</div>
		</div>
  </div>
  <div class="BarContent">
  	<div class="BarContentL">
  		<div class="BarContentR">
  			<div class="BarContentM">
			    <div class="Title"><%=_ctx.appRes("UIViewRelationList.label.references-list")%></div>
			  	<div class="ClearLeft"><span></span></div>
			  </div>
			</div>
		</div>
	</div>
  <div class="SideContent">
		<div class="UIViewRelationList">
			<div class="FrameContent">
			<%def references = uicomponent.getReferences()
				if(references.isEmpty()) { %>  			    			    	
				  <%=_ctx.appRes("UIViewRelationList.label.no-related-document")%>
			<%} else {
					String actionLink ;
					for (rel in references) {
					  String preferenceWS = rel.getSession().getWorkspace().getName() ;
					  String path = rel.getPath() ;
					  actionLink = uicomponent.event("ChangeNode", path, new Parameter("workspaceName", preferenceWS)) ;
					  String relName = path.substring(path.lastIndexOf("/") + 1, path.length()) ; 
       String relTitle;
       if (rel.hasProperty("exo:title")) {
        relTitle = rel.getProperty("exo:title").getString();
       } else {
        relTitle = rel.getName();
       }
            if (relTitle!=null && !"".equals(relTitle)) relName = relTitle; 
				%>
				 	  <div> - <a href="$actionLink">$relName</a></div>
				<% 
				  }
				}
				%>
			</div>
		</div>
  </div>
</div>