Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 35 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 35 |
|
0.00% |
0 / 2 |
132 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
| handle | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
110 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\forum\controller; |
| 15 | |
| 16 | use phpbb\auth\auth; |
| 17 | use phpbb\config\config; |
| 18 | use phpbb\controller\helper as controller_helper; |
| 19 | use phpbb\event\dispatcher; |
| 20 | use phpbb\forum\birthday_helper; |
| 21 | use phpbb\group\helper as group_helper; |
| 22 | use phpbb\language\language; |
| 23 | use phpbb\template\template; |
| 24 | use phpbb\user; |
| 25 | use Symfony\Component\HttpFoundation\Response; |
| 26 | |
| 27 | class index |
| 28 | { |
| 29 | /** @var auth */ |
| 30 | protected $auth; |
| 31 | |
| 32 | /** @var birthday_helper */ |
| 33 | protected $birthday_helper; |
| 34 | |
| 35 | /** @var config */ |
| 36 | protected $config; |
| 37 | |
| 38 | /** @var controller_helper */ |
| 39 | protected $controller_helper; |
| 40 | |
| 41 | /** @var dispatcher */ |
| 42 | protected $dispatcher; |
| 43 | |
| 44 | /** @var group_helper */ |
| 45 | protected $group_helper; |
| 46 | |
| 47 | /** @var language */ |
| 48 | protected $language; |
| 49 | |
| 50 | /** @var user */ |
| 51 | protected $user; |
| 52 | |
| 53 | /** @var template */ |
| 54 | protected $template; |
| 55 | |
| 56 | /** @var string */ |
| 57 | protected $phpbb_root_path; |
| 58 | |
| 59 | /** @var string */ |
| 60 | protected $phpEx; |
| 61 | |
| 62 | /** |
| 63 | * Constructor |
| 64 | * |
| 65 | * @param auth $auth |
| 66 | * @param birthday_helper $birthday_helper |
| 67 | * @param config $config |
| 68 | * @param controller_helper $controller_helper |
| 69 | * @param dispatcher $dispatcher |
| 70 | * @param group_helper $group_helper |
| 71 | * @param language $language |
| 72 | * @param user $user |
| 73 | * @param template $template |
| 74 | * @param string $phpbb_root_path |
| 75 | * @param string $phpEx |
| 76 | */ |
| 77 | public function __construct(auth $auth, birthday_helper $birthday_helper, config $config, controller_helper $controller_helper, dispatcher $dispatcher, group_helper $group_helper, language $language, user $user, template $template, string $phpbb_root_path, string $phpEx) |
| 78 | { |
| 79 | $this->auth = $auth; |
| 80 | $this->birthday_helper = $birthday_helper; |
| 81 | $this->config = $config; |
| 82 | $this->controller_helper = $controller_helper; |
| 83 | $this->dispatcher = $dispatcher; |
| 84 | $this->group_helper = $group_helper; |
| 85 | $this->language = $language; |
| 86 | $this->user = $user; |
| 87 | $this->template = $template; |
| 88 | $this->phpbb_root_path = $phpbb_root_path; |
| 89 | $this->phpEx = $phpEx; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Display the index page |
| 94 | * |
| 95 | * @return Response |
| 96 | */ |
| 97 | public function handle(): Response |
| 98 | { |
| 99 | if (!function_exists('display_forums')) |
| 100 | { |
| 101 | include($this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx); |
| 102 | } |
| 103 | |
| 104 | if (!function_exists('get_username_string')) |
| 105 | { |
| 106 | include($this->phpbb_root_path . 'includes/functions_content.' . $this->phpEx); |
| 107 | } |
| 108 | |
| 109 | $this->language->add_lang('viewforum'); |
| 110 | |
| 111 | display_forums('', $this->config['load_moderators']); |
| 112 | |
| 113 | // This is shown only if display_online_list is true |
| 114 | $this->group_helper->display_legend(); |
| 115 | |
| 116 | $this->birthday_helper->display_birthdays(); |
| 117 | |
| 118 | $this->template->assign_vars(array( |
| 119 | 'TOTAL_POSTS' => $this->language->lang('TOTAL_POSTS_COUNT', (int) $this->config['num_posts']), |
| 120 | 'TOTAL_TOPICS' => $this->language->lang('TOTAL_TOPICS', (int) $this->config['num_topics']), |
| 121 | 'TOTAL_USERS' => $this->language->lang('TOTAL_USERS', (int) $this->config['num_users']), |
| 122 | 'NEWEST_USER' => $this->language->lang('NEWEST_USER', get_username_string('full', $this->config['newest_user_id'], $this->config['newest_username'], $this->config['newest_user_colour'])), |
| 123 | |
| 124 | 'S_LOGIN_ACTION' => append_sid("{$this->phpbb_root_path}ucp.$this->phpEx", 'mode=login'), |
| 125 | 'U_SEND_PASSWORD' => ($this->config['email_enable'] && $this->config['allow_password_reset']) ? $this->controller_helper->route('phpbb_ucp_forgot_password_controller') : '', |
| 126 | 'S_INDEX' => true, |
| 127 | |
| 128 | 'U_CANONICAL' => generate_board_url() . '/', |
| 129 | 'U_MARK_FORUMS' => ($this->user->data['is_registered'] || $this->config['load_anon_lastread']) ? $this->controller_helper->route('phpbb_index_controller', ['hash' => generate_link_hash('global'), 'mark' => 'forums', 'mark_time' => time()]) : '', |
| 130 | 'U_MCP' => ($this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}mcp.$this->phpEx", 'i=main&mode=front') : '') |
| 131 | ); |
| 132 | |
| 133 | $page_title = ($this->config['board_index_text'] !== '') ? $this->config['board_index_text'] : $this->language->lang('INDEX'); |
| 134 | |
| 135 | /** |
| 136 | * You can use this event to modify the page title and load data for the index |
| 137 | * |
| 138 | * @event core.index_modify_page_title |
| 139 | * @var string page_title Title of the index page |
| 140 | * @since 3.1.0-a1 |
| 141 | */ |
| 142 | $vars = array('page_title'); |
| 143 | extract($this->dispatcher->trigger_event('core.index_modify_page_title', compact($vars))); |
| 144 | |
| 145 | return $this->controller_helper->render('index_body.html', $page_title, 200, true); |
| 146 | } |
| 147 | } |