* Form refactoring 3 and more

This commit is contained in:
Visman 2018-10-25 18:19:40 +07:00
parent bb258b01b0
commit addb157fd6
17 changed files with 475 additions and 306 deletions

View file

@ -79,7 +79,7 @@ class Routing
// юзеры
if ($user->viewUsers) {
// список пользователей
$r->add('GET', '/userlist[/{sort:username|registered|num_posts}/{dir:ASC|DESC}/{group:\-1|[1-9]\d*}/{name}][/{page:[1-9]\d*}]', 'Userlist:view', 'Userlist');
$r->add('GET', '/userlist[/{group:all|[1-9]\d*}/{sort:username|registered|num_posts}/{dir:ASC|DESC}/{name}][/{page:[1-9]\d*}]', 'Userlist:view', 'Userlist');
$r->add('POST', '/userlist', 'Userlist:view');
// юзеры
$r->add('GET', '/user/{id:[2-9]|[1-9]\d+}/{name}', 'ProfileView:view', 'User');

View file

@ -50,6 +50,22 @@ class Categories extends Admin
$this->fIswev = $v->getErrors();
}
$this->nameTpl = 'admin/form';
$this->aIndex = 'categories';
$this->form = $this->formEdit();
$this->classForm = 'editcategories';
$this->titleForm = \ForkBB\__('Categories');
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @return array
*/
protected function formEdit()
{
$form = [
'action' => $this->c->Router->link('AdminCategories'),
'hidden' => [
@ -96,6 +112,7 @@ class Categories extends Admin
'fields' => $fields,
];
}
$form['sets']['new-cat'] = [
'fields' => [
'new' => [
@ -108,15 +125,10 @@ class Categories extends Admin
],
];
$this->nameTpl = 'admin/form';
$this->aIndex = 'categories';
$this->form = $form;
$this->classForm = 'editcategories';
$this->titleForm = \ForkBB\__('Categories');
return $this;
return $form;
}
/**
* Удаление категорий
*
@ -156,17 +168,59 @@ class Categories extends Admin
return $this->c->Redirect->page('AdminCategories')->message('Category deleted redirect');
}
$form = [
$this->nameTpl = 'admin/form';
$this->aIndex = 'categories';
$this->aCrumbs[] = [$this->c->Router->link('AdminCategoriesDelete', ['id' => $args['id']]), \ForkBB\__('Delete category head')];
$this->aCrumbs[] = \ForkBB\__('"%s"', $category['cat_name']);
$this->form = $this->formDelete($args, $category);
$this->classForm = 'deletecategory';
$this->titleForm = \ForkBB\__('Delete category head');
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @param array $args
* @param array $category
*
* @return array
*/
protected function formDelete(array $args, array $category)
{
return [
'action' => $this->c->Router->link('AdminCategoriesDelete', $args),
'hidden' => [
'token' => $this->c->Csrf->create('AdminCategoriesDelete', $args),
],
'sets' => [],
'sets' => [
'del' => [
'fields' => [
'confirm' => [
'caption' => \ForkBB\__('Confirm delete'),
'type' => 'checkbox',
'label' => \ForkBB\__('I want to delete the category %s', $category['cat_name']),
'value' => '1',
'checked' => false,
],
],
],
'del-info' => [
'info' => [
'info1' => [
'type' => '', //????
'value' => \ForkBB\__('Delete category warn'),
'html' => true,
],
],
],
],
'btns' => [
'delete' => [
'type' => 'submit',
'value' => \ForkBB\__('Delete category'),
'accesskey' => 'd',
'accesskey' => 's',
],
'cancel' => [
'type' => 'btn',
@ -175,36 +229,5 @@ class Categories extends Admin
],
],
];
$form['sets']['del'] = [
'fields' => [
'confirm' => [
'caption' => \ForkBB\__('Confirm delete'),
'type' => 'checkbox',
'label' => \ForkBB\__('I want to delete the category %s', $category['cat_name']),
'value' => '1',
'checked' => false,
],
],
];
$form['sets']['del-info'] = [
'info' => [
'info1' => [
'type' => '', //????
'value' => \ForkBB\__('Delete category warn'),
'html' => true,
],
],
];
$this->nameTpl = 'admin/form';
$this->aIndex = 'categories';
$this->aCrumbs[] = [$this->c->Router->link('AdminCategoriesDelete', ['id' => $args['id']]), \ForkBB\__('Delete category head')];
$this->aCrumbs[] = \ForkBB\__('"%s"', $category['cat_name']);
$this->form = $form;
$this->classForm = 'deletecategory';
$this->titleForm = \ForkBB\__('Delete category head');
return $this;
}
}

