<%
  import org.exoplatform.web.application.Parameter ;
  import org.exoplatform.wcm.webui.reader.ContentReader;
  def rcontext = _ctx.getRequestContext();
%>
<div class="SideBarContent">
  <div class="BarContent">
    <div class="BarContentL">
      <div class="BarContentR">
        <div class="BarContentM ClearFix">
          <div class="Title"><%=_ctx.appRes("UIViewRelationList.label.languages-list")%></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;
            relName = ContentReader.getXSSCompatibilityContent(relName);
        %>
            <div> - <a href="$actionLink">$relLang ($relName)</a></div>
        <% 
          }
        }
        %>
      </div>
    </div>
  </div>
  <div class="BarContent">
  	<div class="BarContentL">
  		<div class="BarContentR">
  			<div class="BarContentM ClearFix">
			    <div class="Title"><%=_ctx.appRes("UIViewRelationList.label.relation-list")%></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;
            relName = ContentReader.getXSSCompatibilityContent(relName);
				%>
				 	  <div> - <a href="$actionLink">$relName</a></div>
				<% 
				  }
				}
				%>
			</div>
		</div>
  </div>
  <div class="BarContent">
  	<div class="BarContentL">
  		<div class="BarContentR">
  			<div class="BarContentM ClearFix">
			    <div class="Title"><%=_ctx.appRes("UIViewRelationList.label.references-list")%></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;
            relName = ContentReader.getXSSCompatibilityContent(relName);
				%>
				 	  <div> - <a href="$actionLink">$relName</a></div>
				<% 
				  }
				}
				%>
			</div>
		</div>
  </div>
</div>