use of org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration in project OpenOLAT by OpenOLAT.
the class HTMLEditorControllerWithoutFile method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
htmlElement = uifactory.addRichTextElementForStringData("rtfElement", null, body, -1, -1, true, baseContainer, customLinkTreeModel, formLayout, ureq.getUserSession(), getWindowControl());
// Add resize handler
RichTextConfiguration editorConfiguration = htmlElement.getEditorConfiguration();
editorConfiguration.addOnInitCallbackFunction("b_resizetofit_htmleditor");
editorConfiguration.enableEditorHeight();
// The buttons
save = uifactory.addFormLink("savebuttontext", formLayout, Link.BUTTON);
save.addActionListener(FormEvent.ONCLICK);
cancel = uifactory.addFormLink("cancel", formLayout, Link.BUTTON);
cancel.addActionListener(FormEvent.ONCLICK);
saveClose = uifactory.addFormLink("saveandclosebuttontext", formLayout, Link.BUTTON);
saveClose.setVisible(false);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration in project OpenOLAT by OpenOLAT.
the class MaterialFormController method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
richText = uifactory.addRichTextElementForStringData("mce", null, htmlContent, 14, -1, true, qtiPackage.getBaseDir(), null, formLayout, ureq.getUserSession(), getWindowControl());
richText.getEditorConfiguration().setFigCaption(false);
RichTextConfiguration richTextConfig = richText.getEditorConfiguration();
// disable <p> element for enabling vertical layouts
richTextConfig.disableRootParagraphElement();
// set upload dir to the media dir
richTextConfig.setFileBrowserUploadRelPath("media");
// manually enable the source edit button
richTextConfig.enableCode();
// allow script tags...
richTextConfig.setInvalidElements(RichTextConfiguration.INVALID_ELEMENTS_FORM_FULL_VALUE_UNSAVE_WITH_SCRIPT);
richTextConfig.setExtendedValidElements("script[src|type|defer]");
uifactory.addFormSubmitButton("submit", formLayout);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration in project OpenOLAT by OpenOLAT.
the class HottextEditorController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_hot");
titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), formLayout);
titleEl.setElementCssClass("o_sel_assessment_item_title");
titleEl.setMandatory(true);
titleEl.setEnabled(!readOnly);
String relativePath = rootDirectory.toPath().relativize(itemFile.toPath().getParent()).toString();
VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
String question = itemBuilder.getQuestion();
textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", question, 16, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
textEl.setElementCssClass("o_sel_assessment_item_hottext_text");
textEl.addActionListener(FormEvent.ONCLICK);
RichTextConfiguration richTextConfig = textEl.getEditorConfiguration();
richTextConfig.enableQTITools(false, false, true);
richTextConfig.setAdditionalConfiguration(new CorrectAnswersConfiguration());
richTextConfig.setReadOnly(restrictedEdit || readOnly);
// Submit Button
FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsContainer.setElementCssClass("o_sel_hottext_save");
buttonsContainer.setRootForm(mainForm);
buttonsContainer.setVisible(!readOnly);
formLayout.add(buttonsContainer);
uifactory.addFormSubmitButton("submit", buttonsContainer);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration in project openolat by klemens.
the class ItemFormController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_feed_form");
title = uifactory.addTextElement("title", "feed.title.label", 256, item.getTitle(), this.flc);
title.setElementCssClass("o_sel_feed_title");
title.setMandatory(true);
title.setNotEmptyCheck("feed.form.field.is_mandatory");
description = uifactory.addRichTextElementForStringData("description", "feed.form.description", item.getDescription(), 12, -1, false, baseDir, null, formLayout, ureq.getUserSession(), getWindowControl());
RichTextConfiguration descRichTextConfig = description.getEditorConfiguration();
// set upload dir to the media dir
descRichTextConfig.setFileBrowserUploadRelPath("media");
// disable XSS unsave buttons for movie (no media in standard profile)
descRichTextConfig.disableMedia();
content = uifactory.addRichTextElementForStringData("content", "feed.form.content", item.getContent(), 18, -1, false, baseDir, null, formLayout, ureq.getUserSession(), getWindowControl());
RichTextConfiguration richTextConfig = content.getEditorConfiguration();
// set upload dir to the media dir
richTextConfig.setFileBrowserUploadRelPath("media");
// disable XSS unsave buttons for movie (no media in standard profile)
richTextConfig.disableMedia();
content.setVisible(hasContent());
file = uifactory.addFileElement(getWindowControl(), "file", flc);
file.setLabel("feed.item.file.label", null);
if (hasMandatoryMedia()) {
file.setMandatory(true, "feed.item.file.mandatory");
} else {
file.setDeleteEnabled(true);
}
File mediaFile = FeedManager.getInstance().loadItemEnclosureFile(item);
file.setInitialFile(mediaFile);
file.addActionListener(FormEvent.ONCHANGE);
if (baseDir.getLocalSecurityCallback() != null && baseDir.getLocalSecurityCallback().getQuota() != null) {
Long uploadLimitKB = baseDir.getLocalSecurityCallback().getQuota().getUlLimitKB();
String supportAddr = WebappHelper.getMailConfig("mailQuota");
file.setMaxUploadSizeKB(uploadLimitKB.intValue(), "ULLimitExceeded", new String[] { Formatter.roundToString((uploadLimitKB.floatValue() / 1000f), 1), supportAddr });
}
String width = item.getWidth() != null && item.getWidth() > 0 ? Integer.toString(item.getWidth()) : "";
widthEl = uifactory.addTextElement("video-width", "feed.item.file.width", 12, width, flc);
String height = item.getHeight() != null && item.getHeight() > 0 ? Integer.toString(item.getHeight()) : "";
heightEl = uifactory.addTextElement("video-height", "feed.item.file.height", 12, height, flc);
Calendar cal = Calendar.getInstance(ureq.getLocale());
if (item.getPublishDate() != null) {
cal.setTime(item.getPublishDate());
}
publishDateChooser = uifactory.addDateChooser("publishDateChooser", "feed.publish.date", cal.getTime(), formLayout);
publishDateChooser.setNotEmptyCheck("feed.publish.date.is.required");
publishDateChooser.setValidDateCheck("feed.publish.date.invalid");
publishDateChooser.setDateChooserTimeEnabled(true);
publishDateChooser.setVisible(hasDraftMode());
final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
this.flc.add(buttonLayout);
uifactory.addFormSubmitButton("feed.publish", buttonLayout);
if (hasDraftMode()) {
draftButton = uifactory.addFormLink("feed.save.as.draft", buttonLayout, Link.BUTTON);
draftButton.addActionListener(FormEvent.ONCLICK);
}
cancelButton = uifactory.addFormLink("cancel", buttonLayout, Link.BUTTON);
}
use of org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextConfiguration in project openolat by klemens.
the class FeedFormController method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// title might be longer from external source
String saveTitle = PersistenceHelper.truncateStringDbSave(feed.getTitle(), 256, true);
title = uifactory.addTextElement("title", "feed.title.label", 256, saveTitle, formLayout);
title.setElementCssClass("o_sel_feed_title");
title.setMandatory(true);
title.setNotEmptyCheck("feed.form.field.is_mandatory");
description = uifactory.addRichTextElementForStringDataMinimalistic("description", "feed.form.description", feed.getDescription(), 5, -1, formLayout, getWindowControl());
description.setMaxLength(4000);
RichTextConfiguration richTextConfig = description.getEditorConfiguration();
// set upload dir to the media dir
richTextConfig.setFileBrowserUploadRelPath("media");
// Add a delete link and an image component to the image container.
deleteImage = uifactory.addFormLink("feed.image.delete", formLayout, Link.BUTTON);
deleteImage.setVisible(false);
file = uifactory.addFileElement(getWindowControl(), "feed.file.label", formLayout);
file.addActionListener(FormEvent.ONCHANGE);
file.setPreview(ureq.getUserSession(), true);
if (feed.getImageName() != null) {
VFSLeaf imageResource = FeedManager.getInstance().createFeedMediaFile(feed, feed.getImageName(), null);
if (imageResource instanceof LocalFileImpl) {
file.setPreview(ureq.getUserSession(), true);
file.setInitialFile(((LocalFileImpl) imageResource).getBasefile());
deleteImage.setVisible(true);
}
}
Set<String> mimeTypes = new HashSet<String>();
mimeTypes.add("image/jpeg");
mimeTypes.add("image/jpg");
mimeTypes.add("image/png");
mimeTypes.add("image/gif");
file.limitToMimeType(mimeTypes, "feed.form.file.type.error.images", null);
int maxFileSizeKB = feedQuota.getUlLimitKB().intValue();
String supportAddr = WebappHelper.getMailConfig("mailQuota");
file.setMaxUploadSizeKB(maxFileSizeKB, "ULLimitExceeded", new String[] { new Long(maxFileSizeKB / 1024).toString(), supportAddr });
// if external feed, display feed-url text-element:
if (feed.isExternal()) {
feedUrl = uifactory.addTextElement("feedUrl", "feed.form.feedurl", 5000, feed.getExternalFeedUrl(), flc);
feedUrl.setElementCssClass("o_sel_feed_url");
feedUrl.setDisplaySize(70);
String type = feed.getResourceableTypeName();
if (type != null && type.indexOf("BLOG") >= 0) {
feedUrl.setExampleKey("feed.form.feedurl.example", null);
} else {
feedUrl.setExampleKey("feed.form.feedurl.example_podcast", null);
}
}
// Submit and cancelButton buttons
final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("submit", buttonLayout);
cancelButton = uifactory.addFormLink("cancel", buttonLayout, Link.BUTTON);
}
Aggregations