*
*/
public SinglePageController(UserRequest ureq, WindowControl wControl, boolean inIframe, VFSContainer rootContainer, String fileName, String currentUri, boolean allowRelativeLinks, boolean showHomeLink, OLATResourceable contextResourcable) {
super(wControl);
trans = new PackageTranslator(PACKAGE, ureq.getLocale());
Panel mainP = new Panel("iframemain");
myContent = new VelocityContainer("singlepagecontent", VELOCITY_ROOT + "/index.html", trans, this);
homeLinkP = new Panel("homelink");
homeLinkContent = new VelocityContainer("homelinkcontent", VELOCITY_ROOT + "/homelink.html", trans, this);
homeLinkContent.contextPut("showHomeLink",showHomeLink?Boolean.TRUE:Boolean.FALSE);
homeLink = LinkFactory.createCustomLink("command.home", "command.home", "", Link.NONTRANSLATED, homeLinkContent, this);
homeLink.setCustomEnabledLinkCSS("b_content_reset");
homeLink.setTooltip(trans.translate("command.home"), false);
myContent.put("homelinkpanel", homeLinkP);
// remember values in case of later cloning
// g_fileName : initial file name given (no root correction), e.g. bla.html or f/g/blu.html
// always use non-iframe mode for screenreaders
this.g_inIframe = (inIframe && (! getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()));
this.g_showHomeLink = showHomeLink;
this.g_allowRelativeLinks = allowRelativeLinks;
this.g_fileName = fileName;
this.g_rootContainer = rootContainer;
boolean jumpIn = false;
// strip beginning slash
String startURI = ( (fileName.charAt(0) == '/')? fileName.substring(1) : fileName);
// jump (e.g. from search) to the path if the business-launch-path says so.
BusinessControl bc = getWindowControl().getBusinessControl();
ContextEntry ce = bc.popLauncherContextEntry();
if ( ce != null ) { // a context path is left for me
Tracing.logDebug("businesscontrol (for further jumps) would be:"+bc, SinglePageController.class);
OLATResourceable ores = ce.getOLATResourceable();
Tracing.logDebug("OLATResourceable=" + ores, SinglePageController.class);
String typeName = ores.getResourceableTypeName();
// typeName format: 'path=/test1/test2/readme.txt'
// First remove prefix 'path='
String path = typeName.substring("path=".length());
if (path.length() > 0) {
Tracing.logDebug("direct navigation to container-path=" + path, SinglePageController.class);
jumpIn = true;
currentUri = path;
startURI = path;
}
}
// adjust root folder if security does not allow using ../.. etc.
if (!allowRelativeLinks && !jumpIn) {
// start uri is filename without relative path.
// the relative path of the file is added to the vfs rootcontainer
int sla = startURI.lastIndexOf('/');
if (sla != -1) {
String root = startURI.substring(0,sla);
startURI = startURI.substring(sla+1);
VFSContainer newroot = (VFSContainer)rootContainer.resolve(root);
this.g_new_rootContainer = newroot;
} else {
this.g_new_rootContainer = rootContainer;
}
} else {
this.g_new_rootContainer = rootContainer;
}
this.g_initialUri = startURI;
setCurURI(startURI);
// startURI and g_new_rootContainer set
// g_curURI : the current uri (relative to the (evt. corrected) rootcontainer)
// g_new_rootContainer : the given rootcontainer or adjusted in case when relativelinks are not allowed
// Display in iframe when
// a) configured as to be displayed in iframe and not in braille mode
// b) page is a direct jump in (unclear why not in this case, code was like that)
// c) when page type can not be inline rendered (e.g. when page is a pdf file)
if (g_inIframe || jumpIn || !HtmlStaticPageComponent.isFileTypeSupported(startURI)) {
idc = new IFrameDisplayController(ureq, getWindowControl(), g_new_rootContainer, contextResourcable);
idc.addControllerListener(this);
idc.setCurrentURI(startURI);
myContent.put("content", idc.getInitialComponent());
} else {
// in inline mode
// create single page root file now and start component for display dispathing
cpc = new HtmlStaticPageComponent("content", g_new_rootContainer);
cpc.addListener(this);
myContent.put("content", cpc);
if (currentUri != null) {
if (currentUri.charAt(0) == '/') {
//strip beginning slash
currentUri = currentUri.substring(1);
}
setCurURI(currentUri);
cpc.setCurrentURI(currentUri);
} else {
// no bookmarked uri given
setCurURI(startURI);
cpc.setCurrentURI(startURI);
}
}
mainP.setContent(myContent);
setInitialComponent(mainP);
}