Index.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 Index extends Page
  13. {
  14. /**
  15. * Подготовка данных для шаблона
  16. */
  17. public function view(): Page
  18. {
  19. $this->c->Lang->load('index');
  20. $this->c->Lang->load('subforums');
  21. // крайний пользователь // ???? может в stats переместить?
  22. $this->c->stats->userLast = [
  23. 'name' => $this->c->stats->userLast['username'],
  24. 'link' => $this->user->viewUsers
  25. ? $this->c->Router->link(
  26. 'User',
  27. [
  28. 'id' => $this->c->stats->userLast['id'],
  29. 'name' => $this->c->stats->userLast['username'],
  30. ]
  31. )
  32. : null,
  33. ];
  34. // для таблицы разделов
  35. $root = $this->c->forums->loadTree(0);
  36. $forums = empty($root) ? [] : $root->subforums;
  37. $ctgs = [];
  38. if (empty($forums)) {
  39. $this->fIswev = ['i', 'Empty board'];
  40. } else {
  41. foreach ($forums as $forum) {
  42. $ctgs[$forum->cat_id][] = $forum;
  43. }
  44. }
  45. $this->nameTpl = 'index';
  46. $this->onlinePos = 'index';
  47. $this->onlineDetail = true;
  48. $this->onlineFilter = false;
  49. $this->canonical = $this->c->Router->link('Index');
  50. $this->stats = $this->c->stats;
  51. $this->online = $this->c->Online->calc($this)->info();
  52. $this->categoryes = $ctgs;
  53. if (! $this->user->isGuest) {
  54. $this->linkMarkRead = $this->c->Router->link(
  55. 'MarkRead',
  56. [
  57. 'id' => 0,
  58. ]
  59. );
  60. }
  61. if ($this->c->config->i_feed_type > 0) {
  62. $feedType = 2 === $this->c->config->i_feed_type ? 'atom' : 'rss';
  63. $this->pageHeader('feed', 'link', 0, [
  64. 'rel' => 'alternate',
  65. 'type' => "application/{$feedType}+xml",
  66. 'href' => $this->c->Router->link('Feed', ['type' => $feedType]),
  67. ]);
  68. }
  69. return $this;
  70. }
  71. }