fileExists = false;
}
}
}
else {
Folder folder = folderAPI.findFolderByPath(path,hostId,APILocator.getUserAPI().getSystemUser(),false);
Logger.debug(HorizontalMenuBuilder.class, "HorizontalMenuBuilder folder=" + APILocator.getIdentifierAPI().find(folder).getPath());
fileName = folder.getInode() + "_horz.vtl";
menuId = String.valueOf(folder.getInode());
try {
file = new java.io.File(MENU_VTL_PATH + java.io.File.separator + fileName);
if (!file.exists()) {
FileOutputStream fo = new FileOutputStream(file);
fo.close();
itemsList = folderAPI.findMenuItems(folder, APILocator.getUserAPI().getSystemUser(), false);
folderPath = APILocator.getIdentifierAPI().find(folder).getPath();
fileExists = false;
}
} catch (java.io.FileNotFoundException e) {
file = new java.io.File(MENU_VTL_PATH + java.io.File.separator + fileName);
if (!file.exists()) {
itemsList = folderAPI.findMenuItems(folder, APILocator.getUserAPI().getSystemUser(), false);
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 (divName!=null && divName.length()>0) {
String beforeMenu = "<div id=\"" + divName + "\">";
stringbuf.append(beforeMenu);
}
if (ulClassName!=null && ulClassName.length() >0) {
stringbuf.append("<ul class=\"" + ulClassName + "\">");
}
else {
stringbuf.append("<ul>");
}
if (divName!=null && divName.length()>0) {
stringbuf.append("#if($EDIT_MODE)\n");
stringbuf.append("<form action=\"${directorURL}\" method=\"post\" name=\"form_menu_" + menuId + "\" id=\"form_menu_" + menuId + "\">\n");
stringbuf.append("<input type=\"hidden\" name=\"cmd\" value=\"orderMenu\">\n");
stringbuf.append("<input type=\"hidden\" name=\"path\" value=\"" + path + "\">\n");
stringbuf.append("<input type=\"hidden\" name=\"openAll\" value=\"true\">\n");
stringbuf.append("<input type=\"hidden\" name=\"hostId\" value=\"" + hostId + "\">\n");
stringbuf.append("<input type=\"hidden\" name=\"pagePath\" value=\"" + path + "\">\n");
stringbuf.append("<input type=\"hidden\" name=\"referer\" value=\"$VTLSERVLET_URI\">\n");
stringbuf.append("<a href=\"javascript:submitMenu('form_menu_" + menuId + "');\">Reorder Menu\n");
stringbuf.append("</a></form>\n");
stringbuf.append("#end \n");
}
//gets menu items for this folder
java.util.Iterator itemListIterator = itemsList.iterator();
Logger.debug(HorizontalMenuBuilder.class, "HorizontalMenuBuilder number of items=" + itemsList.size());
///FIRST LEVEL MENU ITEMS!!!!
while (itemListIterator.hasNext()) {
Inode itemChild = (Inode) itemListIterator.next();
if (itemChild instanceof Folder) {
Folder folderChild = (Folder) itemChild;
//recursive method here
stringbuf = getMenuItems(stringbuf, folderChild, linkFolders, numberOfLevels, 1, imagePrefix, imageSuffix);
}