function flexprofile_get_data_for_summary_display($form, $user) { $form_id = $form->getGUID(); $data = form_get_data_from_profile($form_id, $user); $area_data = array(); $maps = form_get_maps($form_id); if ($maps) { foreach ($maps as $map) { $field = get_entity($map->field_id); //print($field->internal_name.','.$field->field_type.','.$field->choice_type.','.$field->default_value.'<br />'); $internalname = $field->internal_name; if (isset($data[$internalname]) && $data[$internalname]->value) { $area = $field->area; if ($area) { if (!isset($area_data[$area])) { $area_data[$area] = array(); } $item = new StdClass(); $item->internalname = $internalname; $item->title = form_field_t($form, $field, 'title'); $item->description = form_field_t($form, $field, 'description'); if ($field->field_type == 'choices') { $item->fieldtype = $field->choice_type; $choices = form_get_field_choices($field->getGUID()); $this_choice = ''; foreach ($choices as $choice) { if ($choice->value == $data[$internalname]->value) { $this_choice = $choice; break; } } $item->value = form_choice_t($form, $field, $this_choice); } else { $item->fieldtype = $field->field_type; $item->value = $data[$internalname]->value; } $area_data[$area][] = $item; } } } } return $area_data; }
*/ // Load form model require_once dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"; $form = $vars['entity']; $tab_data = array(); $title = $form->title; $maps = form_get_maps($form_id); if ($maps) { foreach ($maps as $map) { $field = get_entity($map->field_id); $vars = array('internalname' => $field->internal_name, 'value' => $field->default_value); //print($field->internal_name.','.$field->field_type.','.$field->choice_type.','.$field->default_value.'<br />'); if ($field->field_type == 'choices') { $vars['orientation'] = $field->orientation; $field_type = $field->choice_type; $choices = form_get_field_choices($field->getGUID()); if ($choices) { if ($choices[0]->label) { $options_values = array(); foreach ($choices as $choice) { $options_values[$choice->value] = $choice->label; } $vars['options_values'] = $options_values; } else { $options = array(); foreach ($choices as $choice) { $options[$choice->value] = $choice->value; } $vars['options'] = $options; } }
echo '\'form:formtrans:' . $form->name . ':listing_description\' => "' . htmlspecialchars($form->listing_description) . '",' . "\n"; } if ($form->response_text) { echo '\'form:formtrans:' . $form->name . ':response_text\' => "' . htmlspecialchars($form->response_text) . '",' . "\n"; } $tabs = array(); $fields = $vars['fields']; if ($fields && count($fields) > 0) { foreach ($fields as $field) { $field_id = $field->getGUID(); echo '\'form:fieldtrans:' . $field->internal_name . ':title\' => "' . htmlspecialchars($field->title) . '",' . "\n"; if ($field->description) { echo '\'form:fieldtrans:' . $field->internal_name . ':description\' => "' . htmlspecialchars($field->description) . '",' . "\n"; } if ($field->field_type == 'choices') { $choices = form_get_field_choices($field_id); if ($choices) { foreach ($choices as $choice) { echo '\'form:fieldchoicetrans:' . $field->internal_name . ':' . $choice->value . '\' => "' . htmlspecialchars($choice->label) . '",' . "\n"; } } } if ($field->tab && !in_array($field->tab, $tabs)) { $tabs[] = $field->tab; } } } $sd_list = get_entities_from_metadata('form_id', $form_id, 'object', 'form:search_definition'); if ($sd_list) { foreach ($sd_list as $sd) { echo '\'form:sdtrans:' . $form->name . ':' . $sd->internalname . ':title\' => "' . htmlspecialchars($sd->title) . '",' . "\n";
function form_get_field_output($form, $field, $value) { $form_id = $form->getGUID(); if ($form->profile) { $profile = $form->profile; } else { $profile = 0; } $type_array = array('form_data', 'user', 'group'); if (strtolower($field->field_type) == "choices") { $choices = form_get_field_choices($field->getGUID()); if (is_array($value)) { $value_array = array(); foreach ($value as $value2) { $this_choice = ''; foreach ($choices as $choice) { if ($choice->value == $value2) { $this_choice = $choice; break; } } if ($this_choice) { $value_array[$value2] = form_choice_t($form, $field, $this_choice); } else { $value_array[$value2] = $value2; } } return elgg_view("form/output/choice", array('form_id' => $form_id, 'type' => $type_array[$profile], 'internalname' => $field->internal_name, 'value' => $value_array)); } else { $this_choice = ''; foreach ($choices as $choice) { if ($choice->value == $value) { $this_choice = $choice; break; } } if ($this_choice) { return elgg_view("form/output/choice", array('form_id' => $form_id, 'type' => $type_array[$profile], 'internalname' => $field->internal_name, 'value' => $value, 'label' => form_choice_t($form, $field, $this_choice))); } else { return elgg_view("form/output/choice", array('form_id' => $form_id, 'type' => $type_array[$profile], 'internalname' => $field->internal_name, 'value' => $value)); } } } else { $view = form_field_type_to_view($field->field_type, "output"); return elgg_view($view, array('form_id' => $form_id, 'type' => $type_array[$profile], 'internalname' => $field->internal_name, 'value' => $value)); } }