Search in sources :

Example 6 with Filter

use of org.olat.core.util.filter.Filter in project OpenOLAT by OpenOLAT.

the class FeedViewHelper method getItemContentForBrowser.

/**
 * The item content with media file paths that are dispatchable by
 * a FeedMediaDispatcher.
 *
 * @param item
 * @return
 */
public String getItemContentForBrowser(Item item) {
    String itemContent = "";
    if (item != null) {
        String content = item.getContent();
        if (content != null) {
            if (item.getFeed().isExternal()) {
                // Apply xss filter for security reasons. Only necessary for external
                // feeds (e.g. to not let them execute JS code in our OLAT environment)
                Filter xssFilter = FilterFactory.getXSSFilter(content.length() + 1);
                itemContent = xssFilter.filter(content);
            } else {
                // Add relative media base to media elements to display internal media
                // files
                String basePath = baseUri + "/" + item.getGuid();
                Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(basePath);
                itemContent = mediaUrlFilter.filter(content);
            }
        }
    }
    return itemContent;
}
Also used : Filter(org.olat.core.util.filter.Filter)

Example 7 with Filter

use of org.olat.core.util.filter.Filter in project OpenOLAT by OpenOLAT.

the class BlogArtefactHandler method getContent.

@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
    String content = ePFManager.getArtefactFullTextContent(artefact);
    if (content != null) {
        try {
            XStream xstream = XStreamHelper.createXStreamInstance();
            xstream.alias("item", ItemImpl.class);
            ItemImpl item = (ItemImpl) xstream.fromXML(content);
            String mapperBaseURL = "";
            Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(mapperBaseURL);
            sb.append(mediaUrlFilter.filter(item.getDescription())).append(" ").append(mediaUrlFilter.filter(item.getContent()));
        } catch (Exception e) {
            log.warn("Cannot read an artefact of type blog while indexing", e);
        }
    }
}
Also used : Filter(org.olat.core.util.filter.Filter) XStream(com.thoughtworks.xstream.XStream) ItemImpl(org.olat.modules.webFeed.model.ItemImpl)

Example 8 with Filter

use of org.olat.core.util.filter.Filter in project OpenOLAT by OpenOLAT.

the class Mattext method render.

/**
 * @see org.olat.ims.qti.container.qtielements.QTIElement#render(StringBuilder, RenderInstructions)
 */
@Override
public void render(StringBuilder buffer, RenderInstructions ri) {
    buffer.append("<span class=\"o_qti_item_mattext\">");
    // Add static media base URI to render media elements inline
    Filter urlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter((String) ri.get(RenderInstructions.KEY_STATICS_PATH));
    String withBaseUrl = urlFilter.filter(content);
    // Add latex fomulas formatter
    withBaseUrl = Formatter.formatLatexFormulas(withBaseUrl);
    // 
    buffer.append(withBaseUrl);
    buffer.append("</span>");
}
Also used : Filter(org.olat.core.util.filter.Filter)

Example 9 with Filter

use of org.olat.core.util.filter.Filter in project openolat by klemens.

the class BlogArtefactHandler method getContent.

@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
    String content = ePFManager.getArtefactFullTextContent(artefact);
    if (content != null) {
        try {
            XStream xstream = XStreamHelper.createXStreamInstance();
            xstream.alias("item", ItemImpl.class);
            ItemImpl item = (ItemImpl) xstream.fromXML(content);
            String mapperBaseURL = "";
            Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(mapperBaseURL);
            sb.append(mediaUrlFilter.filter(item.getDescription())).append(" ").append(mediaUrlFilter.filter(item.getContent()));
        } catch (Exception e) {
            log.warn("Cannot read an artefact of type blog while indexing", e);
        }
    }
}
Also used : Filter(org.olat.core.util.filter.Filter) XStream(com.thoughtworks.xstream.XStream) ItemImpl(org.olat.modules.webFeed.model.ItemImpl)

Example 10 with Filter

use of org.olat.core.util.filter.Filter in project openolat by klemens.

the class FeedViewHelper method getItemContentForBrowser.

/**
 * The item content with media file paths that are dispatchable by
 * a FeedMediaDispatcher.
 *
 * @param item
 * @return
 */
public String getItemContentForBrowser(Item item) {
    String itemContent = "";
    if (item != null) {
        String content = item.getContent();
        if (content != null) {
            if (item.getFeed().isExternal()) {
                // Apply xss filter for security reasons. Only necessary for external
                // feeds (e.g. to not let them execute JS code in our OLAT environment)
                Filter xssFilter = FilterFactory.getXSSFilter(content.length() + 1);
                itemContent = xssFilter.filter(content);
            } else {
                // Add relative media base to media elements to display internal media
                // files
                String basePath = baseUri + "/" + item.getGuid();
                Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(basePath);
                itemContent = mediaUrlFilter.filter(content);
            }
        }
    }
    return itemContent;
}
Also used : Filter(org.olat.core.util.filter.Filter)

Aggregations

Filter (org.olat.core.util.filter.Filter)32 StringOutput (org.olat.core.gui.render.StringOutput)4 Identity (org.olat.core.id.Identity)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)4 OlatDocument (org.olat.search.model.OlatDocument)4 XStream (com.thoughtworks.xstream.XStream)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 TreeSet (java.util.TreeSet)2 Element (org.dom4j.Element)2 Test (org.junit.Test)2 GlossaryItemManager (org.olat.core.commons.modules.glossary.GlossaryItemManager)2 WindowControl (org.olat.core.gui.control.WindowControl)2 User (org.olat.core.id.User)2 VFSContainerMapper (org.olat.core.util.vfs.VFSContainerMapper)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)2 Control (org.olat.ims.qti.editor.beecom.objects.Control)2 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)2