View file

@ -44,6 +44,22 @@ class Censoring extends Admin
$this->fIswev = $v->getErrors();
}
$this->nameTpl = 'admin/form';
$this->aIndex = 'censoring';
$this->form = $this->formEdit();
$this->classForm = 'editcensorship';
$this->titleForm = \ForkBB\__('Censoring');
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @return array
*/
protected function formEdit()
{
$form = [
'action' => $this->c->Router->link('AdminCensoring'),
'hidden' => [
@ -117,12 +133,6 @@ class Censoring extends Admin
'fields' => $fieldset,
];
$this->nameTpl = 'admin/form';
$this->aIndex = 'censoring';
$this->form = $form;
$this->classForm = 'editcensorship';
$this->titleForm = \ForkBB\__('Censoring');
return $this;
return $form;
}
}

View file

@ -114,6 +114,22 @@ class Forums extends Admin
$this->fIswev = $v->getErrors();
}
$this->nameTpl = 'admin/form';
$this->aIndex = 'forums';
$this->form = $this->formView();
$this->classForm = ['editforums', 'inline'];
$this->titleForm = \ForkBB\__('Forums');
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @return array
*/
protected function formView()
{
$form = [
'action' => $this->c->Router->link('AdminForums'),
'hidden' => [
@ -130,7 +146,7 @@ class Forums extends Admin
'update' => [
'type' => 'submit',
'value' => \ForkBB\__('Update positions'),
'accesskey' => 'u',
'accesskey' => 's',
],
],
];
@ -187,13 +203,7 @@ class Forums extends Admin
}
}
$this->nameTpl = 'admin/form';
$this->aIndex = 'forums';
$this->form = $form;
$this->classForm = ['editforums', 'inline'];
$this->titleForm = \ForkBB\__('Forums');
return $this;
return $form;
}
/**
@ -235,12 +245,55 @@ class Forums extends Admin
return $this->c->Redirect->page('AdminForums')->message('Forum deleted redirect');
}
$form = [
$this->nameTpl = 'admin/form';
$this->aIndex = 'forums';
$this->aCrumbs[] = [$this->c->Router->link('AdminForumsDelete', ['id' => $forum->id]), \ForkBB\__('Delete forum head')];
$this->aCrumbs[] = \ForkBB\__('"%s"', $forum->forum_name);
$this->form = $this->formDelete($args, $forum);
$this->classForm = 'deleteforum';
$this->titleForm = \ForkBB\__('Delete forum head');
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @param array $args
* @param Forum $forum
*
* @return array
*/
protected function formDelete(array $args, Forum $forum)
{
return [
'action' => $this->c->Router->link('AdminForumsDelete', $args),
'hidden' => [
'token' => $this->c->Csrf->create('AdminForumsDelete', $args),
],
'sets' => [],
'sets' => [
'confirm' => [
'fields' => [
'confirm' => [
'caption' => \ForkBB\__('Confirm delete'),
'type' => 'checkbox',
'label' => \ForkBB\__('I want to delete forum %s', $forum->forum_name),
'value' => '1',
'checked' => false,
],
],
],
[
'info' => [
'info1' => [
'type' => '', //????
'value' => \ForkBB\__('Delete forum warn'),
'html' => true,
],
],
],
],
'btns' => [
'delete' => [
'type' => 'submit',
@ -254,37 +307,6 @@ class Forums extends Admin
],
],
];
$form['sets'][] = [
'fields' => [
'confirm' => [
'caption' => \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->aCrumbs[] = [$this->c->Router->link('AdminForumsDelete', ['id' => $forum->id]), \ForkBB\__('Delete forum head')];
$this->aCrumbs[] = \ForkBB\__('"%s"', $forum->forum_name);
$this->form = $form;
$this->classForm = 'deleteforum';
$this->titleForm = \ForkBB\__('Delete forum head');
return $this;
}
/**
@ -381,21 +403,21 @@ class Forums extends Admin
$this->nameTpl = 'admin/form';
$this->aIndex = 'forums';
$this->form = $this->viewForm($forum, $marker, $args);
$this->form = $this->formEdit($args, $forum, $marker);
return $this;
}
/**
* Формирует данные для формы редактирования раздела
* Подготавливает массив данных для формы
*
* @param array $args
* @param Forum $forum
* @param string $marker
* @param array $args
*
* @return array
*/
protected function viewForm(Forum $forum, $marker, array $args)
protected function formEdit(array $args, Forum $forum, $marker)
{
$form = [
'action' => $this->c->Router->link($marker, $args),

View file

@ -50,7 +50,20 @@ class Groups extends Admin
public function view()
{
$this->nameTpl = 'admin/groups';
$this->formNew = [
$this->formNew = $this->formNew();
$this->formDefault = $this->formDefault();
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @return array
*/
protected function formNew()
{
return [
'action' => $this->c->Router->link('AdminGroupsNew'),
'hidden' => [
'token' => $this->c->Csrf->create('AdminGroupsNew'),
@ -74,11 +87,20 @@ class Groups extends Admin
'submit' => [
'type' => 'submit',
'value' => \ForkBB\__('Add'),
'accesskey' => 'a',
'accesskey' => 'n',
],
],
];
$this->formDefault = [
}
/**
* Подготавливает массив данных для формы
*
* @return array
*/
protected function formDefault()
{
return [
'action' => $this->c->Router->link('AdminGroupsDefault'),
'hidden' => [
'token' => $this->c->Csrf->create('AdminGroupsDefault'),
@ -105,8 +127,6 @@ class Groups extends Admin
],
],
];
return $this;
}
/**
@ -261,7 +281,7 @@ class Groups extends Admin
}
$this->nameTpl = 'admin/form';
$this->form = $this->viewForm($group, $marker, $vars);
$this->form = $this->formEdit($vars, $group, $marker);
return $this;
}
@ -315,13 +335,13 @@ class Groups extends Admin
/**
* Формирует данные для формы редактирования группы
*
* @param array $args
* @param Group $group
* @param string $marker
* @param array $args
*
* @return array
*/
protected function viewForm(Group $group, $marker, array $args)
protected function formEdit(array $args, Group $group, $marker)
{
$form = [
'action' => $this->c->Router->link($marker, $args),
@ -657,6 +677,29 @@ class Groups extends Admin
return $this->c->Redirect->page('AdminGroups')->message('Group removed redirect');
}
$this->nameTpl = 'admin/form';
$this->aCrumbs[] = [$this->c->Router->link('AdminGroupsDelete', $args), \ForkBB\__('Group delete')];
$this->aCrumbs[] = \ForkBB\__('"%s"', $group->g_title);
$this->form = $this->formDelete($args, $group, $count, $groups);
$this->titleForm = \ForkBB\__('Group delete');
$this->classForm = 'deletegroup';
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @param array $args
* @param Group $group
* @param int $count
* @param array $groups
*
* @return array
*/
protected function formDelete(array $args, Group $group, $count, array $groups)
{
$form = [
'action' => $this->c->Router->link('AdminGroupsDelete', $args),
'hidden' => [
@ -667,7 +710,7 @@ class Groups extends Admin
'delete' => [
'type' => 'submit',
'value' => \ForkBB\__('Delete group'),
'accesskey' => 'd',
'accesskey' => 's',
],
'cancel' => [
'type' => 'btn',
@ -712,13 +755,6 @@ class Groups extends Admin
],
];
$this->nameTpl = 'admin/form';
$this->aCrumbs[] = [$this->c->Router->link('AdminGroupsDelete', $args), \ForkBB\__('Group delete')];
$this->aCrumbs[] = \ForkBB\__('"%s"', $group->g_title);
$this->form = $form;
$this->titleForm = \ForkBB\__('Group delete');
$this->classForm = 'deletegroup';
return $this;
return $form;
}
}

View file

@ -46,7 +46,24 @@ class Maintenance extends Admin
$this->fIswev = $v->getErrors();
}
$this->formMaintenance = [
$this->nameTpl = 'admin/maintenance';
$this->aIndex = 'maintenance';
$this->formMaintenance = $this->formMaintenance($config);
$this->formRebuild = $this->formRebuild();
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @param Config $config
*
* @return array
*/
protected function formMaintenance(Config $config)
{
return [
'action' => $this->c->Router->link('AdminMaintenance'),
'hidden' => [
'token' => $this->c->Csrf->create('AdminMaintenance'),
@ -79,8 +96,16 @@ class Maintenance extends Admin
],
],
];
}
$this->formRebuild = [
/**
* Подготавливает массив данных для формы
*
* @return array
*/
protected function formRebuild()
{
return [
'action' => $this->c->Router->link('AdminMaintenanceRebuild'),
'hidden' => [
'token' => $this->c->Csrf->create('AdminMaintenanceRebuild'),
@ -142,10 +167,6 @@ class Maintenance extends Admin
],
];
$this->nameTpl = 'admin/maintenance';
$this->aIndex = 'maintenance';
return $this;
}
/**

View file

@ -118,7 +118,7 @@ class Options extends Admin
$this->aIndex = 'options';
$this->nameTpl = 'admin/form';
$this->form = $this->viewForm($config);
$this->form = $this->formEdit($config);
$this->titleForm = \ForkBB\__('Options head');
$this->classForm = 'editoptions';
@ -180,7 +180,7 @@ class Options extends Admin
*
* @return array
*/
protected function viewForm(Config $config)
protected function formEdit(Config $config)
{
$form = [
'action' => $this->c->Router->link('AdminOptions'),

View file

@ -62,7 +62,7 @@ class Permissions extends Admin
$this->aIndex = 'permissions';
$this->nameTpl = 'admin/form';
$this->form = $this->viewForm($config);
$this->form = $this->formEdit($config);
$this->titleForm = \ForkBB\__('Permissions head');
$this->classForm = 'editpermissions';
@ -76,7 +76,7 @@ class Permissions extends Admin
*
* @return array
*/
protected function viewForm(Config $config)
protected function formEdit(Config $config)
{
$form = [
'action' => $this->c->Router->link('AdminPermissions'),

View file

@ -9,21 +9,19 @@ class Ban extends Page
{
/**
* Подготавливает данные для шаблона
*
*
* @param User $user
*
*
* @return Page
*/
public function ban(User $user)
{
$ban = $user->banInfo;
$this->httpStatus = 403;
$this->nameTpl = 'ban';
# $this->onlinePos = 'ban';
# $this->robots = 'noindex';
$this->titles = \ForkBB\__('Info');
$this->ban = $ban;
$this->ban = $user->banInfo;
$this->adminEmail = $this->c->config->o_admin_email;
return $this;

View file

@ -3,6 +3,7 @@
namespace ForkBB\Models\Pages;
use ForkBB\Models\Page;
use ForkBB\Models\Post\Model as Post;
class Delete extends Page
{
@ -61,7 +62,23 @@ class Delete extends Page
$this->crumbs = $this->crumbs($this->formTitle, $topic);
$this->posts = [$post];
$this->postsTitle = \ForkBB\__('Delete info');
$this->form = [
$this->form = $this->formDelete($args, $post, $deleteTopic);
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @param array $args
* @param Post $post
* @param bool $deleteTopic
*
* @return array
*/
protected function formDelete(array $args, Post $post, $deleteTopic)
{
return [
'action' => $this->c->Router->link('DeletePost', ['id' => $post->id]),
'hidden' => [
'token' => $this->c->Csrf->create('DeletePost', ['id' => $post->id]),
@ -71,7 +88,7 @@ class Delete extends Page
'info' => [
'info1' => [
'type' => '', //????
'value' => \ForkBB\__('Topic') . ' «' . \ForkBB\cens($topic->subject) . '»',
'value' => \ForkBB\__('Topic') . ' «' . \ForkBB\cens($post->parent->subject) . '»',
],
'info2' => [
'type' => '', //????
@ -104,7 +121,5 @@ class Delete extends Page
],
],
];
return $this;
}
}

View file

@ -62,7 +62,7 @@ class Edit extends Page
$this->robots = 'noindex';
$this->formTitle = $editSubject ? \ForkBB\__('Edit topic') : \ForkBB\__('Edit post');
$this->crumbs = $this->crumbs($this->formTitle, $topic);
$this->form = $this->messageForm($post, 'EditPost', $args, true, $editSubject);
$this->form = $this->messageForm($args, $post, 'EditPost', true, $editSubject);
return $this;
}
@ -146,8 +146,6 @@ class Edit extends Page
$this->c->search->index($post, 'edit');
return $this->c->Redirect
->page('ViewPost', ['id' => $post->id])
->message('Edit redirect');
return $this->c->Redirect->page('ViewPost', ['id' => $post->id])->message('Edit redirect');
}
}

View file

@ -52,7 +52,7 @@ class Post extends Page
$this->robots = 'noindex';
$this->crumbs = $this->crumbs(\ForkBB\__('Post new topic'), $forum);
$this->formTitle = \ForkBB\__('Post new topic');
$this->form = $this->messageForm($forum, 'NewTopic', $args, false, true);
$this->form = $this->messageForm($args, $forum, 'NewTopic', false, true);
return $this;
}
@ -107,7 +107,7 @@ class Post extends Page
$this->robots = 'noindex';
$this->crumbs = $this->crumbs(\ForkBB\__('Post a reply'), $topic);
$this->formTitle = \ForkBB\__('Post a reply');
$this->form = $this->messageForm($topic, 'NewReply', $args);
$this->form = $this->messageForm($args, $topic, 'NewReply');
return $this;
}
@ -234,8 +234,6 @@ class Post extends Page
$this->c->search->index($post);
}
return $this->c->Redirect
->page('ViewPost', ['id' => $merge ? $lastPost->id : $post->id])
->message('Post redirect');
return $this->c->Redirect->page('ViewPost', ['id' => $merge ? $lastPost->id : $post->id])->message('Post redirect');
}
}

View file

@ -9,16 +9,16 @@ trait PostFormTrait
/**
* Возвращает данные для построения формы создания темы/сообщения
*
* @param array $args
* @param Model $model
* @param string $marker
* @param array $args
* @param bool $editPost
* @param bool $editSubject
* @param bool $quickReply
*
* @return array
*/
protected function messageForm(Model $model, $marker, array $args, $editPost = false, $editSubject = false, $quickReply = false)
protected function messageForm(array $args, Model $model, $marker, $editPost = false, $editSubject = false, $quickReply = false)
{
$vars = isset($args['_vars']) ? $args['_vars'] : null;
unset($args['_vars']);

View file

@ -125,12 +125,51 @@ class Search extends Page
$this->fIswev = $v->getErrors();
}
$form = [
'action' => $this->c->Router->link($marker),
$this->fIndex = 'search';
$this->nameTpl = 'search';
$this->onlinePos = 'search';
$this->canonical = $this->c->Router->link('Search');
$this->robots = 'noindex';
$this->form = $advanced ? $this->formSearchAdvanced($v) : $this->formSearch($v);
$this->crumbs = $this->crumbs();
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @param Validator $v
*
* @return array
*/
protected function formSearch(Validator $v = null)
{
return [
'action' => $this->c->Router->link('Search'),
'hidden' => [
'token' => $this->c->Csrf->create($marker),
'token' => $this->c->Csrf->create('Search'),
],
'sets' => [
'what' => [
'fields' => [
[
'type' => 'info',
'value' => \ForkBB\__('<a href="%s">Advanced search</a>', $this->c->Router->link('SearchAdvanced')),
'html' => true,
],
'keywords' => [
'class' => 'w0',
'type' => 'text',
'maxlength' => 100,
'caption' => \ForkBB\__('Keyword search'),
'value' => $v ? $v->keywords : '',
'required' => true,
'autofocus' => true,
],
],
],
],
'sets' => [],
'btns' => [
'search' => [
'type' => 'submit',
@ -139,143 +178,137 @@ class Search extends Page
],
],
];
}
if ($advanced) {
$form['sets']['what'] = [
'fields' => [
[
'type' => 'info',
'value' => \ForkBB\__('<a href="%s">Simple search</a>', $this->c->Router->link('Search')),
'html' => true,
],
'keywords' => [
'class' => 'w2',
'type' => 'text',
'maxlength' => 100,
'caption' => \ForkBB\__('Keyword search'),
'value' => $v ? $v->keywords : '',
'required' => true,
'autofocus' => true,
],
'author' => [
'class' => 'w1',
'type' => 'text',
'maxlength' => 25,
'caption' => \ForkBB\__('Author search'),
'value' => $v ? $v->author : '*',
'required' => true,
],
[
'type' => 'info',
'value' => \ForkBB\__('Search info'),
/**
* Подготавливает массив данных для формы
*
* @param Validator $v
*
* @return array
*/
protected function formSearchAdvanced(Validator $v = null)
{
return [
'action' => $this->c->Router->link('SearchAdvanced'),
'hidden' => [
'token' => $this->c->Csrf->create('SearchAdvanced'),
],
'sets' => [
'what' => [
'fields' => [
[
'type' => 'info',
'value' => \ForkBB\__('<a href="%s">Simple search</a>', $this->c->Router->link('Search')),
'html' => true,
],
'keywords' => [
'class' => 'w2',
'type' => 'text',
'maxlength' => 100,
'caption' => \ForkBB\__('Keyword search'),
'value' => $v ? $v->keywords : '',
'required' => true,
'autofocus' => true,
],
'author' => [
'class' => 'w1',
'type' => 'text',
'maxlength' => 25,
'caption' => \ForkBB\__('Author search'),
'value' => $v ? $v->author : '*',
'required' => true,
],
[
'type' => 'info',
'value' => \ForkBB\__('Search info'),
],
],
],
];
$form['sets']['where'] = [
'legend' => \ForkBB\__('Search in legend'),
'fields' => [
'forums' => [
'class' => 'w3',
'type' => 'multiselect',
'options' => $this->listForOptions,
'value' => $v ? \explode('.', $v->forums) : null,
'caption' => \ForkBB\__('Forum search'),
'size' => \min(\count($this->listForOptions), 10),
],
'serch_in' => [
'class' => 'w3',
'type' => 'select',
'options' => [
0 => \ForkBB\__('Message and subject'),
1 => \ForkBB\__('Message only'),
2 => \ForkBB\__('Topic only'),
'where' => [
'legend' => \ForkBB\__('Search in legend'),
'fields' => [
'forums' => [
'class' => 'w3',
'type' => 'multiselect',
'options' => $this->listForOptions,
'value' => $v ? \explode('.', $v->forums) : null,
'caption' => \ForkBB\__('Forum search'),
'size' => \min(\count($this->listForOptions), 10),
],
'value' => $v ? $v->serch_in : 0,
'caption' => \ForkBB\__('Search in'),
'serch_in' => [
'class' => 'w3',
'type' => 'select',
'options' => [
0 => \ForkBB\__('Message and subject'),
1 => \ForkBB\__('Message only'),
2 => \ForkBB\__('Topic only'),
],
'value' => $v ? $v->serch_in : 0,
'caption' => \ForkBB\__('Search in'),
],
[
'type' => 'info',
'value' => \ForkBB\__('Search in info'),
],
[
'type' => 'info',
'value' => \ForkBB\__('Search multiple forums info'),
],
],
[
'type' => 'info',
'value' => \ForkBB\__('Search in info'),
],
[
'type' => 'info',
'value' => \ForkBB\__('Search multiple forums info'),
],
'how' => [
'legend' => \ForkBB\__('Search results legend'),
'fields' => [
'sort_by' => [
'class' => 'w4',
'type' => 'select',
'options' => [
0 => \ForkBB\__('Sort by post time'),
1 => \ForkBB\__('Sort by author'),
2 => \ForkBB\__('Sort by subject'),
3 => \ForkBB\__('Sort by forum'),
],
'value' => $v ? $v->sort_by : 0,
'caption' => \ForkBB\__('Sort by'),
],
'sort_dir' => [
'class' => 'w4',
'type' => 'radio',
'values' => [
0 => \ForkBB\__('Descending'),
1 => \ForkBB\__('Ascending'),
],
'value' => $v ? $v->sort_dir : 0,
'caption' => \ForkBB\__('Sort order'),
],
'show_as' => [
'class' => 'w4',
'type' => 'radio',
'values' => [
0 => \ForkBB\__('Show as posts'),
1 => \ForkBB\__('Show as topics'),
],
'value' => $v ? $v->show_as : 0,
'caption' => \ForkBB\__('Show as'),
],
[
'type' => 'info',
'value' => \ForkBB\__('Search results info'),
],
],
],
];
$form['sets']['how'] = [
'legend' => \ForkBB\__('Search results legend'),
'fields' => [
'sort_by' => [
'class' => 'w4',
'type' => 'select',
'options' => [
0 => \ForkBB\__('Sort by post time'),
1 => \ForkBB\__('Sort by author'),
2 => \ForkBB\__('Sort by subject'),
3 => \ForkBB\__('Sort by forum'),
],
'value' => $v ? $v->sort_by : 0,
'caption' => \ForkBB\__('Sort by'),
],
'sort_dir' => [
'class' => 'w4',
'type' => 'radio',
'values' => [
0 => \ForkBB\__('Descending'),
1 => \ForkBB\__('Ascending'),
],
'value' => $v ? $v->sort_dir : 0,
'caption' => \ForkBB\__('Sort order'),
],
'show_as' => [
'class' => 'w4',
'type' => 'radio',
'values' => [
0 => \ForkBB\__('Show as posts'),
1 => \ForkBB\__('Show as topics'),
],
'value' => $v ? $v->show_as : 0,
'caption' => \ForkBB\__('Show as'),
],
[
'type' => 'info',
'value' => \ForkBB\__('Search results info'),
],
],
'btns' => [
'search' => [
'type' => 'submit',
'value' => \ForkBB\__('Search btn'),
'accesskey' => 's',
],
];
} else {
$form['sets']['what'] = [
'fields' => [
[
'type' => 'info',
'value' => \ForkBB\__('<a href="%s">Advanced search</a>', $this->c->Router->link('SearchAdvanced')),
'html' => true,
],
'keywords' => [
'class' => 'w0',
'type' => 'text',
'maxlength' => 100,
'caption' => \ForkBB\__('Keyword search'),
'value' => $v ? $v->keywords : '',
'required' => true,
'autofocus' => true,
],
],
];
}
$this->fIndex = 'search';
$this->nameTpl = 'search';
$this->onlinePos = 'search';
$this->canonical = $this->c->Router->link('Search');
$this->robots = 'noindex';
$this->form = $form;
$this->crumbs = $this->crumbs();
return $this;
],
];
}
/**

View file

@ -152,7 +152,7 @@ class Topic extends Page
$this->stats = null;
if ($topic->canReply && $this->c->config->o_quickpost == '1') {
$this->form = $this->messageForm($topic, 'NewReply', ['id' => $topic->id], false, false, true);
$this->form = $this->messageForm(['id' => $topic->id], $topic, 'NewReply', false, false, true);
}
if ($topic->showViews) {

View file

@ -10,25 +10,23 @@ use InvalidArgumentException;
class Userlist extends Page
{
/**
* Генерирует список доступных групп пользователей
*
* @param bool $onlyKeys
* Возвращает список доступных групп
*
* @return array
*/
protected function groups($onlyKeys = false)
protected function getgroupList()
{
$groups = [
-1 => \ForkBB\__('All users'),
$list = [
'all' => \ForkBB\__('All users'),
];
foreach ($this->c->groups->getList() as $group) {
if (! $group->groupGuest) {
$groups[$group->g_id] = $group->g_title;
$list[$group->g_id] = $group->g_title;
}
}
return $onlyKeys ? \array_keys($groups) : $groups;
return $list;
}
/**
@ -48,7 +46,7 @@ class Userlist extends Page
->addRules([
'sort' => $prefix . 'string|in:username,registered' . ($this->user->showPostCount ? ',num_posts' : ''),
'dir' => $prefix . 'string|in:ASC,DESC',
'group' => $prefix . 'integer|in:' . \implode(',', $this->groups(true)),
'group' => $prefix . 'string|in:' . \implode(',', \array_keys($this->groupList)),
'name' => $prefix . 'string:trim|min:1|max:25' . ($this->user->searchUsers ? '' : '|in:*'),
]);
@ -71,10 +69,10 @@ class Userlist extends Page
}
$filters = [];
if ($v->group < 1) {
$filters['group_id'] = ['!=', 0];
} else {
if (\is_numeric($v->group)) {
$filters['group_id'] = ['=', $v->group];
} else {
$filters['group_id'] = ['!=', 0];
}
if (null !== $v->name) {
$filters['username'] = ['LIKE', $v->name];
@ -100,7 +98,7 @@ class Userlist extends Page
$vars = ['page' => $page];
if (4 === $count) {
$vars['group'] = -1;
$vars['group'] = 'all';
$vars['name'] = '*';
} else {
$vars['group'] = $v->group;
@ -130,6 +128,27 @@ class Userlist extends Page
$this->fIswev = ['i', \ForkBB\__('No users found')];
}
$this->fIndex = 'userlist';
$this->nameTpl = 'userlist';
$this->onlinePos = 'userlist';
$this->canonical = $this->c->Router->link('Userlist', $args);
$this->robots = 'noindex';
$this->crumbs = $this->crumbs([$this->c->Router->link('Userlist'), \ForkBB\__('User list')]);
$this->pagination = $this->c->Func->paginate($pages, $page, 'Userlist', $args);
$this->form = $this->formUserlist($v);
return $this;
}
/**
* Подготавливает массив данных для формы
*
* @param Validator $v
*
* @return array
*/
protected function formUserlist(Validator $v)
{
$form = [
'action' => $this->c->Router->link('Userlist'),
'hidden' => [],
@ -162,7 +181,7 @@ class Userlist extends Page
$fields['group'] = [
'class' => 'w4',
'type' => 'select',
'options' => $this->groups(),
'options' => $this->groupList,
'value' => $v->group,
'caption' => \ForkBB\__('User group'),
];
@ -189,15 +208,6 @@ class Userlist extends Page
];
$form['sets']['users'] = ['fields' => $fields];
$this->fIndex = 'userlist';
$this->nameTpl = 'userlist';
$this->onlinePos = 'userlist';
$this->canonical = $this->c->Router->link('Userlist', $args);
$this->robots = 'noindex';
$this->form = $form;
$this->crumbs = $this->crumbs([$this->c->Router->link('Userlist'), \ForkBB\__('User list')]);
$this->pagination = $this->c->Func->paginate($pages, $page, 'Userlist', $args);
return $this;
return $form;
}
}

View file

@ -128,7 +128,7 @@ body,
font: inherit;
box-sizing: border-box;
word-wrap: break-word;
/*vertical-align: baseline;*/
/*vertical-align: baseline;*/
}
body,
@ -148,6 +148,11 @@ body,
position: relative;
}
#fork div,
#fork fieldset {
min-width: 0;
}
#fork ul,
#fork ol {
list-style: none;
@ -1724,7 +1729,7 @@ body,
#fork .f-fs-category {
display: flex;
align-items: stretch;
min-width: 0;
/*min-width: 0;*/
}
#fork .f-fs-category > legend {
@ -1781,7 +1786,7 @@ body,
#fork .f-fs-forum {
display: flex;
align-items: stretch;
min-width: 0;
/*min-width: 0;*/
}
#fork .f-fs-forum > legend {
@ -1857,7 +1862,7 @@ body,
display: flex;
flex-wrap: wrap;
align-items: stretch;
min-width: 0;
/*min-width: 0;*/
}
#fork .f-fs-permission > legend {
@ -1945,7 +1950,7 @@ body,
display: flex;
flex-wrap: wrap;
align-items: stretch;
min-width: 0;
/*min-width: 0;*/
}
#fork .f-fs-censor .f-child1 {
@ -2160,7 +2165,7 @@ body,
/***********/
#fork .f-fs-header {
display: flex;
min-width: 0;
/*min-width: 0;*/
align-items: center;
}
@ -2182,7 +2187,7 @@ body,
#fork .f-fs-data {
display: flex;
flex-direction: column;
min-width: 0;
/*min-width: 0;*/
}
#fork .f-fs-header .f-wrap-usertitle {
@ -2354,7 +2359,7 @@ body,
#fork .f-fs-result {
display: flex;
align-items: stretch;
min-width: 0;
/*min-width: 0;*/
border-bottom: 0.0625rem dotted #AA7939;
margin-bottom: 0.3125rem;
padding-bottom: 0.3125rem;