Commit c9e61daf authored by Henning Leutz's avatar Henning Leutz 🥋

refactor: #955 - used upload form settings from inherited form class

parent ec7052e1
......@@ -3,6 +3,7 @@
namespace QUI\Upload;
use QUI;
use QUI\Permissions\Permission;
/**
* Class Form
......@@ -20,6 +21,7 @@ class Form extends QUI\QDOM
{
// defaults
$this->setAttributes([
'name' => '', // @todo input field name
'contextMenu' => true,
'multiple' => true,
'sendbutton' => true,
......@@ -36,11 +38,22 @@ class Form extends QUI\QDOM
]);
// set default allowed file types
// @todo
if (!isset($params['allowedFileTypes'])) {
$allowedTypes = Permission::getPermission(
'quiqqer.upload.allowedTypes'
);
$this->setAttribute('allowedFileTypes', $allowedTypes);
}
// set default allowed file endings
// @todo
if (!isset($params['allowedFileEnding'])) {
$allowedEndings = Permission::getPermission(
'quiqqer.upload.allowedEndings'
);
$this->setAttribute('allowedFileEnding', $allowedEndings);
}
parent::setAttributes($params);
}
......
......@@ -158,6 +158,16 @@ class Manager
$_REQUEST['extract'] = QUI\Utils\BoolHelper::JSBool($_REQUEST['extract']);
}
$UploadForm = null;
if (isset($_REQUEST['callable']) && \class_exists($_REQUEST['callable'])) {
$Instance = new $_REQUEST['callable']();
if ($Instance instanceof Form) {
$UploadForm = $Instance;
}
}
// check file count
$configMaxFileCount = Permission::getPermission(
'quiqqer.upload.maxUploadCount'
......@@ -176,7 +186,7 @@ class Manager
}
}
// check mime type
// check mime type and file endings
$configAllowedTypes = Permission::getPermission(
'quiqqer.upload.allowedTypes'
);
......@@ -185,6 +195,12 @@ class Manager
'quiqqer.upload.allowedEndings'
);
if ($UploadForm) {
$configAllowedTypes = $UploadForm->getAttribute('allowedFileTypes');
$configAllowedEndings = $UploadForm->getAttribute('allowedFileEnding');
}
if ($this->checkFnMatch($configAllowedTypes, $fileType) === false) {
throw new QUI\Exception([
'quiqqer/quiqqer',
......
......@@ -10,3 +10,12 @@
{$Site->getAttribute('content')}
</div>
{/if}
{$FormUpload->create()}
<style>
footer {
display: inline-block;
margin-top: 40px;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment