2017-12-31

This commit is contained in:
Visman 2017-12-31 22:58:37 +07:00
parent c5d8403883
commit 9787288da8
13 changed files with 566 additions and 27 deletions

View file

@ -109,7 +109,9 @@ class Routing
$r->add(['GET', 'POST'], '/admin/categories', 'AdminCategories:view', 'AdminCategories' );
$r->add(['GET', 'POST'], '/admin/categories/{id:[1-9]\d*}/delete', 'AdminCategories:delete', 'AdminCategoriesDelete');
$r->add('GET', '/admin/forums', 'AdminForums:view', 'AdminForums' );
$r->add(['GET', 'POST'], '/admin/forums', 'AdminForums:view', 'AdminForums' );
$r->add(['GET', 'POST'], '/admin/forums/{id:[1-9]\d*}/edit', 'AdminForums:edit', 'AdminForumsEdit' );
$r->add(['GET', 'POST'], '/admin/forums/{id:[1-9]\d*}/delete', 'AdminForums:delete', 'AdminForumsDelete' );
$r->add('GET', '/admin/groups', 'AdminGroups:view', 'AdminGroups' );
$r->add('POST', '/admin/groups/default', 'AdminGroups:defaultSet', 'AdminGroupsDefault');
$r->add('POST', '/admin/groups/new[/{base:[1-9]\d*}]', 'AdminGroups:edit', 'AdminGroupsNew' );

View file

@ -109,7 +109,7 @@ class Categories extends Admin
$this->aIndex = 'categories';
$this->titles = \ForkBB\__('Categories');
$this->form = $form;
$this->classForm = 'editcategories';
$this->classForm = ['editcategories', 'inline'];
$this->titleForm = \ForkBB\__('Categories');
return $this;
@ -183,7 +183,7 @@ class Categories extends Admin
'confirm' => [
'title' => \ForkBB\__('Confirm delete'),
'type' => 'checkbox',
'label' => \ForkBB\__('I want to delete this category', $category['cat_name']),
'label' => \ForkBB\__('I want to delete the category %s', $category['cat_name']),
'value' => '1',
'checked' => false,
],
@ -203,7 +203,7 @@ class Categories extends Admin
$this->aIndex = 'categories';
$this->titles = \ForkBB\__('Delete category head');
$this->form = $form;
$this->classForm = 'deletecategory';
$this->classForm = ['deletecategory', 'btnsrow'];
$this->titleForm = \ForkBB\__('Delete category head');
return $this;

View file

