[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
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\install\module\obtain_data\task; 15 16 use phpbb\install\exception\user_interaction_required_exception; 17 18 /** 19 * This class obtains default data from the user related to board (Board name, Board descritpion, etc...) 20 */ 21 class obtain_board_data extends \phpbb\install\task_base implements \phpbb\install\task_interface 22 { 23 /** 24 * @var \phpbb\install\helper\config 25 */ 26 protected $install_config; 27 28 /** 29 * @var \phpbb\install\helper\iohandler\iohandler_interface 30 */ 31 protected $io_handler; 32 33 /** 34 * @var \phpbb\language\language_file_helper 35 */ 36 protected $language_helper; 37 38 /** 39 * Constructor 40 * 41 * @param \phpbb\install\helper\config $config Installer's config 42 * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler Installer's input-output handler 43 * @param \phpbb\language\language_file_helper $lang_helper Language file helper 44 */ 45 public function __construct(\phpbb\install\helper\config $config, 46 \phpbb\install\helper\iohandler\iohandler_interface $iohandler, 47 \phpbb\language\language_file_helper $lang_helper) 48 { 49 $this->install_config = $config; 50 $this->io_handler = $iohandler; 51 $this->language_helper = $lang_helper; 52 53 parent::__construct(true); 54 } 55 56 /** 57 * {@inheritdoc} 58 */ 59 public function run() 60 { 61 // Check if data is sent 62 if ($this->io_handler->get_input('submit_board', false)) 63 { 64 $this->process_form(); 65 } 66 else 67 { 68 $this->request_form_data(); 69 } 70 } 71 72 /** 73 * Process form data 74 */ 75 protected function process_form() 76 { 77 // Board data 78 $default_lang = $this->io_handler->get_input('default_lang', ''); 79 $board_name = $this->io_handler->get_input('board_name', '', true); 80 $board_desc = $this->io_handler->get_input('board_description', '', true); 81 82 // Check default lang 83 $langs = $this->language_helper->get_available_languages(); 84 $lang_valid = false; 85 86 foreach ($langs as $lang) 87 { 88 if ($lang['iso'] === $default_lang) 89 { 90 $lang_valid = true; 91 break; 92 } 93 } 94 95 $this->install_config->set('board_name', $board_name); 96 $this->install_config->set('board_description', $board_desc); 97 98 if ($lang_valid) 99 { 100 $this->install_config->set('default_lang', $default_lang); 101 } 102 else 103 { 104 $this->request_form_data(true); 105 } 106 } 107 108 /** 109 * Request data from the user 110 * 111 * @param bool $use_request_data Whether to use submited data 112 * 113 * @throws user_interaction_required_exception When the user is required to provide data 114 */ 115 protected function request_form_data($use_request_data = false) 116 { 117 if ($use_request_data) 118 { 119 $board_name = $this->io_handler->get_input('board_name', '', true); 120 $board_desc = $this->io_handler->get_input('board_description', '', true); 121 } 122 else 123 { 124 $board_name = '{L_CONFIG_SITENAME}'; 125 $board_desc = '{L_CONFIG_SITE_DESC}'; 126 } 127 128 // Use language because we only check this to be valid 129 $default_lang = $this->install_config->get('user_language', 'en'); 130 131 $langs = $this->language_helper->get_available_languages(); 132 $lang_options = array(); 133 134 foreach ($langs as $lang) 135 { 136 $lang_options[] = array( 137 'value' => $lang['iso'], 138 'label' => $lang['local_name'], 139 'selected' => ($default_lang === $lang['iso']), 140 ); 141 } 142 143 $board_form = array( 144 'default_lang' => array( 145 'label' => 'DEFAULT_LANGUAGE', 146 'type' => 'select', 147 'options' => $lang_options, 148 ), 149 'board_name' => array( 150 'label' => 'BOARD_NAME', 151 'type' => 'text', 152 'default' => $board_name, 153 ), 154 'board_description' => array( 155 'label' => 'BOARD_DESCRIPTION', 156 'type' => 'text', 157 'default' => $board_desc, 158 ), 159 'submit_board' => array( 160 'label' => 'SUBMIT', 161 'type' => 'submit', 162 ), 163 ); 164 165 $this->io_handler->add_user_form_group('BOARD_CONFIG', $board_form); 166 167 throw new user_interaction_required_exception(); 168 } 169 170 /** 171 * {@inheritdoc} 172 */ 173 static public function get_step_count() 174 { 175 return 0; 176 } 177 178 /** 179 * {@inheritdoc} 180 */ 181 public function get_task_lang_name() 182 { 183 return ''; 184 } 185 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |