<%@ page language="java" buffer="64kb" %>

<%@ taglib uri="struts-html"     prefix="html"  %>
<%@ taglib uri="struts-bean"     prefix="bean"  %>
<%@ taglib uri="struts-logic"    prefix="logic" %>
<%@ taglib uri="vkc-taglib"      prefix="vkc"   %>
<%@ page import="vkc.procoba.function.FunctionalViewForm" %>
<%@ page import="vkc.db.entities.VKCCategory" %>

<bean:define id="form" type="vkc.procoba.function.FunctionalViewForm" name="form" scope="request"/>
<bean:define id="category" name="form" property="category" type="vkc.db.entities.VKCCategory"/>

<vkc:init/>

<vkc:hasPermission context="category" requiredPerm="r">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
  <%-- Verzeichnis-Funktionen --%>
  <tr>
    <td width="100%" align="left" class="color_toolbar">
      <table width="100%" cellpadding="0" cellspacing="5">
        <tr>
          <td align="left" nowrap="nowrap"><b><vkc:message key="function.label.function.folder"/>:</b></td>

          <td width="100%" align="left">
          <logic:iterate id="pathdescr" name="form" property="currentFunctionalViewPath" 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=""/>
          </span>
          </logic:greaterThan>

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

          <logic:equal value="false" name="pathdescr" property="lastNode">
          <span dir="ltr">
          <vkc:link page='<%="/functionalView.do?functionalViewId=" + form.getFunctionalViewId()%>' paramId="subfolderId" paramName="pathdescr" paramProperty="pathId" title='<%=pathdescr.getPathName()%>' style="font-weight:normal;"><vkc:write name="pathdescr" property="pathName"/></vkc:link>
          </span>
          </logic:equal>

          </logic:iterate>
          </td>

          <td align="right">
            <table>
              <tr>
	          <logic:notEqual value="<%=VKCCategory.FLAG_CLOSED.toString()%>" name="form" property="category.flag">
	
	          <vkc:hasPermission context="category" requiredPerm="w">
	          <td><vkc:link page="<%=form.getNewDocumentLink()%>"><vkc:img border="0" page="/templates/${template.name}/gfx/button-newdocument.gif" titleKey="vkc.tooltip.insertdocument"/></vkc:link></td>
	          </vkc:hasPermission>
	
	          <vkc:hasPermission context="category" requiredPerm="c">
	          <td><vkc:link page="<%=form.getEditCategoryLink()%>" titleKey="vkc.tooltip.editcategory"><vkc:img border="0" page="/templates/${template.name}/gfx/button-editcat.gif" alt="" titleKey="vkc.tooltip.editcategory"/></vkc:link></td>
	          </vkc:hasPermission>
	
	          <vkc:hasPermission context="category" requiredPerm="C">
	          <td><vkc:link page="<%=form.getCreateCategoryLink()%>" titleKey="vkc.tooltip.newcategory"><vkc:img border="0" page="/templates/${template.name}/gfx/button-newcat.gif" alt="" titleKey="vkc.tooltip.newcategory"/></vkc:link></td>
	          </vkc:hasPermission>
	
	          <logic:equal name="form" property="functionalViewRootCategory" value="false">
		      <vkc:hasPermission context="category" requiredPerm="D" recursiv="true">
		      <td><vkc:link page="<%=form.getDeleteCategoryLink()%>" titleKey="vkc.tooltip.deletecategory" onclick="return confirmDeleteCategory();"><vkc:img border="0" page="/templates/${template.name}/gfx/button-deletecategory.gif" alt="" titleKey="vkc.tooltip.deletecategory"/></vkc:link></td>
		      </vkc:hasPermission>
	          </logic:equal>  
	
	          <vkc:hasPermission context="category" requiredPerm="c" value="true">
	          <td><vkc:link page="<%=form.getEditAclLink()%>"><vkc:img border="0" page="/templates/${template.name}/gfx/button-acl-edit.gif" titleKey="vkc.tooltip.editacl"/></vkc:link></td>
	          </vkc:hasPermission>
	
	          <vkc:hasPermission context="category" requiredPerm="c" value="false">
	          <td><vkc:link page="<%=form.getDisplayAclLink()%>"><vkc:img border="0" page="/templates/${template.name}/gfx/button-acl-view.gif" titleKey="vkc.tooltip.viewacl"/></vkc:link></td>
	          </vkc:hasPermission>
	
	          </logic:notEqual>  
	
	          <logic:equal value="<%=VKCCategory.FLAG_CLOSED.toString()%>" name="form" property="category.flag">
	          <td><vkc:link page="<%=form.getDisplayAclLink()%>"><vkc:img border="0" page="/templates/${template.name}/gfx/button-acl-view.gif" titleKey="vkc.tooltip.viewacl"/></vkc:link></td>
	          </logic:equal>  
              </tr>
            </table>
		  </td>
        </tr>
      </table>
    </td>
  </tr>

  <tr><td valign="top" width="100%" background="<vkc:rewrite page='/templates/${template.name}/gfx/dotted-line-h.gif'/>"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="1"/></td></tr>

  <%-- Unterverzeichnisse --%>
  <tr>
    <td>
      <table cellpadding="0" cellspacing="5" border="0">
        <%-- Link zum übergeordneten Verzeichnis --%>
        <logic:notEqual name="form" property="functionalViewRootCategory" value="true">
        <tr>
          <td colspan="1">
            <table align="left" cellpadding="0" cellspacing="0" border="0">
              <tr><td colspan="1"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="3" border="0"/></td></tr>
              <tr>
                <td nowrap="nowrap"><vkc:img page="/templates/${template.name}/gfx/parent.gif" border="0" alt=""/></td>
                <td nowrap="nowrap">&nbsp;</td>
                <td nowrap="nowrap"><vkc:link page="<%=form.getFunctionalViewFolderViewLink()%>" paramId="subfolderId" paramProperty="parentCategoryId" paramName="category" style="font-weight:normal;"><vkc:message key="vkc.parentcategory" /></vkc:link></td>
              </tr>
            </table>
          </td>
        </tr>
        </logic:notEqual>

        <%-- Liste der Unterverzeichnisse --%>
	    <logic:notEmpty name="form" property="accessibleSubCategories">
        <tr>
          <td align="left">
  		  <vkc:link linkName="categorysortbar"/>
          <table>
            <tr>
              <logic:equal name="form" property="categorySortMode" value='<%= String.valueOf( FunctionalViewForm.CATEGORY_SORT_NAME_DOWN ) %>'>
			  <td><vkc:link href='<%="javascript:changeCategorySortMode(" + FunctionalViewForm.CATEGORY_SORT_NAME_UP + ");"%>' style="font-weight:normal;"><vkc:img page="/templates/${template.name}/gfx/sort-alphabetical-asc.gif" border="0" titleKey="vkc.tooltip.category.sort.name.ascending"/></vkc:link></td>
          	  </logic:equal>
          	  <logic:equal name="form" property="categorySortMode" value='<%= String.valueOf( FunctionalViewForm.CATEGORY_SORT_NAME_UP ) %>'>
			  <td><vkc:link href='<%="javascript:changeCategorySortMode(" + FunctionalViewForm.CATEGORY_SORT_NAME_DOWN + ");"%>' style="font-weight:normal;"><vkc:img page="/templates/${template.name}/gfx/sort-alphabetical-desc.gif" border="0" titleKey="vkc.tooltip.category.sort.name.descending"/></vkc:link></td>
          	  </logic:equal>
              <td><b><vkc:message key="function.label.subfolders" />:</b></td>
            </tr>
          </table>
          </td>
        </tr>
        <tr>
          <td colspan="1">
            <table align="left" cellpadding="0" cellspacing="0" border="0">
	          <logic:iterate id="subcat" name="form" property="accessibleSubCategories" type="vkc.db.entities.VKCSubCategory">
	          <tr><td colspan="1"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="3" border="0"/></td></tr>
		      <tr>
                  <td><vkc:img page='<%="/templates/${template.name}/gfx/" + subcat.getFolderImage()%>' align="texttop" border="0" alt=""/></td>
                  <td nowrap="nowrap">&nbsp;</td>
                  <td nowrap="nowrap" width="100%"><vkc:link page="<%=form.getFunctionalViewFolderViewLink()%>" paramId="subfolderId" paramProperty="subCategoryId" paramName="subcat" style="font-weight:normal;"><vkc:write name="subcat" property="name"/></vkc:link></td>
		      </tr>
              </logic:iterate>
            </table>
          </td>
        </tr>
	    </logic:notEmpty>

        <logic:empty name="form" property="accessibleSubCategories">
        <tr><td align="left" colspan="1"><vkc:message key="function.label.no.subfolders"/></td></tr>
        </logic:empty>

      </table>
    </td>
  </tr>

  <!-- Sortierung der Dokumente -->
  <logic:equal name="form" property="hasDocuments" value="true">
  <vkc:hline colspan="5" lineClass="hline" lineHeight="1" topSpace="0" bottomSpace="5"/>
  <tr>
    <td align="right" width="1%" nowrap="nowrap">
	  <vkc:link linkName="documentsortbar"/>
      <b><vkc:message key="vkc.document.sort"/>:</b>
      <html:select property="documentSortMode" onchange="changeDocumentSortMode();">
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_PUBLISHING_DATE_UP ) %>'><vkc:message key="vkc.document.sort.ascbypublishingdate"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_PUBLISHING_DATE_DOWN ) %>'><vkc:message key="vkc.document.sort.descbypublishingdate"/></html:option>
        <logic:equal name="categorySettings" property="showCreationDate" value="true">
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_CREATION_DATE_UP ) %>'><vkc:message key="vkc.document.sort.ascbycreationdate"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_CREATION_DATE_DOWN ) %>'><vkc:message key="vkc.document.sort.descbycreationdate"/></html:option>
        </logic:equal>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_TITLE_UP ) %>'><vkc:message key="vkc.document.sort.ascbytitle"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_TITLE_DOWN ) %>'><vkc:message key="vkc.document.sort.descbytitle"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_AUTHOR_UP ) %>'><vkc:message key="vkc.document.sort.ascbyauthor"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_AUTHOR_DOWN ) %>'><vkc:message key="vkc.document.sort.descbyauthor"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_PUBLISHER_UP ) %>'><vkc:message key="vkc.document.sort.ascbypublisher"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_PUBLISHER_DOWN ) %>'><vkc:message key="vkc.document.sort.descbypublisher"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_SIZE_UP ) %>'><vkc:message key="vkc.document.sort.ascbysize"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_SIZE_DOWN ) %>'><vkc:message key="vkc.document.sort.descbysize"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_TYPE_UP ) %>'><vkc:message key="vkc.document.sort.ascbytype"/></html:option>
        <html:option value='<%= String.valueOf( FunctionalViewForm.DOCUMENT_SORT_TYPE_DOWN ) %>'><vkc:message key="vkc.document.sort.descbytype"/></html:option>
      </html:select>
    </td>
  </tr>
  </logic:equal>

  <%-- Dokumentenliste (reale und virtuelle) --%>
  <jsp:include page="DocumentListView.jsp" flush="true" />

</table>
</vkc:hasPermission>

<vkc:hasPermission context="category" requiredPerm="r" value="false">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td align="left" width="100%">
      <table cellpadding="0" cellspacing="5" width="100%">
        <tr>
          <td align="left">
      	    <span style="color:red"><vkc:message key="vkc.info.access_denied"/></span>
          </td>
        </tr>

        <vkc:hline colspan="5" lineClass="hline" lineHeight="1" topSpace="0" bottomSpace="5"/>

		<tr>
		  <td align="center">
		    <vkc:button property="action.back.to.parentsubfolder" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.back"/></vkc:button>
		  </td>
		</tr>
      </table>
    </td>
  </tr>  
</table>
</vkc:hasPermission>