function replace_field_label_merge_tags($text, $form)
 {
     preg_match_all('/{([^:]+?)}/', $text, $matches, PREG_SET_ORDER);
     if (empty($matches)) {
         return $text;
     }
     foreach ($matches as $match) {
         list($search, $field_label) = $match;
         foreach ($form['fields'] as $field) {
             $full_input_id = false;
             $matches_admin_label = rgar($field, 'adminLabel') == $field_label;
             $matches_field_label = false;
             if (is_array($field['inputs'])) {
                 foreach ($field['inputs'] as $input) {
                     if (GFFormsModel::get_label($field, $input['id']) == $field_label) {
                         $matches_field_label = true;
                         $input_id = $input['id'];
                         break;
                     }
                 }
             } else {
                 $matches_field_label = GFFormsModel::get_label($field) == $field_label;
                 $input_id = $field['id'];
             }
             if (!$matches_admin_label && !$matches_field_label) {
                 continue;
             }
             $replace = sprintf('{%s:%s}', $field_label, (string) $input_id);
             $text = str_replace($search, $replace, $text);
             break;
         }
     }
     return $text;
 }
 public static function get_field_filter_settings($form)
 {
     $all_fields = $form['fields'];
     // set up filters
     $fields = $all_fields;
     $exclude_types = array('rank', 'page', 'html');
     $operators_by_input_type = array('default' => array('is', 'isnot', '>', '<'), 'name' => array('is', 'isnot', '>', '<', 'contains'), 'address' => array('is', 'isnot', '>', '<', 'contains'), 'text' => array('is', 'isnot', '>', '<', 'contains'), 'textarea' => array('is', 'isnot', '>', '<', 'contains'), 'checkbox' => array('is'), 'multiselect' => array('contains'), 'number' => array('is', 'isnot', '>', '<'), 'select' => array('is', 'isnot', '>', '<'), 'likert' => array('is', 'isnot'), 'list' => array('contains'));
     for ($i = 0; $i < count($all_fields); $i++) {
         $input_type = GFFormsmodel::get_input_type($all_fields[$i]);
         if (in_array($input_type, $exclude_types)) {
             unset($fields[$i]);
         }
     }
     $fields = array_values($fields);
     $field_filters = array(array('key' => '0', 'text' => esc_html__('Any form field', 'gravityforms'), 'operators' => array('contains', 'is'), 'preventMultiple' => false));
     foreach ($fields as $field) {
         $input_type = GFFormsModel::get_input_type($field);
         $operators = isset($operators_by_input_type[$input_type]) ? $operators_by_input_type[$input_type] : $operators_by_input_type['default'];
         if ($field->type == 'product' && in_array($input_type, array('radio', 'select'))) {
             $operators = array('is');
         } elseif (!isset($field->choices) && !in_array('contains', $operators)) {
             $operators[] = 'contains';
         }
         $field_filter = array();
         $key = $field->id;
         if ($input_type == 'likert' && $field->gsurveyLikertEnableMultipleRows) {
             // multi-row likert fields
             $field_filter['key'] = $key;
             $field_filter['group'] = true;
             $field_filter['text'] = GFFormsModel::get_label($field);
             $sub_filters = array();
             $rows = $field->gsurveyLikertRows;
             foreach ($rows as $row) {
                 $sub_filter = array();
                 $sub_filter['key'] = $key . '|' . rgar($row, 'value');
                 $sub_filter['text'] = rgar($row, 'text');
                 $sub_filter['type'] = 'field';
                 $sub_filter['preventMultiple'] = false;
                 $sub_filter['operators'] = $operators;
                 $sub_filter['values'] = $field->choices;
                 $sub_filters[] = $sub_filter;
             }
             $field_filter['filters'] = $sub_filters;
         } elseif ($input_type == 'name' && $field->nameFormat == '' || $input_type == 'address') {
             // standard two input name field
             $field_filter['key'] = $key;
             $field_filter['group'] = true;
             $field_filter['text'] = GFFormsModel::get_label($field);
             $sub_filters = array();
             $inputs = $field->inputs;
             foreach ($inputs as $input) {
                 $sub_filter = array();
                 $sub_filter['key'] = rgar($input, 'id');
                 $sub_filter['text'] = rgar($input, 'label');
                 $sub_filter['preventMultiple'] = false;
                 $sub_filter['operators'] = $operators;
                 $sub_filters[] = $sub_filter;
             }
             $field_filter['filters'] = $sub_filters;
         } elseif ($input_type == 'date') {
             $field_filter['key'] = $key;
             $field_filter['preventMultiple'] = false;
             $field_filter['text'] = GFFormsModel::get_label($field);
             $field_filter['operators'] = $operators;
             $field_filter['placeholder'] = esc_html__('yyyy-mm-dd', 'gravityforms');
             $field_filter['cssClass'] = 'datepicker ymd_dash';
         } else {
             $field_filter['key'] = $key;
             $field_filter['preventMultiple'] = false;
             $field_filter['text'] = GFFormsModel::get_label($field);
             $field_filter['operators'] = $operators;
             if (isset($field->choices)) {
                 $field_filter['values'] = $field->choices;
             }
         }
         $field_filters[] = $field_filter;
     }
     $form_id = $form['id'];
     $entry_meta_filters = self::get_entry_meta_filter_settings($form_id);
     $field_filters = array_merge($field_filters, $entry_meta_filters);
     $field_filters = array_values($field_filters);
     // reset the numeric keys in case some filters have been unset
     $info_filters = self::get_entry_info_filter_settings();
     $field_filters = array_merge($field_filters, $info_filters);
     $field_filters = array_values($field_filters);
     return $field_filters;
 }
	</a>
