use of org.olat.core.util.filter.Filter in project OpenOLAT by OpenOLAT.
the class CSVToQuestionConverter method createMattext.
private Mattext createMattext(String text) {
// text is already in a CDATA
text = text.replace("// <![CDATA[", "").replace("// ]]>", "");
// Use explicit return which create a P tag if you want a line break.
if (text.startsWith("<br />") && text.length() > 6)
text = text.substring(6);
if (text.endsWith("<br />") && text.length() > 6)
text = text.substring(0, text.length() - 6);
// Remove any conditional comments due to strange behavior in test (OLAT-4518)
Filter conditionalCommentFilter = FilterFactory.getConditionalHtmlCommentsFilter();
text = conditionalCommentFilter.filter(text);
Mattext mattext = new Mattext(text);
return mattext;
}
use of org.olat.core.util.filter.Filter in project OpenOLAT by OpenOLAT.
the class FeedViewHelper method getItemDescriptionForBrowser.
/**
* Get the item description with media file paths that are dispatchable by
* a FeedMediaDispatcher.
*
* @param item
* @return
*/
public String getItemDescriptionForBrowser(Item item) {
String itemDescription = "";
if (item != null) {
String description = item.getDescription();
if (description != 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(description.length() + 1);
itemDescription = xssFilter.filter(description);
} else {
// Add relative media base to media elements to display internal media
// files
String basePath = baseUri + "/" + item.getGuid();
Filter mediaUrlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(basePath);
itemDescription = mediaUrlFilter.filter(description);
}
}
itemDescription = Formatter.formatLatexFormulas(itemDescription);
}
return itemDescription;
}
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;
}
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);
}
}
}
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>");
}
Aggregations