[ 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\profilefields\type; 15 16 class type_string extends type_string_common 17 { 18 /** 19 * Request object 20 * @var \phpbb\request\request 21 */ 22 protected $request; 23 24 /** 25 * Template object 26 * @var \phpbb\template\template 27 */ 28 protected $template; 29 30 /** 31 * User object 32 * @var \phpbb\user 33 */ 34 protected $user; 35 36 /** 37 * Construct 38 * 39 * @param \phpbb\request\request $request Request object 40 * @param \phpbb\template\template $template Template object 41 * @param \phpbb\user $user User object 42 */ 43 public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user) 44 { 45 $this->request = $request; 46 $this->template = $template; 47 $this->user = $user; 48 } 49 50 /** 51 * {@inheritDoc} 52 */ 53 public function get_name_short() 54 { 55 return 'string'; 56 } 57 58 /** 59 * {@inheritDoc} 60 */ 61 public function get_options($default_lang_id, $field_data) 62 { 63 $options = array( 64 0 => array('TITLE' => $this->user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_length" value="' . $field_data['field_length'] . '" />'), 65 1 => array('TITLE' => $this->user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_minlen" value="' . $field_data['field_minlen'] . '" />'), 66 2 => array('TITLE' => $this->user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="number" min="0" max="99999" name="field_maxlen" value="' . $field_data['field_maxlen'] . '" />'), 67 3 => array('TITLE' => $this->user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options($field_data) . '</select>'), 68 ); 69 70 return $options; 71 } 72 73 /** 74 * {@inheritDoc} 75 */ 76 public function get_default_option_values() 77 { 78 return array( 79 'field_length' => 10, 80 'field_minlen' => 0, 81 'field_maxlen' => 20, 82 'field_validation' => '.*', 83 'field_novalue' => '', 84 'field_default_value' => '', 85 ); 86 } 87 88 /** 89 * {@inheritDoc} 90 */ 91 public function get_profile_field($profile_row) 92 { 93 $var_name = 'pf_' . $profile_row['field_ident']; 94 return $this->request->variable($var_name, (string) $profile_row['field_default_value'], true); 95 } 96 97 /** 98 * {@inheritDoc} 99 */ 100 public function validate_profile_field(&$field_value, $field_data) 101 { 102 return $this->validate_string_profile_field('string', $field_value, $field_data); 103 } 104 105 /** 106 * {@inheritDoc} 107 */ 108 public function generate_field($profile_row, $preview_options = false) 109 { 110 $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident']; 111 $field_ident = $profile_row['field_ident']; 112 $default_value = $profile_row['lang_default_value']; 113 $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]); 114 115 $this->template->assign_block_vars($this->get_name_short(), array_change_key_case($profile_row, CASE_UPPER)); 116 } 117 118 /** 119 * {@inheritDoc} 120 */ 121 public function get_database_column_type() 122 { 123 return 'VCHAR'; 124 } 125 126 /** 127 * {@inheritDoc} 128 */ 129 public function get_language_options($field_data) 130 { 131 $options = array( 132 'lang_name' => 'string', 133 ); 134 135 if ($field_data['lang_explain']) 136 { 137 $options['lang_explain'] = 'text'; 138 } 139 140 if (strlen($field_data['lang_default_value'])) 141 { 142 $options['lang_default_value'] = 'string'; 143 } 144 145 return $options; 146 } 147 148 /** 149 * {@inheritDoc} 150 */ 151 public function display_options(&$template_vars, &$field_data) 152 { 153 $template_vars = array_merge($template_vars, array( 154 'S_STRING' => true, 155 'L_DEFAULT_VALUE_EXPLAIN' => $this->user->lang['STRING_DEFAULT_VALUE_EXPLAIN'], 156 'LANG_DEFAULT_VALUE' => $field_data['lang_default_value'], 157 )); 158 } 159 }
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 |