Browse Source

2017-12-02

Visman 7 years ago
parent
commit
4f7b2404f6
42 changed files with 941 additions and 677 deletions
  1. 13 0
      app/Core/Validator.php
  2. 26 0
      app/Core/View.php
  3. 2 2
      app/Models/BanList/IsBanned.php
  4. 12 12
      app/Models/Forum.php
  5. 6 6
      app/Models/ForumList/LoadTree.php
  6. 14 1
      app/Models/ForumList/Refresh.php
  7. 10 12
      app/Models/Pages/Message.php
  8. 266 36
      app/Models/Pages/Post.php
  9. 2 3
      app/Models/Pages/Register.php
  10. 2 217
      app/Models/Pages/Topic.php
  11. 1 6
      app/Models/Post.php
  12. 1 1
      app/Models/Topic.php
  13. 12 21
      app/Models/Topic/Load.php
  14. 24 1
      app/Models/User.php
  15. 1 1
      app/Models/User/LoadUserFromCookie.php
  16. 115 0
      app/lang/English/post.po
  17. 115 0
      app/lang/Russian/post.po
  18. 17 25
      app/templates/admin/group.tpl
  19. 8 16
      app/templates/admin/groups.tpl
  20. 1 1
      app/templates/admin/index.tpl
  21. 8 8
      app/templates/admin/statistics.tpl
  22. 3 3
      app/templates/ban.tpl
  23. 1 1
      app/templates/change_passphrase.tpl
  24. 61 72
      app/templates/forum.tpl
  25. 6 6
      app/templates/index.tpl
  26. 8 12
      app/templates/layouts/admin.tpl
  27. 3 3
      app/templates/layouts/debug.tpl
  28. 24 32
      app/templates/layouts/form.tpl
  29. 20 36
      app/templates/layouts/install.tpl
  30. 15 15
      app/templates/layouts/iswev.tpl
  31. 9 13
      app/templates/layouts/main.tpl
  32. 1 1
      app/templates/layouts/redirect.tpl
  33. 13 13
      app/templates/layouts/stats.tpl
  34. 25 29
      app/templates/layouts/subforums.tpl
  35. 3 3
      app/templates/login.tpl
  36. 1 1
      app/templates/maintenance.tpl
  37. 2 2
      app/templates/message.tpl
  38. 1 1
      app/templates/passphrase_reset.tpl
  39. 28 0
      app/templates/post.tpl
  40. 1 1
      app/templates/register.tpl
  41. 2 2
      app/templates/rules.tpl
  42. 58 62
      app/templates/topic.tpl

+ 13 - 0
app/Core/Validator.php

@@ -82,6 +82,7 @@ class Validator
     {
         $this->c = $container;
         $this->validators = [
+            'absent'        => [$this, 'vAbsent'],
             'array'         => [$this, 'vArray'],
             'checkbox'      => [$this, 'vCheckbox'],
             'email'         => [$this, 'vEmail'],
@@ -364,6 +365,15 @@ class Validator
         return $this->errors;
     }
 
+    protected function vAbsent($v, $value)
+    {
+        if (null === $value) {
+            return [$value, false];
+        } else {
+            return [null, 'The :alias should be absent'];
+        }
+    }
+
     protected function vRequired($v, $value)
     {
         if (is_string($value)) {
@@ -408,6 +418,9 @@ class Validator
                     case 'lower':
                         $value = mb_strtolower($value, 'UTF-8');
                         break;
+                    case 'spaces':
+                        $value = preg_replace('%\s+%u', ' ', $value);
+                        break;
                 }
             }
             return [$value, false];

+ 26 - 0
app/Core/View.php

@@ -22,6 +22,32 @@ class View extends Dirk
         parent::__construct($config);
     }
 
