<%@ page language="java" buffer="100kb" errorPage="/common/error.jsp"%>

<%@ page import="org.apache.struts.Globals"%>
<%@ page import="vkc.db.entities.VKCCategory" %>
<%@ page import="vkc.view.WebShare" %>
<%@ page import="vkc.view.TabId" %>
<%@ page import="vkc.view.ClipBoard" %>
<%@ page import="vkc.util.treeview.TreeView" %>
<%@ page import="vkc.administration.form.TrashViewForm" %>
<%@ page import="vkc.view.form.DisplayUrlForm" %>

<%@ taglib uri="struts-html"     prefix="html"     %>
<%@ taglib uri="struts-bean"     prefix="bean"     %>
<%@ taglib uri="struts-logic"    prefix="logic"    %>
<%@ taglib uri="vkc-taglib"      prefix="vkc"      %>
<vkc:init/>

<% ClipBoard clipBoard = (ClipBoard)session.getAttribute( WebShare.CLIPBOARD_KEY ); %>

<html:html locale="true">
<head>
  <meta http-equiv="content-type"  content="text/html; charset=iso-8859-1" />
  <meta http-equiv="cache-control" content="no-cache" />
  <meta http-equiv="pragma"        content="no-cache" />
  <meta http-equiv="expires"       content="0" />
  <meta http-equiv="robots"        content="index" />
  <meta http-equiv="robots"        content="follow" />
  <vkc:cssinclude />
  <link rel="SHORTCUT ICON" href="<vkc:rewrite page='/templates/${template.name}/gfx/vkc.ico'/>">
  <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'/>"></script>
  <script type="text/javascript">
  window.name = "MAINVIEW";
  var aclform = null;
  var associatedTabId = <%=TabId.TRASH_TAB%>;

   function init(){
        var tabView = getTabView();
        var tabViewForm = tabView.document.forms[0];
        
        if (tabView && tabView.systemviewtype == "categoryview" && tabView.selectedTabId != associatedTabId) {
            tabView.location.replace("<%=ctxPath%>/vkcTabView.do?selectedTabId=<%=TabId.TRASH_TAB%>"
          						   + "&lastCategoryId=" + tabViewForm.lastCategoryId.value
          						   + "&lastFunctionalId=" + tabViewForm.lastFunctionalId.value
          						   + "&lastProjectId=" + tabViewForm.lastProjectId.value);
        }
        
       <logic:present name="<%=WebShare.INFO_KEY%>" scope="request">
            <bean:define id="msg" type="java.lang.String" name="<%=WebShare.INFO_KEY%>" scope="request"/>
            alert( '<vkc:message javascript="true" filter="false" key="<%=msg%>"/>' );
       </logic:present>
       
     }
     
   function confirmDeletion(elem) {
        var form  = document.forms[0];
        var action = form.trashAction.value;
        if( action == "deleteDefinitely" )
            if ( !confirm('<vkc:message javascript="true" filter="false" key="vkc.string.confirm.delete.selection"/>') )
                return;
        
        if (form.action.indexOf('?') == -1) {
          form.action = form.action + "?action.trash=true";
        } else {
          form.action = form.action + "&action.trash=true";
        }
        
        disableAllButtons(elem);
        form.submit();
    }
   
    function checkAll( mForm ){
        for (var i=0 ; i<mForm.elements.length ; i++) {
            var elem = mForm.elements[i];
            
            if (elem.name!='allItems') {
                elem.checked=mForm.allItems.checked;
            }
        }
    }
     
  </script>
