folderPath = startFromPath;
fileExists = false;
}
} else {
Folder folder = APILocator.getFolderAPI().findFolderByPath(startFromPath, hostId, user, true);
try{
Logger.debug(StaticMenuBuilder.class, "StaticMenuBuilder folder=" + APILocator.getIdentifierAPI().find(folder).getPath());
}catch (Exception e) {/*do nothing*/}
fileName = folder.getInode() + "_siteMapLevels_"+startFromLevel+"_" + numberOfLevels+"_"+reverseOrder+"_"+addHome + "_" + siteMapIdPrefix+ "_static.vtl";
menuId = String.valueOf(folder.getInode());
String vpath = MENU_VTL_PATH + fileName;
file = new java.io.File(vpath);
//file = new java.io.File(Config.CONTEXT.getRealPath(MENU_VTL_PATH + fileName));
Logger.debug(StaticMenuBuilder.class, "StaticMenuBuilder file=" + MENU_VTL_PATH + fileName);
if (!file.exists()) {
itemsList = APILocator.getFolderAPI().findMenuItems(folder, orderDirection);
for(int i=1; i < startFromLevel;i++){
java.util.List<Inode> itemsList2 = new ArrayList<Inode>();
for(Object inode : itemsList){
if (inode instanceof Folder) {
itemsList2.addAll(APILocator.getFolderAPI().findMenuItems((Folder)inode, orderDirection));
}
}
itemsList = itemsList2;
}
folderPath = APILocator.getIdentifierAPI().find(folder).getPath();
fileExists = false;
}
}
String filePath = "dynamic" + java.io.File.separator + "menus" + java.io.File.separator + fileName;
if (fileExists) {
return filePath;
} else {
if (itemsList.size() > 0) {
stringbuf.append("#if($EDIT_MODE) ");
stringbuf.append("<form action=\"${directorURL}\" method=\"post\" name=\"form_menu_").append(menuId).append("\" id=\"form_menu_").append(menuId)
.append("\">\n");
stringbuf.append("<input type=\"hidden\" name=\"cmd\" value=\"orderMenu\">\n");
stringbuf.append("<input type=\"hidden\" name=\"path\" value=\"").append(startFromPath).append("\">\n");
stringbuf.append("<input type=\"hidden\" name=\"hostId\" value=\"").append(hostId).append("\">\n");
stringbuf.append("<input type=\"hidden\" name=\"pagePath\" value=\"$VTLSERVLET_URI\">\n");
stringbuf.append("<input type=\"hidden\" name=\"referer\" value=\"$VTLSERVLET_URI\">\n");
stringbuf.append("<input type=\"hidden\" name=\"startLevel\" value=\"1\">\n");
stringbuf.append("<input type=\"hidden\" name=\"depth\" value=\"1\">\n");
stringbuf.append("<div class=\"dotMenuReorder\">\n");
stringbuf.append("<a href=\"javascript:document.getElementById('form_menu_").append(menuId).append("').submit();\">");
stringbuf.append("</a></div>\n");
stringbuf.append("</form>");
stringbuf.append("#end ");
stringbuf.append("#if($addParent && $addParent == true)");
Folder parent = APILocator.getFolderAPI().findFolderByPath(currentPath, hostId,user,true);
if(InodeUtils.isSet(parent.getInode())) {
String encodedPath = UtilMethods.encodeURIComponent(APILocator.getIdentifierAPI().find(parent).getPath());
stringbuf.append("#set($parentLink = '").append(encodedPath).append("')");
stringbuf.append("#set($parentName = '").append(UtilMethods.encodeURIComponent(UtilHTML.escapeHTMLSpecialChars(parent.getTitle()))).append("')");
stringbuf.append("<h2><a href=\"").append(encodedPath).append("\" class=\"parentFolder\">");
stringbuf.append(UtilHTML.escapeHTMLSpecialChars(parent.getTitle())).append("</a></h2>\n");
}
stringbuf.append("#end");
stringbuf.append("<ul>");
//adding home folder
if(addHome)
{
String homeTitle = loadHomeTitle(request);
stringbuf.append("<li id=\"").append(siteMapIdPrefix).append("home\"><a href=\"/\">").append(homeTitle).append("</a></li>");
}
// gets menu items for this folder
Logger.debug(StaticMenuBuilder.class, "StaticMenuBuilder number of items=" + itemsList.size());
// /FIRST LEVEL MENU ITEMS!!!!
for (Object itemChild : itemsList) {
if (itemChild instanceof Folder) {
Folder folderChild = (Folder) itemChild;
// recursive method here
stringbuf = buildSubFolderSiteMapMenu(stringbuf, folderChild, numberOfLevels, 1,orderDirection,siteMapIdPrefix);