Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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_base.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 abstract class type_base implements type_interface
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()
054 {
055 return $this->user->lang('FIELD_' . strtoupper($this->get_name_short()));
056 }
057
058 /**
059 * {@inheritDoc}
060 */
061 public function get_service_name()
062 {
063 return 'profilefields.type.' . $this->get_name_short();
064 }
065
066 /**
067 * {@inheritDoc}
068 */
069 public function get_template_filename()
070 {
071 return 'profilefields/' . $this->get_name_short() . '.html';
072 }
073
074 /**
075 * {@inheritDoc}
076 */
077 public function get_field_ident($field_data)
078 {
079 return 'pf_' . $field_data['field_ident'];
080 }
081
082 /**
083 * {@inheritDoc}
084 */
085 public function get_field_name($field_name)
086 {
087 return isset($this->user->lang[$field_name]) ? $this->user->lang[$field_name] : $field_name;
088 }
089
090 /**
091 * {@inheritDoc}
092 */
093 public function get_profile_contact_value($field_value, $field_data)
094 {
095 return $this->get_profile_value($field_value, $field_data);
096 }
097
098 /**
099 * {@inheritDoc}
100 */
101 public function get_language_options_input($field_data)
102 {
103 $field_data['l_lang_name'] = $this->request->variable('l_lang_name', array(0 => ''), true);
104 $field_data['l_lang_explain'] = $this->request->variable('l_lang_explain', array(0 => ''), true);
105 $field_data['l_lang_default_value'] = $this->request->variable('l_lang_default_value', array(0 => ''), true);
106 $field_data['l_lang_options'] = $this->request->variable('l_lang_options', array(0 => ''), true);
107
108 return $field_data;
109 }
110
111 /**
112 * {@inheritDoc}
113 */
114 public function prepare_options_form(&$exclude_options, &$visibility_options)
115 {
116 return $this->request->variable('lang_options', '', true);
117 }
118
119 /**
120 * {@inheritDoc}
121 */
122 public function validate_options_on_submit($error, $field_data)
123 {
124 return $error;
125 }
126
127 /**
128 * {@inheritDoc}
129 */
130 public function get_excluded_options($key, $action, $current_value, &$field_data, $step)
131 {
132 if ($step == 3 && ($field_data[$key] || $action != 'edit') && $key == 'l_lang_options' && is_array($field_data[$key]))
133 {
134 foreach ($field_data[$key] as $lang_id => $options)
135 {
136 $field_data[$key][$lang_id] = is_array($options) ? $options : explode("\n", $options);
137 }
138
139 return $current_value;
140 }
141
142 return $current_value;
143 }
144
145 /**
146 * {@inheritDoc}
147 */
148 public function prepare_hidden_fields($step, $key, $action, &$field_data)
149 {
150 if (!$this->request->is_set($key))
151 {
152 // Do not set this variable, we will use the default value
153 return null;
154 }
155 else if ($key == 'field_ident' && isset($field_data[$key]))
156 {
157 return $field_data[$key];
158 }
159 else
160 {
161 $default_value = '';
162 $lang_fields = array(
163 'l_lang_name',
164 'l_lang_explain',
165 'l_lang_default_value',
166 'l_lang_options',
167 );
168
169 if (in_array($key, $lang_fields))
170 {
171 $default_value = array(0 => '');
172 }
173 return $this->request->variable($key, $default_value, true);
174 }
175 }
176
177 /**
178 * {@inheritDoc}
179 */
180 public function display_options(&$template_vars, &$field_data)
181 {
182 return;
183 }
184
185 /**
186 * Return templated value/field. Possible values for $mode are:
187 * change == user is able to set/enter profile values; preview == just show the value
188 */
189 public function process_field_row($mode, $profile_row)
190 {
191 $preview_options = ($mode == 'preview') ? $profile_row['lang_options'] : false;
192
193 // set template filename
194 $this->template->set_filenames(array(
195 'cp_body' => $this->get_template_filename(),
196 ));
197
198 // empty previously filled blockvars
199 $this->template->destroy_block_vars($this->get_name_short());
200
201 // Assign template variables
202 $this->generate_field($profile_row, $preview_options);
203
204 return $this->template->assign_display('cp_body');
205 }
206 }
207