Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
type_text.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\profilefields\type;
015
016 class type_text extends type_string_common
017 {
018 /**
019 * Request object
020 * @var \phpbb\request\request
021 */
022 protected $request;
023
024 /**
025 * Template object
026 * @var \phpbb\template\template
027 */
028 protected $template;
029
030 /**
031 * User object
032 * @var \phpbb\user
033 */
034 protected $user;
035
036 /**
037 * Construct
038 *
039 * @param \phpbb\request\request $request Request object
040 * @param \phpbb\template\template $template Template object
041 * @param \phpbb\user $user User object
042 */
043 public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user)
044 {
045 $this->request = $request;
046 $this->template = $template;
047 $this->user = $user;
048 }
049
050 /**
051 * {@inheritDoc}
052 */
053 public function get_name_short()
054 {
055 return 'text';
056 }
057
058 /**
059 * {@inheritDoc}
060 */
061 public function get_options($default_lang_id, $field_data)
062 {
063 $options = array(
064 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="rows" value="' . $field_data['rows'] . '" /> ' . $this->user->lang['ROWS'] . '</dd><dd><input type="number" min="0" max="99999" name="columns" value="' . $field_data['columns'] . '" /> ' . $this->user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $field_data['field_length'] . '" />'),
065 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_minlen" value="' . $field_data['field_minlen'] . '" />'),
066 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="9999999999" name="field_maxlen" value="' . $field_data['field_maxlen'] . '" />'),
067 3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options($field_data) . '</select>'),
068 );
069
070 return $options;
071 }
072
073 /**
074 * {@inheritDoc}
075 */
076 public function get_default_option_values()
077 {
078 return array(
079 'field_length' => '5|80',
080 'field_minlen' => 0,
081 'field_maxlen' => 1000,
082 'field_validation' => '.*',
083 'field_novalue' => '',
084 'field_default_value' => '',
085 );
086 }
087
088 /**
089 * {@inheritDoc}
090 */
091 public function get_profile_field($profile_row)
092 {
093 $var_name = 'pf_' . $profile_row['field_ident'];
094 return $this->request->variable($var_name, (string) $profile_row['field_default_value'], true);
095 }
096
097 /**
098 * {@inheritDoc}
099 */
100 public function validate_profile_field(&$field_value, $field_data)
101 {
102 return $this->validate_string_profile_field('text', $field_value, $field_data);
103 }
104
105 /**
106 * {@inheritDoc}
107 */
108 public function generate_field($profile_row, $preview_options = false)
109 {
110 $field_length = explode('|', $profile_row['field_length']);
111 $profile_row['field_rows'] = $field_length[0];
112 $profile_row['field_cols'] = $field_length[1];
113 $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
114 $field_ident = $profile_row['field_ident'];
115 $default_value = $profile_row['lang_default_value'];
116
117 $profile_row['field_value'] = ($this->request->is_set($field_ident)) ? $this->request->variable($field_ident, $default_value, true) : ((!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false) ? $default_value : $this->user->profile_fields[$field_ident]);
118
119 $this->template->assign_block_vars('text', array_change_key_case($profile_row, CASE_UPPER));
120 }
121
122 /**
123 * {@inheritDoc}
124 */
125 public function get_database_column_type()
126 {
127 return 'MTEXT';
128 }
129
130 /**
131 * {@inheritDoc}
132 */
133 public function get_language_options($field_data)
134 {
135 $options = array(
136 'lang_name' => 'string',
137 );
138
139 if ($field_data['lang_explain'])
140 {
141 $options['lang_explain'] = 'text';
142 }
143
144 if (strlen($field_data['lang_default_value']))
145 {
146 $options['lang_default_value'] = 'text';
147 }
148
149 return $options;
150 }
151
152 /**
153 * {@inheritDoc}
154 */
155 public function get_excluded_options($key, $action, $current_value, &$field_data, $step)
156 {
157 if ($step == 2 && $key == 'field_length')
158 {
159 if ($this->request->is_set('rows'))
160 {
161 $field_data['rows'] = $this->request->variable('rows', 0);
162 $field_data['columns'] = $this->request->variable('columns', 0);
163 $current_value = $field_data['rows'] . '|' . $field_data['columns'];
164 }
165 else
166 {
167 $row_col = explode('|', $current_value);
168 $field_data['rows'] = $row_col[0];
169 $field_data['columns'] = $row_col[1];
170 }
171
172 return $current_value;
173 }
174
175 return parent::get_excluded_options($key, $action, $current_value, $field_data, $step);
176 }
177
178 /**
179 * {@inheritDoc}
180 */
181 public function prepare_hidden_fields($step, $key, $action, &$field_data)
182 {
183 if ($key == 'field_length' && $this->request->is_set('rows'))
184 {
185 $field_data['rows'] = $this->request->variable('rows', 0);
186 $field_data['columns'] = $this->request->variable('columns', 0);
187 return $field_data['rows'] . '|' . $field_data['columns'];
188 }
189
190 return parent::prepare_hidden_fields($step, $key, $action, $field_data);
191 }
192
193 /**
194 * {@inheritDoc}
195 */
196 public function display_options(&$template_vars, &$field_data)
197 {
198 $template_vars = array_merge($template_vars, array(
199 'S_TEXT' => true,
200 'L_DEFAULT_VALUE_EXPLAIN' => $this->user->lang['TEXT_DEFAULT_VALUE_EXPLAIN'],
201 'LANG_DEFAULT_VALUE' => $field_data['lang_default_value'],
202 ));
203 }
204 }
205