当前位置: 首页>>代码示例>>PHP>>正文


PHP RGFormsModel::get_choice_text方法代码示例

本文整理汇总了PHP中RGFormsModel::get_choice_text方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_choice_text方法的具体用法?PHP RGFormsModel::get_choice_text怎么用?PHP RGFormsModel::get_choice_text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RGFormsModel的用法示例。


在下文中一共展示了RGFormsModel::get_choice_text方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_value_merge_tag

 public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br)
 {
     $use_value = $modifier == 'value';
     $use_price = in_array($modifier, array('price', 'currency'));
     $format_currency = $modifier == 'currency';
     if (is_array($raw_value) && (string) intval($input_id) != $input_id) {
         $items = array($input_id => $value);
         //float input Ids. (i.e. 4.1 ). Used when targeting specific checkbox items
     } elseif (is_array($raw_value)) {
         $items = $raw_value;
     } else {
         $items = array($input_id => $raw_value);
     }
     $ary = array();
     foreach ($items as $input_id => $item) {
         if ($use_value) {
             list($val, $price) = rgexplode('|', $item, 2);
         } elseif ($use_price) {
             list($name, $val) = rgexplode('|', $item, 2);
             if ($format_currency) {
                 $val = GFCommon::to_money($val, rgar($entry, 'currency'));
             }
         } elseif ($this->type == 'post_category') {
             $use_id = strtolower($modifier) == 'id';
             $item_value = GFCommon::format_post_category($item, $use_id);
             $val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : $item_value;
         } else {
             $val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : RGFormsModel::get_choice_text($this, $raw_value, $input_id);
         }
         $ary[] = GFCommon::format_variable_value($val, $url_encode, $esc_html, $format);
     }
     return GFCommon::implode_non_blank(', ', $ary);
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:33,代码来源:class-gf-field-select.php

示例2: get_field_results


//.........这里部分代码省略.........
                 $row_text = $row['text'];
                 $row_value = $row['value'];
                 $max = 0;
                 foreach ($field->choices as $choice) {
                     if ($multiple_rows) {
                         $choice_value = rgar($choice, 'value');
                         $results_row = rgar($results, $row_value);
                         $results_for_choice = rgar($results_row, $choice_value);
                         $max = max(array($max, $results_for_choice));
                     } else {
                         $max = max(array($max, $results[$choice['value']]));
                     }
                 }
                 $field_results .= '<tr>';
                 if ($multiple_rows) {
                     $field_results .= "<td class='gsurvey-likert-row-label'>" . $row_text . '</td>';
                 }
                 foreach ($field->choices as $choice) {
                     $val = $multiple_rows ? $results[$row_value][$choice['value']] : $results[$choice['value']];
                     $percent = $max > 0 ? round($val / $max * 100, 0) : 0;
                     $red = (int) ($xr + $percent * ($yr - $xr) / ($n - 1));
                     $green = (int) ($xg + $percent * ($yg - $xg) / ($n - 1));
                     $blue = (int) ($xb + $percent * ($yb - $xb) / ($n - 1));
                     $clr = 'rgb(' . $red . ',' . $green . ',' . $blue . ')';
                     $field_results .= "<td class='gsurvey-likert-results' style='background-color:{$clr}'>" . $val . '</td>';
                 }
                 if ($multiple_rows && $scoring_enabled) {
                     $row_sum = $results[$row_value]['row_score_sum'];
                     $average_row_score = $row_sum == 0 ? 0 : round($row_sum / $entry_count, 3);
                     $field_results .= "<td class='gsurvey-likert-results'>" . $average_row_score . '</td>';
                 }
                 $field_results .= '</tr>';
                 if (false === $multiple_rows) {
                     break;
                 }
             }
             $field_results .= '</table>';
             $field_results .= '</div>';
             if ($scoring_enabled) {
                 $sum = $results['sum_of_scores'];
                 $average_score = $sum == 0 ? 0 : round($sum / $entry_count, 3);
                 if ($multiple_rows) {
                     $average_global_score_tooltip = gform_tooltip('gresults_average_global_score', null, true);
                     $field_results .= sprintf("<div class='gsurvey-likert-score'>%s %s: %s</div>", esc_html__('Average global score', 'gravityforms'), $average_global_score_tooltip, $average_score);
                 } else {
                     $field_results .= sprintf("<div class='gsurvey-likert-score'>%s %s: %s</div>", esc_html__('Average score', 'gravityforms'), gform_tooltip('gresults_average_score', null, true), $average_score);
                 }
             }
             break;
         case 'rank':
             $results = $field_data[$field->id];
             arsort($results);
             $field_results .= "<div class='gsurvey-rank-field-results'>";
             $field_results .= ' <table>';
             $field_results .= "     <tr class='gresults-results-field-table-header'>";
             $field_results .= "         <td class='gresults-rank-field-label'>";
             $field_results .= esc_html__('Item', 'gravityforms');
             $field_results .= '         </td>';
             $field_results .= "         <td class='gresults-rank-field-score'>";
             $field_results .= esc_html__('Total Score', 'gravityforms') . '&nbsp;' . gform_tooltip('gresults_total_score', null, true);
             $field_results .= '         </td>';
             $field_results .= "         <td class='gresults-rank-field-rank'>";
             $field_results .= esc_html__('Aggregate Rank', 'gravityforms') . '&nbsp;' . gform_tooltip('gresults_agg_rank', null, true);
             $field_results .= '         </td>';
             $field_results .= '     </tr>';
             $agg_rank = 1;
             foreach ($results as $choice_val => $score) {
                 $field_results .= '<tr>';
                 $field_results .= "      <td class='gresults-rank-field-label' style='text-align:left;'>";
                 $field_results .= RGFormsModel::get_choice_text($field, $choice_val);
                 $field_results .= '      </td>';
                 $field_results .= "      <td class='gresults-rank-field-score'>";
                 $field_results .= $score;
                 $field_results .= '      </td>';
                 $field_results .= "      <td class='gresults-rank-field-rank'>";
                 $field_results .= $agg_rank;
                 $field_results .= '      </td>';
                 $field_results .= '</tr>';
                 $agg_rank++;
             }
             $field_results .= '</table>';
             $field_results .= '</div>';
             break;
         default:
             $page_size = 5;
             $offset = 0;
             $field_id = $field->id;
             $more_remaining = false;
             $default_field_results = self::get_default_field_results($form_id, $field, $search_criteria, $offset, $page_size, $more_remaining);
             $field_results .= "<div class='gresults-results-field-sub-label'>" . esc_html__('Latest values:', 'gravityforms') . '</div>';
             $field_results .= "<ul id='gresults-results-field-content-{$field_id}' class='gresults-results-field-content' data-offset='{$offset}'>";
             $field_results .= $default_field_results;
             $field_results .= '</ul>';
             if ($more_remaining) {
                 $field_results .= "<a id='gresults-results-field-more-link-{$field_id}' class='gresults-results-field-more-link' href='javascript:void(0)' onclick='gresults.getMoreResults({$form_id},{$field_id})'>" . esc_html__('Show more', 'gravityforms') . '</a>';
             }
             break;
     }
     return $field_results;
 }
