Fix missing configuration items in file module config

This commit is contained in:
Kijin Sung 2025-06-01 15:41:22 +09:00
parent b849c597bc
commit eb76f9d8bb
3 changed files with 54 additions and 25 deletions

View file

@ -240,14 +240,21 @@ class FileAdminController extends File
if(!Context::get('use_image_default_file_config')) if(!Context::get('use_image_default_file_config'))
{ {
$config->use_image_default_file_config = 'N'; $config->use_image_default_file_config = 'N';
$config->image_autoconv['bmp2jpg'] = Context::get('image_autoconv_bmp2jpg') === 'Y' ? true : false; foreach (Context::get('image_autoconv') ?: [] as $source_type => $target_type)
$config->image_autoconv['png2jpg'] = Context::get('image_autoconv_png2jpg') === 'Y' ? true : false; {
$config->image_autoconv['webp2jpg'] = Context::get('image_autoconv_webp2jpg') === 'Y' ? true : false; if (in_array($target_type, ['Y', 'N']))
$config->image_autoconv['gif2mp4'] = Context::get('image_autoconv_gif2mp4') === 'Y' ? true : false; {
$config->image_autoconv[$source_type] = tobool($target_type);
}
elseif (in_array($target_type, ['', 'jpg', 'png', 'webp']))
{
$config->image_autoconv[$source_type] = $target_type;
}
}
$config->max_image_width = intval(Context::get('max_image_width')) ?: ''; $config->max_image_width = intval(Context::get('max_image_width')) ?: '';
$config->max_image_height = intval(Context::get('max_image_height')) ?: ''; $config->max_image_height = intval(Context::get('max_image_height')) ?: '';
$config->max_image_size_action = Context::get('max_image_size_action') ?: ''; $config->max_image_size_action = Context::get('max_image_size_action') ?: '';
$config->max_image_size_same_format = Context::get('max_image_size_same_format') === 'Y' ? 'Y' : 'N'; $config->max_image_size_same_format = strval(Context::get('max_image_size_same_format'));
$config->max_image_size_admin = Context::get('max_image_size_admin') === 'Y' ? 'Y' : 'N'; $config->max_image_size_admin = Context::get('max_image_size_admin') === 'Y' ? 'Y' : 'N';
$config->image_quality_adjustment = max(50, min(100, intval(Context::get('image_quality_adjustment')))); $config->image_quality_adjustment = max(50, min(100, intval(Context::get('image_quality_adjustment'))));
$config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false; $config->image_autorotate = Context::get('image_autorotate') === 'Y' ? true : false;

View file

@ -36,8 +36,21 @@ class FileView extends File
// Get file configurations of the module // Get file configurations of the module
$config = FileModel::getFileConfig($current_module_srl); $config = FileModel::getFileConfig($current_module_srl);
if (!isset($config->use_default_file_config))
{
$config->use_default_file_config = 'Y';
}
if (!isset($config->use_image_default_file_config))
{
$config->use_image_default_file_config = 'Y';
}
if (!isset($config->use_video_default_file_config))
{
$config->use_video_default_file_config = 'Y';
}
Context::set('config', $config); Context::set('config', $config);
Context::set('is_ffmpeg', function_exists('exec') && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command) && Rhymix\Framework\Storage::isExecutable($config->ffprobe_command)); Context::set('is_ffmpeg', function_exists('exec') && !empty($config->ffmpeg_command) && Rhymix\Framework\Storage::isExecutable($config->ffmpeg_command) && !empty($config->ffprobe_command) && Rhymix\Framework\Storage::isExecutable($config->ffprobe_command));
Context::set('is_magick', function_exists('exec') && !empty($config->magick_command) && Rhymix\Framework\Storage::isExecutable($config->magick_command));
// Get a permission for group setting // Get a permission for group setting
$group_list = MemberModel::getGroups(); $group_list = MemberModel::getGroups();

View file

@ -55,19 +55,24 @@
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label">{$lang->image_autoconv}</label> <label class="x_control-label">{$lang->image_autoconv}</label>
<div class="x_controls"> <div class="x_controls">
<label for="image_autoconv_bmp2jpg"> {@ $source_types = ['bmp', 'jpg', 'png', 'webp', 'avif', 'heic']}
<input type="checkbox" name="image_autoconv_bmp2jpg" id="image_autoconv_bmp2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['bmp2jpg']" disabled="disabled"|cond="!function_exists('imagebmp')" /> <!--@foreach($source_types as $source_type)-->
{$lang->image_autoconv_bmp2jpg} <div class="image_autoconv_types">
</label> <label for="image_autoconv_{$source_type}" class="x_inline">
<label for="image_autoconv_png2jpg"> {strtoupper($source_type)}
<input type="checkbox" name="image_autoconv_png2jpg" id="image_autoconv_png2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['png2jpg']" disabled="disabled"|cond="!function_exists('imagepng')" /> </label>
{$lang->image_autoconv_png2jpg} <select name="image_autoconv[{$source_type}]" id="image_autoconv_{$source_type}" disabled="disabled"|cond="!$is_magick && in_array($source_type, ['avif', 'heic'])">
</label> <option value=""></option>
<label for="image_autoconv_webp2jpg"> <option value="jpg" selected="selected"|cond="($config->image_autoconv[$source_type] ?? '') === 'jpg' || !empty($config->image_autoconv[$source_type . '2jpg'])">JPG</option>
<input type="checkbox" name="image_autoconv_webp2jpg" id="image_autoconv_webp2jpg" value="Y" checked="checked"|cond="$config->image_autoconv['webp2jpg']" disabled="disabled"|cond="!function_exists('imagewebp')" /> <option value="png" selected="selected"|cond="($config->image_autoconv[$source_type] ?? '') === 'png'">PNG</option>
{$lang->image_autoconv_webp2jpg} <option value="webp" selected="selected"|cond="($config->image_autoconv[$source_type] ?? '') === 'webp'">WebP</option>
</label> </select>
<p class="x_help-block">{$lang->about_image_autoconv}</p> </div>
<!--@endforeach-->
<p class="x_help-block">
{$lang->about_image_autoconv}<br />
{$lang->msg_need_magick}
</p>
</div> </div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">
@ -85,12 +90,16 @@
</p> </p>
<p class="x_help-block"> <p class="x_help-block">
<label class="x_inline" for="max_image_size_same_format_Y"> <label class="x_inline" for="max_image_size_same_format_Y">
<input type="radio" name="max_image_size_same_format" id="max_image_size_same_format_Y" value="Y" checked="checked"|cond="$config->max_image_size_same_format === 'Y'" /> <input type="radio" name="max_image_size_same_format" id="max_image_size_same_format_Y" value="Y" checked="checked"|cond="!isset($config->max_image_size_same_format) || $config->max_image_size_same_format === 'Y'" />
{$lang->max_image_size_same_format_Y} {$lang->max_image_size_same_format_Y}
</label> </label>
<label class="x_inline" for="max_image_size_same_format_N"> <label class="x_inline" for="max_image_size_same_format_to_jpg">
<input type="radio" name="max_image_size_same_format" id="max_image_size_same_format_N" value="N" checked="checked"|cond="$config->max_image_size_same_format !== 'Y'" /> <input type="radio" name="max_image_size_same_format" id="max_image_size_same_format_to_jpg" value="jpg" checked="checked"|cond="$config->max_image_size_same_format === 'jpg' || $config->max_image_size_same_format === 'N'" />
{$lang->max_image_size_same_format_N} {$lang->max_image_size_same_format_to_jpg}
</label>
<label class="x_inline" for="max_image_size_same_format_to_webp">
<input type="radio" name="max_image_size_same_format" id="max_image_size_same_format_to_webp" value="webp" checked="checked"|cond="$config->max_image_size_same_format === 'webp'" />
{$lang->max_image_size_same_format_to_webp}
</label> </label>
<label for="max_image_size_admin"> <label for="max_image_size_admin">
<input type="checkbox" name="max_image_size_admin" id="max_image_size_admin" value="Y" checked="checked"|cond="$config->max_image_size_admin === 'Y'" /> <input type="checkbox" name="max_image_size_admin" id="max_image_size_admin" value="Y" checked="checked"|cond="$config->max_image_size_admin === 'Y'" />
@ -144,11 +153,11 @@
<label class="x_control-label">{$lang->image_autoconv_gif2mp4}</label> <label class="x_control-label">{$lang->image_autoconv_gif2mp4}</label>
<div class="x_controls"> <div class="x_controls">
<label for="image_autoconv_gif2mp4_Y" class="x_inline"> <label for="image_autoconv_gif2mp4_Y" class="x_inline">
<input type="radio" name="image_autoconv_gif2mp4" id="image_autoconv_gif2mp4_Y" value="Y" checked="checked"|cond="$config->image_autoconv['gif2mp4'] === true" disabled="disabled"|cond="!$is_ffmpeg" /> <input type="radio" name="image_autoconv[gif2mp4]" id="image_autoconv_gif2mp4_Y" value="Y" checked="checked"|cond="$config->image_autoconv['gif2mp4'] === true" disabled="disabled"|cond="!$is_ffmpeg" />
{$lang->cmd_yes} {$lang->cmd_yes}
</label> </label>
<label for="image_autoconv_gif2mp4_N" class="x_inline"> <label for="image_autoconv_gif2mp4_N" class="x_inline">
<input type="radio" name="image_autoconv_gif2mp4" id="image_autoconv_gif2mp4_N" value="N" checked="checked"|cond="$config->image_autoconv['gif2mp4'] !== true" disabled="disabled"|cond="!$is_ffmpeg" /> <input type="radio" name="image_autoconv[gif2mp4]" id="image_autoconv_gif2mp4_N" value="N" checked="checked"|cond="$config->image_autoconv['gif2mp4'] !== true" disabled="disabled"|cond="!$is_ffmpeg" />
{$lang->cmd_no} {$lang->cmd_no}
</label> </label>
<p class="x_help-block">{$lang->about_image_autoconv_gif2mp4}</p> <p class="x_help-block">{$lang->about_image_autoconv_gif2mp4}</p>