Beispiel #1
0
 public function profileHeaderB($key, $user, $field)
 {
     // Get the data
     $data = $field->data;
     if (!$data) {
         return;
     }
     $my = FD::user();
     $privacyLib = FD::privacy($my->id);
     if (!$privacyLib->validate('core.view', $field->id, SOCIAL_TYPE_FIELD, $user->id)) {
         return;
     }
     $obj = FD::makeObject($data);
     $theme = FD::themes();
     $hide = true;
     foreach ($obj as $k => &$v) {
         $v = $theme->html('string.escape', $v);
         if (!empty($v)) {
             $hide = false;
         }
     }
     if ($hide) {
         return true;
     }
     $params = $field->getParams();
     // Convert country to full text
     if (!empty($obj->country)) {
         $obj->country_code = $obj->country;
         $obj->country = SocialFieldsUserAddressHelper::getCountryName($obj->country, $params->get('data_source'));
     }
     $theme->set('value', $obj);
     $theme->set('params', $field->getParams());
     echo $theme->output('fields/user/address/widgets/display');
 }
Beispiel #2
0
 /**
  * Displays the sample html codes when the field is added into the profile.
  *
  * @since   1.0
  * @access  public
  * @param   array
  * @param   SocialTableRegistration
  * @return  string  The html output.
  *
  * @author  Jason Rey <*****@*****.**>
  */
 public function onSample()
 {
     // Get the value.
     $address = $this->getAddressValue();
     // Set the value.
     $this->set('value', $address);
     // Get the countries list.
     $countries = SocialFieldsUserAddressHelper::getCountries();
     // Set the countries.
     $this->set('countries', $countries);
     // Get the requirements and set the required parameters
     $required = array('address1' => $this->params->get('required_address1'), 'address2' => $this->params->get('required_address2'), 'city' => $this->params->get('required_city'), 'state' => $this->params->get('required_state'), 'zip' => $this->params->get('required_zip'), 'country' => $this->params->get('required_country'));
     // Set the jsonencoded string for required data
     $this->set('required', FD::json()->encode($required));
     // Get the visible field and set the show parameters
     $show = array('address1' => $this->params->get('show_address1'), 'address2' => $this->params->get('show_address2'), 'city' => $this->params->get('show_city'), 'state' => $this->params->get('show_state'), 'zip' => $this->params->get('show_zip'), 'country' => $this->params->get('show_country'));
     // Set the jsonencoded string for required data
     $this->set('show', FD::json()->encode($show));
     // Set custom required option
     $isRequired = false;
     foreach ($required as $key => $value) {
         if ($value) {
             $isRequired = true;
             break;
         }
     }
     $this->set('options', array('required' => $isRequired));
     return $this->display();
 }