Add file uploads 2/...

This commit is contained in:
Visman 2023-07-05 23:46:19 +07:00
parent 02e8fc4021
commit d7ac9c32c5
4 changed files with 167 additions and 0 deletions

View file

@ -0,0 +1,102 @@
<?php
/**
* This file is part of the ForkBB <https://github.com/forkbb>.
*
* @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
* @license The MIT License (MIT)
*/
declare(strict_types=1);
namespace ForkBB\Models\Pages\Admin;
use ForkBB\Core\Validator;
use ForkBB\Models\Page;
use ForkBB\Models\Pages\Admin;
use ForkBB\Models\Config\Config;
use function \ForkBB\__;
use RuntimeException;
class Uploads extends Admin
{
/**
* Обслуживание
*/
public function view(array $args, string $method): Page
{
$this->c->Lang->load('validator');
$this->c->Lang->load('admin_uploads');
$config = clone $this->c->config;
if ('POST' === $method) {
$v = $this->c->Validator->reset()
->addValidators([
])->addRules([
'token' => 'token:AdminUploads',
'b_upload' => 'required|integer|in:0,1',
'i_upload_img_quality' => 'required|integer|min:0|max:100',
])->addAliases([
])->addArguments([
])->addMessages([
]);
if ($v->validation($_POST)) {
$this->c->config->b_upload = $v->b_upload;
$this->c->config->i_upload_img_quality = $v->i_upload_img_quality;
$this->c->config->save();
return $this->c->Redirect->page('AdminUploads')->message('Data updated redirect', FORK_MESS_SUCC);
}
$this->fIswev = $v->getErrors();
}
$this->nameTpl = 'admin/uploads';
$this->aIndex = 'uploads';
$this->formUploads = $this->formUploads($config);
return $this;
}
/**
* Подготавливает массив данных для формы
*/
protected function formUploads(Config $config): array
{
return [
'action' => $this->c->Router->link('AdminUploads'),
'hidden' => [
'token' => $this->c->Csrf->create('AdminUploads'),
],
'sets' => [
'maint' => [
'legend' => 'Uploads head',
'fields' => [
'b_upload' => [
'type' => 'radio',
'value' => $config->b_upload,
'values' => [1 => __('Yes'), 0 => __('No')],
'caption' => 'Uploads mode label',
'help' => ['Uploads mode help', __('User groups'), $this->c->Router->link('AdminGroups')],
],
'i_upload_img_quality' => [
'type' => 'number',
'min' => '0',
'max' => '100',
'value' => $config->i_upload_img_quality,
'caption' => 'Upload quality label',
'help' => 'Upload quality help',
],
],
],
],
'btns' => [
'submit' => [
'type' => 'submit',
'value' => __('Save changes'),
],
],
];
}
}

View file

@ -0,0 +1,28 @@
#
msgid ""
msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Project-Id-Version: ForkBB\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: ForkBB <mio.visman@yandex.ru>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
msgid "Uploads head"
msgstr "File uploads"
msgid "Uploads mode label"
msgstr "Enable"
msgid "Uploads mode help"
msgstr "Settings for individual groups are available in <a href="%2$s">%1$s</a>."
msgid "Upload quality label"
msgstr "Quality"
msgid "Upload quality help"
msgstr "Images quality between 0 and 100."

View file

@ -0,0 +1,28 @@
#
msgid ""
msgstr ""
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"Project-Id-Version: ForkBB\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: ForkBB <mio.visman@yandex.ru>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ru\n"
msgid "Uploads head"
msgstr "Загрузка файлов"
msgid "Uploads mode label"
msgstr "Включить"
msgid "Uploads mode help"
msgstr "Настройки для отдельных групп доступны в <a href="%2$s">%1$s</a>."
msgid "Upload quality label"
msgstr "Качество"
msgid "Upload quality help"
msgstr "Качество изображений от 0 до 100."

View file

@ -0,0 +1,9 @@
@extends ('layouts/admin')
<section id="fork-uploads" class="f-admin">
<h2>{!! __('Uploads head') !!}</h2>
<div class="f-fdiv">
@if ($form = $p->formUploads)
@include ('layouts/form')
@endif
</div>
</section>