<%
/**
 * Created by The eXo Platform SARL
 * Author : Nguyen Anh Vu
 *          anhvurz90@gmail.com
 * Oct 23, 2009 5:3:43 PM
 */
%>

<% 
  import org.exoplatform.ecm.webui.utils.Utils;
  import org.exoplatform.services.jcr.impl.core.JCRPath;
  import org.exoplatform.services.jcr.impl.core.SessionImpl;
  import org.exoplatform.web.application.Parameter ;  
  import javax.jcr.Node;
  import javax.jcr.Session;
%>
<% 
  def ownedByUserNodesList = uicomponent.getAllOwnedByUserNodes(); 
  if(ownedByUserNodesList == null) return;
  def rcontext = _ctx.getRequestContext();
  rcontext.getJavascriptManager().importJavascript('eXo.ecm.UIJCRExplorer','/ecmexplorer/javascript/');
  rcontext.getJavascriptManager().importJavascript('eXo.ecm.ECMUtils','/ecm-wcm-extension/javascript/');
  java.text.DateFormat dateFormat = uicomponent.getSimpleDateFormat();
  int totalPages = uicomponent.getUIPageIterator().getAvailablePage();
%>

<div class="UIShowAllOwnedByUserResult" id="$uicomponent.id">
  <table class="UIGrid" style="width: 97%">
    <thead>
      <tr>
        <th width="45px">
          <%
            if (uicomponent.iconType.equals("BlueUpArrow")) {
          %>
            <div onclick="<%=uicomponent.event("SortASC", Utils.formatNodeName("type"))%>" title="<%=_ctx.appRes("UIShowAllOwnedByUserResult.title.typeASC")%>">
              <%=_ctx.appRes("UIShowAllOwnedByUserResult.header.type")%>
              <img src="/eXoResources/skin/sharedImages/Blank.gif" alt="" class="BlueUpArrow16x16Icon">
            </div>
          <%
            } else if (uicomponent.iconType.equals("BlueDownArrow")) {
          %>
          <div onclick="<%=uicomponent.event("SortDESC", Utils.formatNodeName("type"))%>" title="<%=_ctx.appRes("UIShowAllOwnedByUserResult.title.typeDESC")%>">
            <%=_ctx.appRes("UIShowAllOwnedByUserResult.header.type")%>
            <img src="/eXoResources/skin/sharedImages/Blank.gif" alt="" class="BlueDownArrow16x16Icon">
          </div>
          <%
            } else {
          %>
            <div onclick="<%=uicomponent.event("SortASC", Utils.formatNodeName("type"))%>" title="<%=_ctx.appRes("UIShowAllOwnedByUserResult.title.typeASC")%>">
              <%=_ctx.appRes("UIShowAllOwnedByUserResult.header.type")%>                
            </div>
          <% } %>
        </th>
        <th>
          <%
            if (uicomponent.iconName.equals("BlueUpArrow")) {
          %>
            <a href="<%=uicomponent.event("SortASC", Utils.formatNodeName("name"))%>" title="<%=_ctx.appRes("UIShowAllOwnedByUserResult.title.nameASC")%>">
              <%=_ctx.appRes("UIShowAllOwnedByUserResult.header.name")%>
              <img src="/eXoResources/skin/sharedImages/Blank.gif" alt="" class="BlueUpArrow16x16Icon"/>
            </a>
          <%
            } else if (uicomponent.iconName.equals("BlueDownArrow")) {
          %>
          <a href="<%=uicomponent.event("SortDESC", Utils.formatNodeName("name"))%>" title="<%=_ctx.appRes("UIShowAllOwnedByUserResult.title.nameDESC")%>">
            <%=_ctx.appRes("UIShowAllOwnedByUserResult.header.name")%>
            <img src="/eXoResources/skin/sharedImages/Blank.gif" alt="" class="BlueDownArrow16x16Icon"/>
          </a>
          <%
            } else {
          %>
            <a href="<%=uicomponent.event("SortASC", Utils.formatNodeName("name"))%>" title="<%=_ctx.appRes("UIShowAllOwnedByUserResult.title.nameASC")%>">
              <%=_ctx.appRes("UIShowAllOwnedByUserResult.header.name")%>         
            </a>
          <% } %>        
        </th>   
        <th style="width:80px;"><%=_ctx.appRes("UIShowAllOwnedByUserResult.header.action")%></th>
      </tr>
    </thead>

    
    
    <tbody>
    <%
      def rowClass = null ;
      boolean even = true ;
      int count = 0;
//      map.clear();
      if (ownedByUserNodesList != null && ownedByUserNodesList.size() > 0) {
        for (node in ownedByUserNodesList) {
          if (even) rowClass = "EvenRow";  
          else rowClass =  "OddRow"; 
          even = !even;
          String nodePath = node.getPath();
         
          //String excerpt = row.getValue("rep:excerpt(.)")== null ? "" : row.getValue("rep:excerpt(.)").getString();
          String excerpt = "";
          String s = "";
          
      %>
          <tr class="$rowClass">
                      
            <td>
              <div class="default16x16Icon ItemIcon <%=Utils.getNodeTypeIcon(node, "16x16Icon")%>" style="margin:auto"><span></span></div>
            </td>
            <td>
              <div class="Text" title="<%=dateFormat.format(uicomponent.getDateCreated(node))%>">
                <%=node.getName()%>
              </div>
              <div>$excerpt</div>
              <div><%=_ctx.appRes("UIShowAllOwnedByUserResult.header.path")%>: <%=nodePath%></div>
              <div><%=_ctx.appRes("UIShowAllOwnedByUserResult.header.dateCreated")%>: <%=dateFormat.format(uicomponent.getDateCreated(node))%></div>
            </td>
            <td>
              <div class="ActionContainer">
                <img onclick="<%=uicomponent.event("View", Utils.formatNodeName(node.getPath()))%>" 
                     alt="" 
                     title="<%=_ctx.appRes("UIShowAllOwnedByUserResult.tooltip.View")%>" 
                     src="/eXoResources/skin/sharedImages/Blank.gif" class="View16x16Icon"/>
              </div>
            </td>                   
          </tr>
    <%
        }
      } else {
    %>
      <tr class="EvenRow">
        <td colspan="3" style="text-align:center;font-style:italic; color: #EF5604;"><%=_ctx.appRes("UIShowAllOwnedByUserResult.msg.empty")%></td>
      </tr>
    <%}%>
    </tbody>
  </table>
  <% if(totalPages>1){ %>
  <div style="margin:1px 0px 20px 0px;">
    <%_ctx.renderUIComponent(uicomponent.getUIPageIterator())%>
  </div>
  <% } %>
</div>