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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

type_string.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 4.02 KiB


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_string 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 'string';
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="field_length" value="' . $field_data['field_length'] . '" />'),
065              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'] . '" />'),
066              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'] . '" />'),
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'        => 10,
080              'field_minlen'        => 0,
081              'field_maxlen'        => 20,
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('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  }
160