Search in sources :

Example 26 with StringMediaResource

use of org.olat.core.gui.media.StringMediaResource in project openolat by klemens.

the class CPPrintMapper method prepareMediaResource.

private StringMediaResource prepareMediaResource(HttpServletRequest httpRequest, String page, String enc, String contentType) {
    StringMediaResource smr = new StringMediaResource();
    if (XHTML_CONTENT_TYPE.equals(contentType)) {
        // check if the application/xhtml+xml is supported (not supported by IEs)
        // if not, replace the content type by text/html for compatibility
        String accept = httpRequest.getHeader("Accept");
        if (accept == null || accept.indexOf(XHTML_CONTENT_TYPE) < 0) {
            contentType = DEFAULT_CONTENT_TYPE;
        }
    }
    String mimetype = contentType + ";charset=" + StringHelper.check4xMacRoman(enc);
    smr.setContentType(mimetype);
    smr.setEncoding(enc);
    // inject some javascript code to size iframe to proper height, but only when not a page with framesets
    if (page.indexOf(TAG_FRAMESET) != -1 || page.indexOf(TAG_FRAMESET_UPPERC) != -1) {
        // is frameset -> deliver unparsed
        smr.setData(page);
    } else {
        smr.setData(page);
    }
    return smr;
}
Also used : StringMediaResource(org.olat.core.gui.media.StringMediaResource)

Aggregations

StringMediaResource (org.olat.core.gui.media.StringMediaResource)26 File (java.io.File)8 NotFoundMediaResource (org.olat.core.gui.media.NotFoundMediaResource)6 StringWriter (java.io.StringWriter)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 GlossaryItemManager (org.olat.core.commons.modules.glossary.GlossaryItemManager)4 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 JavaSource2HTMLConverter (de.java2html.converter.JavaSource2HTMLConverter)3 JavaSource (de.java2html.javasource.JavaSource)3 JavaSourceParser (de.java2html.javasource.JavaSourceParser)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2 JSONObject (org.json.JSONObject)2 KalendarEventRenderWrapper (org.olat.commons.calendar.ui.components.KalendarEventRenderWrapper)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 GlossaryItem (org.olat.core.commons.modules.glossary.GlossaryItem)2