@ -0,0 +1,243 @@
<?php
namespace ForkBB\Models\Pages\Admin;
use ForkBB\Core\Container;
use ForkBB\Models\Forum\Model as Forum;
use ForkBB\Models\Pages\Admin;
class Forums extends Admin
{
/**
* Просмотр, редактирвоание и добавление разделов
*
* @param array $args
* @param string $method
*
* @return Page
*/
public function view(array $args, $method)
{
$this->c->Lang->load('admin_forums');
if ('POST' === $method) {
$v = $this->c->Validator->setRules([
'token' => 'token:AdminForums',
'form.*.disp_position' => 'required|integer|min:0|max:9999999999',
])->setArguments([
])->setMessages([
]);
if ($v->validation($_POST)) {
$this->c->DB->beginTransaction();
foreach ($v->form as $key => $row) {
$forum = $this->c->forums->get((int) $key);
$forum->disp_position = $row['disp_position'];
$this->c->forums->update($forum);
}
$this->c->DB->commit();
$this->c->Cache->delete('forums_mark'); //????
return $this->c->Redirect->page('AdminForums')->message('Forums updated redirect');
}
$this->fIswev = $v->getErrors();
}
$form = [
'action' => $this->c->Router->link('AdminForums'),
'hidden' => [
'token' => $this->c->Csrf->create('AdminForums'),
],
'sets' => [],
'btns' => [
'submit' => [
'type' => 'submit',
'value' => \ForkBB\__('Update positions'),
'accesskey' => 'u',
],
],
];
$root = $this->c->forums->get(0);
$list = $this->createList([], $root, -1);
$fieldset = [];
$cid = null;
foreach ($list as $forum) {
if ($cid !== $forum->cat_id) {
if (null !== $cid) {
$form['sets'][] = [
'fields' => $fieldset,
];
}
$form['sets'][] = [
'info' => [
'info1' => [
'type' => '', //????
'value' => $forum->cat_name,
],
],
];
$fieldset = [];
}
$cid = $forum->cat_id;
$fieldset[] = [
'dl' => ['name', 'depth' . $forum->depth],
'type' => 'btn',
'value' => $forum->forum_name,
'title' => \ForkBB\__('Forum label'),
'link' => $this->c->Router->link('AdminForumsEdit', ['id' => $forum->id]),
];
$fieldset["form[{$forum->id}][disp_position]"] = [
'dl' => 'position',
'type' => 'number',
'min' => 0,
'max' => 9999999999,
'value' => $forum->disp_position,
'title' => \ForkBB\__('Position label'),
];
$fieldset[] = [
'dl' => 'delete',
'type' => 'btn',
'value' => '❌',
'title' => \ForkBB\__('Delete'),
'link' => $this->c->Router->link('AdminForumsDelete', ['id' => $forum->id]),
];
}
$form['sets'][] = [
'fields' => $fieldset,
];
$this->nameTpl = 'admin/form';
$this->aIndex = 'forums';
$this->titles = \ForkBB\__('Forums');
$this->form = $form;
$this->classForm = ['editforums', 'inline'];
$this->titleForm = \ForkBB\__('Forums');
return $this;
}
/**
* Получение списка разделов и подразделов
*
* @param array $list
* @param Forum $forum
* @param int $depth
*
* @return array
*/
protected function createList(array $list, Forum $forum, $depth)
{
++$depth;
foreach ($forum->subforums as $sub) {
$sub->__depth = $depth;
$list[] = $sub;
$list = $this->createList($list, $sub, $depth);
}
return $list;
}
/**
* Удаление категорий
*
* @param array $args
* @param string $method
*
* @return Page
*/
public function delete(array $args, $method)
{
$forum = $this->c->forums->get((int) $args['id']);
if (! $forum instanceof Forum) {
return $this->c->Message->message('Bad request');
}
$this->c->Lang->load('admin_forums');
if ('POST' === $method) {
$v = $this->c->Validator->setRules([
'token' => 'token:AdminForumsDelete',
'confirm' => 'integer',
'delete' => 'string',
'cancel' => 'string',
])->setArguments([
'token' => $args,
]);
if (! $v->validation($_POST) || null === $v->delete) {
return $this->c->Redirect->page('AdminForums')->message('Cancel redirect');
} elseif ($v->confirm !== 1) {
return $this->c->Redirect->page('AdminForums')->message('No confirm redirect');
}
$this->c->DB->beginTransaction();
$this->c->forums->delete($forum);
$this->c->DB->commit();
$this->c->Cache->delete('forums_mark'); //????
return $this->c->Redirect->page('AdminForums')->message('Forum deleted redirect');
}
$form = [
'action' => $this->c->Router->link('AdminForumsDelete', $args),
'hidden' => [
'token' => $this->c->Csrf->create('AdminForumsDelete', $args),
],
'sets' => [],
'btns' => [
'delete' => [
'type' => 'submit',
'value' => \ForkBB\__('Delete forum'),
'accesskey' => 'd',
],
'cancel' => [
'type' => 'submit',
'value' => \ForkBB\__('Cancel'),
],
],
];
$form['sets'][] = [
'fields' => [
'confirm' => [
'title' => \ForkBB\__('Confirm delete'),
'type' => 'checkbox',
'label' => \ForkBB\__('I want to delete forum %s', $forum->forum_name),
'value' => '1',
'checked' => false,
],
],
];
$form['sets'][] = [
'info' => [
'info1' => [
'type' => '', //????
'value' => \ForkBB\__('Delete forum warn'),
'html' => true,
],
],
];
$this->nameTpl = 'admin/form';
$this->aIndex = 'forums';
$this->titles = \ForkBB\__('Delete forum head');
$this->form = $form;
$this->classForm = ['deleteforum', 'btnsrow'];
$this->titleForm = \ForkBB\__('Delete forum head');
return $this;
}
}