</head>
<body onload="javascript:init();" marginwidth="0" marginheight="0">
<html:form action="/showTrash" method="post">
  <bean:define id="form"      name="trashViewForm" type="vkc.administration.form.TrashViewForm" />
  <bean:define id="category"  name="form" property="category" type="vkc.db.entities.VKCCategory" />
  <html:hidden name="form" property="categoryId"/>
  <table width="100%" cellspacing="1" cellpadding="0" border="0">
    <tr>
      <td class="color_toolbar">
        <table width="100%" cellspacing="0" cellpadding="0" border="0">
          <tr>
            <!-- Kategoriepfad -->
            <td width="70%" align="left">
              <table border="0">
                <tr>
                  <td> 
                    <logic:equal name="form" property="empty" value="false">
                      <vkc:img page="/templates/${template.name}/gfx/trash-not-empty.gif" alt="" border="0"/>
                    </logic:equal>
                    <logic:equal name="form" property="empty" value="true">
                      <vkc:img page="/templates/${template.name}/gfx/trash-empty.gif" alt="" border="0"/>
                   </logic:equal>
                  </td>
                  <td align="left">
                    <bean:define id="absPathDescr" name="category"     property="absPathDescr" />
                    <bean:define id="pathNodes"    name="absPathDescr" property="pathNodes"    />
                      <logic:iterate id="pathdescr" name="pathNodes" indexId="index" type="vkc.util.VKCCategoryPathNode">
                 
                        <logic:greaterThan name="index" value="0">
                      	  <span dir="ltr">
                          <vkc:img page="/templates/${template.name}/gfx/dot.gif" alt="" border="0"/>
                      	  </span>
                        </logic:greaterThan>

                        <logic:equal name="pathdescr" property="lastNode" value="true">
                      	  <span dir="ltr">
                          <b><vkc:write name="pathdescr" property="pathName"/></b>
                      	  </span>
                        </logic:equal>

                        <logic:equal name="pathdescr" property="lastNode" value="false">
                          <logic:equal name="pathdescr" property="inTrash" value="true"> 
                        	  <span dir="ltr">
                              <vkc:link page="/showTrash.do" paramId="categoryId" paramName="pathdescr" paramProperty="pathId" title='<%=pathdescr.getPathName()%>'><vkc:write name="pathdescr" property="pathName"/></vkc:link>
                        	  </span>
                          </logic:equal>
                        
                          <logic:equal name="pathdescr" property="inTrash" value="false"> 
                        	  <span dir="ltr">
                              <vkc:link page="/showCategory.do" paramId="categoryId" paramName="pathdescr" paramProperty="pathId" title='<%=pathdescr.getPathName()%>'><vkc:write name="pathdescr" property="pathName"/></vkc:link>
                        	  </span>
                          </logic:equal>
                        </logic:equal>
                      </logic:iterate>
                  </td>
                </tr>
              </table>
            </td>
          </tr>        
        </table>
      </td>
    </tr>
  </table>

