use of org.olat.core.util.filter.Filter in project openolat by klemens.
the class MaterialFormController method formOK.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
*/
@Override
protected void formOK(UserRequest ureq) {
// trust authors, don't to XSS filtering
String newHtml = richText.getRawValue();
// the text fragment is saved in a cdata, remove cdata from movie plugin
newHtml = newHtml.replace("// <![CDATA[", "").replace("// ]]>", "");
// Use explicit return which create a P tag if you want a line break.
if (newHtml.startsWith("<br />") && newHtml.length() > 6)
newHtml = newHtml.substring(6);
if (newHtml.endsWith("<br />") && newHtml.length() > 6)
newHtml = newHtml.substring(0, newHtml.length() - 6);
// Remove any conditional comments due to strange behavior in test (OLAT-4518)
Filter conditionalCommentFilter = FilterFactory.getConditionalHtmlCommentsFilter();
newHtml = conditionalCommentFilter.filter(newHtml);
//
if (htmlContent.equals(newHtml)) {
// No changes. Cancel editing.
fireEvent(ureq, Event.CANCELLED_EVENT);
} else {
if (isRestrictedEditMode) {
// In restricted edit mode, if the content has changed, write a memento
// (by firing the before change event).
QTIObjectBeforeChangeEvent qobce = new QTIObjectBeforeChangeEvent();
qobce.init(mat.getId(), htmlContent);
fireEvent(ureq, qobce);
}
// Collect the content of all MatElements in a single text element
// (text/html) and save it (for Material objects with multiple elements
// such as images, videos, text, breaks, etc. this can be regarded as
// "lazy migration" to the new rich text style).
Mattext textHtml = new Mattext(newHtml);
// A single text/html element will be left over.
List<QTIObject> elements = new ArrayList<QTIObject>(1);
elements.add(textHtml);
mat.setElements(elements);
fireEvent(ureq, Event.DONE_EVENT);
}
}
use of org.olat.core.util.filter.Filter in project openolat by klemens.
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;
}
Aggregations