<%
	import org.exoplatform.web.application.Parameter ;  
  import org.exoplatform.ecm.webui.utils.Utils;

  def node = uicomponent.getNode() ;
  def originalNode = uicomponent.getOriginalNode();
  String namespace = "kfx:" ;
  Parameter[] params = [new Parameter("workspaceName", node.getSession().getWorkspace().getName()), new Parameter("findDrive","true")];
  private String formatNodeName(String text) {
    return text.replaceAll("'", "\\\\'");
  }
%>
<style>
  <% _ctx.include(uicomponent.getTemplateSkin("kfx:document", "Stylesheet")); %>    
</style>
<div class="WorkKofax">
	<table class="UIGrid">      	 			
	  <tr>
	    <td style="width:25%"><%=_ctx.appRes("Kofax.view.label.document-name")%></td>
	    <td><%=originalNode.getName()%></td>
	  </tr>
	
	  <%
		  for(property in node.getProperties()) {
		    def propertyName = property.getName() ;
		    if(propertyName.startsWith(namespace)) { %>
				  <tr>
				    <td style="width:25%"><%=propertyName.substring(namespace.length(), propertyName.length())%></td>
				    <td><%=node.getProperty(propertyName).getString()%></td>
				  </tr>
		<%
		    }
		  }
		  int i = 1;
		  for(child in uicomponent.getAttachments()) { 
		    if(child.hasNode("jcr:content")) {
		%>
			  <tr>
			    <td style="width:25%"><%=_ctx.appRes("Kofax.view.label.downloadable")%> #<%=i%></td>
					<%						  
						  String actionLink = uicomponent.event("ChangeNode", child.getPath(), params);
					%>
					<td>
						<a href="$actionLink">
						 		<%=child.getName()%>
					 	</a>
					</td>
					<!--
			    <td>
			      <a href="<%=uicomponent.getDownloadLink(child)%>">
			        <%=child.getName()%>
			      </a>
			    </td>
					-->
			  </tr>
		<%  } else {%>
		      <tr>
				    <td style="width:25%"><%=_ctx.appRes("Kofax.view.label.downloadable")%> #<%=i%></td>
				    <td>
				      <a href="<%=uicomponent.event("ChangeNode", Utils.formatNodeName(child.getPath()), params)%>">
				        <%=child.getName()%>
				      </a>
				    </td>
				  </tr>
		<%      
		    }
	      i++ ;
		  } 
		%>
	</table>
	<div><% _ctx.include(uicomponent.getViewTemplate("mix:votable", "view1")); %></div>
  <div><% _ctx.include(uicomponent.getViewTemplate("exo:comments", "view1")); %></div>

</div>
