Visman 7 سال پیش
والد
کامیت
2a132adc24
5فایلهای تغییر یافته به همراه83 افزوده شده و 25 حذف شده
  1. 2 2
      app/Core/Router.php
  2. 31 2
      app/Models/Pages/Userlist.php
  3. 24 14
      app/Models/User/Model.php
  4. 6 6
      app/templates/userlist.tpl
  5. 20 1
      public/style/ForkBB/style.css

+ 2 - 2
app/Core/Router.php

@@ -95,7 +95,7 @@ class Router
     {
         if (\is_string($url)
             && \parse_url($url, PHP_URL_HOST) === $this->host
-            && ($route = $this->route('GET', \rawurldecode(\parse_url($url, PHP_URL_PATH))))
+            && ($route = $this->route('GET', \rawurldecode(\parse_url($url, \PHP_URL_PATH))))
             && $route[0] === self::OK
         ) {
             if (isset($route[3])) {
@@ -297,7 +297,7 @@ class Router
      */
     protected function parse($route)
     {
-        $parts = \preg_split('%([\[\]{}/])%', $route, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
+        $parts = \preg_split('%([\[\]{}/])%', $route, -1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE);
 
         $s = 1;
         $base = $parts[0];

+ 31 - 2
app/Models/Pages/Userlist.php

@@ -25,10 +25,10 @@ class Userlist extends Page
 
         $v = $this->c->Validator->reset()
             ->addRules([
-                'sort'  => 'string|in:username,registered,num_posts',
+                'sort'  => 'string|in:username,registered' . ($this->user->showPostCount ? ',num_posts' : ''),
                 'dir'   => 'string|in:ASC,DESC',
                 'group' => 'integer|min:-1|max:9999999999|not_in:0,' . $this->c->GROUP_GUEST,
-                'name'  => 'string:trim|min:1|max:25',
+                'name'  => 'string:trim|min:1|max:25' . ($this->user->searchUsers ? '' : '|in:*'),
             ]);
 
         $error = true;
@@ -71,10 +71,39 @@ class Userlist extends Page
             $this->startNum = ($page - 1) * $this->c->config->o_disp_users;
             $ids = \array_slice($ids, $this->startNum, $this->c->config->o_disp_users);
             $this->userList = $this->c->users->load($ids);
+
+            $links = [];
+            $vars = ['page' => $page];
+
+            if (4 === $count) {
+                $vars['group'] = -1;
+                $vars['name']  = '*';
+            } else {
+                $vars['group'] = $v->group;
+                $vars['name']  = $v->name;
+            }
+
+            $this->active = 0;
+
+            foreach (['username', 'num_posts', 'registered'] as $i => $sort) {
+                $vars['sort'] = $sort;
+
+                foreach (['ASC', 'DESC'] as $j => $dir) {
+                    $vars['dir'] = $dir;
+                    $links[$i * 2 + $j] = $this->c->Router->link('Userlist', $vars);
+
+                    if ($v->sort === $sort && $v->dir === $dir) {
+                        $this->active = $i * 2 + $j;
+                    }
+                }
+            }
+
+            $this->links = $links;
         } else {
             $this->startNum = 0;
             $this->userList = null;
             // ни чего не найдено
+            $this->links = [null, null, null, null, null, null];
         }
 
         $this->fIndex       = 'userlist';

+ 24 - 14
app/Models/User/Model.php

@@ -49,7 +49,7 @@ class Model extends DataModel
     protected function getisAdmMod()
     {
         return $this->group_id === $this->c->GROUP_ADMIN
-            || '1' == $this->g_moderator;
+            || 1 == $this->g_moderator;
     }
 
     /**
@@ -63,7 +63,7 @@ class Model extends DataModel
      */
     public function isModerator(BaseModel $model)
     {
-        if ('1' != $this->g_moderator) {
+        if (1 != $this->g_moderator) {
             return false;
         }
 
@@ -83,7 +83,7 @@ class Model extends DataModel
      */
     protected function getlogged()
     {
-        return empty($this->a['logged']) ? time() : $this->a['logged'];
+        return empty($this->a['logged']) ? \time() : $this->a['logged'];
     }
 
     /**
@@ -105,11 +105,11 @@ class Model extends DataModel
     {
         $langs = $this->c->Func->getLangs();
 
-        $lang = $this->isGuest || empty($this->a['language']) || ! in_array($this->a['language'], $langs)
+        $lang = $this->isGuest || empty($this->a['language']) || ! \in_array($this->a['language'], $langs)
             ? $this->c->config->o_default_lang
             : $this->a['language'];
 
-        if (in_array($lang, $langs)) {
+        if (\in_array($lang, $langs)) {
             return $lang;
         } else {
             return isset($langs[0]) ? $langs[0] : 'English';
@@ -125,11 +125,11 @@ class Model extends DataModel
     {
         $styles = $this->c->Func->getStyles();
 
-        $style = $this->isGuest || empty($this->a['style']) || ! in_array($this->a['style'], $styles)
+        $style = $this->isGuest || empty($this->a['style']) || ! \in_array($this->a['style'], $styles)
             ? $this->c->config->o_default_style
             : $this->a['style'];
 
-        if (in_array($style, $styles)) {
+        if (\in_array($style, $styles)) {
             return $style;
         } else {
             return isset($styles[0]) ? $styles[0] : 'ForkBB';
@@ -157,12 +157,12 @@ class Model extends DataModel
      */
     protected function getavatar()
     {
-        $filetypes = array('jpg', 'gif', 'png');
+        $filetypes = ['jpg', 'gif', 'png'];
 
         foreach ($filetypes as $type) {
             $path = $this->c->DIR_PUBLIC . "{$this->c->config->o_avatars_dir}/{$this->id}.{$type}";
 
-            if (file_exists($path) && getimagesize($path)) {
+            if (\file_exists($path) && \getimagesize($path)) {
                 return $this->c->PUBLIC_URL . "{$this->c->config->o_avatars_dir}/{$this->id}.{$type}";
             }
         }
@@ -217,7 +217,17 @@ class Model extends DataModel
      */
     protected function getviewUsers()
     {
-        return $this->g_view_users == '1' || $this->isAdmin;
+        return 1 == $this->g_view_users || $this->isAdmin;
+    }
+
+    /**
+     * Статус поиска пользователей
+     *
+     * @return bool
+     */
+    protected function getsearchUsers()
+    {
+        return 1 == $this->g_search_users || $this->isAdmin;
     }
 
     /**
@@ -227,7 +237,7 @@ class Model extends DataModel
      */
     protected function getshowAvatar()
     {
-        return $this->c->config->o_avatars == '1' && $this->show_avatars == '1';
+        return '1' == $this->c->config->o_avatars && 1 == $this->show_avatars;
     }
 
     /**
@@ -237,7 +247,7 @@ class Model extends DataModel
      */
     protected function getshowUserInfo()
     {
-        return $this->c->config->o_show_user_info == '1';
+        return '1' == $this->c->config->o_show_user_info;
     }
 
     /**
@@ -247,7 +257,7 @@ class Model extends DataModel
      */
     protected function getshowSignature()
     {
-        return $this->c->config->o_signatures == '1' && $this->show_sig == '1';
+        return '1' == $this->c->config->o_signatures && 1 == $this->show_sig;
     }
 
     /**
@@ -257,6 +267,6 @@ class Model extends DataModel
      */
     protected function getshowPostCount()
     {
-        return $this->c->config->o_show_post_count == '1' || $this->isAdmMod;
+        return '1' == $this->c->config->o_show_post_count || $this->isAdmMod;
     }
 }

+ 6 - 6
app/templates/userlist.tpl

@@ -57,26 +57,26 @@
           <li class="f-row f-thead" value="{{ $p->startNum }}">
             <span class="f-hcell f-cusername">
               <span class="f-hc-table">
-                <span class="f-hc-tasc">▲</span>
+                <span class="f-hc-tasc"><a @if (0 === $p->active) class="active" @endif href="{!! $p->links[0] !!}"></a></span>
                 <span class="f-hc-tname">{!! __('Username') !!}</span>
-                <span class="f-hc-tdesc">▼</span>
+                <span class="f-hc-tdesc"><a @if (1 === $p->active) class="active" @endif href="{!! $p->links[1] !!}"></a></span>
               </span>
             </span>
             <span class="f-hcell f-ctitle">{!! __('Title') !!}</span>
     @if ($p->user->showPostCount)
             <span class="f-hcell f-cnumposts">
               <span class="f-hc-table">
-                <span class="f-hc-tasc">▲</span>
+                <span class="f-hc-tasc"><a @if (2 === $p->active) class="active" @endif href="{!! $p->links[2] !!}"></a></span>
                 <span class="f-hc-tname">{!! __('Posts') !!}</span>
-                <span class="f-hc-tdesc">▼</span>
+                <span class="f-hc-tdesc"><a @if (3 === $p->active) class="active" @endif href="{!! $p->links[3] !!}"></a></span>
               </span>
             </span>
     @endif
             <span class="f-hcell f-cdatereg">
               <span class="f-hc-table">
-                <span class="f-hc-tasc">▲</span>
+                <span class="f-hc-tasc"><a @if (4 === $p->active) class="active" @endif href="{!! $p->links[4] !!}"></a></span>
                 <span class="f-hc-tname">{!! __('Registered') !!}</span>
-                <span class="f-hc-tdesc">▼</span>
+                <span class="f-hc-tdesc"><a @if (5 === $p->active) class="active" @endif href="{!! $p->links[5] !!}"></a></span>
               </span>
             </span>
           </li>

+ 20 - 1
public/style/ForkBB/style.css

@@ -1953,11 +1953,30 @@ li + li .f-btn {
 
   .f-hc-table .f-hc-tasc,
   .f-hc-table .f-hc-tdesc {
-    font-size: 0.625rem;
+    font-size: 0.75rem;
     display: block;
     text-align: center;
   }
 
+  .f-hc-table .f-hc-tname {
+    padding: 0.125rem 0;
+    display: block;
+  }
+
+  .f-hc-tasc > a,
+  .f-hc-tdesc > a {
+/*    display: block; */
+    padding: 0 0.25rem;
+    border: 0;
+  }
+
+  .f-hc-tasc > a.active,
+  .f-hc-tdesc > a.active {
+/*    background-color: #814A00;
+    color: #F8F4E3; */
+    border: 0.0625rem solid #814A00;
+  }
+
   .f-ulist .f-cell > b,
   .f-ulist .f-cell > i {
     font-style: normal;