use of org.olat.core.gui.GlobalSettings in project OpenOLAT by OpenOLAT.
the class CourseCreationConfiguration method getSinglePageText.
/**
* @param translator
* @return single page content
*/
public String getSinglePageText(Translator translator) {
VelocityContainer vc = new VelocityContainer("singlePageTemplate", CourseCreationHelper.class, "singlePageTemplate", translator, null);
vc.contextPut("coursetitle", courseTitle);
// prepare rendering of velocity page for the content of the single page node
GlobalSettings globalSettings = new GlobalSettings() {
public int getFontSize() {
return 100;
}
public AJAXFlags getAjaxFlags() {
return new EmptyAJAXFlags();
}
public boolean isIdDivsForced() {
return false;
}
};
Context context = vc.getContext();
Renderer fr = Renderer.getInstance(vc, translator, null, new RenderResult(), globalSettings);
StringOutput wOut = new StringOutput(10000);
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(fr, vc, wOut);
context.put("r", vrdec);
VelocityHelper.getInstance().mergeContent(vc.getPage(), context, wOut, null);
// free the decorator
context.remove("r");
IOUtils.closeQuietly(vrdec);
return WysiwygFactory.createXHtmlFileContent(wOut.toString(), courseTitle);
}
use of org.olat.core.gui.GlobalSettings in project openolat by klemens.
the class CourseCreationConfiguration method getSinglePageText.
/**
* @param translator
* @return single page content
*/
public String getSinglePageText(Translator translator) {
VelocityContainer vc = new VelocityContainer("singlePageTemplate", CourseCreationHelper.class, "singlePageTemplate", translator, null);
vc.contextPut("coursetitle", courseTitle);
// prepare rendering of velocity page for the content of the single page node
GlobalSettings globalSettings = new GlobalSettings() {
public int getFontSize() {
return 100;
}
public AJAXFlags getAjaxFlags() {
return new EmptyAJAXFlags();
}
public boolean isIdDivsForced() {
return false;
}
};
Context context = vc.getContext();
Renderer fr = Renderer.getInstance(vc, translator, null, new RenderResult(), globalSettings);
StringOutput wOut = new StringOutput(10000);
VelocityRenderDecorator vrdec = new VelocityRenderDecorator(fr, vc, wOut);
context.put("r", vrdec);
VelocityHelper.getInstance().mergeContent(vc.getPage(), context, wOut, null);
// free the decorator
context.remove("r");
IOUtils.closeQuietly(vrdec);
return WysiwygFactory.createXHtmlFileContent(wOut.toString(), courseTitle);
}
use of org.olat.core.gui.GlobalSettings in project openolat by klemens.
the class Renderer method render.
/**
* used by the renderer, and also by the panel and tabbedpane renderer to delegate rendering
* @param sb
* @param source
* @param args
*/
public void render(StringOutput sb, Component source, String[] args) {
GlobalSettings gset = getGlobalSettings();
boolean ajaxon = gset.getAjaxFlags().isIframePostEnabled();
// wrap with div's so javascript can replace this component by doing a document.getElementById(cid).innerHTML and so on.
boolean domReplaceable = source.isDomReplaceable();
boolean useSpan = source.getSpanAsDomReplaceable();
boolean domReplacementWrapperRequired = source.isDomReplacementWrapperRequired();
boolean forceDebugDivs = gset.isIdDivsForced();
if (source.isVisible()) {
int lev = renderResult.getNestedLevel();
if (lev > 60)
throw new AssertException("components were nested more than 60 times, assuming endless loop bug: latest comp name: " + source.getComponentName());
Translator componentTranslator = source.getTranslator();
// identifier for dom replacement
if (domReplaceable && domReplacementWrapperRequired && (ajaxon || forceDebugDivs)) {
if (useSpan) {
sb.append("<span id='o_c").append(source.getDispatchID());
} else {
sb.append("<div id='o_c").append(source.getDispatchID());
}
if (Settings.isDebuging()) {
// sb.append("' title='").append(source.getComponentName());
}
sb.append("'>");
}
ComponentRenderer cr = findComponentRenderer(source);
URLBuilder cubu = urlBuilder.createCopyFor(source);
renderResult.incNestedLevel();
// ---- for gui debug mode, direct the rendering to a special componentrenderer
InterceptHandlerInstance dhi = renderResult.getInterceptHandlerInstance();
if (dhi != null) {
cr = dhi.createInterceptComponentRenderer(cr);
}
try {
int preRenderLength = sb.length();
cr.render(this, sb, source, cubu, componentTranslator, renderResult, args);
if (preRenderLength == sb.length()) {
// Add bugfix for IE min-height on empty div problem: min-height does
// not get applied when div contains an empty comment.
// Affects IE6, IE7
sb.append("<!-- empty -->");
}
source.setDirty(false);
} catch (Exception e) {
// in order to produce a decent error msg, we need to postpone the
// exception
renderResult.setRenderExceptionInfo("exception while rendering component '" + source.getComponentName() + "' (" + source.getClass().getName() + ") " + source.getListenerInfo() + "<br />Message of exception: " + e.getMessage(), e);
}
renderResult.decNestedLevel();
if (ajaxon && domReplaceable && domReplacementWrapperRequired) {
if (useSpan) {
sb.append("</span>");
} else {
sb.append("</div>");
}
}
} else {
// not visible
if (domReplaceable && (ajaxon || forceDebugDivs)) {
// browser dom tree
if (useSpan) {
sb.append("<span id=\"o_c").append(source.getDispatchID()).append("\"></span>");
} else {
// Add bugfix for IE min-height on empty div problem: min-height does
// not get applied when div contains an empty comment.
// Affects IE6, IE7
sb.append("<div id=\"o_c").append(source.getDispatchID()).append("\"><!-- empty --></div>");
}
}
}
}
Aggregations