Exemple #1
0
 public static function mtd_transform_entry_data($entry)
 {
     $data = array();
     $root_element["type"] = "root";
     $root_element["title"] = $entry["id"] . ": " . $entry["date_created"];
     $root_element["id"] = "id-entry-" . $entry["id"];
     $form_id = rgar($entry, "form_id");
     $form = RGFormsModel::get_form_meta($form_id);
     $fields = $form["fields"];
     foreach ($fields as $field) {
         $field_data = array();
         $field_data["header"] = $field["label"];
         $elements = array();
         $value = RGFormsModel::get_lead_field_value($entry, $field);
         if (is_array($value) && isset($field["choices"])) {
             $choices = rgar($field, "choices");
             foreach ($choices as $choice) {
                 $found = false;
                 foreach ($value as $item) {
                     if ($item == rgar($choice, "value")) {
                         $found = true;
                         break;
                     }
                 }
                 $element = array();
                 $element["type"] = "checkbox";
                 $element["caption"] = $choice["text"];
                 $element["value"] = $found;
                 $elements[] = $element;
             }
         } else {
             $element = array();
             $element["type"] = "string";
             $element["caption"] = GFFormsModel::get_choice_text($field, $value);
             $elements[] = $element;
         }
         $field_data["elements"] = $elements;
         $data[] = $field_data;
     }
     $root_element["sections"] = $data;
     return $root_element;
 }
Exemple #2
0
 public function merge_tag_filter($value, $merge_tag, $options, $field, $raw_value)
 {
     if ($field['type'] != 'survey') {
         return $value;
     }
     $input_type = GFFormsModel::get_input_type($field);
     if ($input_type == 'likert' && rgar($field, 'gsurveyLikertEnableMultipleRows')) {
         //sort array by key in natural order so that email notification will display correct results
         uksort($raw_value, array($this, 'compare_likert_values'));
         //replacing value with text
         if (is_array($raw_value)) {
             $new_value = "<ul class='gsurvey-likert-entry'>";
             $i = 0;
             foreach ($raw_value as $v) {
                 $row_text = $this->get_likert_row_text($field, $i++);
                 $col_text = $this->get_likert_column_text($field, $v);
                 $new_value .= sprintf('<li>%s: %s</li>', $row_text, $col_text);
             }
             $new_value .= '</ul>';
         } else {
             $new_value = $this->get_likert_column_text($field, $value);
         }
     } elseif ($input_type == 'rank' && is_array($field['choices'])) {
         $ordered_values = explode(',', $value);
         $new_value = "<ol class='gsurvey-rank-entry'>";
         foreach ($ordered_values as $ordered_value) {
             $ordered_label = GFCommon::selection_display($ordered_value, $field, $currency = '', $use_text = true);
             $new_value .= sprintf('<li>%s</li>', $ordered_label);
         }
         $new_value .= '</ol>';
     } else {
         $new_value = GFFormsModel::get_choice_text($field, $value);
     }
     return $new_value;
 }
Exemple #3
0
 public static function mtd_transform_entry_data($entry)
 {
     $data = array();
     $root_element['type'] = 'root';
     $root_element['title'] = $entry['id'] . ': ' . $entry['date_created'];
     $root_element['id'] = 'id-entry-' . $entry['id'];
     $form_id = rgar($entry, 'form_id');
     $form = RGFormsModel::get_form_meta($form_id);
     $fields = $form['fields'];
     foreach ($fields as $field) {
         $field_data = array();
         $field_data['header'] = $field->label;
         $elements = array();
         $value = RGFormsModel::get_lead_field_value($entry, $field);
         if (is_array($value) && isset($field->choices)) {
             $choices = $field->choices;
             foreach ($choices as $choice) {
                 $found = false;
                 foreach ($value as $item) {
                     if ($item == rgar($choice, 'value')) {
                         $found = true;
                         break;
                     }
                 }
                 $element = array();
                 $element['type'] = 'checkbox';
                 $element['caption'] = $choice['text'];
                 $element['value'] = $found;
                 $elements[] = $element;
             }
         } else {
             $element = array();
             $element['type'] = 'string';
             $element['caption'] = GFFormsModel::get_choice_text($field, $value);
             $elements[] = $element;
         }
         $field_data['elements'] = $elements;
         $data[] = $field_data;
     }
     $root_element['sections'] = $data;
     return $root_element;
 }
Exemple #4
0
 /**
  * Retrieve the label of a given field id (for a specific form)
  *
  * @access public
  * @since 1.17 Added $field_value parameter
  *
  * @param array $form Gravity Forms form array
  * @param string $field_id ID of the field. If an input, full input ID (like `1.3`)
  * @param string|array $field_value Raw value of the field.
  * @return string
  */
 public static function get_field_label($form = array(), $field_id = '', $field_value = '')
 {
     if (empty($form) || empty($field_id)) {
         return '';
     }
     $field = self::get_field($form, $field_id);
     $label = rgar($field, 'label');
     if (floor($field_id) !== floatval($field_id)) {
         $label = GFFormsModel::get_choice_text($field, $field_value, $field_id);
     }
     return $label;
 }