View file

@ -691,7 +691,7 @@ class Groups extends Admin
$this->titles = \ForkBB\__('Group delete');
$this->form = $form;
$this->titleForm = \ForkBB\__('Group delete');
$this->classForm = 'deletegroup';
$this->classForm = ['deletegroup', 'btnsrow'];
return $this;
}

View file

@ -27,7 +27,7 @@ msgstr "Delete category (together with all forums and posts it contains)"
msgid "Confirm delete"
msgstr "Delete category?"
msgid "I want to delete this category"
msgid "I want to delete the category %s"
msgstr "Yes, I want to delete the category <b>%s</b>"
msgid "Delete category warn"

View file

@ -0,0 +1,139 @@
#
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 "Forum added redirect"
msgstr "Forum added. Redirecting …"
msgid "Forum deleted redirect"
msgstr "Forum deleted. Redirecting …"
msgid "Forums updated redirect"
msgstr "Forums updated. Redirecting …"
msgid "Forum updated redirect"
msgstr "Forum updated. Redirecting …"
msgid "Perms reverted redirect"
msgstr "Permissions reverted to defaults. Redirecting …"
msgid "Must enter name message"
msgstr "You must enter a forum name."
msgid "Must be integer message"
msgstr "Position must be a positive integer value."
msgid "New forum"
msgstr "New forum"
msgid "Add forum head"
msgstr "Add forum"
msgid "Create new subhead"
msgstr "Create a new forum"
msgid "Add forum label"
msgstr "Add forum to category"
msgid "Add forum help"
msgstr "Select the category to which you wish to add a new forum."
msgid "Add forum"
msgstr "Add forum"
msgid "No categories exist"
msgstr "No categories exist"
msgid "Edit forums head"
msgstr "Edit forums"
msgid "Category subhead"
msgstr "Category:"
msgid "Forum label"
msgstr "Forum"
msgid "Edit link"
msgstr "Edit"
msgid "Delete forum"
msgstr "Delete forum"
msgid "Position label"
msgstr "Position"
msgid "Update positions"
msgstr "Update positions"
msgid "Delete forum head"
msgstr "Delete forum"
msgid "Confirm delete"
msgstr "Delete forum?"
msgid "I want to delete forum %s"
msgstr "Yes, I want to delete the forum <b>%s</b>"
msgid "Delete forum warn"
msgstr "<b>WARNING!</b> Deleting a forum will delete all topics and posts (if any) in that forum!"
msgid "Edit forum head"
msgstr "Edit forum"
msgid "Edit details subhead"
msgstr "Edit forum details"
msgid "Forum name label"
msgstr "Forum name"
msgid "Forum description label"
msgstr "Description (HTML)"
msgid "Category label"
msgstr "Category"
msgid "Sort by label"
msgstr "Sort topics by"
msgid "Last post"
msgstr "Last post"
msgid "Topic start"
msgstr "Topic start"
msgid "Subject"
msgstr "Subject"
msgid "Redirect label"
msgstr "Redirect URL"
msgid "Redirect help"
msgstr "Only available in empty forums"
msgid "Group permissions subhead"
msgstr "Edit group permissions for this forum"
msgid "Group permissions info"
msgstr "In this form, you can set the forum specific permissions for the different user groups. If you haven\'t made any changes to this forum\'s group permissions, what you see below is the default based on settings in %s. Administrators always have full permissions and are thus excluded. Permission settings that differ from the default permissions for the user group are marked red. The "Read forum" permission checkbox will be disabled if the group in question lacks the "Read board" permission. For redirect forums, only the "Read forum" permission is editable."
msgid "Read forum label"
msgstr "Read forum"
msgid "Post replies label"
msgstr "Post replies"
msgid "Post topics label"
msgstr "Post topics"
msgid "Revert to default"
msgstr "Revert to default"

View file