<logic:equal name="form" property="empty" value="false">
 
 <table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td width="100%">
      <table width="100%" cellspacing="3" cellpadding="0" border="0">
        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="20" height="5" border="0"/></td></tr>

        <%-- Beschreibung --%>
        <tr>
          <td>
          <logic:equal name="form" property="tinyMCECompatible" value="true">
          <vkc:write name="category" property="description" displayAsHTML="true" renderNewLine="true"/>
          </logic:equal>
          <logic:equal name="form" property="tinyMCECompatible" value="false">
          <vkc:write name="category" property="description" stripHTML="true" renderNewLine="true"/>
          </logic:equal>
          </td>
        </tr>

        <%-- additional attributes --%>
        <logic:notEmpty name="category" property="addAttributes">
        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="20" height="20" border="0"/></td></tr>
        <tr>
          <td>
            <table width="100%" cellspacing="3" cellpadding="0" border="0">
              <colgroup><col><col width="100%"></colgroup>
              <logic:iterate id="addAttr" name="category" property="addAttributes" type="vkc.db.entities.VKCAddAttribute">
              <tr align="left" valign="top">
                <td><b><vkc:write name="addAttr" property="name"/>:&nbsp;</b></td>
                <td><vkc:write name="addAttr" property="valuestring"/></td>
              </tr>
              </logic:iterate>
            </table>
          </td>
        </tr>
        </logic:notEmpty>
        <%-- end of additional attributes --%>

        <%-- dynamical attributes --%>
        <logic:notEmpty name="category" property="dynaAttributes">
        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="20" height="20" border="0"/></td></tr>
        <tr>
          <td>
            <table width="100%" cellspacing="3" cellpadding="0" border="0">
              <colgroup><col><col width="100%"></colgroup>
              <logic:iterate id="dynaAttr" name="category" property="dynaAttributes" type="vkc.db.entities.VKCDynaAttribute">
              <tr align="left" valign="top">
                <td><b><vkc:write name="dynaAttr" property="name"/>:&nbsp;</b></td>
                <td><vkc:write name="dynaAttr" property="value"/></td>
              </tr>
              </logic:iterate>
            </table>
          </td>
        </tr>
        </logic:notEmpty>
        <%-- end dynamical attributes --%>

        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="5" border="0"/></td></tr>

        <logic:notEqual name="category" property="trashCategory" value="true">
        <tr>
          <td align="left"><vkc:img page="/templates/${template.name}/gfx/parent.gif" align="texttop" border="0" alt=""/>&nbsp;<vkc:link page="/showTrash.do" paramId="categoryId" paramName="category" paramProperty="parentCategoryId"><vkc:message key="vkc.parentcategory" /></vkc:link></td>
        </tr>
        </logic:notEqual>

        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="5" border="0"/></td></tr>

        <tr>
          <td>
            <table cellspacing="2" cellpadding="0" border="0" align="left">

              <!-- Unterkategorien und Dokumente -->
              <colgroup><col><col align="center"><col width="100%"></colgroup>

              <!-- begin iteration subcategories -->
              <logic:iterate id="subCat" name="form" property="accessibleSubcategories" type="vkc.db.entities.VKCSubCategory">
                <tr>
                  <% if ( clipBoard != null && clipBoard.getOperation() == ClipBoard.CUT_OPERATION && clipBoard.isCategoryInClipboard( subCat.getSubCategoryId() ) ) { %>
                    <td><html:multibox property="selectedCategoryIds" onfocus="this.blur();"><vkc:write name="subCat" property="subCategoryId"/></html:multibox></td>
                    <td><vkc:img page='<%="/templates/" + template + "/gfx/" +subCat.getFolderImageShaded()%>' altKey='vkc.category' align='texttop' border='0'/></td>
                    <td><vkc:link page="/showTrash.do" style="color:#aaaaaa" paramId="categoryId" paramName="subCat" paramProperty="subCategoryId"><vkc:write name="subCat" property="name"/></vkc:link>
                    </td>
                  <%} else { %>
                    <td><html:multibox property="selectedCategoryIds" onfocus="this.blur();"><vkc:write name="subCat" property="subCategoryId"/></html:multibox></td>
                    <td><vkc:img page='<%="/templates/" + template + "/gfx/" +subCat.getFolderImage()%>' altKey='vkc.category' align='texttop' border='0'/></td>
                    <td><vkc:link page="/showTrash.do" paramId="categoryId" paramName="subCat" paramProperty="subCategoryId"><vkc:write name="subCat" property="name"/></vkc:link>
                    </td>
                  <%} %>
                </tr>
              </logic:iterate>
              <!-- end iteration subcategories -->

              <!-- begin iteration documents -->
              <logic:iterate id="doc" name="form" property="documents" type="vkc.db.entities.VKCDocument">
                <tr>
                  <% if ( clipBoard != null && clipBoard.getOperation() == ClipBoard.CUT_OPERATION && clipBoard.isDocumentInClipboard( doc.getDocumentId() ) ) { %>
                  <td><html:multibox property="selectedDocumentIds" onfocus="this.blur();"><vkc:write name="doc" property="documentId"/></html:multibox></td>
                  <td><vkc:img page='<%="/templates/" + template + doc.getDocumentIconShaded()%>' altKey='vkc.category' align='texttop' border='0'/></td>
                  <td><font color="#aaaaaa"><b><vkc:write name="doc" property="title"/></b>&nbsp;(<vkc:write name="doc" property="title"/>:&nbsp;<vkc:write name="doc" property='<%= "formattedDocSize(" + user.getLanguageId() + ")" %>'/>  &nbsp;[<vkc:write name="doc" property="authorName"/>:&nbsp;<vkc:write name="doc" property="published" formatKey="date.medium.format"/>])</font></td>
                  <%} else { %>
                  <td><html:multibox property="selectedDocumentIds" onfocus="this.blur();"><vkc:write name="doc" property="documentId"/></html:multibox></td>
                  <td><vkc:img page='<%="/templates/" + template + doc.getDocumentIcon()%>' altKey='vkc.category' align='texttop' border='0'/></td>
                  <td><b><vkc:write name="doc" property="title"/></b>&nbsp;(<vkc:write name="doc" property="name"/>:&nbsp;<vkc:write name="doc" property='<%= "formattedDocSize(" + user.getLanguageId() + ")" %>'/>  &nbsp;[<vkc:write name="doc" property="authorName"/>:&nbsp;<vkc:write name="doc" property="published" formatKey="date.medium.format"/>])</td>
                  <% } %>
                </tr>
              </logic:iterate>
              <!-- end iteration documents -->

              <tr>
                <td><input type="checkbox" name="allItems" value="allItems" onclick="javascript:checkAll(this.form);"></td>
                <td colspan="2" align="left"><vkc:message key="vkc.string.checkAll"/></td>
              </tr>

              <tr>
                <td valign="left" colspan="2"><vkc:img page="/templates/${template.name}/gfx/function-arrow.gif" alt="-->" align="texttop" border="0"/></td>
                <td valign="left" nowrap="nowrap">
                  <html:select property="trashAction">
                    <html:option value="noaction">-- <vkc:message key="vkc.string.chooseFunction"/> --</html:option>
                    <html:option value="move2Clipboard"><vkc:message key="vkc.trash.action.move2Clipboard"/></html:option>
                    <html:option value="deleteDefinitely"><vkc:message key="vkc.trash.action.deleteDefinitely"/></html:option>
                  </html:select>&nbsp;<vkc:button property="action.execute" onclick="confirmDeletion(this);" property="action.trash"><vkc:message key="button.execute"/></vkc:button>
                </td>
              </tr>
              
              <logic:present name="<%=Globals.ERROR_KEY%>">
                <tr>
                  <td colspan="3"><br><b><vkc:errors/></b></td>
                </tr>
              </logic:present>
              
          </table>
        </td>
      </tr>
      
    </table>
    
  </td>
</tr>
</table>
</logic:equal>
<logic:equal name="form" property="empty" value="true">
<P>
<center><b><vkc:message key="vkc.trash.isEmpty"/></b></center>
</logic:equal>

</html:form>
</body>
</html:html>