开发者ID:arobbins,项目名称:davis,代码行数:101,代码来源:class-gf-results.php

示例3: get_field_results


//.........这里部分代码省略.........
             $field_results .= "<div class='gsurvey-likert-field-results'>";
             $field_results .= "<table class='gsurvey-likert'>";
             $field_results .= "<tr>";
             if ($multiple_rows) {
                 $field_results .= "<td></td>";
             }
             foreach ($field["choices"] as $choice) {
                 $field_results .= "<td class='gsurvey-likert-choice-label'>" . $choice['text'] . "</td>";
             }
             $field_results .= "</tr>";
             foreach ($field["gsurveyLikertRows"] as $row) {
                 $row_text = $row["text"];
                 $row_value = $row["value"];
                 $max = 0;
                 foreach ($field["choices"] as $choice) {
                     if ($multiple_rows) {
                         $choice_value = rgar($choice, "value");
                         $results_row = rgar($results, $row_value);
                         $results_for_choice = rgar($results_row, $choice_value);
                         $max = max(array($max, $results_for_choice));
                     } else {
                         $max = max(array($max, $results[$choice['value']]));
                     }
                 }
                 $field_results .= "<tr>";
                 if ($multiple_rows) {
                     $field_results .= "<td class='gsurvey-likert-row-label'>" . $row_text . "</td>";
                 }
                 foreach ($field["choices"] as $choice) {
                     $val = $multiple_rows ? $results[$row_value][$choice['value']] : $results[$choice['value']];
                     $percent = $max > 0 ? round($val / $max * 100, 0) : 0;
                     $red = (int) ($xr + $percent * ($yr - $xr) / ($n - 1));
                     $green = (int) ($xg + $percent * ($yg - $xg) / ($n - 1));
                     $blue = (int) ($xb + $percent * ($yb - $xb) / ($n - 1));
                     $clr = 'rgb(' . $red . ',' . $green . ',' . $blue . ')';
                     $field_results .= "<td class='gsurvey-likert-results' style='background-color:{$clr}'>" . $val . "</td>";
                 }
                 $field_results .= "</tr>";
                 if (false === $multiple_rows) {
                     break;
                 }
             }
             $field_results .= "</table>";
             $field_results .= "</div>";
             if (rgar($field, "gsurveyLikertEnableScoring") && class_exists("GFSurvey")) {
                 $sum = $results["sum_of_scores"];
                 $average_score = $sum == 0 ? 0 : round($sum / $entry_count, 3);
                 $field_results .= "<div class='gsurvey-likert-score'>" . __("Average score: ", "gravityforms") . $average_score . "</div>";
             }
             break;
         case "rank":
             $results = $field_data[$field["id"]];
             arsort($results);
             $field_results .= "<div class='gsurvey-rank-field-results'>";
             $field_results .= " <table>";
             $field_results .= "     <tr class='gresults-results-field-table-header'>";
             $field_results .= "         <td class='gresults-rank-field-label'>";
             $field_results .= __("Item", "gravityforms");
             $field_results .= "         </td>";
             $field_results .= "         <td class='gresults-rank-field-score'>";
             $field_results .= __("Total Score", "gravityforms") . "&nbsp;" . gform_tooltip("gresults_total_score", null, true);
             $field_results .= "         </td>";
             $field_results .= "         <td class='gresults-rank-field-rank'>";
             $field_results .= __("Aggregate Rank", "gravityforms") . "&nbsp;" . gform_tooltip("gresults_agg_rank", null, true);
             $field_results .= "         </td>";
             $field_results .= "     </tr>";
             $agg_rank = 1;
             foreach ($results as $choice_val => $score) {
                 $field_results .= "<tr>";
                 $field_results .= "      <td class='gresults-rank-field-label' style='text-align:left;'>";
                 $field_results .= RGFormsModel::get_choice_text($field, $choice_val);
                 $field_results .= "      </td>";
                 $field_results .= "      <td class='gresults-rank-field-score'>";
                 $field_results .= $score;
                 $field_results .= "      </td>";
                 $field_results .= "      <td class='gresults-rank-field-rank'>";
                 $field_results .= $agg_rank;
                 $field_results .= "      </td>";
                 $field_results .= "</tr>";
                 $agg_rank++;
             }
             $field_results .= "</table>";
             $field_results .= "</div>";
             break;
         default:
             $page_size = 5;
             $offset = 0;
             $field_id = $field["id"];
             $field_results .= "<div class='gresults-results-field-sub-label'>" . __("Latest values:", "gravityforms") . "</div>";
             $field_results .= "<ul id='gresults-results-field-content-{$field_id}' class='gresults-results-field-content' data-offset='{$page_size}'>";
             $more_remaining = false;
             $field_results .= self::get_default_field_results($form_id, $field, $search_criteria, $offset, $page_size, $more_remaining);
             $field_results .= "</ul>";
             if ($more_remaining) {
                 $field_results .= "<a id='gresults-results-field-more-link-{$field_id}' class='gresults-results-field-more-link' href='javascript:void(0)' onclick='gresults.getMoreResults({$form_id},{$field_id})'>Show more</a>";
             }
             break;
     }
     return $field_results;
 }
