if (!con.hasCompleteRelationships()) {
context.setLastError("Current content does not belong to a page hierarchy");
return errorReturnContext;
}
WGStructEntry struct = con.getStructEntry();
while (struct != null && struct.getLevel() > level) {
struct = struct.getParentEntry();
}
if (struct != null) {
WGContent targetCon = _languageChooser.selectContentForPage(struct, isBI);
if (targetCon != null) {
return context.getTMLContextForDocument(targetCon);
}
else {
context.setLastError("Page on level " + level + " has no appropriate content document");
return errorReturnContext;
}
}
else {
context.setLastError("Failed to go to page level " + level);
return errorReturnContext;
}
}
else if (contextFunction.equals("np")) {
String namePart = UniqueNamePartFormatter.INSTANCE.format(contextExpression);
String uname = context.content().getUniqueName();
if (WGUtils.isEmpty(uname)) {
uname = context.content().getStructEntry().getUniqueName();
}
String fullname;
if (!WGUtils.isEmpty(uname)) {
fullname = uname + "." + namePart;
}
else {
fullname = namePart;
}
WGContent content = _languageChooser.selectContentForName(context.content().getDatabase(), fullname, context.isbrowserinterface());
if (content != null) {
return context.getTMLContextForDocument(navigator.chooseRelevantContent(content, mainContent));
}
context.setLastError("Could not retrieve content for hdb unique name " + fullname);
return errorReturnContext;
}
// From here special functions for BI
else if (contextFunction.equals("$struct")) {
WGStructEntry entry = db.getStructEntryByKey(contextExpression);
if (entry != null) {
return context.getTMLContextForDocument(entry);
}
else {
context.setLastError("Could not retrieve struct entry with key '" + contextExpression + "'");