소스 검색

2018-01-23

Visman 7 년 전
부모
커밋
c75f487e38

+ 5 - 5
app/Core/Func.php

@@ -69,20 +69,20 @@ class Func
      * @param int $cur
      * @param string $marker
      * @param array $args
+     * @param string $info
      *
      * @return array
      */
-    public function paginate($all, $cur, $marker, array $args = [])
+    public function paginate($all, $cur, $marker, array $args = [], $info = 'Page %1$s of %2$s')
     {
         $pages = [];
         if ($all < 2) {
-            $pages[] = [null, 1, true];
+//            $pages[] = [null, 1, true];
         } else {
             if ($cur > 0) {
+                $pages[] = [\ForkBB\__($info, $cur, $all), 'info', null];
                 $cur = min(max(1, $cur), $all);
-                if ($cur === 2) {
-                    $pages[] = [$this->c->Router->link($marker, $args), 'prev', null];
-                } elseif ($cur > 2) {
+                if ($cur > 1) {
                     $pages[] = [$this->c->Router->link($marker, ['page' => $cur - 1] + $args), 'prev', null];
                 }
                 $tpl = [1 => 1];

+ 25 - 12
app/Models/Pages/Search.php

@@ -389,9 +389,10 @@ class Search extends Page
     {
         $this->c->Lang->load('search');
 
-        $model       = $this->c->search;
-        $model->page = isset($args['page']) ? (int) $args['page'] : 1;
-        $action      = $args['action'];
+        $model        = $this->c->search;
+        $model->page  = isset($args['page']) ? (int) $args['page'] : 1;
+        $action       = $args['action'];
+        $asTopicsList = true;
         switch ($action) {
             case 'search':
                 if (1 === $model->showAs) {
@@ -407,7 +408,8 @@ class Search extends Page
                     } else {
                         $model->name  = \ForkBB\__('By both show as posts', $args['keywords'], $args['author']);
                     }
-                    //?????
+                    $list = $model->actionP($action);
+                    $asTopicsList = false;
                 }
                 $model->linkMarker = $advanced ? 'SearchAdvanced' : 'Search';;
                 $model->linkArgs   = $args;
@@ -430,14 +432,25 @@ class Search extends Page
             return $this->view(['advanced' => 'advanced'], 'GET');
         }
 
-        $this->fIndex       = 'search';
-        $this->nameTpl      = 'forum';
-        $this->onlinePos    = 'search';
-        $this->robots       = 'noindex';
-        $this->model        = $model;
-        $this->topics       = $list;
-        $this->crumbs       = $this->crumbs($model);
-        $this->showForum    = true;
+        if ($asTopicsList) {
+            $this->c->Lang->load('forum');
+
+            $this->nameTpl   = 'forum';
+            $this->topics    = $list;
+        } else {
+            $this->c->Lang->load('topic');
+
+            $this->nameTpl   = 'topic';
+            $this->posts     = $list;
+        }
+
+        $this->fIndex        = 'search';
+        $this->nameTpl       = $asTopicsList ? 'forum' : 'topic';
+        $this->onlinePos     = 'search';
+        $this->robots        = 'noindex';
+        $this->model         = $model;
+        $this->crumbs        = $this->crumbs($model);
+        $this->searchMode    = true;
 
         return $this;
     }

+ 1 - 1
app/Models/Pages/Topic.php

@@ -146,7 +146,7 @@ class Topic extends Page
         $this->onlinePos    = 'topic-' . $topic->id;
         $this->onlineDetail = true;
         $this->canonical    = $this->c->Router->link('Topic', ['id' => $topic->id, 'name' => \ForkBB\cens($topic->subject), 'page' => $topic->page]);
-        $this->topic        = $topic;
+        $this->model        = $topic;
         $this->posts        = $posts;
         $this->crumbs       = $this->crumbs($topic);
         $this->online       = $this->c->Online->calc($this)->info();

+ 73 - 31
app/Models/Post/View.php

@@ -78,11 +78,7 @@ class View extends Action
      */
     public function view($arg)
     {
-        if ($arg instanceof Topic) {
-            $expanded = false;
-        } elseif ($arg instanceof Search) {
-            $expanded = true;
-        } else {
+        if (! $arg instanceof Topic && ! $arg instanceof Search) {
             throw new InvalidArgumentException('Expected Topic or Search');
         }
 
@@ -98,42 +94,88 @@ class View extends Action
                 WHERE id IN (?ai:ids)';
         $warnings = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_GROUP);
 
-        if (! $expanded) {
+        $userIds = [];
+        $result  = array_flip($arg->idsList);
+
+        if ($arg instanceof Topic) {
             $vars = [
                 ':ids' => $arg->idsList,
-                ':fields' => $this->queryFields([
-                    'p' => array_map(function($val) {return true;}, $this->c->dbMap->posts), // все поля в true
-                    'u' => array_map(function($val) {return true;}, $this->c->dbMap->users), // все поля в true
-                    'g' => array_map(function($val) {return true;}, $this->c->dbMap->groups), // все поля в true
-                ]),
             ];
-
-            $sql = 'SELECT ?p:fields
+            $sql = 'SELECT p.*
                     FROM ::posts AS p
-                    INNER JOIN ::users AS u ON u.id=p.poster_id
-                    INNER JOIN ::groups AS g ON g.g_id=u.group_id
                     WHERE p.id IN (?ai:ids)';
-        } else {
+            $stmt = $this->c->DB->query($sql, $vars);
 
-        }
+            while ($row = $stmt->fetch()) {
+                $post = $this->manager->create($row);
 
-        $stmt = $this->c->DB->query($sql, $vars);
+                if (isset($warnings[$row['id']])) {
+                    $post->__warnings = $warnings[$row['id']];
+                }
 
-        $result = array_flip($arg->idsList);
+                $userIds[$post->poster_id] = true;
 
-        while ($row = $stmt->fetch()) {
-            $post = $this->manager->create();
-            $user = $this->c->users->create();
-            $this->setData(['p' => $post, 'u.g' => $user], $row);
-            if (isset($warnings[$row['id']])) {
-                $post->__warnings = $warnings[$row['id']];
+                $result[$post->id] = $post;
+            }
+        } else {
+            if ($this->c->user->isGuest) {
+                $vars = [
+                    ':ids' => $arg->idsList,
+                    ':fields' => $this->queryFields([
+                        'p'   => array_map(function($val) {return true;}, $this->c->dbMap->posts), // все поля в true
+                        't'   => array_map(function($val) {return true;}, $this->c->dbMap->topics), // все поля в true
+                    ]),
+                ];
+                $sql = 'SELECT ?p:fields
+                        FROM ::posts AS p
+                        INNER JOIN ::topics AS t ON t.id=p.topic_id
+                        WHERE p.id IN (?ai:ids)';
+
+            } else {
+                $vars = [
+                    ':ids' => $arg->idsList,
+                    ':uid' => $this->c->user->id,
+                    ':fields' => $this->queryFields([
+                        'p'   => array_map(function($val) {return true;}, $this->c->dbMap->posts), // все поля в true
+                        't'   => array_map(function($val) {return true;}, $this->c->dbMap->topics), // все поля в true
+#                        's'   => ['user_id' => 'is_subscribed'],
+                        'mof' => ['mf_mark_all_read' => true],
+                        'mot' => ['mt_last_visit' => true, 'mt_last_read' => true],
+                    ]),
+                ];
+                $sql = 'SELECT ?p:fields
+                        FROM ::posts AS p
+                        INNER JOIN ::topics AS t ON t.id=p.topic_id
+                        LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND t.forum_id=mof.fid)
+                        LEFT JOIN ::mark_of_topic AS mot ON (mot.uid=?i:uid AND t.id=mot.tid)
+                        WHERE p.id IN (?ai:ids)';
+#                        LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
             }
-            $result[$post->id] = $post;
-            if (! $this->c->users->get($user->id) instanceof User) {
-                $this->c->users->set($user->id, $user);
+
+            $stmt = $this->c->DB->query($sql, $vars);
+
+            while ($row = $stmt->fetch()) {
+
+                $post  = $this->manager->create();
+                $topic = $this->c->topics->create();
+                $this->setData(['p' => $post, 't.s.mof.mot' => $topic], $row);
+
+                if (isset($warnings[$row['id']])) {
+                    $post->__warnings = $warnings[$row['id']];
+                }
+
+                $userIds[$post->poster_id] = true;
+
+                $result[$post->id] = $post;
+
+                if (! $this->c->topics->get($topic->id)) {
+                    $this->c->topics->set($topic->id, $topic);
+                }
             }
         }
 
+        $this->c->users->load(array_keys($userIds));
+
         $offset    = ($arg->page - 1) * $this->c->user->disp_posts;
         $postCount = 0;
         $timeMax   = 0;
@@ -144,17 +186,17 @@ class View extends Action
                     $timeMax = $post->posted;
                 }
                 if ($post->id === $arg->first_post_id && $offset > 0) {
-                    $post->postNumber = 1;
+                    $post->__postNumber = 1;
                 } else {
                     ++$postCount;
-                    $post->postNumber = $offset + $postCount;
+                    $post->__postNumber = $offset + $postCount;
                 }
             }
             $arg->timeMax = $timeMax;
         } else {
             foreach ($result as $post) {
                 ++$postCount;
-                $post->postNumber = $offset + $postCount; //????
+                $post->__postNumber = $offset + $postCount; //????
             }
         }
         return $result;

+ 71 - 0
app/Models/Search/ActionP.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace ForkBB\Models\Search;
+
+use ForkBB\Models\Method;
+use ForkBB\Models\Forum\Model as Forum;
+use PDO;
+use InvalidArgumentException;
+use RuntimeException;
+
+class ActionP extends Method
+{
+    /**
+     * Поисковые действия по сообщениям
+     *
+     * @param string $action
+     *
+     * @throws InvalidArgumentException
+     *
+     * @return false|array
+     */
+    public function actionP($action)
+    {
+        $root = $this->c->forums->get(0);
+        if (! $root instanceof Forum || empty($root->descendants)) {
+            return []; //????
+        }
+
+        $sql = null;
+        switch ($action) {
+            case 'search':
+                $list = $this->model->queryIds;
+                break;
+#            case 'last':
+#                $sql = 'SELECT t.id
+#                        FROM ::topics AS t
+#                        WHERE t.forum_id IN (?ai:forums) AND t.moved_to IS NULL
+#                        ORDER BY t.last_post DESC';
+#                break;
+#            case 'unanswered':
+#                $sql = 'SELECT t.id
+#                        FROM ::topics AS t
+#                       WHERE t.forum_id IN (?ai:forums) AND t.moved_to IS NULL AND t.num_replies=0
+#                        ORDER BY t.last_post DESC';
+#                break;
+            default:
+                throw new InvalidArgumentException('Unknown action: ' . $action);
+        }
+
+        if (null !== $sql) {
+            $vars = [
+                ':forums' => array_keys($root->descendants),
+            ];
+            $list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
+        }
+
+        $this->model->numPages = (int) ceil((count($list) ?: 1) / $this->c->user->disp_posts);
+
+        // нет такой страницы в результате поиска
+        if (! $this->model->hasPage()) {
+            return false;
+        // результат пуст
+        } elseif (empty($list)) {
+            return [];
+        }
+
+        $this->model->idsList = array_slice($list, ($this->model->page - 1) * $this->c->user->disp_posts, $this->c->user->disp_posts);
+
+        return $this->c->posts->view($this->model);
+    }
+}

+ 1 - 1
app/Models/Search/Execute.php

@@ -64,7 +64,7 @@ class Execute extends Method
 
         if (! empty($row['search_time']) && time() - $row['search_time'] < 60 * 5) { //????
             $result                    = explode("\n", $row['search_data']);
-            $this->model->queryIds     = explode(',', $result[0]);
+            $this->model->queryIds     = '' == $result[0] ? [] : explode(',', $result[0]);
             $this->model->queryNoCache = false;
             return true;
         } elseif ($flood) {

+ 32 - 14
app/Models/User/Load.php

@@ -9,17 +9,19 @@ class Load extends Action
 {
     /**
      * Получение пользователя по условию
-     * 
+     *
      * @param mixed $value
      * @param string $field
-     * 
+     *
      * @throws InvalidArgumentException
-     * 
-     * @return int|User
+     *
+     * @return mixed
      */
     public function load($value, $field = 'id')
     {
-        switch ($field) {
+        $flag = is_array($value);
+
+        switch (($flag ? 'a_' : '') . $field) {
             case 'id':
                 $where = 'u.id=?i:field';
                 break;
@@ -29,23 +31,39 @@ class Load extends Action
             case 'email':
                 $where = 'u.email=?s:field';
                 break;
+            case 'a_id':
+                $where = 'u.id IN (?ai:field)';
+                break;
+            case 'a_username':
+                $where = 'u.username IN (?as:field)';
+                break;
+            case 'a_email':
+                $where = 'u.email IN (?as:field)';
+                break;
             default:
                 throw new InvalidArgumentException('Field not supported');
         }
         $vars = [':field' => $value];
-        $sql = 'SELECT u.*, g.* 
-                FROM ::users AS u 
-                LEFT JOIN ::groups AS g ON u.group_id=g.g_id 
+        $sql = 'SELECT u.*, g.*
+                FROM ::users AS u
+                LEFT JOIN ::groups AS g ON u.group_id=g.g_id
                 WHERE ' . $where;
 
         $data = $this->c->DB->query($sql, $vars)->fetchAll();
 
-        // число найденных пользователей отлично от одного или гость
-        $count = count($data);
-        if (1 !== $count || 1 === $data[0]['id']) {
-            return $count;
+        if ($flag) {
+            $result = [];
+            foreach ($data as $row) {
+                $result[] = $this->manager->create($row);
+            }
+            return $result;
+        } else {
+            $count = count($data);
+            // число найденных пользователей отлично от одного или гость
+            if (1 !== $count || 1 === $data[0]['id']) {
+                return $count;
+            }
+            return $this->manager->create($data[0]);
         }
-
-        return $this->manager->create($data[0]);
     }
 }

+ 48 - 18
app/Models/User/Manager.php

@@ -10,9 +10,9 @@ class Manager extends ManagerModel
 {
     /**
      * Создает новую модель пользователя
-     * 
+     *
      * @param array $attrs
-     * 
+     *
      * @return User
      */
     public function create(array $attrs = [])
@@ -22,38 +22,68 @@ class Manager extends ManagerModel
 
     /**
      * Получение пользователя по условию
-     * 
+     *
      * @param mixed $value
      * @param string $field
-     * 
-     * @return int|User
+     *
+     * @return mixed
      */
     public function load($value, $field = 'id')
     {
-        $user = $field === 'id' ? $this->get($value) : null;
+        if (is_array($value)) {
+            $result = [];
+            if ($field === 'id') {
+                $temp = [];
+                foreach ($value as $id) {
+                    if ($this->get($id) instanceof User) {
+                        $result[$id] = $this->get($id);
+                    } else {
+                        $temp[] = $id;
+                    }
+                }
+                $value = $temp;
+            }
+            if (empty($value)) {
+                return $result;
+            }
+            foreach ($this->Load->load($value, $field) as $user) {
+                if ($user instanceof User) {
+                    if ($this->get($user->id) instanceof User) {
+                        $result[$user->id] = $this->get($user->id);
+                    } else {
+                        $result[$user->id] = $user;
+                        $this->set($user->id, $user);
+                    }
+                }
+            }
 
-        if (! $user instanceof User) {
-            $user = $this->Load->load($value, $field);
+            return $result;
+        } else {
+            $user = $field === 'id' ? $this->get($value) : null;
 
-            if ($user instanceof User) {
-                $test = $this->get($user->id);
+            if (! $user instanceof User) {
+                $user = $this->Load->load($value, $field);
 
-                if ($test instanceof User) {
-                    return $test;
-                }
+                if ($user instanceof User) {
+                    $test = $this->get($user->id);
 
-                $this->set($user->id, $user);
+                    if ($test instanceof User) {
+                        return $test;
+                    }
+
+                    $this->set($user->id, $user);
+                }
             }
-        }
 
-        return $user;
+            return $user;
+        }
     }
 
     /**
      * Обновляет данные пользователя
      *
      * @param User $user
-     * 
+     *
      * @return User
      */
     public function update(User $user)
@@ -65,7 +95,7 @@ class Manager extends ManagerModel
      * Добавляет новую запись в таблицу пользователей
      *
      * @param User $user
-     * 
+     *
      * @return int
      */
     public function insert(User $user)

+ 8 - 0
app/lang/English/common.po

@@ -188,12 +188,20 @@ msgid_plural "%s Replies"
 msgstr[0] "<strong>%s</strong> Reply"
 msgstr[1] "<strong>%s</strong> Replies"
 
+msgid "%s View"
+msgid_plural "%s Views"
+msgstr[0] "<strong>%s</strong> View"
+msgstr[1] "<strong>%s</strong> Views"
+
 msgid "Pages"
 msgstr "Pages:"
 
 msgid "Page %s"
 msgstr "(Page %s)"
 
+msgid "Page %1$s of %2$s"
+msgstr "Page %1$s of %2$s ·"
+
 msgid "BBCode"
 msgstr "BBCode:"
 

+ 0 - 5
app/lang/English/forum.po

@@ -18,11 +18,6 @@ msgstr "Post new topic"
 msgid "Views"
 msgstr "Views"
 
-msgid "%s View"
-msgid_plural "%s Views"
-msgstr[0] "<strong>%s</strong> View"
-msgstr[1] "<strong>%s</strong> Views"
-
 msgid "Moved"
 msgstr "Moved:"
 

+ 9 - 0
app/lang/Russian/common.po

@@ -189,12 +189,21 @@ msgstr[0] "<strong>%s</strong> Ответ"
 msgstr[1] "<strong>%s</strong> Ответа"
 msgstr[2] "<strong>%s</strong> Ответов"
 
+msgid "%s View"
+msgid_plural "%s Views"
+msgstr[0] "<strong>%s</strong> Просмотр"
+msgstr[1] "<strong>%s</strong> Просмотра"
+msgstr[2] "<strong>%s</strong> Просмотров"
+
 msgid "Pages"
 msgstr "Страницы"
 
 msgid "Page %s"
 msgstr "(Страница %s)"
 
+msgid "Page %1$s of %2$s"
+msgstr "Страница %1$s из %2$s ·"
+
 msgid "BBCode"
 msgstr "BB-коды:"
 

+ 0 - 6
app/lang/Russian/forum.po

@@ -18,12 +18,6 @@ msgstr "Создать тему"
 msgid "Views"
 msgstr "Просмотров"
 
-msgid "%s View"
-msgid_plural "%s Views"
-msgstr[0] "<strong>%s</strong> Просмотр"
-msgstr[1] "<strong>%s</strong> Просмотра"
-msgstr[2] "<strong>%s</strong> Просмотров"
-
 msgid "Moved"
 msgstr "Перенесено"
 

+ 1 - 1
app/lang/Russian/topic.po

@@ -55,7 +55,7 @@ msgid "Last edit"
 msgstr "Последний раз отредактировано %1$s (%2$s)"
 
 msgid "Edited"
-msgstr "Изменено"
+msgstr "Отредактировано"
 
 msgid "Report"
 msgstr "Просигналить"

+ 14 - 10
app/templates/forum.tpl

@@ -19,21 +19,25 @@
   @endif
 @endsection
 @section ('pagination')
+  @if ($p->model->pagination)
         <nav class="f-pages">
-  @foreach ($p->model->pagination as $cur)
-    @if ($cur[2])
-          <span class="f-page active">{{ $cur[1] }}</span>
-    @elseif ($cur[1] === 'space')
+    @foreach ($p->model->pagination as $cur)
+      @if ($cur[2])
+          <a class="f-page active" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
+      @elseif ('info' === $cur[1])
+          <span class="f-pinfo">{!! $cur[0] !!}</span>
+      @elseif ('space' === $cur[1])
           <span class="f-page f-pspacer">{!! __('Spacer') !!}</span>
-    @elseif ($cur[1] === 'prev')
+      @elseif ('prev' === $cur[1])
           <a rel="prev" class="f-page f-pprev" href="{!! $cur[0] !!}">{!! __('Previous') !!}</a>
-    @elseif ($cur[1] === 'next')
+      @elseif ('next' === $cur[1])
           <a rel="next" class="f-page f-pnext" href="{!! $cur[0] !!}">{!! __('Next') !!}</a>
-    @else
+      @else
           <a class="f-page" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
-    @endif
-  @endforeach
+      @endif
+    @endforeach
         </nav>
+  @endif
 @endsection
 @extends ('layouts/main')
 @if ($forums = $p->model->subforums)
@@ -120,7 +124,7 @@
       @endif
                 </h3>
                 <p class="f-cmposter">{!! __('by') !!} {{ $topic->poster }}</p>
-      @if ($p->showForum)
+      @if ($p->searchMode)
                 <p class="f-cmforum"><a href="{!! $topic->parent->link !!}">{{ $topic->parent->forum_name }}</a></p>
       @endif
               </div>

+ 57 - 32
app/templates/topic.tpl

@@ -12,37 +12,41 @@
       </ul>
 @endsection
 @section ('linkpost')
-  @if ($p->topic->canReply || $p->topic->closed)
+  @if ($p->model->canReply || $p->model->closed)
         <div class="f-link-post">
-    @if ($p->topic->closed)
+    @if ($p->model->closed)
           {!! __('Topic closed') !!}
     @else
-          <a class="f-btn" href="{!! $p->topic->linkReply !!}">{!! __('Post reply') !!}</a>
+          <a class="f-btn" href="{!! $p->model->linkReply !!}">{!! __('Post reply') !!}</a>
     @endif
         </div>
   @endif
 @endsection
 @section ('pagination')
+  @if ($p->model->pagination)
         <nav class="f-pages">
-  @foreach ($p->topic->pagination as $cur)
-    @if ($cur[2])
-          <span class="f-page active">{{ $cur[1] }}</span>
-    @elseif ($cur[1] === 'space')
+    @foreach ($p->model->pagination as $cur)
+      @if ($cur[2])
+          <a class="f-page active" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
+      @elseif ('info' === $cur[1])
+          <span class="f-pinfo">{!! $cur[0] !!}</span>
+      @elseif ('space' === $cur[1])
           <span class="f-page f-pspacer">{!! __('Spacer') !!}</span>
-    @elseif ($cur[1] === 'prev')
+      @elseif ('prev' === $cur[1])
           <a rel="prev" class="f-page f-pprev" href="{!! $cur[0] !!}">{!! __('Previous') !!}</a>
-    @elseif ($cur[1] === 'next')
+      @elseif ('next' === $cur[1])
           <a rel="next" class="f-page f-pnext" href="{!! $cur[0] !!}">{!! __('Next') !!}</a>
-    @else
+      @else
           <a class="f-page" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
-    @endif
-  @endforeach
+      @endif
+    @endforeach
         </nav>
+  @endif
 @endsection
 @extends ('layouts/main')
     <div class="f-nav-links">
 @yield ('crumbs')
-@if ($p->topic->canReply || $p->topic->closed || $p->topic->pagination)
+@if ($p->model->canReply || $p->model->closed || $p->model->pagination)
       <div class="f-links-b clearfix">
   @yield ('pagination')
   @yield ('linkpost')
@@ -50,16 +54,24 @@
 @endif
     </div>
     <section class="f-main f-topic">
-      <h2>{{ cens($p->topic->subject) }}</h2>
+@if ($p->searchMode)
+      <h2>{{ $p->model->name }}</h2>
+@else
+      <h2>{{ cens($p->model->subject) }}</h2>
+@endif
 @foreach ($p->posts as $post)
-      <article id="p{!! $post->id !!}" class="clearfix f-post @if ($post->user->gender == 1) f-user-male @elseif ($post->user->gender == 2) f-user-female @endif @if ($post->user->online) f-user-online @endif">
+      <article id="p{!! $post->id !!}" class="clearfix f-post @if ($post->user->gender == 1) f-user-male @elseif ($post->user->gender == 2) f-user-female @endif @if ($post->user->online) f-user-online @endif @if (1 === $post->postNumber && ! $p->searchMode) f-post-first @endif">
         <header class="f-post-header clearfix">
-          <h3>{{ cens($p->topic->subject) }} - #{!! $post->postNumber !!}</h3>
-          <span class="f-post-posted"><time datetime="{{ utc($post->posted) }}">{{ dt($post->posted) }}</time></span>
+  @if ($p->searchMode)
+          <h3>@if ($post->id !== $post->parent->first_post_id) {!! __('Re') !!} @endif {{ cens($post->parent->subject) }}</h3>
+  @else
+          <h3>@if ($post->postNumber > 1) {!! __('Re') !!} @endif {{ cens($p->model->subject) }}</h3>
+  @endif
+          <span class="f-post-posted"><a href="{!! $post->link !!}" rel="bookmark"><time datetime="{{ utc($post->posted) }}">{{ dt($post->posted) }}</time></a></span>
   @if ($post->edited)
           <span class="f-post-edited" title="{!! __('Last edit', $post->edited_by, dt($post->edited)) !!}">{!! __('Edited') !!}</span>
   @endif
-          <span class="f-post-number"><a href="{!! $post->link !!}" rel="bookmark">№{!! $post->postNumber !!}</a></span>
+          <span class="f-post-number">#{!! $post->postNumber !!}</span>
         </header>
         <div class="f-post-body clearfix">
           <address class="f-post-left clearfix">
@@ -69,17 +81,17 @@
   @else
               <li class="f-username">{{ $post->user->username }}</li>
   @endif
-  @if ($post->showUserAvatar && $post->user->avatar)
+  @if (! $p->searchMode && $post->showUserAvatar && $post->user->avatar)
               <li class="f-avatar">
                 <img alt="{{ $post->user->username }}" src="{!! $post->user->avatar !!}">
               </li>
   @endif
               <li class="f-usertitle"><span>{{ $post->user->title() }}</span></li>
-  @if ($post->showPostCount && $post->user->num_posts)
+  @if (! $p->searchMode && $post->showPostCount && $post->user->num_posts)
               <li class="f-postcount"><span>{!! __('%s post', $post->user->num_posts, num($post->user->num_posts)) !!}</span></li>
   @endif
             </ul>
-  @if ($post->showUserInfo)
+  @if (! $p->searchMode && $post->showUserInfo)
             <ul class="f-user-info-add">
               <li><span>{!! __('Registered:') !!} {{ dt($post->user->registered, true) }}</span></li>
     @if ($post->user->location)
@@ -87,12 +99,22 @@
     @endif
               <li><span></span></li>
             </ul>
+  @endif
+  @if ($p->searchMode)
+            <ul class="f-post-search-info">
+              <li class="f-psiforum"><span>{!! __('Forum') !!}: <a href="{!! $post->parent->parent->link !!}">{{ $post->parent->parent->forum_name }}</a></span></li>
+              <li class="f-psitopic"><span>{!! __('Topic') !!}: <a href="{!! $post->parent->link !!}">{{ cens($post->parent->subject) }}</a></span></li>
+              <li class="f-psireply"><span>{!! __('%s Reply', $post->parent->num_replies, num($post->parent->num_replies)) !!}</span></li>
+    @if ($post->parent->showViews)
+              <li class="f-psireply"><span>{!! __('%s View', $post->parent->num_views, num($post->parent->num_views)) !!}</span></li>
+    @endif
+            </ul>
   @endif
           </address>
           <div class="f-post-right f-post-main">
             {!! $post->html() !!}
           </div>
-  @if ($post->showSignature && $post->user->signature)
+  @if (! $p->searchMode && $post->showSignature && $post->user->signature)
           <div class="f-post-right f-post-signature">
             <hr>
             {!! $post->user->htmlSign !!}
@@ -103,30 +125,33 @@
           <div class="f-post-left">
             <span></span>
           </div>
-  @if ($post->canReport || $post->canDelete || $post->canEdit || $post->canQuote)
+  @if ($p->searchMode)
+  @else
+    @if ($post->canReport || $post->canDelete || $post->canEdit || $post->canQuote)
           <div class="f-post-right clearfix">
             <ul>
-    @if ($post->canReport)
+      @if ($post->canReport)
               <li class="f-postreport"><a class="f-btn f-minor" href="{!! $post->linkReport !!}">{!! __('Report') !!}</a></li>
-    @endif
-    @if ($post->canDelete)
+      @endif
+      @if ($post->canDelete)
               <li class="f-postdelete"><a class="f-btn" href="{!! $post->linkDelete !!}">{!! __('Delete') !!}</a></li>
-    @endif
-    @if ($post->canEdit)
+      @endif
+      @if ($post->canEdit)
               <li class="f-postedit"><a class="f-btn" href="{!! $post->linkEdit !!}">{!! __('Edit') !!}</a></li>
-    @endif
-    @if ($post->canQuote)
+      @endif
+      @if ($post->canQuote)
               <li class="f-postquote"><a class="f-btn" href="{!! $post->linkQuote !!}">{!! __('Quote') !!}</a></li>
-    @endif
+      @endif
             </ul>
           </div>
+    @endif
   @endif
         </footer>
       </article>
 @endforeach
     </section>
     <div class="f-nav-links">
-@if ($p->topic->canReply || $p->topic->closed || $p->topic->pagination)
+@if ($p->model->canReply || $p->model->closed || $p->model->pagination)
       <div class="f-links-a clearfix">
   @yield ('linkpost')
   @yield ('pagination')

+ 16 - 0
public/style/ForkBB/style.css

@@ -725,6 +725,17 @@ select {
   color: #F8F4E3;
 }
 
+.f-pinfo {
+  display: none;
+}
+
+@media screen and (min-width: 50rem) {
+  .f-pinfo {
+    font-size: 0.875rem;
+    line-height: 1.125rem;
+    display: inline;
+  }
+}
 /********/
 /* Тело */
 /********/
@@ -1804,6 +1815,11 @@ li + li .f-btn {
   padding-bottom: 0.625rem;
 }
 
+.f-post-search-info {
+  font-size: 0.875rem;
+  padding-top: 0.625rem;
+}
+
 @media screen and (min-width: 50rem) {
   .f-search-form .f-fdiv .f-field-w1,
   .f-search-form .f-fdiv .f-field-w2 {