<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ page import="com.opencms.flex.jsp.*,com.opencms.file.*,java.util.*" %>
<%!
//private static final String NAVDIRECTIONKEY = "NavDirection";
private static final String NAVDIRECTIONKEY = "Title";
public void buildSiteMap(com.opencms.flex.jsp.CmsJspActionElement cms,
String uri, java.io.Writer out, boolean onlyShowCurrent, String currentFolder, String currentPage, int indent) throws Exception {
String desc;
String navText = "";
int fromIndex = 0;
int toIndex = 0;
int navTextMaxLen = 25;
ArrayList navList = cms.getNavigation().getNavigationForFolder(uri);
// Check direction
if (cms.property(NAVDIRECTIONKEY, uri, "down").equals("up")) { java.util.Collections.reverse(navList); }
if (navList.size() > 0)
{
Iterator navItem = navList.iterator();
CmsJspNavElement nav, link;
String target;
String spacer;
while (navItem.hasNext())
{
nav = (CmsJspNavElement) navItem.next();
spacer = "";
for (int nCnt = 0; nCnt < (nav.getNavTreeLevel()-indent); nCnt++) {spacer += "<img src='"+cms.link("../resources/images/navSpacer.gif")+"' width='16px' height='16px'>";}
if (nav != null)
{
navText = nav.getNavText();
toIndex = navText.indexOf("<");
if (toIndex > navTextMaxLen || toIndex == -1) {toIndex = navTextMaxLen;}
if (navText.length() > toIndex)
{
fromIndex = navText.indexOf(" ", toIndex);
if (fromIndex < toIndex) {fromIndex = toIndex;}
navText = navText.substring(0, fromIndex)+" ...";
}
if (nav.isFolderLink())
{
link = getFolderLink(cms, nav.getResourceName());
if (link == null) {
target = "#";
} else {
target = cms.link( link.getResourceName() );
}
out.write("<tr><td align=left valign=middle class='navigationFolder' nowrap>"+spacer);
if (currentFolder.indexOf(nav.getResourceName()) > -1)
{
out.write("<img src='"+cms.link("../resources/images/navFolderOpen.gif")+"' width='16px' height='16px'> <b><a href='" + target + "'>" + navText + "</a></b></td></tr>\n");
} else {
out.write("<img src='"+cms.link("../resources/images/navFolderClose.gif")+"' width='16px' height='16px'> <a href='" + target + "'>" + navText + "</a></td></tr>\n");
}
out.write("</td></tr>");
if ( (currentFolder.indexOf(nav.getResourceName()) > -1 && onlyShowCurrent) || !onlyShowCurrent) buildSiteMap(cms, nav.getResourceName(), out, onlyShowCurrent, currentFolder, currentPage, indent);
} else {
out.write("<tr><td align=left valign=middle class='navigationFile' nowrap>"+spacer);
if (nav.getResourceName().equals(currentPage))
{
out.write("<img src='"+cms.link("../resources/images/navFileOpen.gif")+"' width='16px' height='16px'> <b>" + navText + "</b></td></tr>\n");
} else {
out.write("<img src='"+cms.link("../resources/images/navFileClose.gif")+"' width='16px' height='16px'> <a href='" + cms.link(nav.getResourceName()) + "' >" + navText + "</a></td></tr>\n");
}
out.write("</td></tr>");
}
}
}
}
}
public CmsJspNavElement getFolderLink(com.opencms.flex.jsp.CmsJspActionElement cms, String folderUri)
{
ArrayList navList = cms.getNavigation().getNavigationForFolder(folderUri);
CmsJspNavElement nav;
Iterator navItem;
CmsJspNavElement link;
// Check direction
if (cms.property(NAVDIRECTIONKEY, folderUri, "down").equals("up")) { java.util.Collections.reverse(navList); }
if (navList.size() > 0)
{
// First check files
navItem = navList.iterator();
while (navItem.hasNext()) {
nav = (CmsJspNavElement) navItem.next();
if (nav != null && !nav.isFolderLink()) {
return nav;
}
}
// then check folders
navItem = navList.iterator();
while (navItem.hasNext()) {
nav = (CmsJspNavElement) navItem.next();
if (nav != null && nav.isFolderLink()) {
link = getFolderLink(cms, nav.getResourceName());
if (link != null) {
return link;
}
}
}
}
// No valid link found ... return null
return null;
}
%>
<table cellpadding='0' cellspacing='0' border='0'>
<%
String startingFolder = "/wwwfasnacht/";
// create a JSP action element
com.opencms.flex.jsp.CmsJspActionElement cms = new com.opencms.flex.jsp.CmsJspActionElement(pageContext, request, response);
String currentFolder = cms.getRequestContext().getFolderUri();
String currentPage = cms.getRequestContext().getUri();
int indent = (new StringTokenizer(startingFolder,"/")).countTokens() - 1;
buildSiteMap(cms, startingFolder, out, true, currentFolder, currentPage, indent);
%>
</table>