Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
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_string_common.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_string_common extends type_base
017 {
018 protected $validation_options = array(
019 'CHARS_ANY' => '.*',
020 'NUMBERS_ONLY' => '[0-9]+',
021 'ALPHA_ONLY' => '[\w]+',
022 'ALPHA_UNDERSCORE' => '[\w_]+',
023 'ALPHA_DOTS' => '[\w.]+',
024 'ALPHA_SPACERS' => '[\w\x20_+\-\[\]]+',
025 'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-_]+',
026 'LETTER_NUM_ONLY' => '[\p{Lu}\p{Ll}0-9]+',
027 'LETTER_NUM_UNDERSCORE' => '[\p{Lu}\p{Ll}0-9_]+',
028 'LETTER_NUM_DOTS' => '[\p{Lu}\p{Ll}0-9.]+',
029 'LETTER_NUM_SPACERS' => '[\p{Lu}\p{Ll}0-9\x20_+\-\[\]]+',
030 'LETTER_NUM_PUNCTUATION' => '[\p{Lu}\p{Ll}][\p{Lu}\p{Ll}0-9.,\-_]+',
031 );
032
033 /**
034 * Return possible validation options
035 */
036 public function validate_options($field_data)
037 {
038 $validate_options = '';
039 foreach ($this->validation_options as $lang => $value)
040 {
041 $selected = ($field_data['field_validation'] == $value) ? ' selected="selected"' : '';
042 $validate_options .= '<option value="' . $value . '"' . $selected . '>' . $this->user->lang[$lang] . '</option>';
043 }
044
045 return $validate_options;
046 }
047
048 /**
049 * {@inheritDoc}
050 */
051 public function get_default_field_value($field_data)
052 {
053 return $field_data['lang_default_value'];
054 }
055
056 /**
057 * Validate entered profile field data
058 *
059 * @param string $field_type Field type (string or text)
060 * @param mixed $field_value Field value to validate
061 * @param array $field_data Array with requirements of the field
062 * @return mixed String with key of the error language string, false otherwise
063 */
064 public function validate_string_profile_field($field_type, &$field_value, $field_data)
065 {
066 if (trim($field_value) === '' && !$field_data['field_required'])
067 {
068 return false;
069 }
070 else if (trim($field_value) === '' && $field_data['field_required'])
071 {
072 return $this->user->lang('FIELD_REQUIRED', $this->get_field_name($field_data['lang_name']));
073 }
074
075 if ($field_data['field_minlen'] && utf8_strlen($field_value) < $field_data['field_minlen'])
076 {
077 return $this->user->lang('FIELD_TOO_SHORT', (int) $field_data['field_minlen'], $this->get_field_name($field_data['lang_name']));
078 }
079 else if ($field_data['field_maxlen'] && utf8_strlen(html_entity_decode($field_value)) > $field_data['field_maxlen'])
080 {
081 return $this->user->lang('FIELD_TOO_LONG', (int) $field_data['field_maxlen'], $this->get_field_name($field_data['lang_name']));
082 }
083
084 if (!empty($field_data['field_validation']) && $field_data['field_validation'] != '.*')
085 {
086 $field_validate = ($field_type != 'text') ? $field_value : bbcode_nl2br($field_value);
087 if (!preg_match('#^' . str_replace('\\\\', '\\', $field_data['field_validation']) . '$#iu', $field_validate))
088 {
089 $validation = array_search($field_data['field_validation'], $this->validation_options);
090 if ($validation)
091 {
092 return $this->user->lang('FIELD_INVALID_CHARS_' . $validation, $this->get_field_name($field_data['lang_name']));
093 }
094 return $this->user->lang('FIELD_INVALID_CHARS_INVALID', $this->get_field_name($field_data['lang_name']));
095 }
096 }
097
098 return false;
099 }
100
101 /**
102 * {@inheritDoc}
103 */
104 public function get_profile_value($field_value, $field_data)
105 {
106 if (($field_value === null || $field_value === '') && !$field_data['field_show_novalue'])
107 {
108 return null;
109 }
110
111 $field_value = make_clickable($field_value);
112 $field_value = censor_text($field_value);
113 $field_value = bbcode_nl2br($field_value);
114 return $field_value;
115 }
116
117 /**
118 * {@inheritDoc}
119 */
120 public function get_profile_value_raw($field_value, $field_data)
121 {
122 if (($field_value === null || $field_value === '') && !$field_data['field_show_novalue'])
123 {
124 return null;
125 }
126
127 return $field_value;
128 }
129
130 /**
131 * {@inheritDoc}
132 */
133 public function get_profile_contact_value($field_value, $field_data)
134 {
135 return $this->get_profile_value_raw($field_value, $field_data);
136 }
137
138 /**
139 * {@inheritDoc}
140 */
141 public function prepare_options_form(&$exclude_options, &$visibility_options)
142 {
143 $exclude_options[1][] = 'lang_default_value';
144
145 return $this->request->variable('lang_options', '', true);
146 }
147 }
148