开发者ID:rushabhrakholiya,项目名称:TEST,代码行数:101,代码来源:class-gf-results.php

示例4: get_option_info

 public static function get_option_info($value, $option, $use_choice_text)
 {
     if (empty($value)) {
         return array();
     }
     list($name, $price) = explode("|", $value);
     if ($use_choice_text) {
         $name = RGFormsModel::get_choice_text($option, $name);
     }
     return array("name" => $name, "price" => $price);
 }
开发者ID:ipman3,项目名称:Mediassociates-wp,代码行数:11,代码来源:common.php

示例5: get_value_entry_detail

 /**
  * Format the entry value for display on the entry detail page and for the {all_fields} merge tag.
  *
  * @param string|array $value The field value.
  * @param string $currency The entry currency code.
  * @param bool|false $use_text When processing choice based fields should the choice text be returned instead of the value.
  * @param string $format The format requested for the location the merge is being used. Possible values: html, text or url.
  * @param string $media The location where the value will be displayed. Possible values: screen or email.
  *
  * @return string
  */
 public function get_value_entry_detail($value, $currency = '', $use_text = false, $format = 'html', $media = 'screen')
 {
     $ordered_values = !empty($value) ? explode(',', $value) : '';
     $new_value = '';
     if (is_array($ordered_values)) {
         switch ($format) {
             case 'text':
                 $c = 1;
                 foreach ($ordered_values as &$ordered_value) {
                     $ordered_value = $c++ . '. ' . RGFormsModel::get_choice_text($this, $ordered_value);
                 }
                 $new_value = implode(', ', $ordered_values);
                 break;
             default:
                 foreach ($ordered_values as $ordered_value) {
                     $new_value .= sprintf('<li>%s</li>', RGFormsModel::get_choice_text($this, $ordered_value));
                 }
                 $new_value = sprintf("<ol class='gsurvey-rank-entry'>%s</ol>", $new_value);
         }
     }
     return $new_value;
 }
