[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/profilefields/type/ -> type_base.php (source)

   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  abstract class type_base implements type_interface
  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()
  54      {
  55          return $this->user->lang('FIELD_' . strtoupper($this->get_name_short()));
  56      }
  57  
  58      /**
  59      * {@inheritDoc}
  60      */
  61  	public function get_service_name()
  62      {
  63          return 'profilefields.type.' . $this->get_name_short();
  64      }
  65  
  66      /**
  67      * {@inheritDoc}
  68      */
  69  	public function get_template_filename()
  70      {
  71          return 'profilefields/' . $this->get_name_short() . '.html';
  72      }
  73  
  74      /**
  75      * {@inheritDoc}
  76      */
  77  	public function get_field_ident($field_data)
  78      {
  79          return 'pf_' . $field_data['field_ident'];
  80      }
  81  
  82      /**
  83      * {@inheritDoc}
  84      */
  85  	public function get_field_name($field_name)
  86      {
  87          return isset($this->user->lang[$field_name]) ? $this->user->lang[$field_name] : $field_name;
  88      }
  89  
  90      /**
  91      * {@inheritDoc}
  92      */
  93  	public function get_profile_contact_value($field_value, $field_data)
  94      {
  95          return $this->get_profile_value($field_value, $field_data);
  96      }
  97  
  98      /**
  99      * {@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  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1