draft images feature #14

This commit is contained in:
ghost 2023-09-24 18:56:21 +03:00
parent 947e359976
commit 6b112d441c
4 changed files with 64 additions and 2 deletions

View File

@ -106,12 +106,23 @@ class AppControllerSubmit
),
]
],
'image' => (object)
[
'error' => [],
'attribute' => (object)
[
'required' => $this->_validator->getPageImageRequired(),
'accept' => implode(',', $this->_validator->getPageImageMimeTypes()),
'placeholder' => sprintf(
_('Image file (use Ctrl to select multiple files)')
),
],
],
'torrent' => (object)
[
'error' => [],
'attribute' => (object)
[
'value' => null,
'required' => $this->_validator->getPageTorrentRequired(),
'accept' => implode(',', $this->_validator->getPageTorrentMimeTypes()),
'placeholder' => sprintf(

View File

@ -298,6 +298,17 @@ class AppModelValidator
return true;
}
/// Page image
public function getPageImageRequired() : bool
{
return $this->_config->page->image->required;
}
public function getPageImageMimeTypes() : array
{
return $this->_config->page->image->mime;
}
/// Page torrent
public function getPageTorrentRequired() : bool
{

View File

@ -89,9 +89,34 @@
minlength="<?php echo $form->keywords->attribute->minlength ?>"
maxlength="<?php echo $form->keywords->attribute->maxlength ?>"><?php echo $form->keywords->attribute->value ?></textarea>
</div>
<div class="margin-y-8 padding-t-4">
<label for="image">
<?php echo _('Images') ?>
</label>
<sub class="opacity-0 parent-hover-opacity-09"
title="<?php echo $form->image->attribute->placeholder ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</svg>
</sub>
<?php foreach ($form->image->error as $errors) { ?>
<?php foreach ($errors as $error) { ?>
<div class="text-color-red margin-y-8">
<?php echo $error ?>
</div>
<?php } ?>
<?php } ?>
<input class="width-100 margin-t-8"
type="file"
multiple="multiple"
name="image"
id="image"
accept="<?php echo $form->image->attribute->accept ?>"
<?php echo $form->image->attribute->required ? 'required="required"' : false ?> />
</div>
<div class="margin-y-8 padding-t-4">
<label for="torrent">
<?php echo _('Torrent file') ?>
<?php echo _('Torrents') ?>
</label>
<sub class="opacity-0 parent-hover-opacity-09"
title="<?php echo $form->torrent->attribute->placeholder ?>">

View File

@ -39,6 +39,21 @@
"max": 20
}
},
"image":
{
"required": false,
"mime": [
"image/png",
"image/gif",
"image/jpeg",
"image/webp"
],
"quantity":
{
"min": 0,
"max": 20
}
},
"torrent":
{
"required": true,