예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function generate_field($profile_row, $preview_options = false)
 {
     $profile_row['field_ident'] = isset($profile_row['var_name']) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
     $field_ident = $profile_row['field_ident'];
     $default_value = $profile_row['field_default_value'];
     // checkbox - set the value to "true" if it has been set to 1
     if ($profile_row['field_length'] == 2) {
         $value = $this->request->is_set($field_ident) && $this->request->variable($field_ident, $default_value) == 1 ? true : (!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false ? $default_value : $this->user->profile_fields[$field_ident]);
     } else {
         $value = $this->request->is_set($field_ident) ? $this->request->variable($field_ident, $default_value) : (!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false ? $default_value : $this->user->profile_fields[$field_ident]);
     }
     $profile_row['field_value'] = (int) $value;
     $this->template->assign_block_vars('bool', array_change_key_case($profile_row, CASE_UPPER));
     if ($profile_row['field_length'] == 1) {
         if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1)) {
             if ($preview_options) {
                 $this->lang_helper->load_preview_options($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
             } else {
                 $this->lang_helper->load_option_lang($profile_row['lang_id']);
             }
         }
         $options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);
         foreach ($options as $option_id => $option_value) {
             $this->template->assign_block_vars('bool.options', array('OPTION_ID' => $option_id, 'CHECKED' => $value == $option_id ? ' checked="checked"' : '', 'VALUE' => $option_value));
         }
     }
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function generate_field($profile_row, $preview_options = false)
 {
     $profile_row['field_ident'] = isset($profile_row['var_name']) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
     $field_ident = $profile_row['field_ident'];
     $default_value = $profile_row['field_default_value'];
     $value = $this->request->is_set($field_ident) ? $this->request->variable($field_ident, $default_value) : (!isset($this->user->profile_fields[$field_ident]) || $preview_options !== false ? $default_value : $this->user->profile_fields[$field_ident]);
     if (!$this->lang_helper->is_set($profile_row['field_id'], $profile_row['lang_id'], 1)) {
         if ($preview_options) {
             $this->lang_helper->load_preview_options($profile_row['field_id'], $profile_row['lang_id'], $preview_options);
         } else {
             $this->lang_helper->load_option_lang($profile_row['lang_id']);
         }
     }
     $profile_row['field_value'] = (int) $value;
     $this->template->assign_block_vars('dropdown', array_change_key_case($profile_row, CASE_UPPER));
     $options = $this->lang_helper->get($profile_row['field_id'], $profile_row['lang_id']);
     foreach ($options as $option_id => $option_value) {
         $this->template->assign_block_vars('dropdown.options', array('OPTION_ID' => $option_id, 'SELECTED' => $value == $option_id ? ' selected="selected"' : '', 'VALUE' => $option_value));
     }
 }