Rules.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * This file is part of the ForkBB <https://github.com/forkbb>.
  4. *
  5. * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
  6. * @license The MIT License (MIT)
  7. */
  8. declare(strict_types=1);
  9. namespace ForkBB\Models\Pages;
  10. use ForkBB\Models\Page;
  11. use function \ForkBB\__;
  12. class Rules extends Page
  13. {
  14. /**
  15. * Подготавливает данные для шаблона
  16. */
  17. public function view(): Page
  18. {
  19. $this->fIndex = self::FI_RULES;
  20. $this->nameTpl = 'rules';
  21. $this->onlinePos = 'rules';
  22. $this->onlineDetail = null;
  23. $this->canonical = $this->c->Router->link('Rules');
  24. $this->crumbs = $this->crumbs(
  25. [
  26. $this->c->Router->link('Rules'),
  27. 'Forum rules',
  28. ]
  29. );
  30. $this->rules = $this->c->config->o_rules_message;
  31. return $this;
  32. }
  33. /**
  34. * Подготавливает данные для шаблона
  35. */
  36. public function confirmation(): Page
  37. {
  38. $this->c->Lang->load('register');
  39. $this->fIndex = self::FI_REG;
  40. $this->nameTpl = 'rules';
  41. $this->onlinePos = 'rules';
  42. $this->onlineDetail = null;
  43. $this->robots = 'noindex';
  44. $this->crumbs = $this->crumbs(
  45. 'Forum rules',
  46. [
  47. $this->c->Router->link('Register'),
  48. 'Register',
  49. ]
  50. );
  51. $this->rules = 1 === $this->c->config->b_rules ? $this->c->config->o_rules_message : __('If no rules');
  52. $this->form = $this->formAgree();
  53. return $this;
  54. }
  55. /**
  56. * Подготавливает массив данных для формы
  57. */
  58. protected function formAgree(): array
  59. {
  60. return [
  61. 'action' => $this->c->Router->link('RegisterForm'),
  62. 'hidden' => [
  63. 'token' => $this->c->Csrf->create('RegisterForm'),
  64. ],
  65. 'sets' => [
  66. 'agree' => [
  67. 'fields' => [
  68. 'agree' => [
  69. 'type' => 'checkbox',
  70. 'label' => 'Agree',
  71. 'value' => $this->c->Csrf->create('Register'),
  72. ],
  73. ],
  74. ],
  75. ],
  76. 'btns' => [
  77. 'register' => [
  78. 'type' => 'submit',
  79. 'value' => __('Register'),
  80. ],
  81. ],
  82. ];
  83. }
  84. }