开发者ID:GravityPDF,项目名称:gravityformssurvey,代码行数:33,代码来源:class-gf-field-rank.php

示例6: extract

/**
 * Display the radio field type
 *
 * @package GravityView
 * @subpackage GravityView/templates/fields
 */
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
$display_type = isset($field_settings['choice_display']) ? $field_settings['choice_display'] : 'value';
$output = '';
if (floatval($field_id) === floor(floatval($field_id))) {
    if ('value' === $display_type) {
        // For the complete field value
        $output = $display_value;
    } else {
        $output = RGFormsModel::get_choice_text($field, $display_value);
    }
} else {
    // For part of the field value
    $entry_keys = array_keys($entry);
    foreach ($entry_keys as $input_key) {
        if (is_numeric($input_key) && floatval($input_key) === floatval($field_id)) {
            if (in_array($field['type'], array('radio', 'checkbox')) && !empty($entry[$input_key])) {
                $output = apply_filters('gravityview_field_tick', '<span class="dashicons dashicons-yes"></span>', $entry, $field);
            } else {
                $output = $entry[$input_key];
            }
        }
    }
}
echo $output;
开发者ID:mgratch,项目名称:GravityView,代码行数:31,代码来源:radio.php

示例7: get_value_export

 /**
  * Format the entry value before it is used in entry exports and by framework add-ons using GFAddOn::get_field_value().
  *
  * @param array $entry The entry currently being processed.
  * @param string $input_id The field or input ID.
  * @param bool|false $use_text When processing choice based fields should the choice text be returned instead of the value.
  * @param bool|false $is_csv Is the value going to be used in the .csv entries export?
  *
  * @return string
  */
 public function get_value_export($entry, $input_id = '', $use_text = false, $is_csv = false)
 {
     if (empty($input_id)) {
         $input_id = $this->id;
     }
     return RGFormsModel::get_choice_text($this, rgar($entry, $input_id));
 }