</div>

<div class="left half">
<span class="medium">Task:
<span class="red"> 
<?php 
$f_id = 1;
// Form ID
$f_ld = $_GET['task'];
// Field ID
$form = RGFormsModel::get_form_meta($f_id);
// Get Form Meta
$field = GFFormsModel::get_field($form, $f_ld);
// Get Field
echo $label = GFFormsModel::get_label($field);
?>
</span>
</span>
</div>

<div class="right half medium">
    <?php 
switch ($lead[41]) {
    case 'complete':
        $estimate_status = 'purple';
        break;
    case 'active':
        $estimate_status = 'green';
        break;
    case 'inactive':
 public static function get_field_filter_settings($form)
 {
     $all_fields = $form["fields"];
     // set up filters
     $fields = $all_fields;
     $exclude_types = array("rank", "page", "html");
     $operators_by_field_type = array("default" => array("is", "isnot", ">", "<"), "checkbox" => array("is"), "multiselect" => array("contains"), "number" => array("is", "isnot", ">", "<"), "likert" => array("is", "isnot"), "list" => array("contains"));
     for ($i = 0; $i < count($all_fields); $i++) {
         $field_type = GFFormsmodel::get_input_type($all_fields[$i]);
         if (in_array($field_type, $exclude_types)) {
             unset($fields[$i]);
         }
     }
     $fields = array_values($fields);
     $field_filters = array(array("key" => "0", "text" => __("Any form field", "gravityforms"), "operators" => array("contains", "is")));
     foreach ($fields as $field) {
         $field_type = GFFormsModel::get_input_type($field);
         $operators = isset($operators_by_field_type[$field_type]) ? $operators_by_field_type[$field_type] : $operators_by_field_type["default"];
         if (!isset($field["choices"]) && !in_array("contains", $operators)) {
             $operators[] = "contains";
         }
         $field_filter = array();
         $key = $field["id"];
         if ($field_type == "likert" && rgar($field, "gsurveyLikertEnableMultipleRows")) {
             // multi-row likert fields
             $field_filter["key"] = $key;
             $field_filter["group"] = true;
             $field_filter["text"] = GFFormsModel::get_label($field);
             $sub_filters = array();
             $rows = rgar($field, "gsurveyLikertRows");
             foreach ($rows as $row) {
                 $sub_filter = array();
                 $sub_filter["key"] = $key . "|" . rgar($row, "value");
                 $sub_filter["text"] = rgar($row, "text");
                 $sub_filter["type"] = "field";
                 $sub_filter["preventMultiple"] = false;
                 $sub_filter["operators"] = $operators;
                 $sub_filter["values"] = $field["choices"];
                 $sub_filters[] = $sub_filter;
             }
             $field_filter["filters"] = $sub_filters;
         } elseif ($field_type == "name" && rgar($field, "nameFormat") == "" || $field_type == "address") {
             // standard two input name field
             $field_filter["key"] = $key;
             $field_filter["group"] = true;
             $field_filter["text"] = GFFormsModel::get_label($field);
             $sub_filters = array();
             $inputs = rgar($field, "inputs");
             foreach ($inputs as $input) {
                 $sub_filter = array();
                 $sub_filter["key"] = rgar($input, "id");
                 $sub_filter["text"] = rgar($input, "label");
                 $sub_filter["preventMultiple"] = false;
                 $sub_filter["operators"] = $operators;
                 $sub_filters[] = $sub_filter;
             }
             $field_filter["filters"] = $sub_filters;
         } else {
             $field_filter["key"] = $key;
             $field_filter["preventMultiple"] = false;
             $field_filter["text"] = GFFormsModel::get_label($field);
             $field_filter["operators"] = $operators;
             if (isset($field["choices"])) {
                 $field_filter["values"] = $field["choices"];
             }
         }
         $field_filters[] = $field_filter;
     }
     $form_id = $form["id"];
     $entry_meta_filters = self::get_entry_meta_filter_settings($form_id);
     $field_filters = array_merge($field_filters, $entry_meta_filters);
     $field_filters = array_values($field_filters);
     // reset the numeric keys in case some filters have been unset
     $info_filters = self::get_entry_info_filter_settings();
     $field_filters = array_merge($field_filters, $info_filters);
     $field_filters = array_values($field_filters);
     return $field_filters;
 }
 public static function get_body($entry, $form)
 {
     $current_body = self::$_current_body;
     if (is_array($current_body)) {
         return $current_body;
     }
     $body = array();
     foreach ($form['fields'] as $field) {
         $input_type = GFFormsModel::get_input_type($field);
         if ($input_type == 'honeypot') {
             //skip the honeypot field
             continue;
         }
         $field_value = GFFormsModel::get_lead_field_value($entry, $field);
         if (!empty($entry)) {
             $field_value = apply_filters('gform_zapier_field_value', $field_value, $form['id'], $field->id, $entry);
         }
         $field_label = GFFormsModel::get_label($field);
         $inputs = $field instanceof GF_Field ? $field->get_entry_inputs() : rgar($field, 'inputs');
         if (is_array($inputs) && (is_array($field_value) || empty($entry))) {
             //handling multi-input fields
             $non_blank_items = array();
             //field has inputs, complex field like name, address and checkboxes. Get individual inputs
             foreach ($inputs as $input) {
                 $input_label = GFFormsModel::get_label($field, $input['id']);
                 $field_id = (string) $input['id'];
                 $input_value = rgar($field_value, $field_id);
                 $body[$input_label] = $input_value;
                 if (!rgblank($input_value)) {
                     $non_blank_items[] = $input_value;
                 }
             }
             //Also adding an item for the "whole" field, which will be a concatenation of the individual inputs
             switch ($input_type) {
                 case 'checkbox':
                     //checkboxes will create a comma separated list of values
                     $body[$field_label] = implode(', ', $non_blank_items);
                     break;
                 case 'name':
                 case 'address':
                     //name and address will separate inputs by a single blank space
                     $body[$field_label] = implode(' ', $non_blank_items);
                     break;
             }
         } else {
             $body[$field_label] = rgblank($field_value) ? '' : $field_value;
         }
     }
     $entry_meta = GFFormsModel::get_entry_meta($form['id']);
     foreach ($entry_meta as $meta_key => $meta_config) {
         $body[$meta_config['label']] = empty($entry) ? null : rgar($entry, $meta_key);
     }
     self::$_current_body = $body;
     return $body;
 }
 function settings_editable_fields($field)
 {
     $form = $this->get_current_form();
     $choices = array();
     if (isset($form['fields']) && is_array($form['fields'])) {
         foreach ($form['fields'] as $form_field) {
             if ($form_field->displayOnly) {
                 continue;
             }
             $choices[] = array('label' => GFFormsModel::get_label($form_field), 'value' => $form_field->id);
         }
     }
     $field['choices'] = $choices;
     $this->settings_select($field);
 }
示例#7
0
 public static function get_body($entry, $form)
 {
     $body = array();
     foreach ($form["fields"] as $field) {
         if ($field["type"] == "honeypot") {
             //skip the honeypot field
             continue;
         }
         $field_value = GFFormsModel::get_lead_field_value($entry, $field);
         if (!empty($entry)) {
             $field_value = apply_filters("gform_zapier_field_value", $field_value, $form["id"], $field["id"], $entry);
         }
         $field_label = GFFormsModel::get_label($field);
         if (is_array($field["inputs"])) {
             //handling multi-input fields
             $non_blank_items = array();
             //field has inputs, complex field like name, address and checkboxes. Get individual inputs
             foreach ($field["inputs"] as $input) {
                 $input_label = GFFormsModel::get_label($field, $input["id"]);
                 $field_id = (string) $input["id"];
                 $input_value = $field_value == null ? "" : $field_value[$field_id];
                 $body[$input_label] = $input_value;
                 if (!rgblank($input_value)) {
                     $non_blank_items[] = $input_value;
                 }
             }
             //Also adding an item for the "whole" field, which will be a concatenation of the individual inputs
             switch (GFFormsModel::get_input_type($field)) {
                 case "checkbox":
                     //checkboxes will create a comma separated list of values
                     $body[$field_label] = implode(", ", $non_blank_items);
                     break;
                 case "name":
                 case "address":
                     //name and address will separate inputs by a single blank space
                     $body[$field_label] = implode(" ", $non_blank_items);
                     break;
             }
         } else {
             $body[$field_label] = rgblank($field_value) ? "" : $field_value;
         }
     }
     $entry_meta = GFFormsModel::get_entry_meta($form["id"]);
     foreach ($entry_meta as $meta_key => $meta_config) {
         $body[$meta_config["label"]] = empty($entry) ? null : rgar($entry, $meta_key);
     }
     return $body;
 }