瀏覽代碼

Change the structure of statistics, online list and moderators list

Visman 4 年之前
父節點
當前提交
b247dcaf49

+ 12 - 4
app/Models/Forum/Model.php

@@ -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;
     }
 

+ 19 - 21
app/Models/Online/Info.php

@@ -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;
 
-        $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;
 

+ 10 - 8
app/Models/Pages/Index.php

@@ -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 {

+ 6 - 6
app/templates/layouts/stats.forkbb.php

@@ -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 -->

+ 3 - 3
app/templates/layouts/subforums.forkbb.php

@@ -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 -->