Allow pre-setting upload_target_type for each editor

This commit is contained in:
Kijin Sung 2023-11-19 21:29:15 +09:00
parent fdc9e1e98d
commit 9a6524d63d
6 changed files with 27 additions and 6 deletions

View file

@ -263,13 +263,13 @@ class EditorModel extends Editor
// Set upload config in session
$upload_config = [];
if (isset($option->allowed_filesize) && $option->allowed_filesize > 0)
$upload_config_keys = ['allowed_filesize', 'allowed_extensions', 'upload_target_type'];
foreach ($upload_config_keys as $key)
{
$upload_config['allowed_filesize'] = $option->allowed_filesize;
}
if (isset($option->allowed_extensions) && !empty($option->allowed_extensions))
{
$upload_config['allowed_extensions'] = $option->allowed_extensions;
if (isset($option->$key) && !empty($option->$key))
{
$upload_config[$key] = $option->$key;
}
}
FileController::setUploadInfo($option->editor_sequence, $upload_target_srl, $option->module_srl ?? 0, $upload_config);
@ -455,6 +455,16 @@ class EditorModel extends Editor
}
}
// Preset upload target type
if ($type === 'document')
{
$option->upload_target_type = 'doc';
}
elseif ($type === 'comment')
{
$option->upload_target_type = 'com';
}
// Other settings
$option->primary_key_name = $primary_key_name;
$option->content_key_name = $content_key_name;