Change the structure of statistics, online list and moderators list

This commit is contained in:
Visman 2021-03-07 21:43:42 +07:00
parent 09f65b94c9
commit b247dcaf49
5 changed files with 51 additions and 43 deletions

View file

@ -244,22 +244,30 @@ class Model extends DataModel
return [];
}
if ('1' == $this->c->user->g_view_users) {
if ('1' == $this->c->user->viewUsers) {
foreach ($attr as $id => &$cur) {
$cur = [
$this->c->Router->link(
'name' => $cur,
'link' => $this->c->Router->link(
'User',
[
'id' => $id,
'name' => $cur,
]
),
$cur,
];
}
unset($cur);
} else {
foreach ($attr as $id => &$cur) {
$cur = [
'name' => $cur,
'link' => null,
];
}
}
unset($cur);
return $attr;
}

View file

@ -24,40 +24,38 @@ class Info extends Method
return null;
}
$viewUsers = $this->c->user->viewUsers;
$this->model->maxNum = $this->c->config->a_max_users['number'];
$this->model->maxTime = $this->c->config->a_max_users['time'];
$info = [];
$info = [];
if ('1' == $this->c->user->g_view_users) {
foreach ($this->model->users as $id => $name) {
$info[] = [
$this->c->Router->link(
foreach ($this->model->users as $id => $name) {
$info[] = [
'name' => $name,
'link' => $viewUsers
? $this->c->Router->link(
'User',
[
'id' => $id,
'name' => $name,
]
),
$name,
];
}
} else {
foreach ($this->model->users as $name) {
$info[] = $name;
}
)
: null,
];
}
$this->model->numUsers = \count($info);
$s = 0;
$this->model->numUsers = \count($info);
$s = 0;
foreach ($this->model->bots as $bot => $arr) {
$count = \count($arr);
$s += $count;
if ($count > 1) {
$info[] = '[Bot] ' . $bot . ' (' . $count . ')';
} else {
$info[] = '[Bot] ' . $bot;
}
$count = \count($arr);
$s += $count;
$info[] = [
'name' => "[Bot] {$bot}" . ($count > 1 ? " ({$count})" : ''),
'link' => null,
];
}
$this->model->numGuests = $s + \count($this->model->guests);
$this->model->info = $info;

View file

@ -24,22 +24,24 @@ class Index extends Page
$this->c->Lang->load('subforums');
// крайний пользователь // ???? может в stats переместить?
$this->c->stats->userLast = $this->user->viewUsers
? [
$this->c->Router->link(
'User', [
$this->c->stats->userLast = [
'name' => $this->c->stats->userLast['username'],
'link' => $this->user->viewUsers
? $this->c->Router->link(
'User',
[
'id' => $this->c->stats->userLast['id'],
'name' => $this->c->stats->userLast['username'],
]
),
$this->c->stats->userLast['username'],
]
: $this->c->stats->userLast['username'];
)
: null,
];
// для таблицы разделов
$root = $this->c->forums->loadTree(0);
$forums = empty($root) ? [] : $root->subforums;
$ctgs = [];
if (empty($forums)) {
$this->fIswev = ['i', __('Empty board')];
} else {

View file

@ -11,10 +11,10 @@
<dl class="f-stusers">
<dt>{!! __('User info') !!}</dt>
@if ($p->stats)
@if (\is_string($p->stats->userLast))
<dd>{!! __('Newest user') !!} {{ $p->stats->userLast }}</dd>
@if ($p->stats->userLast['link'])
<dd>{!! __('Newest user') !!} <a href="{{ $p->stats->userLast['link'] }}">{{ $p->stats->userLast['name'] }}</a></dd>
@else
<dd>{!! __('Newest user') !!} <a href="{{ $p->stats->userLast[0] }}">{{ $p->stats->userLast[1] }}</a></dd>
<dd>{!! __('Newest user') !!} {{ $p->stats->userLast['name'] }}</dd>
@endif
@endif
@if ($p->online)
@ -28,10 +28,10 @@
<dl class="f-inline f-onlinelist"><!-- inline -->
<dt>{!! __('Online users') !!}</dt>
@foreach ($p->online->info as $cur)
@if (\is_string($cur))
<dd>{{ $cur }}</dd>
@if ($cur['link'])
<dd><a href="{{ $cur['link'] }}">{{ $cur['name'] }}</a></dd>
@else
<dd><a href="{{ $cur[0] }}">{{ $cur[1] }}</a></dd>
<dd>{{ $cur['name'] }}</dd>
@endif
@endforeach
</dl><!-- endinline -->

View file

@ -37,10 +37,10 @@
<dl class="f-inline f-modlist"><!-- inline -->
<dt>{!! __('Moderated by', \count($cur->moderators)) !!}</dt>
@foreach ($cur->moderators as $mod)
@if (\is_string($mod))
<dd>{{ $mod }}</dd>
@if ($mod['link'])
<dd><a href="{{ $mod['link'] }}">{{ $mod['name'] }}</a></dd>
@else
<dd><a href="{{ $mod[0] }}">{{ $mod[1] }}</a></dd>
<dd>{{ $mod['name'] }}</dd>
@endif
@endforeach
</dl><!-- endinline -->