开发者ID:GravityPDF,项目名称:gravityformssurvey,代码行数:17,代码来源:class-gf-field-rating.php

示例8: get_product_fields

 public function get_product_fields($form, $lead, $use_choice_text = false, $use_admin_label = false)
 {
     $products = array();
     foreach ($form["fields"] as $field) {
         $id = $field["id"];
         $lead_value = RGFormsModel::get_lead_field_value($lead, $field);
         $quantity_field = GFCommon::get_product_fields_by_type($form, array("quantity"), $id);
         $quantity = sizeof($quantity_field) > 0 ? RGFormsModel::get_lead_field_value($lead, $quantity_field[0]) : 1;
         switch ($field["type"]) {
             case "product":
                 //ignore products that have been hidden by conditional logic
                 $is_hidden = RGFormsModel::is_field_hidden($form, $field, array(), $lead);
                 if ($is_hidden) {
                     continue;
                 }
                 //if single product, get values from the multiple inputs
                 if (is_array($lead_value)) {
                     $product_quantity = sizeof($quantity_field) == 0 && !rgar($field, "disableQuantity") ? rgget($id . ".3", $lead_value) : $quantity;
                     if (empty($product_quantity)) {
                         continue;
                     }
                     if (!rgget($id, $products)) {
                         $products[$id] = array();
                     }
                     $products[$id]["name"] = $use_admin_label && !rgempty("adminLabel", $field) ? $field["adminLabel"] : $lead_value[$id . ".1"];
                     $products[$id]["price"] = rgar($lead_value, $id . ".2");
                     $products[$id]["quantity"] = $product_quantity;
                 } else {
                     if (!empty($lead_value)) {
                         if (empty($quantity)) {
                             continue;
                         }
                         if (!rgar($products, $id)) {
                             $products[$id] = array();
                         }
                         if ($field["inputType"] == "price") {
                             $name = $field["label"];
                             $price = $lead_value;
                         } else {
                             list($name, $price) = explode("|", $lead_value);
                         }
                         $products[$id]["name"] = !$use_choice_text ? $name : RGFormsModel::get_choice_text($field, $name);
                         $products[$id]["price"] = $price;
                         $products[$id]["quantity"] = $quantity;
                         $products[$id]["options"] = array();
                     }
                 }
                 if (isset($products[$id])) {
                     $options = GFCommon::get_product_fields_by_type($form, array("option"), $id);
                     foreach ($options as $option) {
                         $option_value = RGFormsModel::get_lead_field_value($lead, $option);
                         $option_label = empty($option["adminLabel"]) ? $option["label"] : $option["adminLabel"];
                         if (is_array($option_value)) {
                             foreach ($option_value as $value) {
                                 $option_info = GFCommon::get_option_info($value, $option, $use_choice_text);
                                 if (!empty($option_info)) {
                                     $products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
                                 }
                             }
                         } else {
                             if (!empty($option_value)) {
                                 $option_info = GFCommon::get_option_info($option_value, $option, $use_choice_text);
                                 $products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
                             }
                         }
                     }
                 }
                 break;
         }
     }
     $shipping_field = GFCommon::get_fields_by_type($form, array("shipping"));
     $shipping_price = $shipping_name = "";
     if (!empty($shipping_field) && !RGFormsModel::is_field_hidden($form, $shipping_field[0], array(), $lead)) {
         $shipping_price = RGFormsModel::get_lead_field_value($lead, $shipping_field[0]);
         $shipping_name = $shipping_field[0]["label"];
         if ($shipping_field[0]["inputType"] != "singleshipping") {
             list($shipping_method, $shipping_price) = explode("|", $shipping_price);
             $shipping_name = $shipping_field[0]["label"] . " ({$shipping_method})";
         }
     }
     $shipping_price = GFCommon::to_number($shipping_price);
     $product_info = array("products" => $products, "shipping" => array("name" => $shipping_name, "price" => $shipping_price));
     $product_info = apply_filters("gform_product_info_{$form["id"]}", apply_filters("gform_product_info", $product_info, $form, $lead), $form, $lead);
     return $product_info;
 }
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:85,代码来源:gravityforms-product-addons.php

