Message.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 Message extends Page
  13. {
  14. /**
  15. * Подготавливает данные для шаблона
  16. */
  17. public function message(/* string|array */ $message, bool $back = true, int $status = 400, array $headers = []): Page
  18. {
  19. $this->nameTpl = 'message';
  20. $this->onlinePos = 'info-' . $status;
  21. $this->onlineDetail = null;
  22. $this->httpStatus = \max(200, $status);
  23. $this->titles = 'Info';
  24. $this->back = $back;
  25. if (! empty($headers)) {
  26. foreach ($headers as $header) {
  27. $this->header($header[0], $header[1], $header[2] ?? true);
  28. }
  29. }
  30. if ($status < 200) {
  31. $type = 'i';
  32. } elseif ($status < 300) {
  33. $type = 's';
  34. } elseif ($status < 400) {
  35. $type = 'w';
  36. } else {
  37. $type = 'e';
  38. }
  39. if (
  40. '' === $message
  41. && empty($this->fIswev)
  42. ) {
  43. $message = 'Empty message';
  44. }
  45. if ('' !== $message) {
  46. $this->fIswev = [$type, $message];
  47. }
  48. return $this;
  49. }
  50. /**
  51. * Задает массивы главной навигации форума
  52. */
  53. protected function boardNavigation(): void
  54. {
  55. if ($this->c->config->i_fork_revision < $this->c->FORK_REVISION) {
  56. return;
  57. }
  58. parent::boardNavigation();
  59. }
  60. }