/** * Method to get the field options. * * @return array The field option objects. */ protected function getOptions() { // Initialize variables. $options = array(); if (!self::$countries) { self::$countries = array(); $countries = Geocode::countries(); if ($countries && !empty($countries)) { self::$countries = $countries; } } if ($this->element['option_blank']) { $options[] = Dropdown::option('', App::get('language')->txt('- Select -'), 'value', 'text'); } foreach (self::$countries as $option) { // Create a new option object based on the <option /> element. $tmp = Dropdown::option((string) $option->code, App::get('language')->alt(trim((string) $option->name), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text'); // Add the option object to the result set. $options[] = $tmp; } reset($options); return $options; }
</div> </div> </li> <?php } ?> <?php } ?> <?php } ?> <?php // get countries list $co = \Hubzero\Geocode\Geocode::countries(); ?> <?php if ($this->registration->Citizenship != REG_HIDE && $this->profile->get('countryorigin')) { ?> <?php if ($this->params->get('access_countryorigin') == 0 || $this->params->get('access_countryorigin') == 1 && $loggedin || $this->params->get('access_countryorigin') == 2 && $isUser) { ?> <li class="profile-countryorigin field"> <div class="field-content"> <div class="key"><?php echo Lang::txt('PLG_GROUPS_PROFILE_CITIZENSHIP'); ?> </div> <?php $img = '';
/** * Retrieves option values for a profile field * * @apiMethod GET * @apiUri /members/fieldValues * @apiParameter { * "name": "field", * "description": "Profile field of interest", * "type": "string", * "required": true, * "default": "" * } * @return void */ public function fieldValuesTask() { $name = Request::getVar('field', ''); $field = Field::all()->whereEquals('name', $name)->row(); if (!$field->get('id')) { App::abort(404, 'Field not found'); } // Create object with values $response = new stdClass(); $response->type = $field->get('type'); $values = array(); if ($field->get('type') == 'country') { $countries = \Hubzero\Geocode\Geocode::countries(); foreach ($countries as $option) { // Create a new option object based on the <option /> element. $tmp = new stdClass(); $tmp->value = (string) $option->code; $tmp->label = trim((string) $option->name); // Add the option object to the result set. $values[] = $tmp; } } else { foreach ($field->options()->ordered()->rows() as $option) { $values[] = $option->toObject(); } } $response->values = $values; // Return object $this->send($response); }