@ -27,11 +27,11 @@ msgstr "Удаление категории (вместе со всеми раз
msgid "Confirm delete"
msgstr "Удалить категорию?"
msgid "I want to delete this category"
msgid "I want to delete the category %s"
msgstr "Да, я хочу удалить категорию <b>%s</b>"
msgid "Delete category warn"
msgstr "<b>ВНИМАНИЕ!</b> Удаляя категорию вы удалите все разделы, темы и сообщения относящиеся к ней (если таковые имеются)!"
msgstr "<b>ВНИМАНИЕ!</b> При удалении категории будут удалены все разделы, темы и сообщения находящиеся в ней!"
msgid "Must enter integer message"
msgstr "Позиция должна быть неотрицательным целым числом."

View file

@ -0,0 +1,139 @@
#
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 "Forum added redirect"
msgstr "Раздел добавлен. Переадресация …"
msgid "Forum deleted redirect"
msgstr "Раздел удален. Переадресация …"
msgid "Forums updated redirect"
msgstr "Разделы изменены. Переадресация …"
msgid "Forum updated redirect"
msgstr "Раздел изменен. Переадресация …"
msgid "Perms reverted redirect"
msgstr "Права сброшены в значения по умолчанию. Переадресация …"
msgid "Must enter name message"
msgstr "Необходимо ввести имя раздела."
msgid "Must be integer message"
msgstr "Позиция должна быть неотрицательным целым числом."
msgid "New forum"
msgstr "Новый раздел"
msgid "Add forum head"
msgstr "Добавление раздела"
msgid "Create new subhead"
msgstr "Создание нового раздела"
msgid "Add forum label"
msgstr "Добавить в категорию"
msgid "Add forum help"
msgstr "Выберите категорию, в которую будет добавлена новый раздел."
msgid "Add forum"
msgstr "Добавить"
msgid "No categories exist"
msgstr "Нет ни одной категории"
msgid "Edit forums head"
msgstr "Правка разделов"
msgid "Category subhead"
msgstr "Категория:"
msgid "Forum label"
msgstr "Раздел"
msgid "Edit link"
msgstr "Править"
msgid "Delete forum"
msgstr "Удалить раздел"
msgid "Position label"
msgstr "Позиция"
msgid "Update positions"
msgstr "Изменить позиции"
msgid "Delete forum head"
msgstr "Удаление раздела"
msgid "Confirm delete"
msgstr "Удалить раздел?"
msgid "I want to delete forum %s"
msgstr "Да, я хочу удалить раздел <b>%s</b>"
msgid "Delete forum warn"
msgstr "<b>ВНИМАНИЕ!</b> При удалении раздела будут удалены все темы и сообщения находящиеся в нем!"
msgid "Edit forum head"
msgstr "Правка раздела"
msgid "Edit details subhead"
msgstr "Параметры раздела"
msgid "Forum name label"
msgstr "Название раздела"
msgid "Forum description label"
msgstr "Описание (HTML)"
msgid "Category label"
msgstr "Категория"
msgid "Sort by label"
msgstr "Сортировать темы по"
msgid "Last post"
msgstr "Последнему сообщению"
msgid "Topic start"
msgstr "Дате старта темы"
msgid "Subject"
msgstr "Заголовку"
msgid "Redirect label"
msgstr "URL переадресации"
msgid "Redirect help"
msgstr "Доступно только для пустых разделов"
msgid "Group permissions subhead"
msgstr "Изменения прав доступа к разделу"
msgid "Group permissions info"
msgstr "Вы можете установить для этого раздела особые привилегии для различных групп пользователей. Если вы не вносили никаких изменений, то то, что вы видите внизу — права по умолчанию, установленные в "%s". Админы всегда имеют полные права, которые нельзя отнять. Права, отличающиеся от прав по умолчанию выделены красным. Галочка "Читать" будет недоступна, если у данной группы нет права "Чтение разделов". Для переадресованных разделов доступно для редактирования только право "Читать"."
msgid "Read forum label"
msgstr "Читать раздел"
msgid "Post replies label"
msgstr "Комментировать"
msgid "Post topics label"
msgstr "Создавать темы"
msgid "Revert to default"
msgstr "Вернуть по умолчанию"

