Add file uploads 8/...
This commit is contained in:
parent
765fbab1d1
commit
f454d3ad10
8 changed files with 44 additions and 10 deletions
|
@ -71,8 +71,8 @@ class Attachments extends Manager
|
|||
$file->rename(false)->rewrite(false);
|
||||
|
||||
if ($file instanceof Image) {
|
||||
$file->setQuality($this->c->config->i_upload_img_quality ?? 75);
|
||||
//->resize($this->c->config->i_avatars_width, $this->c->config->i_avatars_height)
|
||||
$file->setQuality($this->c->config->i_upload_img_quality ?? 75)
|
||||
->resize($this->c->config->i_upload_img_axis_limit, $this->c->config->i_upload_img_axis_limit);
|
||||
}
|
||||
|
||||
$status = $file->toFile($location);
|
||||
|
@ -124,7 +124,7 @@ class Attachments extends Manager
|
|||
return;
|
||||
}
|
||||
|
||||
\preg_match_all('%' . self::FOLDER . '((\d{4})/(\d+)/[\w-]+?_(\d{3})\.[\w-]+)\b%', $post->message, $matches, \PREG_SET_ORDER);
|
||||
\preg_match_all('%' . self::FOLDER . '((\d{4})/(\d+)/[\w-]+?_(\d{3})\.[\w-]+)\b%', $post->message, $matches, \PREG_SET_ORDER); // ???? проверять html?
|
||||
|
||||
$attInPost = [];
|
||||
|
||||
|
|
|
@ -1572,6 +1572,7 @@ class Install extends Admin
|
|||
's_РЕГИСТР' => 'Ok',
|
||||
'b_upload' => 1,
|
||||
'i_upload_img_quality' => 75,
|
||||
'i_upload_img_axis_limit' => 1920,
|
||||
];
|
||||
|
||||
foreach ($forkConfig as $name => $value) {
|
||||
|
|
|
@ -610,8 +610,9 @@ class Update extends Admin
|
|||
{
|
||||
$config = $this->c->config;
|
||||
|
||||
$config->b_upload = 1;
|
||||
$config->i_upload_img_quality = 75;
|
||||
$config->b_upload = 1;
|
||||
$config->i_upload_img_quality = 75;
|
||||
$config->i_upload_img_axis_limit = 1920;
|
||||
|
||||
$config->save();
|
||||
|
||||
|
|
|
@ -33,17 +33,19 @@ class Uploads extends Admin
|
|||
$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',
|
||||
'token' => 'token:AdminUploads',
|
||||
'b_upload' => 'required|integer|in:0,1',
|
||||
'i_upload_img_quality' => 'required|integer|min:0|max:100',
|
||||
'i_upload_img_axis_limit' => 'required|integer|min:100|max:20000',
|
||||
])->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->b_upload = $v->b_upload;
|
||||
$this->c->config->i_upload_img_quality = $v->i_upload_img_quality;
|
||||
$this->c->config->i_upload_img_axis_limit = $v->i_upload_img_axis_limit;
|
||||
$this->c->config->save();
|
||||
|
||||
return $this->c->Redirect->page('AdminUploads')->message('Data updated redirect', FORK_MESS_SUCC);
|
||||
|
@ -88,6 +90,14 @@ class Uploads extends Admin
|
|||
'caption' => 'Upload quality label',
|
||||
'help' => 'Upload quality help',
|
||||
],
|
||||
'i_upload_img_axis_limit' => [
|
||||
'type' => 'number',
|
||||
'min' => '100',
|
||||
'max' => '20000',
|
||||
'value' => $config->i_upload_img_axis_limit,
|
||||
'caption' => 'Upload axis limit label',
|
||||
'help' => 'Upload axis limit help',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
@ -163,6 +163,11 @@ class PMEdit extends AbstractPM
|
|||
|
||||
$this->pms->update(Cnst::PTOPIC, $topic);
|
||||
|
||||
// синхронизация вложений
|
||||
if ($this->userRules->useUpload) {
|
||||
$this->c->attachments->syncWithPost($post, true);
|
||||
}
|
||||
|
||||
// антифлуд
|
||||
if ($calcUser) {
|
||||
$this->user->u_pm_last_post = $now;
|
||||
|
|
|
@ -227,6 +227,11 @@ class PMPost extends AbstractPM
|
|||
|
||||
$this->pms->update(Cnst::PTOPIC, $topic->calcStat());
|
||||
|
||||
// синхронизация вложений
|
||||
if ($this->userRules->useUpload) {
|
||||
$this->c->attachments->syncWithPost($post);
|
||||
}
|
||||
|
||||
// новый диалог в архив
|
||||
if (
|
||||
$this->newTopic
|
||||
|
|
|
@ -26,3 +26,9 @@ msgstr "Quality"
|
|||
|
||||
msgid "Upload quality help"
|
||||
msgstr "Images quality between 0 and 100."
|
||||
|
||||
msgid "Upload axis limit label"
|
||||
msgstr "Axis limit"
|
||||
|
||||
msgid "Upload axis limit help"
|
||||
msgstr "The uploaded image will be resized if its width/height is greater than this limit."
|
||||
|
|
|
@ -26,3 +26,9 @@ msgstr "Качество"
|
|||
|
||||
msgid "Upload quality help"
|
||||
msgstr "Качество изображений от 0 до 100."
|
||||
|
||||
msgid "Upload axis limit label"
|
||||
msgstr "Ограничение по оси"
|
||||
|
||||
msgid "Upload axis limit help"
|
||||
msgstr "К загруженному изображению будет применен ресайз, если его ширина/высота больше этого ограничения."
|
||||
|
|
Loading…
Add table
Reference in a new issue