Skip to content
Snippets Groups Projects
Commit 8ea20ffc authored by gnaegi's avatar gnaegi
Browse files

OO-264 fixed redscreen when file edit limit reached, show error to user instead of RS

parent b73bd3a6
No related branches found
No related tags found
No related merge requests found
......@@ -108,6 +108,7 @@ public class HTMLEditorController extends FormBasicController {
private boolean editable = true;
private boolean newFile = true;
private boolean editorCheckEnabled = true; // default
private String fileToLargeError = null;
/**
* Factory method to create a file based HTML editor instance that uses
......@@ -146,10 +147,10 @@ public class HTMLEditorController extends FormBasicController {
if ( size > FolderConfig.getMaxEditSizeLimit()) {
// limit to reasonable size, see OO-57
setTranslator(Util.createPackageTranslator(PlainTextEditorController.class, getLocale(),getTranslator()));
getWindowControl().setError(translate("plaintext.error.tolarge", new String[]{(size / 1000) + "", (FolderConfig.getMaxEditSizeLimit()/1000)+""}));
fileToLargeError = translate("plaintext.error.tolarge", new String[]{(size / 1000) + "", (FolderConfig.getMaxEditSizeLimit()/1000)+""});
this.body = "";
this.editable = false;
//initForm(ureq);
initForm(ureq);
return;
}
......@@ -222,29 +223,34 @@ public class HTMLEditorController extends FormBasicController {
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
htmlElement = uifactory.addRichTextElementForFileData("rtfElement", null, body, -1, -1, false, baseContainer, fileName, customLinkTreeModel, formLayout, ureq.getUserSession(), getWindowControl());
//
// Add resize handler
RichTextConfiguration editorConfiguration = htmlElement.getEditorConfiguration();
editorConfiguration.addOnInitCallbackFunction("b_resizetofit_htmleditor");
editorConfiguration.setNonQuotedConfigValue(RichTextConfiguration.HEIGHT, "b_initialEditorHeight()");
//
// The buttons
save = uifactory.addFormLink("savebuttontext", formLayout, Link.BUTTON);
save.addActionListener(this, FormEvent.ONCLICK);
cancel = uifactory.addFormLink("cancel", formLayout, Link.BUTTON);
cancel.addActionListener(this, FormEvent.ONCLICK);
saveClose = uifactory.addFormLink("saveandclosebuttontext", formLayout, Link.BUTTON);
saveClose.addActionListener(this, FormEvent.ONCLICK);
//
// Add some file metadata
VelocityContainer vc = (VelocityContainer) formLayout.getComponent();
metadataVC = createVelocityContainer("metadata");
vc.put("metadata", metadataVC);
long lm = fileLeaf.getLastModified();
metadataVC.contextPut("lastModified", Formatter.getInstance(ureq.getLocale()).formatDateAndTime(new Date(lm)));
metadataVC.contextPut("charSet", charSet);
metadataVC.contextPut("fileName", fileName);
if (fileToLargeError != null) {
VelocityContainer vc = (VelocityContainer) formLayout.getComponent();
vc.contextPut("fileToLargeError", fileToLargeError);
} else {
htmlElement = uifactory.addRichTextElementForFileData("rtfElement", null, body, -1, -1, false, baseContainer, fileName, customLinkTreeModel, formLayout, ureq.getUserSession(), getWindowControl());
//
// Add resize handler
RichTextConfiguration editorConfiguration = htmlElement.getEditorConfiguration();
editorConfiguration.addOnInitCallbackFunction("b_resizetofit_htmleditor");
editorConfiguration.setNonQuotedConfigValue(RichTextConfiguration.HEIGHT, "b_initialEditorHeight()");
//
// The buttons
save = uifactory.addFormLink("savebuttontext", formLayout, Link.BUTTON);
save.addActionListener(this, FormEvent.ONCLICK);
cancel = uifactory.addFormLink("cancel", formLayout, Link.BUTTON);
cancel.addActionListener(this, FormEvent.ONCLICK);
saveClose = uifactory.addFormLink("saveandclosebuttontext", formLayout, Link.BUTTON);
saveClose.addActionListener(this, FormEvent.ONCLICK);
//
// Add some file metadata
VelocityContainer vc = (VelocityContainer) formLayout.getComponent();
metadataVC = createVelocityContainer("metadata");
vc.put("metadata", metadataVC);
long lm = fileLeaf.getLastModified();
metadataVC.contextPut("lastModified", Formatter.getInstance(ureq.getLocale()).formatDateAndTime(new Date(lm)));
metadataVC.contextPut("charSet", charSet);
metadataVC.contextPut("fileName", fileName);
}
}
public boolean isEditable() {
......
<div class="b_htmleditor_wrapper b_clearfix">
#if($fileToLargeError)
<div class="o_cpeditor_message">
<div class="b_error">
$fileToLargeError
</div>
</div>
#end
#if($locked)
<p class="b_warning">
$r.translate("error.pageeditedby", $lockOwner)
......
......@@ -32,7 +32,7 @@
<!-- Restrict sending document to links to enforce authentication -->
SendDocLinkOnly=${folder.sendDocumentLinkOnly}
<!-- max edit filesize for online-editing in Bytes -->
EditFileSizeLimit=524288
EditFileSizeLimit=${folder.editFileSizeLimitBytes}
</value>
</property>
</bean>
......
......@@ -41,6 +41,8 @@ folder.maxulmb=50
folder.quotamb=100
folder.sendDocumentToExtern=true
folder.sendDocumentLinkOnly=true
# file size limit for HTML and text editor is 1MB
folder.editFileSizeLimitBytes=1048576
########################################################################
# Application settings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment