iter.setSkipHiddenSubPages(Utils.isTrue(allowHiding));
boolean styleNotApplied = !Utils.isNullOrEmpty(style);
int showLastLevel = -1;
while (iter.hasNext()) {
PageInfo currentPageInfo = (PageInfo) iter.next();
Path currentPath = currentPageInfo.getPath();
int level = Math.max(baseLevel, currentPageInfo.getLevel());
if (currentPageInfo.getLevel() <= showLastLevel) {
showLastLevel = -1;
}
if (siteInfo.getHideSubmenu(currentPath) && showLastLevel == -1) {
showLastLevel = currentPageInfo.getLevel();
}
boolean add = false;
if (itemsAll) {
add = true;
} else {
Path parentPath = currentPath.getParent();
if (parentPath.isRelative() || pathInMenu.isContainedIn(parentPath)) {
if (itemsOnPath && pathInMenu.isContainedIn(currentPath)) {
add = true;
} else if (level <= baseLevel) {
add = itemsFirstLevel;
} else if (currentPath.getElementCount() == pathInMenu.getElementCount()) {
add = itemsLastLevel;
} else if (currentPath.getElementCount() > pathInMenu.getElementCount()) {
add = itemsChildren;
} else {
add = itemsIntermediateLevels;
}
}
}
if (add) {
// Close off any pending lower levels
for (int i = lastLevel - 1; i >= level; i--) {
writeIndented(outWriter, "</li>", i + 1);
writeIndented(outWriter, "</ul>", i);
}
// If we're a level deeper - then create new sub ul+li
for (int i = lastLevel; i < level; i++) {
if (styleNotApplied) {
writeIndented(outWriter, "<ul class=\"" + style + "\">", i);
styleNotApplied = false;
} else {
if (artisteer) {
writeIndented(outWriter, "<ul class='active'>", i);
} else {
writeIndented(outWriter, "<ul>", i);
}
}
writeIndented(outWriter, "<li>", i + 1);
}
// If we do not have an open li at the right level - then create one
if (level <= lastLevel) {
writeIndented(outWriter, "</li>", level);
writeIndented(outWriter, "<li>", level);
}
String link = webSite.getLink(currentPageInfo, pageDirPath).toString();
String artStart, artEnd;
if (currentPageInfo.getLevel() - baseLevel < 1 && artisteer) {
artStart = "<span class='l'></span><span class='r'></span><span class='t'>";
artEnd = "</span>";
} else {
artStart = artEnd = "";
}
if (currentPageInfo.getLevel() > 0 && pathInMenu.isContainedIn(currentPath)
&& !(currentPageInfo.getPath().equals(pathInMenu)
|| currentPageInfo.getPath().equals(rootPath)
|| Utils.isNullOrEmpty(currentPathStyle))) {
outWriter.write("<a href=\"" + link + "\" class='" + currentPathStyle +
"'>" + artStart + siteInfo.getPageTitle(currentPageInfo) + artEnd + "</a>");
} else if (currentPageInfo.getPath().equals(pathInMenu)) {
if (isEdit || linkCurrent) {
if (!(Utils.isNullOrEmpty(currentStyle) && Utils.isNullOrEmpty(currentPathStyle))) {
outWriter.write("<a href=\"" + link + "\" class='" + currentPathStyle +
" " + currentStyle + "'>" + artStart +
siteInfo.getPageTitle(currentPageInfo) + artEnd + "</a>");