View file

@ -1,5 +1,5 @@
@extends ('layouts/admin')
<section class="f-admin @if ($p->classForm) f-{!! $p->classForm !!}-form @endif">
<section class="f-admin @if ($p->classForm) f-{!! implode('-form f-', (array) $p->classForm) !!}-form @endif">
<h2>{!! $p->titleForm !!}</h2>
<div class="f-fdiv">
@if ($form = $p->form)

View file

@ -19,7 +19,7 @@
<legend>{!! $set['legend'] !!}</legend>
@endif
@foreach ($set['fields'] as $key => $cur)
<dl @if (isset($cur['dl'])) class="f-field-{{ $cur['dl'] }}" @endif>
<dl @if (isset($cur['dl'])) class="f-field-{!! implode(' f-field-', (array) $cur['dl']) !!}" @endif>
<dt> @if (isset($cur['title']))<label class="f-child1 @if (isset($cur['required'])) f-req @endif" @if (is_string($key)) for="id-{{ $key }}" @endif>{!! $cur['title'] !!}</label> @endif</dt>
<dd>
@if ('text' === $cur['type'])

View file

@ -26,7 +26,7 @@
</section>
@endif
@if ($form = $p->form)
<section class="f-post-form">
<section class="f-post-form f-btnsrow-form">
<h2>{!! $p->formTitle !!}</h2>
<div class="f-fdiv">
@include ('layouts/form')

View file

@ -138,7 +138,7 @@
@include ('layouts/stats')
@endif
@if ($form = $p->form)
<section class="f-post-form">
<section class="f-post-form f-btnsrow-form">
<h2>{!! __('Quick post') !!}</h2>
<div class="f-fdiv">
@include ('layouts/form')

View file

@ -528,6 +528,10 @@ select {
/* margin-top: 0.625rem; */
}
.f-fdiv .f-finfo + fieldset {
padding-top: 0;
}
.f-ctrl {
border: 0.0625rem solid #AA7939;
}
@ -1533,15 +1537,13 @@ li + li .f-btn {
border: 0;
}
.f-post-form .f-btn,
.f-deletegroup-form .f-btn,
.f-deletecategory-form .f-btn {
.f-btnsrow-form .f-btns .f-btn {
width: auto;
display: inline;
}
.f-deletegroup-form .f-btns {
text-align: center;
/* text-align: center; */
}
#id-message {
@ -1564,49 +1566,63 @@ li + li .f-btn {
/*********************/
/* Админка/Категории */
/* Админка/Разделы */
/*********************/
.f-editcategories-form dt {
.f-inline-form dt {
display: none;
}
.f-editcategories-form dd {
.f-inline-form dd {
padding-left: 0;
}
.f-editcategories-form .f-field-name {
.f-inline-form .f-field-name {
float: left;
width: calc(100% - 8rem);
}
.f-editcategories-form .f-field-position {
.f-inline-form .f-field-position {
padding-left: 0.625rem;
float: left;
width: 5rem;
}
.f-editcategories-form .f-field-delete {
.f-inline-form .f-field-delete {
padding-left: 0.625rem;
float: left;
width: 3rem;
overflow: hidden;
}
.f-editcategories-form .f-field-delete .f-btn {
.f-inline-form .f-field-delete .f-btn {
margin: 0;
text-align: center;
}
.f-editcategories-form dl:first-child dt,
.f-editcategories-form dl:nth-child(2) dt,
.f-editcategories-form dl:nth-child(3) dt,
.f-editcategories-form dl:last-child dt {
.f-inline-form .f-field-name .f-btn {
margin: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.f-inline-form fieldset dl:nth-child(-n+3) dt,
.f-inline-form .f-field-new dt {
display: block;
width: 100%;
overflow: hidden;
float: none;
}
.f-editcategories-form .f-child1 {
.f-inline-form .f-child1 {
font-weight: normal;
}
.f-field-depth1 dd {
padding-left: 0.625rem;
}
.f-field-depth2 dd {
padding-left: 1.25rem;
}