+    /**
+     * Compile Statements that start with "@"
+     *
+     * @param  string  $value
+     * 
+     * @return mixed
+     */
+    protected function compileStatements($value)
+    {
+        return preg_replace_callback(
+            '/[ \t]*+\B@(\w+)([ \t]*)(\( ( (?>[^()]+) | (?3) )* \))?/x',
+            function($match) {
+                if (method_exists($this, $method = 'compile' . ucfirst($match[1]))) {
+                    if (isset($match[3])) {
+                        return $this->$method($match[3]);
+                    } else {
+                        return $this->$method('') . $match[2];
+                    }
+                } else {
+                    return $match[0];
+                }
+            },
+            $value
+        );
+    }
+
     /**
      * Трансформация скомпилированного шаблона
      *

+ 2 - 2
app/Models/BanList/IsBanned.php

@@ -16,11 +16,11 @@ class IsBanned extends MethodModel
      */
     public function isBanned(User $user)
     {
-        $name  = $this->trimToNull($this->model->username, true);
+        $name  = $this->model->trimToNull($this->model->username, true);
         if (null !== $name && isset($this->model->userList[$name])) {
             return 1;
         }
-        $email = $this->trimToNull($this->model->email);
+        $email = $this->model->trimToNull($this->model->email);
         if (null !== $email) {
             foreach ($this->model->otherList as $row) {
                 if (null === $row['email']) {

+ 12 - 12
app/Models/Forum.php

@@ -36,7 +36,7 @@ class Forum extends DataModel
         return $this->post_topics == 1
             || (null === $this->post_topics && $user->g_post_topics == 1)
             || $user->isAdmin
-            || ($user->isAdmMod && isset($this->moderators[$user->id]));
+            || $user->isModerator($this);
     }
 
     /**
@@ -116,22 +116,22 @@ class Forum extends DataModel
             return [];
         }
 
-        $moderators = [];
-        $mods = unserialize($this->a['moderators']);
-        foreach ($mods as $name => $id) {
-            if ($this->c->user->g_view_users == '1') {
-                $moderators[$id] = [
+        if ($this->c->user->g_view_users == '1') {
+            $arr = $this->a['moderators'];
+            foreach($arr as $id => &$cur) {
+                $cur = [
                     $this->c->Router->link('User', [
-                        'id' => $id,
-                        'name' => $name,
+                        'id'   => $id,
+                        'name' => $cur,
                     ]),
-                    $name
+                    $cur,
                 ];
-            } else {
-                $moderators[$id] = $name;
             }
+            unset($cur);
+            return $arr;
+        } else {
+            return $this->a['moderators'];
         }
-        return $moderators;
     }
 
     /**

+ 6 - 6
app/Models/ForumList/LoadTree.php

@@ -56,21 +56,21 @@ class LoadTree extends MethodModel
         ];
 
         if ($this->c->user->isGuest) {
-            $sql = 'SELECT f.id, f.forum_desc, f.moderators, f.num_topics, f.sort_by,
-                           f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.last_topic
+            $sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
+                           f.last_post, f.last_post_id, f.last_poster, f.last_topic
                     FROM ::forums AS f
                     WHERE id IN (?ai:forums)';
         } elseif ($this->c->config->o_forum_subscriptions == '1') {
-            $sql = 'SELECT f.id, f.forum_desc, f.moderators, f.num_topics, f.sort_by,
-                           f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.last_topic,
+            $sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
+                           f.last_post, f.last_post_id, f.last_poster, f.last_topic,
                            mof.mf_mark_all_read, s.user_id AS is_subscribed
                     FROM ::forums AS f 
                     LEFT JOIN ::forum_subscriptions AS s ON (s.user_id=?i:uid AND s.forum_id=f.id) 
                     LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND mof.fid=f.id)
                     WHERE f.id IN (?ai:forums)';
         } else {
-            $sql = 'SELECT f.id, f.forum_desc, f.moderators, f.num_topics, f.sort_by,
-                           f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.last_topic,
+            $sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
+                           f.last_post, f.last_post_id, f.last_poster, f.last_topic,
                            mof.mf_mark_all_read 
                     FROM ::forums AS f 
                     LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:id AND mof.fid=f.id)

+ 14 - 1
app/Models/ForumList/Refresh.php

@@ -35,7 +35,7 @@ class Refresh extends MethodModel
         if ($read == '1') {
             $list = [];
             $sql  = 'SELECT f.cat_id, c.cat_name, f.id, f.forum_name, f.redirect_url, f.parent_forum_id,
-                            f.disp_position, fp.post_topics, fp.post_replies
+                            f.moderators, f.disp_position, fp.post_topics, fp.post_replies
                      FROM ::categories AS c
                      INNER JOIN ::forums AS f ON c.id=f.cat_id
                      LEFT JOIN ::forum_perms AS fp ON (fp.group_id=?i:gid AND fp.forum_id=f.id)
@@ -44,6 +44,7 @@ class Refresh extends MethodModel
 
             $stmt = $this->c->DB->query($sql, $vars);
             while ($row = $stmt->fetch()) {
+                $row['moderators'] = $this->formatModers($row['moderators']);
                 $list[$row['id']] = $row;
             }
             
@@ -59,6 +60,18 @@ class Refresh extends MethodModel
         return $this->list;
     }
 
+    /**
+     * Преобразует строку со списком модераторов в массив
+     * 
+     * @param string $str
+     * 
+     * @return null|array
+     */
+    protected function formatModers($str)
+    {
+        return empty($str) ? null : array_flip(unserialize($str));
+    }
+
     /**
      * Формирует список доступных разделов
      *

+ 10 - 12
app/Models/Pages/Message.php

@@ -2,30 +2,28 @@
 
 namespace ForkBB\Models\Pages;
 
+use ForkBB\Models\Page;
+
 class Message extends Page
 {
-    /**
-     * Имя шаблона
-     * @var string
-     */
-    protected $nameTpl = 'message';
-
     /**
      * Подготавливает данные для шаблона
+     *
      * @param string $message
      * @param bool $back
      * @param int $status
+     *
      * @return Page
      */
     public function message($message, $back = true, $status = 404, array $headers = [])
     {
-        $this->httpStatus = $status;
+        $this->nameTpl     = 'message';
+        $this->httpStatus  = $status;
         $this->httpHeaders = $headers;
-        $this->titles[] = __('Info');
-        $this->data = [
-            'message' => __($message),
-            'back' => $back,
-        ];
+        $this->titles      = __('Info');
+        $this->message     = __($message);
+        $this->back        = $back;
+
         return $this;
     }
 }

+ 266 - 36
app/Models/Pages/Post.php

@@ -2,67 +2,297 @@
 
 namespace ForkBB\Models\Pages;
 
+use ForkBB\Core\Validator;
+use ForkBB\Models\Page;
+
 class Post extends Page
 {
-    use UsersTrait;
-    use OnlineTrait;
     use CrumbTrait;
 
-    /**
-     * Имя шаблона
-     * @var string
-     */
-    protected $nameTpl = 'post';
-
-    /**
-     * Позиция для таблицы онлайн текущего пользователя
-     * @var null|string
-     */
-    protected $onlinePos = 'post';
-
-    /**
-     * Данные по текущей теме
-     * @var array
-     */
-    protected $topic;
-
     /**
      * Подготовка данных для шаблона
+     * 
      * @param array $args
+     * 
      * @return Page
      */
     public function newTopic(array $args)
     {
-        list($fTree, $fDesc, $fAsc) = $this->c->forums;
+        $forum = $this->c->forums->forum($args['id']);
 
-        // раздел отсутствует в доступных
-        if (empty($fDesc[$args['id']])) {
+        // раздел отсутствует в доступных или является ссылкой
+        if (empty($forum) || $forum->redirect_url) {
             return $this->c->Message->message('Bad request');
         }
 
-        $parent = isset($fDesc[$args['id']][0]) ? $fDesc[$args['id']][0] : 0;
-        $perm = $fTree[$parent][$args['id']];
+        $user = $this->c->user;
 
-        // раздел является ссылкой
-        if (null !== $perm['redirect_url']) {
+        if (! $user->isAdmin
+            && (null === $forum->post_topics && $user->g_post_topics == '0' || $forum->post_topics == '0')
+            && ! $user->isModerator($forum)
+        ) {
             return $this->c->Message->message('Bad request');
         }
 
-        $vars = [':fid' => $args['id']];
-        $sql = 'SELECT f.* FROM ::forums AS f WHERE f.id=?i:fid';
+        $this->c->Lang->load('post');
 
-        $forum = $this->c->DB->query($sql, $vars)->fetch();
-        $user = $this->c->user;
+        $this->nameTpl   = 'post';
+        $this->onlinePos = 'forum-' . $forum->id;
+        $this->canonical = $this->c->Router->link('NewTopic', $args);
+        $this->robots    = 'noindex';
+        $this->crumbs    = $this->crumbs(__('Post new topic'), $forum);
+        $this->form      = $this->messageForm($forum, 'NewTopic', $args, true);
+        
+        return $this;
+    }
 
-        $moders = empty($forum['moderators']) ? [] : array_flip(unserialize($forum['moderators']));
+    public function newTopicPost(array $args)
+    {
+        $this->c->Lang->load('post');
 
-        if (! $user->isAdmin
-            && (! $user->isAdmMod || ! isset($moders[$user->id]))
-            && (null === $perm['post_topics'] && $user->g_post_topics == '0' || $perm['post_topics'] == '0')
-        ) {
+        if ($this->c->user->isGuest) {
+            $ruleEmail    = ($this->c->config->p_force_guest_email == '1' ? 'required|' : '') . 'string:trim,lower|email|check_email';
+            $ruleUsername = 'required|string:trim,spaces|min:2|max:25|login|check_username';
+        } else {
+            $ruleEmail    = 'absent';
+            $ruleUsername = 'absent';
+        }
+            
+        $v = $this->c->Validator->addValidators([
+            'check_email'    => [$this, 'vCheckEmail'],
+            'check_username' => [$this, 'vCheckUsername'],
+            'check_subject'  => [$this, 'vCheckSubject'],
+        ])->setRules([
+            'token'    => 'token:NewTopic',
+            'message'  => 'required|string:trim|max:65536',
+            'email'    => [$ruleEmail, __('Email')],
+            'username' => [$ruleUsername, __('Username')],
+            'subject'  => ['required|string:trim,spaces|min:1|max:70|check_subject', __('Subject')],
+        ])->setArguments([
+            'token' => $args,
+        ])->setMessages([
+            'username.login'    => __('Login format'),
+        ]);
+
+        if (! $v->validation($_POST)) {
+            $this->fIswev = $v->getErrors();
+            $args['_vars'] = $v->getData();
+            return $this->newTopic($args);
+        }
+
+
+        exit('ok');
+    }
+
+    public function newReply(array $args)
+    {
+        $topic = $this->c->ModelTopic->load($args['id']); //????
+
+        if (empty($topic->id) || $topic->moved_to || ! $topic->canReply) { //????
             return $this->c->Message->message('Bad request');
         }
 
+        $this->c->Lang->load('post');
+        
+        $this->nameTpl   = 'post';
+        $this->onlinePos = 'topic-' . $topic->id;
+        $this->canonical = $this->c->Router->link('NewReply', $args);
+        $this->robots    = 'noindex';
+        $this->crumbs    = $this->crumbs(__('Post a reply'), $topic);
+        $this->form      = $this->messageForm($topic, 'NewReply', $args);
+                
         return $this;
     }
+
+    public function newReplyPost(array $args)
+    {
+        
+    }
+
+    /**
+     * Дополнительная проверка email
+     * 
+     * @param Validator $v
+     * @param string $email
+     * 
+     * @return array
+     */
+    public function vCheckEmail(Validator $v, $email)
+    {
+        $error = false;
+        $user = $this->c->ModelUser;
+        $user->__email = $email;
+
+        // email забанен
+        if ($this->c->bans->isBanned($user) > 0) {
+            $error = __('Banned email');
+        }
+        return [$email, $error];
+    }
+
+    /**
+     * Дополнительная проверка username
+     * 
+     * @param Validator $v
+     * @param string $username
+     * 
+     * @return array
+     */
+    public function vCheckUsername(Validator $v, $username)
+    {
+        $error = false;
+        $user = $this->c->ModelUser;
+        $user->__username = $username;
+
+        // username = Гость
+        if (preg_match('%^(guest|' . preg_quote(__('Guest'), '%') . ')$%iu', $username)) {
+            $error = __('Username guest');
+        // цензура
+        } elseif ($user->cens()->$username !== $username) {
+            $error = __('Username censor');
+        // username забанен
+        } elseif ($this->c->bans->isBanned($user) > 0) {
+            $error = __('Banned username');
+        }
+        return [$username, $error];
+    }
+
+    /**
+     * Дополнительная проверка subject
+     * 
+     * @param Validator $v
+     * @param string $username
+     * 
+     * @return array
+     */
+    public function vCheckSubject(Validator $v, $subject)
+    {
+        $error = false;
+        if ($this->c->censorship->censor($subject) == '') {
+            $error = __('No subject after censoring');
+        } elseif ($this->c->config->p_subject_all_caps == '0' 
+            && mb_strtolower($subject, 'UTF-8') !== $subject
+            && mb_strtoupper($subject, 'UTF-8') === $subject
+        ) {
+            $error = __('All caps subject');
+        }
+        return [$subject, $error];
+    }
+
+    /**
+     * Возвращает данные для построения формы сообщения
+     * 
+     * @param Model $model
+     * @param string $marker
+     * @param array $args
+     * @param bool $editSubject
+     * 
+     * @return array
+     */
+    protected function messageForm($model, $marker, array $args, $editSubject = false)
+    {
+        $vars = isset($args['_vars']) ? $args['_vars'] : null;
+        unset($args['_vars']);
+
+        $form = [
+            'action' => $this->c->Router->link($marker, $args),
+            'hidden' => [
+                'token' => $this->c->Csrf->create($marker, $args),
+            ],
+            'sets'   => [],
+            'btns'   => [
+                'submit'  => ['submit', __('Submit'), 's'],
+                'preview' => ['submit', __('Preview'), 'p'],
+            ],
+        ];
+
+        $fieldset = [];
+        if ($this->c->user->isGuest) {
+            $fieldset['username'] = [
+                'dl'        => 't1',
+                'type'      => 'text',
+                'maxlength' => 25,
+                'title'     => __('Username'),
+                'required'  => true,
+                'pattern'   => '^.{2,25}$',
+                'value'     => isset($vars['username']) ? $vars['username'] : null,
+            ];
+            $fieldset['email'] = [
+                'dl'        => 't2',
+                'type'      => 'text',
+                'maxlength' => 80,
+                'title'     => __('Email'),
+                'required'  => $this->c->config->p_force_guest_email == '1',
+                'pattern'   => '.+@.+',
+                'value'     => isset($vars['email']) ? $vars['email'] : null,
+            ];
+        }
+
+        if ($editSubject) {
+            $fieldset['subject'] = [
+                'type'      => 'text',
+                'maxlength' => 70,
+                'title'     => __('Subject'),
+                'required'  => true,
+                'value'     => isset($vars['subject']) ? $vars['subject'] : null,
+            ];
+        }
+
+        $fieldset['message'] = [
+            'type'     => 'textarea',
+            'title'    => __('Message'),
+            'required' => true,
+            'value'    => isset($vars['message']) ? $vars['message'] : null,
+            'bb'       => [
+                ['link', __('BBCode'), __($this->c->config->p_message_bbcode == '1' ? 'on' : 'off')],
+                ['link', __('url tag'), __($this->c->config->p_message_bbcode == '1' && $this->c->user->g_post_links == '1' ? 'on' : 'off')],
+                ['link', __('img tag'), __($this->c->config->p_message_bbcode == '1' && $this->c->config->p_message_img_tag == '1' ? 'on' : 'off')],
+                ['link', __('Smilies'), __($this->c->config->o_smilies == '1' ? 'on' : 'off')],
+            ],
+        ];
+        $form['sets'][] = [
+            'fields' => $fieldset,
+        ];
+
+        $fieldset = [];
+        if ($this->c->user->isAdmin || $this->c->user->isModerator($model)) {
+            $fieldset['stick_topic'] = [
+                'type'    => 'checkbox',
+                'label'   => __('Stick topic'),
+                'value'   => '1',
+                'checked' => ! empty($vars['stick_topic']),
+            ];
+            if ($editSubject) {
+                $fieldset['stick_fp'] = [
+                    'type'    => 'checkbox',
+                    'label'   => __('Stick first post'),
+                    'value'   => '1',
+                    'checked' => ! empty($vars['stick_fp']),
+                ];
+            } else {
+                $fieldset['merge_post'] = [
+                    'type'    => 'checkbox',
+                    'label'   => __('Merge posts'),
+                    'value'   => '1',
+                    'checked' => isset($vars['merge_post']) ? (bool) $vars['merge_post'] : 1,
+                ];
+            }
+        }
+        if ($this->c->config->o_smilies == '1') {
+            $fieldset['hide_smilies'] = [
+                'type'    => 'checkbox',
+                'label'   => __('Hide smilies'),
+                'value'   => '1',
+                'checked' => ! empty($vars['hide_smilies']),
+            ];
+        }
+        if ($fieldset) {
+            $form['sets'][] = [
+                'legend' => __('Options'),
+                'fields' => $fieldset,
+            ];
+        }
+
+        return $form;
+    }
 }

+ 2 - 3
app/Models/Pages/Register.php

@@ -26,7 +26,7 @@ class Register extends Page
             'agree'    => 'required|token:Register',
             'on'       => 'integer',
             'email'    => ['required_with:on|string:trim,lower|email|check_email', __('Email')],
-            'username' => ['required_with:on|string:trim|min:2|max:25|login|check_username', __('Username')],
+            'username' => ['required_with:on|string:trim,spaces|min:2|max:25|login|check_username', __('Username')],
             'password' => ['required_with:on|string|min:16|password', __('Passphrase')],
         ])->setMessages([
             'agree.required'    => ['cancel', 'cancel'],
@@ -57,7 +57,7 @@ class Register extends Page
         $this->agree      = $v->agree;
         $this->on         = '1';
         $this->email      = $v->email;
-        $this->username  = $v->username;
+        $this->username   = $v->username;
 
         return $this;
     }
@@ -96,7 +96,6 @@ class Register extends Page
      */
     public function vCheckUsername(Validator $v, $username)
     {
-        $username = preg_replace('%\s+%su', ' ', $username);
         $error = false;
         $user = $this->c->ModelUser;
         $user->__username = $username;

+ 2 - 217
app/Models/Pages/Topic.php

@@ -137,186 +137,6 @@ class Topic extends Page
 
         $user = $this->c->user;
 
-
-/*
-        list($fTree, $fDesc, $fAsc) = $this->c->forums;
-
-        $moders = empty($topic['moderators']) ? [] : array_flip(unserialize($topic['moderators']));
-        $parent = isset($fDesc[$topic['forum_id']][0]) ? $fDesc[$topic['forum_id']][0] : 0;
-        $perm = $fTree[$parent][$topic['forum_id']];
-
-        if($user->isBot) {
-            $perm['post_replies'] = 0;
-        }
-
-        $newOn = null;
-        if ($user->isAdmin) {
-            $newOn = true;
-        } elseif ($topic['closed'] == '1') {
-            $newOn = false;
-        } elseif ($perm['post_replies'] === 1
-            || (null === $perm['post_replies'] && $user->g_post_replies == '1')
-            || ($user->isAdmMod && isset($moders[$user->id]))
-        ) {
-            $newOn = true;
-        }
-
-
-        // парсер и его настройка для сообщений
-        $bbcodes = include $this->c->DIR_CONFIG . '/defaultBBCode.php';
-        $smilies = $this->c->smilies->list; //????
-        foreach ($smilies as &$cur) {
-            $cur = $this->c->PUBLIC_URL . '/img/sm/' . $cur;
-        }
-        unset($cur);
-        $bbInfo = $this->c->BBCODE_INFO;
-        $bbWList = $this->c->config->p_message_bbcode == '1' ? null : [];
-        $bbBList = $this->c->config->p_message_img_tag == '1' ? [] : ['img'];
-        $parser = $this->c->Parser;
-        $parser->setBBCodes($bbcodes)
-               ->setAttr('isSign', false)
-               ->setWhiteList($bbWList)
-               ->setBlackList($bbBList);
-        if ($user->show_smilies == '1') {
-            $parser->setSmilies($smilies)
-                   ->setSmTpl($bbInfo['smTpl'], $bbInfo['smTplTag'], $bbInfo['smTplBl']);
-        }
-
-        $genders = [1 => ' f-user-male', 2 => ' f-user-female'];
-        $postCount = 0;
-        $posts = [];
-        $signs = [];
-        $posters = [];
-        $timeMax = 0;
-        while ($cur = $stmt->fetch()) {
-            // данные по автору сообшения
-            if (isset($posters[$cur['poster_id']])) {
-                $post = $posters[$cur['poster_id']];
-            } else {
-                $post = [
-                    'poster'            => $cur['username'],
-                    'poster_id'         => $cur['poster_id'],
-                    'poster_title'      => $this->c->censorship->censor($this->userGetTitle($cur)),
-                    'poster_avatar'     => null,
-                    'poster_registered' => null,
-                    'poster_location'   => null,
-                    'poster_info_add'   => false,
-                    'poster_link'       => null,
-                    'poster_posts'      => null,
-                    'poster_gender'     => '',
-                    'poster_online'     => '',
-
-                ];
-                if ($cur['poster_id'] > 1) {
-                    if ($user->g_view_users == '1') {
-                        $post['poster_link'] = $this->c->Router->link('User', ['id' => $cur['poster_id'], 'name' => $cur['username']]);
-                    }
-                    if ($this->c->config->o_avatars == '1' && $user->show_avatars == '1') {
-                        $post['poster_avatar'] = $this->userGetAvatarLink($cur['poster_id']);
-                    }
-                    if ($this->c->config->o_show_user_info == '1') {
-                        $post['poster_info_add'] = true;
-
-                        $post['poster_registered'] = $this->time($cur['registered'], true);
-
-                        $post['poster_posts']     = $this->number($cur['num_posts']);
-                        $post['poster_num_posts'] = $cur['num_posts'];
-
-                        if ($cur['location'] != '') {
-                            $post['poster_location'] = $this->c->censorship->censor($cur['location']);
-                        }
-                        if (isset($genders[$cur['gender']])) {
-                            $post['poster_gender'] = $genders[$cur['gender']];
-                        }
-                    }
-                    $post['poster_online'] = ' f-user-online'; //????
-
-                    $posters[$cur['poster_id']] = $post;
-
-                    if ($this->c->config->o_signatures == '1'
-                        && $cur['signature'] != ''
-                        && $user->show_sig == '1'
-                        && ! isset($signs[$cur['poster_id']])
-                    ) {
-                        $signs[$cur['poster_id']] = $cur['signature'];
-                    }
-                }
-            }
-
-            // данные по сообщению
-            $post['id']         = $cur['id'];
-            $post['link']       = $this->c->Router->link('ViewPost', ['id' => $cur['id']]);
-            $post['posted']     = $this->time($cur['posted']);
-            $post['posted_utc'] = gmdate('Y-m-d\TH:i:s\Z', $cur['posted']);
-
-            $timeMax = max($timeMax, $cur['posted']);
-
-            $parser->parse($this->c->censorship->censor($cur['message']));
-            if ($this->c->config->o_smilies == '1' && $user->show_smilies == '1' && $cur['hide_smilies'] == '0') {
-                $parser->detectSmilies();
-            }
-            $post['message'] = $parser->getHtml();
-
-            // номер сообшения в теме
-            if ($stickFP && $offset > 0 && $cur['id'] == $topic['first_post_id']) {
-                $post['post_number'] = 1;
-            } else {
-                ++$postCount;
-                $post['post_number'] = $offset + $postCount;
-            }
-
-            // данные по элементам управления
-            $controls = [];
-            $vars = ['id' => $cur['id']];
-            if (! $user->isAdmin && ! $user->isGuest) {
-                $controls['report'] = [$this->c->Router->link('ReportPost', $vars), 'Report'];
-            }
-            if ($user->isAdmin
-                || ($user->isAdmMod && isset($moders[$user->id]) && ! in_array($cur['poster_id'], $this->c->admins->list)) //????
-            ) {
-                $controls['delete'] = [$this->c->Router->link('DeletePost', $vars), 'Delete'];
-                $controls['edit'] = [$this->c->Router->link('EditPost', $vars), 'Edit'];
-            } elseif ($topic['closed'] != '1'
-                && $cur['poster_id'] == $user->id
-                && ($user->g_deledit_interval == '0' || $cur['edit_post'] == '1' || time() - $cur['posted'] < $user->g_deledit_interval)
-            ) {
-                if (($cur['id'] == $topic['first_post_id'] && $user->g_delete_topics == '1') || ($cur['id'] != $topic['first_post_id'] && $user->g_delete_posts == '1')) {
-                    $controls['delete'] = [$this->c->Router->link('DeletePost', $vars), 'Delete'];
-                }
-                if ($user->g_edit_posts == '1') {
-                    $controls['edit'] = [$this->c->Router->link('EditPost', $vars), 'Edit'];
-                }
-            }
-            if ($newOn) {
-                $controls['quote'] = [$this->c->Router->link('NewReply', ['id' => $topic['id'], 'quote' => $cur['id']]), 'Reply'];
-            }
-
-            $post['controls'] = $controls;
-
-            $posts[] = $post;
-        }
-
-        if ($signs) {
-            // настройка парсера для подписей
-            $bbWList = $this->c->config->p_sig_bbcode == '1' ? $bbInfo['forSign'] : [];
-            $bbBList = $this->c->config->p_sig_img_tag == '1' ? [] : ['img'];
-            $parser->setAttr('isSign', true)
-                   ->setWhiteList($bbWList)
-                   ->setBlackList($bbBList);
-
-            foreach ($signs as &$cur) {
-                $parser->parse($this->c->censorship->censor($cur));
-                if ($this->c->config->o_smilies_sig == '1' && $user->show_smilies == '1') {
-                    $parser->detectSmilies();
-                }
-                $cur = $parser->getHtml();
-            }
-            unset($cur);
-        }
-
-        $topic['subject'] = $this->c->censorship->censor($topic['subject']);
-
-*/
         // данные для формы быстрого ответа
         $form = null;
         if ($topic->canReply && $this->c->config->o_quickpost == '1') {
@@ -368,7 +188,7 @@ class Topic extends Page
             ];
 
             $fieldset = [];
-            if ($user->isAdmin || ($user->isAdmMod && isset($moders[$user->id]))) {
+            if ($user->isAdmin || $user->isModerator($topic)) {
                 $fieldset['merge'] = [
                     'type'    => 'checkbox',
                     'label'   => __('Merge posts'),
@@ -399,42 +219,7 @@ class Topic extends Page
             $topic->incViews();
         }
         $topic->updateVisits();
-/*
-        if (! $user->isGuest) {
-            $vars = [
-                ':uid'   => $user->id,
-                ':tid'   => $topic->id,
-                ':read'  => $topic->mt_last_read,
-                ':visit' => $topic->mt_last_visit,
-            ];
-            $flag = false;
-            $lower = max((int) $user->u_mark_all_read, (int) $topic->mf_mark_all_read, (int) $topic->mt_last_read); //????
-            if ($timeMax > $lower) {
-                $vars[':read'] = $timeMax;
-                $flag = true;
-            }
-            $upper = max($lower, (int) $topic->mt_last_visit, (int) $user->last_visit); //????
-            if ($topic->last_post > $upper) {
-                $vars[':visit'] = $topic->last_post;
-                $flag = true;
-            }
-            if ($flag) {
-                if (empty($topic->mt_last_read) && empty($topic->mt_last_visit)) {
-                    $this->c->DB->exec('INSERT INTO ::mark_of_topic (uid, tid, mt_last_visit, mt_last_read)
-                                        SELECT ?i:uid, ?i:tid, ?i:visit, ?i:read
-                                        FROM ::groups
-                                        WHERE NOT EXISTS (SELECT 1
-                                                          FROM ::mark_of_topic
-                                                          WHERE uid=?i:uid AND tid=?i:tid)
-                                        LIMIT 1', $vars);
-                } else {
-                    $this->c->DB->exec('UPDATE ::mark_of_topic
-                                        SET mt_last_visit=?i:visit, mt_last_read=?i:read
-                                        WHERE uid=?i:uid AND tid=?i:tid', $vars);
-                }
-            }
-        }
-*/
+
         return $this;
     }
 }

+ 1 - 6
app/Models/Post.php

@@ -83,12 +83,7 @@ class Post extends DataModel
         if (! $user->isAdmin && ! $user->isGuest) {
             $controls['report'] = [$this->c->Router->link('ReportPost', $vars), 'Report'];
         }
-        if ($user->isAdmin
-            || ($user->isAdmMod
-                && ! $this->user->isAdmin
-                && isset($this->parent->parent->moderators[$user->id])
-            )
-        ) {
+        if ($user->isAdmin || ($user->isModerator($this) && ! $this->user->isAdmin)) {
             $controls['delete'] = [$this->c->Router->link('DeletePost', $vars), 'Delete'];
             $controls['edit'] = [$this->c->Router->link('EditPost', $vars), 'Edit'];
         } elseif ($this->parent->closed != '1'

+ 1 - 1
app/Models/Topic.php

@@ -37,7 +37,7 @@ class Topic extends DataModel
             return false;
         } elseif ($this->parent->post_replies == '1'
             || (null === $this->parent->post_replies && $this->c->user->g_post_replies == '1')
-            || ($this->c->user->isAdmMod && isset($this->parent->moderators[$this->c->user->id]))
+            || $this->c->user->isModerator($this)
         ) {
             return true;
         } else {

+ 12 - 21
app/Models/Topic/Load.php

@@ -22,19 +22,17 @@ class Load extends MethodModel
                 ':uid' => $this->c->user->id,
             ];
             if ($this->c->user->isGuest) {
-                $sql = 'SELECT t.*, f.moderators
+                $sql = 'SELECT t.*
                         FROM ::topics AS t
-                        INNER JOIN ::forums AS f ON f.id=t.forum_id
                         INNER JOIN ::posts AS p ON t.id=p.topic_id
                         WHERE p.id=?i:pid';
 
             } else {
-                $sql = 'SELECT t.*, f.moderators, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
+                $sql = 'SELECT t.*, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
                         FROM ::topics AS t
-                        INNER JOIN ::forums AS f ON f.id=t.forum_id
                         INNER JOIN ::posts AS p ON t.id=p.topic_id
                         LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
-                        LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND f.id=mof.fid)
+                        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=?i:pid';
             }
@@ -44,17 +42,15 @@ class Load extends MethodModel
                 ':uid' => $this->c->user->id,
             ];
             if ($this->c->user->isGuest) {
-                $sql = 'SELECT t.*, f.moderators
+                $sql = 'SELECT t.*
                         FROM ::topics AS t
-                        INNER JOIN ::forums AS f ON f.id=t.forum_id
                         WHERE t.id=?i:tid';
 
             } else {
-                $sql = 'SELECT t.*, f.moderators, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
+                $sql = 'SELECT t.*, s.user_id AS is_subscribed, mof.mf_mark_all_read, mot.mt_last_visit, mot.mt_last_read
                         FROM ::topics AS t
-                        INNER JOIN ::forums AS f ON f.id=t.forum_id
                         LEFT JOIN ::topic_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=?i:uid)
-                        LEFT JOIN ::mark_of_forum AS mof ON (mof.uid=?i:uid AND f.id=mof.fid)
+                        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 t.id=?i:tid';
             }
@@ -64,11 +60,9 @@ class Load extends MethodModel
 
         // тема отсутствует или недоступна
         if (empty($data)) {
-            return $this->emptyTopic();
+            return $this->model->setAttrs([]);
         }
 
-        $forForum['moderators'] = $data['moderators'];
-        unset($data['moderators']);
         if (! $this->c->user->isGuest) {
             $forForum['mf_mark_all_read'] = $data['mf_mark_all_read'];
             unset($data['mf_mark_all_read']);
@@ -76,18 +70,15 @@ class Load extends MethodModel
         $this->model->setAttrs($data);
         $forum = $this->model->parent;
 
-        // раздел не доступен
+        // раздел недоступен
         if (empty($forum)) {
-            return $this->emptyTopic();
+            return $this->model->setAttrs([]);
         }
 
-        $forum->replAttrs($forForum);
+        if (! empty($forForum)) {
+            $forum->replAttrs($forForum);
+        }
 
         return $this->model;
     }
-
-    protected function emptyTopic()
-    {
-        return $this->model->setAttrs([]);
-    }
 }

+ 24 - 1
app/Models/User.php

@@ -2,8 +2,11 @@
 
 namespace ForkBB\Models;
 
-use ForkBB\Models\DataModel;
 use ForkBB\Core\Container;
+use ForkBB\Models\DataModel;
+use ForkBB\Models\Model;
+use ForkBB\Models\Forum;
+use RuntimeException;
 
 class User extends DataModel
 {
@@ -67,6 +70,26 @@ class User extends DataModel
             || $this->g_moderator == '1';
     }
 
+    /**
+     * Статус модератора для указанной модели
+     * 
+     * @param Model $model
+     * 
+     * @throws RuntimeException
+     * 
+     * @return bool
+     */
+    public function isModerator(Model $model)
+    {
+        while (! $model instanceof Forum) {
+            $model = $model->parent;
+            if (! $model instanceof Model) {
+                throw new RuntimeException('Moderator\'s rights can not be found');
+            }
+        }
+        return isset($model->moderators[$this->id]);
+    }
+
     /**
      * Время последнего действия пользователя
      *

+ 1 - 1
app/Models/User/LoadUserFromCookie.php

@@ -23,7 +23,7 @@ class LoadUserFromCookie extends MethodModel
                 $this->model = $this->loadUser(1);
             } elseif ($this->c->config->o_check_ip == '1'
                 && $this->model->isAdmMod
-                && $this->model->registration_ip != $this->model->ip
+                && $this->model->registration_ip !== $this->model->ip
             ) {
                 $this->model = $this->loadUser(1);
             }

+ 115 - 0
app/lang/English/post.po

@@ -0,0 +1,115 @@
+#
+msgid ""
+msgstr ""
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"Project-Id-Version: ForkBB\n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Last-Translator: \n"
+"Language-Team: ForkBB <mio.visman@yandex.ru>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: en\n"
+
+msgid "No subject"
+msgstr "Topics must contain a subject."
+
+msgid "No subject after censoring"
+msgstr "Topics must contain a subject. After applying censoring filters, your subject was empty."
+
+msgid "Too long subject"
+msgstr "Subjects cannot be longer than 70 characters."
+
+msgid "No message"
+msgstr "You must enter a message."
+
+msgid "No message after censoring"
+msgstr "You must enter a message. After applying censoring filters, your message was empty."
+
+msgid "Too long message"
+msgstr "Posts cannot be longer than %s characters."
+
+msgid "All caps subject"
+msgstr "Subjects cannot contain only capital letters."
+
+msgid "All caps message"
+msgstr "Posts cannot contain only capital letters."
+
+msgid "Empty after strip"
+msgstr "It seems your post consisted of empty BBCodes only. It is possible that this happened because e.g. the innermost quote was discarded because of the maximum quote depth level."
+
+msgid "Post errors"
+msgstr "Post errors"
+
+msgid "Post errors info"
+msgstr "The following errors need to be corrected before the message can be posted:"
+
+msgid "Post preview"
+msgstr "Post preview"
+
+msgid "Guest name"
+msgstr "Name"
+
+msgid "Post redirect"
+msgstr "Post entered. Redirecting …"
+
+msgid "Post a reply"
+msgstr "Post a reply"
+
+msgid "Post new topic"
+msgstr "Post new topic"
+
+msgid "Hide smilies"
+msgstr "Never show smilies as icons for this post"
+
+msgid "Subscribe"
+msgstr "Subscribe to this topic"
+
+msgid "Stay subscribed"
+msgstr "Stay subscribed to this topic"
+
+msgid "Topic review"
+msgstr "Topic review (newest first)"
+
+msgid "Flood start"
+msgstr "At least %s seconds have to pass between posts. Please wait %s seconds and try posting again."
+
+msgid "Preview"
+msgstr "Preview"
+
+msgid "EditPost edit"
+msgstr "To allow to edit the given message without restrictions"
+
+msgid "Stick first post"
+msgstr "To stick the first post on all pages of topic"
+
+msgid "Edit post legend"
+msgstr "Edit the post and submit changes"
+
+msgid "Silent edit"
+msgstr "Silent edit (don't display \"Edited by ...\" in topic view)"
+
+msgid "Edit post"
+msgstr "Edit post"
+
+msgid "Merge posts"
+msgstr "Merge with previous if it yours"
+
+msgid "Edit redirect"
+msgstr "Post updated. Redirecting …"
+
+msgid "Login format"
+msgstr "The username must begin with a letter. May contain letters, numbers, spaces, dots, dashes and underscores."
+
+msgid "Banned email"
+msgstr "The email address you entered is banned in this forum."
+
+msgid "Username guest"
+msgstr "The username guest is reserved. Please choose another username."
+
+msgid "Username censor"
+msgstr "The username you entered contains one or more censored words. Please choose another username."
+
+msgid "Banned username"
+msgstr "The username you entered is banned in this forum. Please choose another username."

+ 115 - 0
app/lang/Russian/post.po

@@ -0,0 +1,115 @@
+#
+msgid ""
+msgstr ""
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+"Project-Id-Version: ForkBB\n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Last-Translator: \n"
+"Language-Team: ForkBB <mio.visman@yandex.ru>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: ru\n"
+
+msgid "No subject"
+msgstr "Тема должна содержать заголовок."
+
+msgid "No subject after censoring"
+msgstr "Тема должна содержать заголовок. После применения цензуры ваше название темы было удалено."
+
+msgid "Too long subject"
+msgstr "Заголовок не может быть длиннее 70 символов."
+
+msgid "No message"
+msgstr "Вы должны ввести сообщение."
+
+msgid "No message after censoring"
+msgstr "Вы должны ввести сообщение. После применения цензуры ваше сообщение было удалено."
+
+msgid "Too long message"
+msgstr "Сообщение не может быть длиннее %s символов."
+
+msgid "All caps subject"
+msgstr "Заголовок не должен состоять из одних заглавных букв."
+
+msgid "All caps message"
+msgstr "Сообщение не должно состоять из одних заглавных букв."
+
+msgid "Empty after strip"
+msgstr "Кажется, ваше сообщение состоит только из пустых BB-кодов. Это могло произойти, например, из-за превышения глубины цитирования сообщений."
+
+msgid "Post errors"
+msgstr "Ошибки"
+
+msgid "Post errors info"
+msgstr "Следующие ошибки необходимо исправить, прежде чем сообщение будет опубликовано:"
+
+msgid "Post preview"
+msgstr "Предварительный просмотр сообщения"
+
+msgid "Guest name"
+msgstr "Имя"
+
+msgid "Post redirect"
+msgstr "Сообщение сохранено. Переадресация &hellip;"
+
+msgid "Post a reply"
+msgstr "Публикация ответа"
+
+msgid "Post new topic"
+msgstr "Публикация новой темы"
+
+msgid "Hide smilies"
+msgstr "Никогда не показывать смайлы в виде картинок в этом сообщении"
+
+msgid "Subscribe"
+msgstr "Подписаться на эту тему"
+
+msgid "Stay subscribed"
+msgstr "Оставить подписку на эту тему"
+
+msgid "Topic review"
+msgstr "Обзор темы (новое вверху)"
+
+msgid "Flood start"
+msgstr "Хотя бы %s секунд должно пройти между отправкой сообщений. Пожалуйста, подождите %s секунд и попробуйте снова."
+
+msgid "Preview"
+msgstr "Предпросмотр"
+
+msgid "EditPost edit"
+msgstr "Разрешить редактировать данное сообщение без ограничений"
+
+msgid "Stick first post"
+msgstr "Закрепить первое сообщение на всех страницах темы"
+
+msgid "Edit post legend"
+msgstr "Редактирование сообщения"
+
+msgid "Silent edit"
+msgstr "Скрытое редактирование (не показывать \"Отредактировано &hellip;\" в теме)"
+
+msgid "Edit post"
+msgstr "Редактирование сообщения"
+
+msgid "Merge posts"
+msgstr "Соединить с предыдущим сообщением, если оно ваше"
+
+msgid "Edit redirect"
+msgstr "Сообщение обновлено. Переадресация &hellip;"
+
+msgid "Login format"
+msgstr "Имя пользователя должно начинаться с буквы. Может содержать буквы, цифры, пробел, точку, дефис и знак подчеркивания."
+
+msgid "Banned email"
+msgstr "Введенный почтовый адрес заблокирован."
+
+msgid "Username guest"
+msgstr "Гость - зарезервированное имя. Пожалуйста, выберите другое имя."
+
+msgid "Username censor"
+msgstr "Выбранное имя пользователя содержит запрещенные слова. Пожалуйста, выберите другое имя."
+
+msgid "Banned username"
+msgstr "Введенное имя пользователя заблокировано. Пожалуйста, выберите другое имя."

+ 17 - 25
app/templates/admin/group.tpl

@@ -1,43 +1,35 @@
-@extends('layouts/admin')
+@extends ('layouts/admin')
       <section class="f-admin">
         <h2>{!! __('Group settings head') !!}</h2>
         <div class="f-fdiv">
           <form class="f-form" method="post" action="{!! $p->formAction !!}">
             <input type="hidden" name="token" value="{!! $p->formToken !!}">
             <dl>
-@foreach($p->form as $key => $cur)
+@foreach ($p->form as $key => $cur)
               <dt>{!! $cur['title'] !!}</dt>
               <dd>
-@if($cur['type'] == 'text')
-                <input class="f-ctrl" @if(isset($cur['required'])){!! 'required' !!}@endif type="text" name="{{ $key }}" maxlength="{!! $cur['maxlength'] !!}" value="{{ $cur['value'] }}" tabindex="{!! ++$p->tabindex !!}">
-@elseif($cur['type'] == 'number')
+  @if ($cur['type'] == 'text')
+                <input class="f-ctrl" @if (isset($cur['required'])) required @endif type="text" name="{{ $key }}" maxlength="{!! $cur['maxlength'] !!}" value="{{ $cur['value'] }}" tabindex="{!! ++$p->tabindex !!}">
+  @elseif ($cur['type'] == 'number')
                 <input class="f-ctrl" type="number" name="{{ $key }}" min="{!! $cur['min'] !!}" max="{!! $cur['max'] !!}" value="{{ $cur['value'] }}" tabindex="{!! ++$p->tabindex !!}">
-@elseif($cur['type'] == 'select')
+  @elseif ($cur['type'] == 'select')
                 <select class="f-ctrl" name="{{ $key }}" tabindex="{!! ++$p->tabindex !!}">
-@foreach($cur['options'] as $v => $n)
-@if($v == $cur['value'])
-                  <option value="{{ $v }}" selected>{{ $n }}</option>
-@else
-                  <option value="{{ $v }}">{{ $n }}</option>
-@endif
-@endforeach
+    @foreach ($cur['options'] as $v => $n)
+                  <option value="{{ $v }}" @if ($v == $cur['value']) selected @endif>{{ $n }}</option>
+    @endforeach
                 </select>
-@elseif($cur['type'] == 'radio')
-@foreach($cur['values'] as $v => $n)
-@if($v == $cur['value'])
-                <label class="f-label"><input type="radio" name="{{ $key }}" value="{{ $v }}" checked tabindex="{!! ++$p->tabindex !!}">{{ $n }}</label>
-@else
-                <label class="f-label"><input type="radio" name="{{ $key }}" value="{{ $v }}" tabindex="{!! ++$p->tabindex !!}">{{ $n }}</label>
-@endif
-@endforeach
-@endif
-@if(isset($cur['info']))
+  @elseif ($cur['type'] == 'radio')
+    @foreach ($cur['values'] as $v => $n)
+                <label class="f-label"><input type="radio" name="{{ $key }}" value="{{ $v }}" @if ($v == $cur['value']) checked @endif tabindex="{!! ++$p->tabindex !!}">{{ $n }}</label>
+    @endforeach
+  @endif
+  @if (isset($cur['info']))
                 <span class="f-child4">{!! $cur['info'] !!}</span>
-@endif
+  @endif
               </dd>
 @endforeach
             </dl>
-@if($p->warn)
+@if ($p->warn)
             <p class="f-finfo">{!! $p->warn !!}</p>
 @endif
             <div>

+ 8 - 16
app/templates/admin/groups.tpl

@@ -1,4 +1,4 @@
-@extends('layouts/admin')
+@extends ('layouts/admin')
       <section class="f-admin">
         <h2>{!! __('Add group subhead') !!}</h2>
         <div class="f-fdiv">
@@ -8,12 +8,8 @@
               <dt>{!! __('New group label') !!}</dt>
               <dd>
                 <select class="f-ctrl" id="id-basegroup" name="basegroup" tabindex="{!! ++$p->tabindex !!}">
-@foreach($p->groupsNew as $cur)
-@if ($cur[0] == $p->defaultGroup)
-                  <option value="{!! $cur[0] !!}" selected>{{ $cur[1] }}</option>
-@else
-                  <option value="{!! $cur[0] !!}">{{ $cur[1] }}</option>
-@endif
+@foreach ($p->groupsNew as $cur)
+                  <option value="{!! $cur[0] !!}" @if ($cur[0] == $p->defaultGroup) selected @endif>{{ $cur[1] }}</option>
 @endforeach
                 </select>
                 <span class="f-child4">{!! __('New group help') !!}</span>
@@ -34,12 +30,8 @@
               <dt>{!! __('Default group label') !!}</dt>
               <dd>
                 <select class="f-ctrl" id="id-defaultgroup" name="defaultgroup" tabindex="{!! ++$p->tabindex !!}">
-@foreach($p->groupsDefault as $cur)
-@if ($cur[0] == $p->defaultGroup)
-                  <option value="{!! $cur[0] !!}" selected>{{ $cur[1] }}</option>
-@else
-                  <option value="{!! $cur[0] !!}">{{ $cur[1] }}</option>
-@endif
+@foreach ($p->groupsDefault as $cur)
+                  <option value="{!! $cur[0] !!}" @if ($cur[0] == $p->defaultGroup) selected @endif>{{ $cur[1] }}</option>
 @endforeach
                 </select>
                 <span class="f-child4">{!! __('Default group help') !!}</span>
@@ -56,12 +48,12 @@
         <div>
           <p>{!! __('Edit groups info') !!}</p>
           <ol class="f-grlist">
-@foreach($p->groupsList as $cur)
+@foreach ($p->groupsList as $cur)
             <li>
               <a href="{!! $cur[0] !!}" tabindex="{!! ++$p->tabindex !!}">{{ $cur[1] }}</a>
-@if($cur[2])
+  @if ($cur[2])
               <a class="f-btn" href="{!! $cur[2] !!}" tabindex="{!! ++$p->tabindex !!}">{!! __('Delete link') !!}</a>
-@endif
+  @endif
             </li>
 @endforeach
           </ol>

+ 1 - 1
app/templates/admin/index.tpl

@@ -1,4 +1,4 @@
-@extends('layouts/admin')
+@extends ('layouts/admin')
       <section class="f-admin">
         <h2>{!! __('Forum admin head') !!}</h2>
         <div>

+ 8 - 8
app/templates/admin/statistics.tpl

@@ -1,11 +1,11 @@
-@extends('layouts/admin')
+@extends ('layouts/admin')
       <section class="f-admin">
         <h2>{!! __('Server statistics head') !!}</h2>
         <div>
           <dl>
             <dt>{!! __('Server load label') !!}</dt>
             <dd>{!! __('Server load data', $p->serverLoad, $p->numOnline) !!}</dd>
-@if($p->isAdmin)
+@if ($p->isAdmin)
             <dt>{!! __('Environment label') !!}</dt>
             <dd>
               {!! __('Environment data OS', PHP_OS) !!}<br>
@@ -15,16 +15,16 @@
             <dt>{!! __('Database label') !!}</dt>
             <dd>
               {{ $p->dbVersion }}
-@if($p->tRecords && $p->tSize)
+  @if ($p->tRecords && $p->tSize)
               <br>{!! __('Database data rows', $p->tRecords) !!}
               <br>{!! __('Database data size', $p->tSize) !!}
-@endif
-@if($p->tOther)
+  @endif
+  @if ($p->tOther)
               <br><br>{!! __('Other')!!}
-@foreach($p->tOther as $key => $value)
+    @foreach ($p->tOther as $key => $value)
               <br>{{ $key }} = {{ $value }}
-@endforeach
-@endif
+    @endforeach
+  @endif
             </dd>
 @endif
           </dl>

+ 3 - 3
app/templates/ban.tpl

@@ -1,11 +1,11 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-message">
       <h2>{{ __('Info') }}</h2>
       <p>{!! __('Ban message') !!}</p>
-@if(! empty($p->ban['expire']))
+@if (! empty($p->ban['expire']))
       <p>{!! __('Ban message 2', $p->ban['expire']) !!}</p>
 @endif
-@if(! empty($p->ban['message']))
+@if (! empty($p->ban['message']))
       <p>{!! __('Ban message 3') !!}</p>
       <p><strong>{{ $p->ban['message'] }}</strong></p>
 @endif

+ 1 - 1
app/templates/change_passphrase.tpl

@@ -1,4 +1,4 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-login">
       <div class="f-fdiv f-lrdiv">
         <h2>{!! __('Change pass') !!}</h2>

+ 61 - 72
app/templates/forum.tpl

@@ -1,42 +1,44 @@
-@section('crumbs')
+@section ('crumbs')
       <ul class="f-crumbs">
-@foreach($p->crumbs as $cur)
-@if($cur[2])
-        <li class="f-crumb"><a href="{!! $cur[0] !!}" class="active">{{ $cur[1] }}</a></li>
-@else
-        <li class="f-crumb"><a href="{!! $cur[0] !!}">{{ $cur[1] }}</a></li>
-@endif
-@endforeach
+  @foreach ($p->crumbs as $cur)
+        <li class="f-crumb"><!-- inline -->
+    @if ($cur[0])
+          <a href="{!! $cur[0] !!}" @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</a>
+    @else
+          <span @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</span>
+    @endif
+        </li><!-- endinline -->
+  @endforeach
       </ul>
 @endsection
-@section('linknewtopic')
-@if($p->forum->canCreateTopic)
+@section ('linknewtopic')
+  @if ($p->forum->canCreateTopic)
         <div class="f-link-post">
           <a class="f-btn" href="{!! $p->forum->linkCreateTopic !!}">{!! __('Post topic') !!}</a>
         </div>
-@endif
+  @endif
 @endsection
-@section('pagination')
+@section ('pagination')
         <nav class="f-pages">
-@foreach($p->forum->pagination as $cur)
-@if($cur[2])
+  @foreach ($p->forum->pagination as $cur)
+    @if ($cur[2])
           <span class="f-page active">{{ $cur[1] }}</span>
-@elseif($cur[1] === 'space')
+    @elseif ($cur[1] === 'space')
           <span class="f-page f-pspacer">{!! __('Spacer') !!}</span>
-@elseif($cur[1] === 'prev')
+    @elseif ($cur[1] === 'prev')
           <a rel="prev" class="f-page f-pprev" href="{!! $cur[0] !!}">{!! __('Previous') !!}</a>
-@elseif($cur[1] === 'next')
+    @elseif ($cur[1] === 'next')
           <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>
 @endsection
-@extends('layouts/main')
-@if($forums = $p->forums)
+@extends ('layouts/main')
+@if ($forums = $p->forums)
     <div class="f-nav-links">
-@yield('crumbs')
+  @yield ('crumbs')
     </div>
     <section class="f-subforums">
       <ol class="f-ftlist">
@@ -48,22 +50,22 @@
               <div class="f-hcell f-cstats">{!! __('Stats') !!}</div>
               <div class="f-hcell f-clast">{!! __('Last post') !!}</div>
             </li>
-@include('layouts/subforums')
+  @include ('layouts/subforums')
           </ol>
         </li>
       </ol>
     </section>
 @endif
     <div class="f-nav-links">
-@yield('crumbs')
-@if($p->forum->canCreateTopic || $p->forum->pagination)
+@yield ('crumbs')
+@if ($p->forum->canCreateTopic || $p->forum->pagination)
       <div class="f-links-b clearfix">
-@yield('pagination')
-@yield('linknewtopic')
+  @yield ('pagination')
+  @yield ('linknewtopic')
       </div>
 @endif
     </div>
-@if($p->topics)
+@if ($p->topics)
     <section class="f-main f-forum">
       <h2>{{ $p->forum->forum_name }}</h2>
       <div class="f-ftlist">
@@ -73,8 +75,8 @@
             <div class="f-hcell f-cstats">{!! __('Stats') !!}</div>
             <div class="f-hcell f-clast">{!! __('Last post') !!}</div>
           </li>
-@foreach($p->topics as $topic)
-@if($topic->moved_to)
+  @foreach ($p->topics as $topic)
+    @if ($topic->moved_to)
           <li id="topic-{!! $topic->id !!}" class="f-row f-fredir">
             <div class="f-cell f-cmain">
               <div class="f-ficon"></div>
@@ -83,52 +85,39 @@
               </div>
             </div>
           </li>
-@else
-          <li id="topic-{!! $topic->id !!}" class="f-row<!-- inline -->
-@if($topic->hasNew !== false) f-fnew
-@endif
-@if($topic->hasUnread !== false) f-funread
-@endif
-@if($topic->sticky) f-fsticky
-@endif
-@if($topic->closed) f-fclosed
-@endif
-@if($topic->poll_type) f-fpoll
-@endif
-@if($topic->dot) f-fposted
-@endif
-            "><!-- endinline -->
+    @else
+          <li id="topic-{!! $topic->id !!}" class="f-row @if ($topic->hasNew !== false) f-fnew @endif @if ($topic->hasUnread !== false) f-funread @endif @if ($topic->sticky) f-fsticky @endif @if ($topic->closed) f-fclosed @endif @if ($topic->poll_type) f-fpoll @endif @if ($topic->dot) f-fposted @endif">
             <div class="f-cell f-cmain">
               <div class="f-ficon"></div>
               <div class="f-finfo">
                 <h3>
-@if($topic->dot)
+      @if ($topic->dot)
                   <span class="f-tdot">·</span>
-@endif
-@if($topic->sticky)
+      @endif
+      @if ($topic->sticky)
                   <span class="f-stickytxt">{!! __('Sticky') !!}</span>
-@endif
-@if($topic->closed)
+      @endif
+      @if ($topic->closed)
                   <span class="f-closedtxt">{!! __('Closed') !!}</span>
-@endif
-@if($topic->poll_type)
+      @endif
+      @if ($topic->poll_type)
                   <span class="f-polltxt">{!! __('Poll') !!}</span>
-@endif
+      @endif
                   <a class="f-ftname" href="{!! $topic->link !!}">{{ $topic->cens()->subject }}</a>
-@if($topic->pagination)
+      @if ($topic->pagination)
                   <span class="f-tpages">
-@foreach($topic->pagination as $cur)
-@if($cur[1] === 'space')
+        @foreach ($topic->pagination as $cur)
+          @if ($cur[1] === 'space')
                     <span class="f-page f-pspacer">{!! __('Spacer') !!}</span>
-@else
+          @else
                     <a class="f-page" href="{!! $cur[0] !!}">{{ $cur[1] }}</a>
-@endif
-@endforeach
+           @endif
+        @endforeach
                   </span>
-@endif
-@if($topic->hasNew !== false)
+      @endif
+      @if ($topic->hasNew !== false)
                   <span class="f-newtxt"><a href="{!! $topic->linkNew !!}" title="{!! __('New posts info') !!}">{!! __('New posts') !!}</a></span>
-@endif
+      @endif
                 </h3>
                 <p class="f-cmposter">{!! __('by') !!} {{ $topic->poster }}</p>
               </div>
@@ -136,9 +125,9 @@
             <div class="f-cell f-cstats">
               <ul>
                 <li>{!! __('%s Reply', $topic->num_replies, $topic->num()->num_replies) !!}</li>
-@if($topic->showViews)
+      @if ($topic->showViews)
                 <li>{!! __('%s View', $topic->num_views, $topic->num()->num_views) !!}</li>
-@endif
+      @endif
               </ul>
             </div>
             <div class="f-cell f-clast">
@@ -148,18 +137,18 @@
               </ul>
             </div>
           </li>
-@endif
-@endforeach
+    @endif
+  @endforeach
         </ol>
       </div>
     </section>
     <div class="f-nav-links">
-@if($p->forum->canCreateTopic || $p->forum->pagination)
+  @if ($p->forum->canCreateTopic || $p->forum->pagination)
       <div class="f-links-a clearfix">
-@yield('linknewtopic')
-@yield('pagination')
+    @yield ('linknewtopic')
+    @yield ('pagination')
       </div>
-@endif
-@yield('crumbs')
+  @endif
+  @yield ('crumbs')
     </div>
 @endif

+ 6 - 6
app/templates/index.tpl

@@ -1,8 +1,8 @@
-@extends('layouts/main')
-@if($p->categoryes)
+@extends ('layouts/main')
+@if ($p->categoryes)
     <section class="f-main">
       <ol class="f-ftlist">
-@foreach($p->categoryes as $id => $forums)
+  @foreach ($p->categoryes as $id => $forums)
         <li id="cat-{!! $id !!}" class="f-category">
           <h2>{{ current($forums)->cat_name }}</h2>
           <ol class="f-table">
@@ -11,11 +11,11 @@
               <div class="f-hcell f-cstats">{!! __('Stats') !!}</div>
               <div class="f-hcell f-clast">{!! __('Last post') !!}</div>
             </li>
-@include('layouts/subforums')
+    @include ('layouts/subforums')
           </ol>
         </li>
-@endforeach
+  @endforeach
       </ol>
     </section>
 @endif
-@include('layouts/stats')
+@include ('layouts/stats')

+ 8 - 12
app/templates/layouts/admin.tpl

@@ -1,24 +1,20 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <div class="f-main clearfix">
       <aside class="f-admin-menu">
-@if($p->aNavigation)
+@if ($p->aNavigation)
         <nav class="admin-nav f-menu">
           <input id="admin-nav-checkbox" style="display: none;" type="checkbox">
           <label class="f-menu-toggle" for="admin-nav-checkbox"></label>
-@foreach($p->aNavigation as $aNameSub => $aNavigationSub)
+  @foreach ($p->aNavigation as $aNameSub => $aNavigationSub)
           <h2 class="f-menu-items">{!! __($aNameSub) !!}</h2>
           <ul class="f-menu-items">
-@foreach($aNavigationSub as $key => $val)
-@if($key == $p->aIndex)
-            <li><a id="anav-{{ $key }}" class="active" href="{!! $val[0] !!}">{!! $val[1] !!}</a></li>
-@else
-            <li><a id="anav-{{ $key }}" href="{!! $val[0] !!}">{!! $val[1] !!}</a></li>
-@endif
-@endforeach
+    @foreach ($aNavigationSub as $key => $val)
+            <li><a id="anav-{{ $key }}" @if ($key == $p->aIndex) class="active" @endif href="{!! $val[0] !!}">{!! $val[1] !!}</a></li>
+    @endforeach
           </ul>
-@endforeach
+  @endforeach
         </nav>
 @endif
       </aside>
-@yield('content')
+@yield ('content')
     </div>

+ 3 - 3
app/templates/layouts/debug.tpl

@@ -1,7 +1,7 @@
     <section class="f-debug">
       <h2>{!! __('Debug table') !!}</h2>
       <p class="f-debugtime">[ {!! __('Querytime', $p->time, $p->numQueries) !!} - {!! __('Memory usage', $p->memory) !!} {!! __('Peak usage', $p->peak) !!} ]</p>
-@if($p->queries)
+@if ($p->queries)
       <table>
         <thead>
           <tr>
@@ -10,12 +10,12 @@
           </tr>
         </thead>
         <tbody>
-@foreach($p->queries as $cur)
+  @foreach ($p->queries as $cur)
           <tr>
             <td class="tcl">{{ $cur[1] }}</td>
             <td class="tcr">{{ $cur[0] }}</td>
           </tr>
-@endforeach
+  @endforeach
           <tr>
             <td class="tcl">{{ $p->total }}</td>
             <td class="tcr"></td>

+ 24 - 32
app/templates/layouts/form.tpl

@@ -1,50 +1,42 @@
         <form class="f-form" method="post" action="{!! $form['action'] !!}">
-@if($form['hidden'])
-@foreach($form['hidden'] as $key => $val)
+@if ($form['hidden'])
+  @foreach ($form['hidden'] as $key => $val)
           <input type="hidden" name="{{ $key }}" value="{{ $val }}">
-@endforeach
+  @endforeach
 @endif
-@foreach($form['sets'] as $fieldset)
+@foreach ($form['sets'] as $fieldset)
           <fieldset>
-@if(isset($fieldset['legend']))
+  @if(isset ($fieldset['legend']))
             <legend>{!! $fieldset['legend'] !!}</legend>
-@endif
-@foreach($fieldset['fields'] as $key => $cur)
-@if(isset($cur['dl']))
-            <dl class="f-field-{{ $cur['dl'] }}">
-@else
-            <dl>
-@endif
-@if(isset($cur['title']))
-              <dt><label class="f-child1{!! empty($cur['required']) ? '' : ' f-req' !!}" for="id-{{ $key }}">{!! $cur['title'] !!}</label></dt>
-@else
-              <dt></dt>
-@endif
+  @endif
+  @foreach ($fieldset['fields'] as $key => $cur)
+            <dl @if (isset($cur['dl'])) class="f-field-{{ $cur['dl'] }}" @endif>
+              <dt> @if (isset($cur['title']))<label class="f-child1 @if (isset($cur['required'])) f-req @endif" for="id-{{ $key }}">{!! $cur['title'] !!}</label> @endif</dt>
               <dd>
-@if($cur['type'] === 'textarea')
-                <textarea{!! empty($cur['required']) ? '' : ' required' !!} class="f-ctrl" id="id-{{ $key }}" name="{{ $key }}">{{ $cur['value'] or '' }}</textarea>
-@if(isset($cur['bb']))
+    @if ($cur['type'] === 'textarea')
+                <textarea @if (isset($cur['required'])) required @endif class="f-ctrl" id="id-{{ $key }}" name="{{ $key }}">{{ $cur['value'] or '' }}</textarea>
+      @if (isset($cur['bb']))
                 <ul class="f-child5">
-@foreach($cur['bb'] as $val)
+        @foreach ($cur['bb'] as $val)
                   <li><span><a href="{!! $val[0] !!}">{!! $val[1] !!}</a> {!! $val[2] !!}</span></li>
-@endforeach
+        @endforeach
                 </ul>
-@endif
-@elseif($cur['type'] === 'text')
-                <input{!! empty($cur['required']) ? '' : ' required' !!} class="f-ctrl" id="id-{{ $key }}" name="{{ $key }}" type="text" maxlength="{{ $cur['maxlength'] or '' }}" pattern="{{ $cur['pattern'] or '' }}" value="{{ $cur['value'] or '' }}">
-@elseif($cur['type'] === 'checkbox')
-                <label class="f-child2"><input type="checkbox" id="id-{{ $key }}" name="{{ $key }}" value="{{ $cur['value'] or '0' }}"{!! empty($cur['checked']) ? '' : ' checked' !!}>{!! $cur['label'] !!}</label>
-@endif
-@if(isset($cur['info']))
+      @endif
+    @elseif ($cur['type'] === 'text')
+                <input @if (isset($cur['required'])) required @endif class="f-ctrl" id="id-{{ $key }}" name="{{ $key }}" type="text" @if (! empty($cur['maxlength'])) maxlength="{{ $cur['maxlength'] }}" @endif @if (isset($cur['pattern'])) pattern="{{ $cur['pattern'] }}" @endif @if (isset($cur['value'])) value="{{ $cur['value'] }}" @endif>
+    @elseif ($cur['type'] === 'checkbox')
+                <label class="f-child2"><input type="checkbox" id="id-{{ $key }}" name="{{ $key }}" value="{{ $cur['value'] or '1' }}" @if (! empty($cur['checked'])) checked @endif>{!! $cur['label'] !!}</label>
+    @endif
+    @if (isset($cur['info']))
                 <p class="f-child4">{!! $cur['info'] !!}</p>
-@endif
+    @endif
               </dd>
             </dl>
-@endforeach
+  @endforeach
           </fieldset>
 @endforeach
           <p>
-@foreach($form['btns'] as $key => $cur)
+@foreach ($form['btns'] as $key => $cur)
             <input class="f-btn" type="{{ $cur[0] }}" name="{{ $key }}" value="{{ $cur[1] }}" accesskey="{{ $cur[2] }}">
 @endforeach
           </p>

+ 20 - 36
app/templates/layouts/install.tpl

@@ -4,7 +4,7 @@
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>{!! __('ForkBB Installation') !!}</title>
-@foreach($p->pageHeads as $cur)
+@foreach ($p->pageHeads as $cur)
   <{!! $cur !!}>
 @endforeach
 </head>
@@ -16,10 +16,10 @@
         <p class="f-description">{!! __('Welcome') !!}</p>
       </div>
     </header>
-@if($p->fIswev)
-@include('layouts/iswev')
+@if ($p->fIswev)
+  @include ('layouts/iswev')
 @endif
-@if(is_array($p->installLangs))
+@if (is_array($p->installLangs))
     <section class="f-install">
       <div class="f-fdiv">
         <h2>{!! __('Choose install language') !!}</h2>
@@ -27,13 +27,9 @@
           <div>
             <label class="f-child1">{!! __('Install language') !!}</label>
             <select class="f-ctrl" id="id-installlang" name="installlang">
-@foreach($p->installLangs as $cur)
-@if(isset($cur[1]))
-              <option value="{{ $cur[0] }}" selected>{{ $cur[0] }}</option>
-@else
-              <option value="{{ $cur[0] }}">{{ $cur[0] }}</option>
-@endif
-@endforeach
+  @foreach ($p->installLangs as $cur)
+              <option value="{{ $cur[0] }}" @if (isset($cur[1])) selected @endif>{{ $cur[0] }}</option>
+  @endforeach
             </select>
             <label class="f-child4">{!! __('Choose install language info') !!}</label>
           </div>
@@ -44,7 +40,7 @@
       </div>
     </section>
 @endif
-@if(empty($p->fIswev['e']))
+@if (empty($p->fIswev['e']))
     <section class="f-main f-install">
       <div class="f-fdiv">
         <h2>{!! __('Install', $p->rev) !!}</h2>
@@ -57,13 +53,9 @@
           <div>
             <label class="f-child1 f-req">{!! __('Database type') !!}</label>
             <select class="f-ctrl" id="id-dbtype" name="dbtype">
-@foreach($p->dbTypes as $key => $cur)
-@if(empty($cur[1]))
-              <option value="{{ $key }}">{{ $cur[0] }}</option>
-@else
-              <option value="{{ $key }}" selected>{{ $cur[0] }}</option>
-@endif
-@endforeach
+  @foreach ($p->dbTypes as $key => $cur)
+              <option value="{{ $key }}" @if (!empty($cur[1])) selected @endif>{{ $cur[0] }}</option>
+  @endforeach
             </select>
             <label class="f-child4">{!! __('Info 2') !!}</label>
           </div>
@@ -126,32 +118,24 @@
             <label class="f-child1 f-req" for="id-baseurl">{!! __('Base URL') !!}</label>
             <input required class="f-ctrl" id="id-baseurl" type="text" name="baseurl" value="{{ $p->baseurl }}">
           </div>
-@if(is_array($p->defaultLangs))
+  @if (is_array($p->defaultLangs))
           <div>
             <label class="f-child1 f-req">{!! __('Default language') !!}</label>
             <select class="f-ctrl" id="id-defaultlang" name="defaultlang">
-@foreach($p->defaultLangs as $cur)
-@if(isset($cur[1]))
-              <option value="{{ $cur[0] }}" selected>{{ $cur[0] }}</option>
-@else
-              <option value="{{ $cur[0] }}">{{ $cur[0] }}</option>
-@endif
-@endforeach
+    @foreach ($p->defaultLangs as $cur)
+              <option value="{{ $cur[0] }}" @if (isset($cur[1])) selected @endif>{{ $cur[0] }}</option>
+    @endforeach
             </select>
           </div>
-@else
+  @else
           <input type="hidden" name="defaultlang" value="{!! $p->defaultLangs !!}">
-@endif
+  @endif
           <div>
             <label class="f-child1 f-req">{!! __('Default style') !!}</label>
             <select class="f-ctrl" id="id-defaultstyle" name="defaultstyle">
-@foreach($p->defaultStyles as $cur)
-@if(isset($cur[1]))
-              <option value="{{ $cur[0] }}" selected>{{ $cur[0] }}</option>
-@else
-              <option value="{{ $cur[0] }}">{{ $cur[0] }}</option>
-@endif
-@endforeach
+  @foreach ($p->defaultStyles as $cur)
+              <option value="{{ $cur[0] }}" @if (isset($cur[1])) selected @endif>{{ $cur[0] }}</option>
+  @endforeach
             </select>
           </div>
           <div>

+ 15 - 15
app/templates/layouts/iswev.tpl

@@ -1,50 +1,50 @@
-@if(isset($p->fIswev['i']))
+@if (isset($p->fIswev['i']))
     <section class="f-iswev f-info">
       <h2>Info message</h2>
       <ul>
-@foreach($p->fIswev['i'] as $cur)
+  @foreach ($p->fIswev['i'] as $cur)
         <li class="f-icontent">{!! $cur !!}</li>
-@endforeach
+  @endforeach
       </ul>
     </section>
 @endif
-@if(isset($p->fIswev['s']))
+@if (isset($p->fIswev['s']))
     <section class="f-iswev f-success">
       <h2>Successful operation message</h2>
       <ul>
-@foreach($p->fIswev['s'] as $cur)
+  @foreach ($p->fIswev['s'] as $cur)
         <li class="f-scontent">{!! $cur !!}</li>
-@endforeach
+  @endforeach
       </ul>
     </section>
 @endif
-@if(isset($p->fIswev['w']))
+@if (isset($p->fIswev['w']))
     <section class="f-iswev f-warning">
       <h2>Warning message</h2>
       <ul>
-@foreach($p->fIswev['w'] as $cur)
+  @foreach ($p->fIswev['w'] as $cur)
         <li class="f-wcontent">{!! $cur !!}</li>
-@endforeach
+  @endforeach
       </ul>
     </section>
 @endif
-@if(isset($p->fIswev['e']))
+@if (isset($p->fIswev['e']))
     <section class="f-iswev f-error">
       <h2>Error message</h2>
       <ul>
-@foreach($p->fIswev['e'] as $cur)
+  @foreach ($p->fIswev['e'] as $cur)
         <li class="f-econtent">{!! $cur !!}</li>
-@endforeach
+  @endforeach
       </ul>
     </section>
 @endif
-@if(isset($p->fIswev['v']))
+@if (isset($p->fIswev['v']))
     <section class="f-iswev f-validation">
       <h2>Validation message</h2>
       <ul>
-@foreach($p->fIswev['v'] as $cur)
+  @foreach ($p->fIswev['v'] as $cur)
         <li class="f-vcontent">{!! $cur !!}</li>
-@endforeach
+  @endforeach
       </ul>
     </section>
 @endif

+ 9 - 13
app/templates/layouts/main.tpl

@@ -4,7 +4,7 @@
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>{{ $p->pageTitle }}</title>
-@foreach($p->pageHeaders as $cur)
+@foreach ($p->pageHeaders as $cur)
   <{!! $cur !!}>
 @endforeach
 </head>
@@ -15,32 +15,28 @@
         <h1><a href="{!! $p->fRootLink !!}">{{ $p->fTitle }}</a></h1>
         <p class="f-description">{!! $p->fDescription !!}</p>
       </div>
-@if($p->fNavigation)
+@if ($p->fNavigation)
       <nav class="main-nav f-menu">
         <input id="main-nav-checkbox" style="display: none;" type="checkbox">
         <label class="f-menu-toggle" for="main-nav-checkbox"></label>
         <ul class="f-menu-items">
-@foreach($p->fNavigation as $key => $val)
-@if($key == $p->fIndex)
-          <li><a id="nav-{{ $key }}" class="active" href="{!! $val[0] !!}">{!! $val[1] !!}</a></li>
-@else
-          <li><a id="nav-{{ $key }}" href="{!! $val[0] !!}">{!! $val[1] !!}</a></li>
-@endif
-@endforeach
+  @foreach ($p->fNavigation as $key => $val)
+          <li><a id="nav-{{ $key }}" @if ($key == $p->fIndex) class="active" @endif href="{!! $val[0] !!}">{!! $val[1] !!}</a></li>
+  @endforeach
         </ul>
       </nav>
 @endif
     </header>
-@if($p->fAnnounce)
+@if ($p->fAnnounce)
     <section class="f-announce">
       <h2>{!! __('Announcement') !!}</h2>
       <p class="f-ancontent">{!! $p->fAnnounce !!}</p>
     </section>
 @endif
-@if($p->fIswev)
-@include('layouts/iswev')
+@if ($p->fIswev)
+  @include ('layouts/iswev')
 @endif
-@yield('content')
+@yield ('content')
     <footer class="f-footer clearfix">
       <h2>{!! __('Board footer') !!}</h2>
       <div class="left">

+ 1 - 1
app/templates/layouts/redirect.tpl

@@ -5,7 +5,7 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="refresh" content="{!! $p->timeout !!};URL={{ $p->link }}">
   <title>{{ $p->pageTitle }}</title>
-@foreach($p->pageHeaders as $cur)
+@foreach ($p->pageHeaders as $cur)
   <{!! $cur !!}>
 @endforeach
 </head>

+ 13 - 13
app/templates/layouts/stats.tpl

@@ -1,7 +1,7 @@
     <section class="f-stats">
       <h2>{!! __('Stats info') !!}</h2>
       <div class="clearfix">
-@if($p->stats)
+@if ($p->stats)
         <dl class="right">
           <dt>{!! __('Board stats') !!}</dt>
           <dd>{!! __('No of users') !!} <strong>{!! $p->stats->num()->userTotal !!}</strong></dd>
@@ -11,30 +11,30 @@
 @endif
         <dl class="left">
           <dt>{!! __('User info') !!}</dt>
-@if($p->stats)
-@if(is_string($p->stats->userLast))
+@if ($p->stats)
+  @if (is_string($p->stats->userLast))
           <dd>{!! __('Newest user')  !!} {{ $p->stats->userLast }}</dd>
-@else
+  @else
           <dd>{!! __('Newest user')  !!} <a href="{!! $p->stats->userLast[0] !!}">{{ $p->stats->userLast[1] }}</a></dd>
+  @endif
 @endif
-@endif
-@if($p->online)
+@if ($p->online)
           <dd>{!! __('Visitors online', $p->online->num()->numUsers, $p->online->num()->numGuests) !!}</dd>
 @endif
-@if($p->stats)
+@if ($p->stats)
           <dd>{!! __('Most online', $p->online->num()->maxNum, $p->online->dt()->maxTime) !!}</dd>
 @endif
         </dl>
-@if($p->online && $p->online->info)
+@if ($p->online && $p->online->info)
         <dl class="f-inline f-onlinelist"><!-- inline -->
           <dt>{!! __('Online users') !!}</dt>
-@foreach($p->online->info as $cur)
-@if(is_string($cur))
+  @foreach ($p->online->info as $cur)
+    @if (is_string($cur))
           <dd>{{ $cur }}</dd>
-@else
+    @else
           <dd><a href="{!! $cur[0] !!}">{{ $cur[1] }}</a></dd>
-@endif
-@endforeach
+    @endif
+  @endforeach
         </dl><!-- endinline -->
 @endif
       </div>

+ 25 - 29
app/templates/layouts/subforums.tpl

@@ -1,54 +1,50 @@
-@foreach($forums as $cur)
-@if($cur->redirect_url)
+@foreach ($forums as $cur)
+  @if ($cur->redirect_url)
             <li id="forum-{!! $cur->id !!}" class="f-row f-fredir">
               <div class="f-cell f-cmain">
                 <div class="f-ficon"></div>
                 <div class="f-finfo">
                   <h3><span class="f-fredirtext">{!! __('Link to') !!}</span> <a class="f-ftname" href="{!! $cur->redirect_url !!}">{{ $cur->forum_name }}</a></h3>
-@if($cur->forum_desc)
+    @if ($cur->forum_desc)
                   <p class="f-fdesc">{!! $cur->forum_desc !!}</p>
-@endif
+    @endif
                 </div>
               </div>
             </li>
-@else
-@if($cur->tree->newMessages)
-            <li id="forum-{!! $cur->id !!}" class="f-row f-fnew">
-@else
-            <li id="forum-{!! $cur->id !!}" class="f-row">
-@endif
+  @else
+            <li id="forum-{!! $cur->id !!}" class="f-row @if ($cur->tree->newMessages) f-fnew @endif">
               <div class="f-cell f-cmain">
                 <div class="f-ficon"></div>
                 <div class="f-finfo">
                   <h3>
                     <a class="f-ftname" href="{!! $cur->link !!}">{{ $cur->forum_name }}</a>
-@if($cur->tree->newMessages)
+    @if ($cur->tree->newMessages)
                     <span class="f-newtxt"><a href="">{!! __('New posts') !!}</a></span>
-@endif
+    @endif
                   </h3>
-@if($cur->subforums)
+    @if ($cur->subforums)
                   <dl class="f-inline f-fsub"><!-- inline -->
                     <dt>{!! __('Sub forum', count($cur->subforums)) !!}</dt>
-@foreach($cur->subforums as $sub)
+      @foreach ($cur->subforums as $sub)
                     <dd><a href="{!! $sub->link !!}">{{ $sub->forum_name }}</a></dd>
-@endforeach
+      @endforeach
                   </dl><!-- endinline -->
-@endif
-@if($cur->forum_desc)
+    @endif
+    @if ($cur->forum_desc)
                   <p class="f-fdesc">{!! $cur->forum_desc !!}</p>
-@endif
-@if($cur->moderators)
+    @endif
+    @if ($cur->moderators)
                   <dl class="f-inline f-modlist"><!-- inline -->
                     <dt>{!! __('Moderated by', count($cur->moderators)) !!}</dt>
-@foreach($cur->moderators as $mod)
-@if(is_string($mod))
+      @foreach ($cur->moderators as $mod)
+        @if (is_string($mod))
                     <dd>{{ $mod }}</dd>
-@else
+        @else
                     <dd><a href="{!! $mod[0] !!}">{{ $mod[1] }}</a></dd>
-@endif
-@endforeach
+        @endif
+      @endforeach
                   </dl><!-- endinline -->
-@endif
+    @endif
                 </div>
               </div>
               <div class="f-cell f-cstats">
@@ -59,15 +55,15 @@
               </div>
               <div class="f-cell f-clast">
                 <ul>
-@if($cur->tree->last_post_id)
+    @if ($cur->tree->last_post_id)
                   <li class="f-cltopic"><a href="{!! $cur->tree->linkLast !!}" title="&quot;{{ $cur->tree->cens()->last_topic }}&quot; - {!! __('Last post') !!}">{{ $cur->tree->cens()->last_topic }}</a></li>
                   <li class="f-clposter">{!! __('by') !!} {{ $cur->tree->last_poster }}</li>
                   <li class="f-cltime">{!! $cur->tree->dt()->last_post !!}</li>
-@else
+    @else
                   <li class="f-cltopic">{!! __('Never') !!}</li>
-@endif
+    @endif
                 </ul>
               </div>
             </li>
-@endif
+  @endif
 @endforeach

+ 3 - 3
app/templates/login.tpl

@@ -1,4 +1,4 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-login">
       <div class="f-fdiv f-lrdiv">
         <h2>{!! __('Login') !!}</h2>
@@ -20,7 +20,7 @@
             </dl>
             <dl>
               <dt></dt>
-@if($p->save)
+@if ($p->save)
               <dd><label class="f-child2"><input type="checkbox" name="save" value="1" tabindex="3" checked>{!! __('Remember me') !!}</label></dd>
 @else
               <dd><label class="f-child2"><input type="checkbox" name="save" value="1" tabindex="3">{!! __('Remember me') !!}</label></dd>
@@ -32,7 +32,7 @@
           </p>
         </form>
       </div>
-@if($p->regLink)
+@if ($p->regLink)
       <div class="f-fdiv f-lrdiv">
         <p class="f-child3"><a href="{!! $p->regLink !!}" tabindex="6">{!! __('Not registered') !!}</a></p>
       </div>

+ 1 - 1
app/templates/maintenance.tpl

@@ -1,4 +1,4 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-maintenance">
       <h2>{{ __('Maintenance') }}</h2>
       <p>{!! $p->maintenanceMessage !!}</p>

+ 2 - 2
app/templates/message.tpl

@@ -1,8 +1,8 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-message">
       <h2>{!! __('Info') !!}</h2>
       <p>{!! $p->message !!}</p>
-@if($p->back)
+@if ($p->back)
       <p><a href="javascript: history.go(-1)">{!! __('Go back') !!}</a></p>
 @endif
     </section>

+ 1 - 1
app/templates/passphrase_reset.tpl

@@ -1,4 +1,4 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-login">
       <div class="f-fdiv f-lrdiv">
         <h2>{!! __('Passphrase reset') !!}</h2>

+ 28 - 0
app/templates/post.tpl

@@ -0,0 +1,28 @@
+@section ('crumbs')
+      <ul class="f-crumbs">
+  @foreach ($p->crumbs as $cur)
+        <li class="f-crumb"><!-- inline -->
+    @if ($cur[0])
+          <a href="{!! $cur[0] !!}" @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</a>
+    @else
+          <span @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</span>
+    @endif
+        </li><!-- endinline -->
+  @endforeach
+      </ul>
+@endsection
+@extends ('layouts/main')
+    <div class="f-nav-links">
+@yield ('crumbs')
+    </div>
+    <section class="f-main f-topic">
+      <h2>{{ '' }}</h2>
+    </section>
+@if ($form = $p->form)
+    <section class="post-form">
+      <h2>{!! __('Quick post') !!}</h2>
+      <div class="f-fdiv">
+  @include ('layouts/form')
+      </div>
+    </section>
+@endif

+ 1 - 1
app/templates/register.tpl

@@ -1,4 +1,4 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-register">
       <div class="f-fdiv f-lrdiv">
         <h2>{!! __('Register') !!}</h2>

+ 2 - 2
app/templates/rules.tpl

@@ -1,8 +1,8 @@
-@extends('layouts/main')
+@extends ('layouts/main')
     <section class="f-main f-rules">
       <h2>{!! $p->title !!}</h2>
       <div id="id-rules">{!! $p->rules !!}</div>
-@if($p->formAction)
+@if ($p->formAction)
       <div class="f-fdiv f-lrdiv">
         <form class="f-form" method="post" action="{!! $p->formAction !!}">
           <input type="hidden" name="token" value="{!! $p->formToken !!}">

+ 58 - 62
app/templates/topic.tpl

@@ -1,62 +1,58 @@
-@section('crumbs')
+@section ('crumbs')
       <ul class="f-crumbs">
-@foreach($p->crumbs as $cur)
-@if($cur[2])
-        <li class="f-crumb"><a href="{!! $cur[0] !!}" class="active">{{ $cur[1] }}</a></li>
-@else
-        <li class="f-crumb"><a href="{!! $cur[0] !!}">{{ $cur[1] }}</a></li>
-@endif
-@endforeach
+  @foreach ($p->crumbs as $cur)
+        <li class="f-crumb"><!-- inline -->
+    @if ($cur[0])
+          <a href="{!! $cur[0] !!}" @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</a>
+    @else
+          <span @if ($cur[2]) class="active" @endif>{{ $cur[1] }}</span>
+    @endif
+        </li><!-- endinline -->
+  @endforeach
       </ul>
 @endsection
-@section('linkpost')
-@if($p->topic->canReply || $p->topic->closed)
+@section ('linkpost')
+  @if ($p->topic->canReply || $p->topic->closed)
         <div class="f-link-post">
-@if($p->topic->closed)
-          __('Topic closed')
-@else
+    @if ($p->topic->closed)
+          {!! __('Topic closed') !!}
+    @else
           <a class="f-btn" href="{!! $p->topic->linkReply !!}">{!! __('Post reply') !!}</a>
-@endif
+    @endif
         </div>
-@endif
+  @endif
 @endsection
-@section('pagination')
+@section ('pagination')
         <nav class="f-pages">
-@foreach($p->topic->pagination as $cur)
-@if($cur[2])
+  @foreach ($p->topic->pagination as $cur)
+    @if ($cur[2])
           <span class="f-page active">{{ $cur[1] }}</span>
-@elseif($cur[1] === 'space')
+    @elseif ($cur[1] === 'space')
           <span class="f-page f-pspacer">{!! __('Spacer') !!}</span>
-@elseif($cur[1] === 'prev')
+    @elseif ($cur[1] === 'prev')
           <a rel="prev" class="f-page f-pprev" href="{!! $cur[0] !!}">{!! __('Previous') !!}</a>
-@elseif($cur[1] === 'next')
+    @elseif ($cur[1] === 'next')
           <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>
 @endsection
-@extends('layouts/main')
+@extends ('layouts/main')
     <div class="f-nav-links">
-@yield('crumbs')
-@if($p->topic->canReply || $p->topic->closed || $p->topic->pagination)
+@yield ('crumbs')
+@if ($p->topic->canReply || $p->topic->closed || $p->topic->pagination)
       <div class="f-links-b clearfix">
-@yield('pagination')
-@yield('linkpost')
+  @yield ('pagination')
+  @yield ('linkpost')
       </div>
 @endif
     </div>
     <section class="f-main f-topic">
       <h2>{{ $p->topic->cens()->subject }}</h2>
-@foreach($p->posts as $post)
-      <article id="p{!! $post->id !!}" class="clearfix f-post<!-- inline -->
-@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
-      "><!-- endinline -->
+@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">
         <header class="f-post-header clearfix">
           <h3>{{ $p->topic->cens()->subject }} - #{!! $post->postNumber !!}</h3>
           <span class="left"><time datetime="{{ $post->utc()->posted }}">{{ $post->dt()->posted }}</time></span>
@@ -65,75 +61,75 @@
         <div class="f-post-body clearfix">
           <address class="f-post-left clearfix">
             <ul class="f-user-info">
-@if($post->showUserLink)
+  @if ($post->showUserLink)
               <li class="f-username"><a href="{!! $post->user->link !!}">{{ $post->user->username }}</a></li>
-@else
+  @else
               <li class="f-username">{{ $post->user->username }}</li>
-@endif
-@if($post->showUserAvatar && $post->user->avatar)
+  @endif
+  @if ($post->showUserAvatar && $post->user->avatar)
               <li class="f-avatar">
                 <img alt="{{ $post->user->username }}" src="{!! $post->user->avatar !!}">
               </li>
-@endif
+  @endif
               <li class="f-usertitle"><span>{{ $post->user->title() }}</span></li>
-@if($post->showUserInfo)
+  @if ($post->showUserInfo)
               <li class="f-postcount"><span>{!! __('%s post', $post->user->num_posts, $post->user->num()->num_posts) !!}</span></li>
-@endif
+  @endif
             </ul>
-@if($post->showUserInfo)
+  @if ($post->showUserInfo)
             <ul class="f-user-info-add">
               <li><span>{!! __('Registered:') !!} {{ $post->user->dt(true)->registered }}</span></li>
-@if($post->user->location)
+    @if ($post->user->location)
               <li><span>{!! __('From') !!} {{ $post->user->cens()->location }}</span></li>
-@endif
+    @endif
               <li><span></span></li>
             </ul>
-@endif
+  @endif
           </address>
           <div class="f-post-right f-post-main">
             {!! $post->html() !!}
           </div>
-@if($post->showSignature && $post->user->signature)
+  @if ($post->showSignature && $post->user->signature)
           <div class="f-post-right f-post-signature">
             <hr>
             {!! $post->user->htmlSign !!}
           </div>
-@endif
+  @endif
         </div>
         <footer class="f-post-footer clearfix">
           <div class="f-post-left">
             <span></span>
           </div>
-@if($post->controls)
+  @if ($post->controls)
           <div class="f-post-right clearfix">
             <ul>
-@foreach($post->controls as $key => $control)
+    @foreach ($post->controls as $key => $control)
               <li class="f-post{!! $key !!}"><a class="f-btn" href="{!! $control[0] !!}">{!! __($control[1]) !!}</a></li>
-@endforeach
+    @endforeach
             </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->topic->canReply || $p->topic->closed || $p->topic->pagination)
       <div class="f-links-a clearfix">
-@yield('linkpost')
-@yield('pagination')
+  @yield ('linkpost')
+  @yield ('pagination')
       </div>
 @endif
-@yield('crumbs')
+@yield ('crumbs')
     </div>
-@if($p->online)
-@include('layouts/stats')
+@if ($p->online)
+  @include ('layouts/stats')
 @endif
-@if($form = $p->form)
+@if ($form = $p->form)
     <section class="post-form">
       <h2>{!! __('Quick post') !!}</h2>
       <div class="f-fdiv">
-@include('layouts/form')
+  @include ('layouts/form')
       </div>
     </section>
 @endif