示例9: display_poll_on_entry_print

 public function display_poll_on_entry_print($value, $field, $lead, $form)
 {
     $new_value = $value;
     if ($field['type'] == 'poll' && is_array($field['choices'])) {
         if ($field['inputType'] == 'checkbox') {
             foreach ($field['choices'] as $choice) {
                 $val = $choice['value'];
                 $text = RGFormsModel::get_choice_text($field, $val);
                 $new_value = str_replace($val, $text, $new_value);
             }
         } else {
             //replacing value with text
             $new_value = RGFormsModel::get_choice_text($field, $value);
         }
     }
     return $new_value;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:17,代码来源:polls.php

示例10: display_poll_on_entry_detail

 /**
  * Format the Poll field values for display on the entry detail page and print entry.
  *
  * @param string|array $value The field value.
  * @param GF_Field $field The field currently being processed.
  * @param array $entry The entry object currently being processed.
  * @param array $form The form object currently being processed.
  *
  * @return string|array
  */
 public function display_poll_on_entry_detail($value, $field, $entry, $form)
 {
     if ($field->type == 'poll') {
         if ($field->is_entry_detail()) {
             $results = $this->gpoll_get_results($form['id'], $field->id, 'green', true, true, $entry);
             $new_value = sprintf('<div class="gpoll_entry">%s</div>', rgar($results, 'summary'));
             $this->gpoll_add_scripts = true;
             //if original response is not in results display below
             $selected_values = $this->get_selected_values($form['id'], $field->id, $entry);
             $possible_choices = $this->get_possible_choices($form['id'], $field->id);
             foreach ($selected_values as $selected_value) {
                 if (!in_array($selected_value, $possible_choices)) {
                     $new_value = sprintf('%s<h2>%s</h2>%s', $new_value, esc_html__('Original Response', 'gravityformspolls'), $value);
                     break;
                 }
             }
             return $new_value;
         } elseif (is_array($field->choices)) {
             if ($field->inputType == 'checkbox') {
                 foreach ($field->choices as $choice) {
                     $val = rgar($choice, 'value');
                     $text = rgar($choice, 'text');
                     $value = str_replace($val, $text, $value);
                 }
             } else {
                 $value = RGFormsModel::get_choice_text($field, $value);
             }
         }
     }
     return $value;
 }
开发者ID:GravityPDF,项目名称:gravityformspolls,代码行数:41,代码来源:class-gf-polls.php

示例11: display_survey_fields_on_entry_detail

 public function display_survey_fields_on_entry_detail($value, $field, $lead, $form)
 {
     if (rgar($field, 'type') !== 'survey') {
         return $value;
     }
     $new_value = $value;
     $field_type = GFFormsModel::get_input_type($field);
     switch ($field_type) {
         case 'likert':
             $new_value = $this->get_survey_field_content('', $field, $value, $lead['id'], $form['id'], $lead);
             // if original response is not in results display below
             // TODO - handle orphaned responses (original choice is deleted)
             break;
         case 'rank':
             $new_value = $this->get_rank_entry_value_formatted($field, $value);
             break;
         case 'rating':
             $new_value = GFCommon::selection_display($value, $field, $currency = '', $use_text = true);
             break;
         case 'radio':
         case 'checkbox':
         case 'select':
             if (isset($field['inputs']) && is_array($field['inputs'])) {
                 foreach ($field['choices'] as $choice) {
                     $val = rgar($choice, 'value');
                     $text = RGFormsModel::get_choice_text($field, $val);
                     $new_value = str_replace($val, $text, $new_value);
                 }
             } else {
                 $new_value = RGFormsModel::get_choice_text($field, $value);
             }
             break;
     }
     return $new_value;
 }
开发者ID:qhuit,项目名称:dcosta,代码行数:35,代码来源:class-gf-survey.php

示例12: maybe_format_field_values

 /**
  * If the field is a Poll type radio, select or checkbox then replace the choice value with the choice text.
  *
  * @param string $value The field value.
  * @param GF_Field|null $field The field object being processed or null.
  *
  * @return string
  */
 public function maybe_format_field_values($value, $field)
 {
     if (is_object($field) && $field->type == 'quiz') {
         switch ($field->inputType) {
             case 'radio':
             case 'select':
                 return RGFormsModel::get_choice_text($field, $value);
             case 'checkbox':
                 if (is_array($value)) {
                     foreach ($value as &$choice) {
                         if (!empty($choice)) {
                             $choice = RGFormsModel::get_choice_text($field, $choice);
                         }
                     }
                 } else {
                     foreach ($field->choices as $choice) {
                         $val = rgar($choice, 'value');
                         $text = rgar($choice, 'text');
                         $value = str_replace($val, $text, $value);
                     }
                 }
         }
     }
     return $value;
 }
开发者ID:GravityPDF,项目名称:gravityformsquiz,代码行数:33,代码来源:class-gf-quiz.php

示例13: zapier_field_value

 /**
  * Format the Survey field values so they use the choice text instead of values before they are sent to Zapier.
  *
  * @param string|array $value The field value.
  * @param int $form_id The ID of the form currently being processed.
  * @param string $field_id The ID of the field currently being processed.
  * @param array $entry The entry object currently being processed.
  *
  * @return string|array
  */
 public function zapier_field_value($value, $form_id, $field_id, $entry)
 {
     if (!rgblank($value)) {
         $form_meta = RGFormsModel::get_form_meta($form_id);
         $field = RGFormsModel::get_field($form_meta, $field_id);
         if (is_object($field) && $field->type == 'survey') {
             switch ($field->inputType) {
                 case 'likert':
                     if (is_array($value)) {
                         foreach ($value as $key => &$row) {
                             if (!empty($row)) {
                                 $row = $field->get_column_text($value, false, $key);
                             }
                         }
                     } else {
                         return $field->get_column_text($value);
                     }
                     break;
                 case 'rank':
                 case 'rating':
                 case 'radio':
                 case 'select':
                     return $field->get_value_export($entry, $field_id, true);
                 case 'checkbox':
                     foreach ($value as &$choice) {
                         if (!empty($choice)) {
                             $choice = RGFormsModel::get_choice_text($field, $choice);
                         }
                     }
             }
         }
     }
     return $value;
 }
开发者ID:GravityPDF,项目名称:gravityformssurvey,代码行数:44,代码来源:class-gf-survey.php

示例14: merge_tag_filter

 public function merge_tag_filter($value, $merge_tag, $options, $field, $raw_value)
 {
     if ($merge_tag == 'all_fields' && $field['type'] == 'quiz' && is_array($field['choices'])) {
         if ($field['inputType'] == 'checkbox') {
             //parse checkbox string (from $value variable) and replace values with text
             foreach ($raw_value as $key => $val) {
                 $text = RGFormsModel::get_choice_text($field, $val);
                 $value = str_replace($val, $text, $value);
             }
         } else {
             //replacing value with text
             $value = RGFormsModel::get_choice_text($field, $value);
         }
     }
     return $value;
 }
开发者ID:amprog,项目名称:gravity-forms-quiz,代码行数:16,代码来源:class-gf-quiz.php


注:本文中的RGFormsModel::get_choice_text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。