本文整理汇总了PHP中RGFormsModel::get_lead_field_value方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_lead_field_value方法的具体用法?PHP RGFormsModel::get_lead_field_value怎么用?PHP RGFormsModel::get_lead_field_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::get_lead_field_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_data
function output_data($pdf, $lead = array(), $form = array(), $fieldData = array())
{
$pdf->AddPage();
$dataArray = array(array('Project ID #', 3), array('Project Name', 28), array('Name of person responsible for fire safety at your exhibit', 5), array('Their Email', 15), array('Their phone', 16), array('Description', 19), array('Describe your safety concerns', 12), array('Describe how you plan to keep your exhibit safe', 20), array('Who will be assisting at your exhibit to keep it safe', 11), array('Placement Requirements', 7), array('Do you have Insurance', 9), array('Additional Comments', 13), array('Are you 18 years or older?', 23), array('Signed', 25), array('I am the Parent and/or Legal Guardian of', 26), array('Date', 27));
$pdf->SetFillColor(190, 210, 247);
$lineheight = 6;
foreach ($dataArray as $data) {
$fieldID = $data[1];
if (isset($fieldData[$fieldID])) {
$field = $fieldData[$fieldID];
$value = RGFormsModel::get_lead_field_value($lead, $field);
if (RGFormsModel::get_input_type($field) != 'email') {
$display_value = GFCommon::get_lead_field_display($field, $value);
$display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
} else {
$display_value = $value;
}
} else {
$display_value = '';
}
$pdf->MultiCell(0, $lineheight, $data[0] . ': ');
$pdf->MultiCell(0, $lineheight, $display_value, 0, 'L', true);
$pdf->Ln();
}
}
示例2: output_data
function output_data($pdf, $lead = array(), $form = array(), $fieldData = array())
{
$pdf->AddPage();
$dataArray = array(array('Project ID #', 3, 'text'), array('Project Name', 38, 'text'), array('Name of person responsible for fire safety at your exhibit', 21, 'text'), array('Their Email', 23, 'text'), array('Their Phone', 24, 'text'), array('Description', 37, 'textarea'), array('Describe your fire safety concerns', 19, 'textarea'), array('Describe how you plan to keep your exhibit safe', 27, 'textarea'), array('Who will be assisting at your exhibit to keep it safe', 20, 'text'), array('Placement Requirements', 7, 'textarea'), array('What is burning', 10, 'text'), array('What is the fuel source', 11, 'text'), array('how much is fuel is burning and in what time period', 12, 'textarea'), array('how much fuel will you have at the event, including tank sizes', 13, 'textarea'), array('where and how is the fuel stored', 14, 'text'), array('Does the valve have an electronic propane sniffer', 15, 'text'), array('Other suppression devices', 16, 'textarea'), array('Do you have insurance?', 18, 'text'), array('Additional comments', 28, 'textarea'), array('Are you 18 years or older?', 30, 'text'), array('Signed', 32, 'text'), array('I am the Parent and/or Legal Guardian of', 33, 'text'), array('Date', 34, 'text'));
$pdf->SetFillColor(190, 210, 247);
$lineheight = 6;
foreach ($dataArray as $data) {
$fieldID = $data[1];
if (isset($fieldData[$fieldID])) {
$field = $fieldData[$fieldID];
$value = RGFormsModel::get_lead_field_value($lead, $field);
if (RGFormsModel::get_input_type($field) != 'email') {
$display_value = GFCommon::get_lead_field_display($field, $value);
$display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
} else {
$display_value = $value;
}
} else {
$display_value = '';
}
$pdf->MultiCell(0, $lineheight, $data[0] . ': ');
$pdf->MultiCell(0, $lineheight, $display_value, 0, 'L', true);
$pdf->Ln();
}
}
示例3: preview_special_merge_tags
/**
* Adds special support for file upload, post image and multi input merge tags.
*/
public static function preview_special_merge_tags($value, $input_id, $merge_tag, $field)
{
// added to prevent overriding :noadmin filter (and other filters that remove fields)
if (!$value) {
return $value;
}
$input_type = RGFormsModel::get_input_type($field);
$is_upload_field = in_array($input_type, array('post_image', 'fileupload'));
$is_multi_input = is_array(rgar($field, 'inputs'));
$is_input = intval($input_id) != $input_id;
if (!$is_upload_field && !$is_multi_input) {
return $value;
}
// if is individual input of multi-input field, return just that input value
if ($is_input) {
return $value;
}
$form = RGFormsModel::get_form_meta($field['formId']);
$lead = self::create_lead($form);
$currency = GFCommon::get_currency();
if (is_array(rgar($field, 'inputs'))) {
$value = RGFormsModel::get_lead_field_value($lead, $field);
return GFCommon::get_lead_field_display($field, $value, $currency);
}
switch ($input_type) {
case 'fileupload':
$value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead);
$value = self::preview_image_display($field, $form, $value);
break;
default:
$value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead);
$value = GFCommon::get_lead_field_display($field, $value, $currency);
break;
}
return $value;
}
示例4: get_lead_row
public static function get_lead_row($lid, $atts, $fields)
{
ob_start();
/*
* Get our lead information
*/
$lead = GFAPI::get_entry($lid);
/*
* Update the created by date
*/
$lead['date_created_usa'] = date('m/d/Y', strtotime($lead['date_created']));
$lead['date_created'] = date('d/m/Y', strtotime($lead['date_created']));
/*
* Loop through the columns
*/
foreach ($atts['columns'] as $cid) {
?>
<td class="gfpdfe_<?php
echo $cid;
?>
">
<?php
if (is_numeric($cid)) {
$value = RGFormsModel::get_lead_field_value($lead, $fields[$cid]);
echo GFPDFEntryDetail::pdf_get_lead_field_display($fields[$cid], $value, $lead['currency']);
} else {
echo array_key_exists($cid, $lead) ? $lead[$cid] : '';
}
?>
</td>
<?php
}
$html = ob_get_contents();
ob_end_flush();
return $html;
}
示例5: stickylist_shortcode
//.........这里部分代码省略.........
if ($initial_sort == "date_added" && $initial_sort_direction == "ASC") {
$entries = array_reverse($entries);
}
$entries = apply_filters('filter_entries', $entries);
$list_html = "<div id='sticky-list-wrapper_{$form_id}'>";
if ($enable_sort && $enable_search) {
$list_html .= "<input class='search' placeholder='" . __("Search", "sticky-list") . "' />";
}
$list_html .= "<table class='sticky-list'><thead><tr>";
$fields = $form["fields"];
$i = 0;
foreach ($fields as $field) {
if (isset($field["stickylistField"]) && $field["stickylistField"] != "") {
if (isset($field["stickylistFieldLabel"]) && $field["stickylistFieldLabel"] != "") {
$label = $field["stickylistFieldLabel"];
} else {
$label = $field["label"];
}
$class_label = "header-" . str_replace(" ", "-", strtolower($label));
$list_html .= "<th class='sort {$class_label}' data-sort='sort-{$i}'>{$label}</th>";
$i++;
}
}
if ($enable_view || $enable_edit || $enable_delete || $enable_postlink || $enable_duplicate) {
$list_html .= "<th class='sticky-action'>{$action_column_header}</th>";
}
$list_html .= "</tr></thead><tbody class='list'>";
foreach ($entries as $entry) {
$entry_id = $entry["id"];
$list_html .= "<tr>";
$i = 0;
foreach ($form["fields"] as $field) {
if (isset($field["stickylistField"]) && $field["stickylistField"] != "") {
$field_value = RGFormsModel::get_lead_field_value($entry, $field);
$tdClass = "stickylist-" . $field["type"];
$nowrap = "";
if (isset($field["stickylistFieldNoWrap"]) && $field["stickylistFieldNoWrap"] != "") {
$nowrap = " sticky-nowrap";
}
if ($field["type"] == "post_custom_field" && $field["inputType"] == "fileupload") {
$custom_file_upload = true;
} else {
$custom_file_upload = false;
}
if ($field["type"] == "product" || $field["type"] == "shipping" || $field["type"] == "option") {
if (is_array($field_value)) {
if ($field["type"] == "option") {
foreach ($field_value as &$option) {
$option = substr($option, 0, strpos($option, "|"));
}
$field_value = array_filter($field_value);
$field_value = implode(", ", $field_value);
} else {
$field_value = end($field_value);
}
$list_html .= "<td class='sort-{$i} {$nowrap} {$tdClass}'>{$field_value}</td>";
} else {
$field_value = substr($field_value, 0, strpos($field_value, "|"));
$list_html .= "<td class='sort-{$i} {$nowrap} {$tdClass}'>{$field_value}</td>";
}
} elseif (is_array($field_value)) {
ksort($field_value);
$field_values = "";
foreach ($field_value as $field => $value) {
$field_values .= $value . " ";
}
示例6: replace_field_variable
public static function replace_field_variable($text, $form, $lead, $url_encode, $esc_html, $nl2br, $format, $input_id, $match, $esc_attr = false)
{
$field = RGFormsModel::get_field($form, $input_id);
if (!$field instanceof GF_Field) {
$field = GF_Fields::create($field);
}
$value = RGFormsModel::get_lead_field_value($lead, $field);
$raw_value = $value;
if (is_array($value)) {
$value = rgar($value, $input_id);
}
$value = self::format_variable_value($value, $url_encode, $esc_html, $format, $nl2br);
// modifier will be at index 4 unless used in a conditional shortcode in which case it would be at index 5
$i = $match[0][0] == '{' ? 4 : 5;
$modifier = strtolower(rgar($match, $i));
$value = $field->get_value_merge_tag($value, $input_id, $lead, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br);
if (!in_array($field->type, array('html', 'section', 'signature'))) {
$value = self::encode_shortcodes($value);
}
if ($esc_attr) {
$value = esc_attr($value);
}
if ($modifier == 'label') {
$value = empty($value) ? '' : $field->label;
} else {
if ($modifier == 'qty' && $field->type == 'product') {
//getting quantity associated with product field
$products = self::get_product_fields($form, $lead, false, false);
$value = 0;
foreach ($products['products'] as $product_id => $product) {
if ($product_id == $field->id) {
$value = $product['quantity'];
}
}
}
}
//Encoding left curly bracket so that merge tags entered in the front end are displayed as is and not parsed
$value = self::encode_merge_tag($value);
//filter can change merge tag value
$value = apply_filters('gform_merge_tag_filter', $value, $input_id, $modifier, $field, $raw_value);
if ($value === false) {
$value = '';
}
if ($match[0][0] != '{') {
// replace the merge tag in the conditional shortcode merge_tag attr
$value = str_replace($match[1], $value, $match[0]);
}
$text = str_replace($match[0], $value, $text);
return $text;
}
示例7: get_items
/**
* Get items
*
* @see Pronamic_Pay_PaymentDataInterface::get_items()
* @return Pronamic_IDeal_Items
*/
public function get_items()
{
$items = new Pronamic_IDeal_Items();
$number = 0;
// Products
$products = GFCommon::get_product_fields($this->form, $this->lead);
foreach ($products['products'] as $product) {
$description = $product['name'];
$price = GFCommon::to_number($product['price']);
$quantity = $product['quantity'];
$item = new Pronamic_IDeal_Item();
$item->setNumber($number++);
$item->setDescription($description);
$item->setPrice($price);
$item->setQuantity($quantity);
$items->addItem($item);
if (isset($product['options']) && is_array($product['options'])) {
foreach ($product['options'] as $option) {
$description = $option['option_label'];
$price = GFCommon::to_number($option['price']);
$item = new Pronamic_IDeal_Item();
$item->setNumber($number++);
$item->setDescription($description);
$item->setPrice($price);
$item->setQuantity($quantity);
// Product quantity
$items->addItem($item);
}
}
}
// Shipping
if (isset($products['shipping'])) {
$shipping = $products['shipping'];
if (isset($shipping['price']) && !empty($shipping['price'])) {
$description = $shipping['name'];
$price = GFCommon::to_number($shipping['price']);
$quantity = 1;
$item = new Pronamic_IDeal_Item();
$item->setNumber($number++);
$item->setDescription($description);
$item->setPrice($price);
$item->setQuantity($quantity);
$items->addItem($item);
}
}
// Donations
$donation_fields = GFCommon::get_fields_by_type($this->form, array('donation'));
foreach ($donation_fields as $i => $field) {
$value = RGFormsModel::get_lead_field_value($this->lead, $field);
if (!empty($value)) {
$description = '';
if (isset($field['adminLabel']) && !empty($field['adminLabel'])) {
$description = $field['adminLabel'];
} elseif (isset($field['label'])) {
$description = $field['label'];
}
$separator_position = strpos($value, '|');
if (false !== $separator_position) {
$label = substr($value, 0, $separator_position);
$value = substr($value, $separator_position + 1);
$description .= ' - ' . $label;
}
$price = GFCommon::to_number($value);
$quantity = 1;
$item = new Pronamic_IDeal_Item();
$item->setNumber($i);
$item->setDescription($description);
$item->setQuantity($quantity);
$item->setPrice($price);
$items->addItem($item);
}
}
return $items;
}
示例8: lead_detail_grid
public static function lead_detail_grid($form, $lead, $allow_display_empty_fields = false)
{
$form_id = absint($form['id']);
$display_empty_fields = false;
if ($allow_display_empty_fields) {
$display_empty_fields = rgget('gf_display_empty_fields', $_COOKIE);
}
$display_empty_fields = apply_filters('gform_entry_detail_grid_display_empty_fields', $display_empty_fields, $form, $lead);
?>
<table cellspacing="0" class="widefat fixed entry-detail-view">
<thead>
<tr>
<th id="details">
<?php
$title = sprintf('%s : %s %s', esc_html($form['title']), esc_html__('Entry # ', 'gravityforms'), absint($lead['id']));
echo apply_filters('gravityflow_title_entry_detail', $title, $form, $lead);
?>
</th>
<th style="width:140px; font-size:10px; text-align: right;">
<?php
if ($allow_display_empty_fields) {
?>
<input type="checkbox" id="gentry_display_empty_fields" <?php
echo $display_empty_fields ? "checked='checked'" : '';
?>
onclick="ToggleShowEmptyFields();" />
<label for="gentry_display_empty_fields"><?php
esc_html_e('show empty fields', 'gravityforms');
?>
</label>
<?php
}
?>
</th>
</tr>
</thead>
<tbody>
<?php
$count = 0;
$field_count = sizeof($form['fields']);
$has_product_fields = false;
foreach ($form['fields'] as $field) {
switch (RGFormsModel::get_input_type($field)) {
case 'section':
if (!GFCommon::is_section_empty($field, $form, $lead) || $display_empty_fields) {
$count++;
$is_last = $count >= $field_count ? true : false;
?>
<tr>
<td colspan="2" class="entry-view-section-break<?php
echo $is_last ? ' lastrow' : '';
?>
"><?php
echo esc_html(GFCommon::get_label($field));
?>
</td>
</tr>
<?php
}
break;
case 'captcha':
case 'html':
case 'password':
case 'page':
//ignore captcha, html, password, page field
break;
default:
//ignore product fields as they will be grouped together at the end of the grid
if (GFCommon::is_product_field($field->type)) {
$has_product_fields = true;
continue;
}
$value = RGFormsModel::get_lead_field_value($lead, $field);
$display_value = GFCommon::get_lead_field_display($field, $value, $lead['currency']);
$display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
if ($display_empty_fields || !empty($display_value) || $display_value === '0') {
$count++;
$is_last = $count >= $field_count && !$has_product_fields ? true : false;
$last_row = $is_last ? ' lastrow' : '';
$display_value = empty($display_value) && $display_value !== '0' ? ' ' : $display_value;
$content = '
<tr>
<td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</td>
</tr>
<tr>
<td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td>
</tr>';
$content = apply_filters('gform_field_content', $content, $field, $value, $lead['id'], $form['id']);
echo $content;
}
break;
}
}
$products = array();
if ($has_product_fields) {
$products = GFCommon::get_product_fields($form, $lead);
if (!empty($products['products'])) {
?>
<tr>
<td colspan="2" class="entry-view-field-name"><?php
//.........这里部分代码省略.........
示例9: field_value
/**
* Given an entry and a form field id, calculate the entry value for that field.
*
* @access public
* @param array $entry
* @param integer $field
* @return null|string
*/
public static function field_value($entry, $field_settings, $format = 'html')
{
if (empty($entry['form_id']) || empty($field_settings['id'])) {
return NULL;
}
$gravityview_view = GravityView_View::getInstance();
if (class_exists('GFCache')) {
/**
* Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run.
*
* The reason is that the cache was checking against a field value stored in a transient every time `GFFormsModel::get_lead_field_value()` is called.
*
* What we're doing here is telling the GFCache that it's already checked the transient and the value is false, forcing it to just use the non-cached data, which is actually faster.
*
* @hack
* @since 1.3
* @param string $cache_key Field Value transient key used by Gravity Forms
* @param mixed false Setting the value of the cache to false so that it's not used by Gravity Forms' GFFormsModel::get_lead_field_value() method
* @param boolean false Tell Gravity Forms not to store this as a transient
* @param int 0 Time to store the value. 0 is maximum amount of time possible.
*/
GFCache::set("GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0);
}
$field_id = $field_settings['id'];
$form = $gravityview_view->getForm();
$field = gravityview_get_field($form, $field_id);
$field_type = RGFormsModel::get_input_type($field);
if ($field_type) {
$field_type = $field['type'];
$value = RGFormsModel::get_lead_field_value($entry, $field);
} else {
// For non-integer field types (`id`, `date_created`, etc.)
$field_type = $field_id;
$field['type'] = $field_id;
$value = isset($entry[$field_type]) ? $entry[$field_type] : NULL;
}
// Prevent any PHP warnings that may be generated
ob_start();
$display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format);
if ($errors = ob_get_clean()) {
do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors);
}
$display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form);
// prevent the use of merge_tags for non-admin fields
if (!empty($field['adminOnly'])) {
$display_value = self::replace_variables($display_value, $form, $entry);
}
// Check whether the field exists in /includes/fields/{$field_type}.php
// This can be overridden by user template files.
$field_exists = $gravityview_view->locate_template("fields/{$field_type}.php");
// Set the field data to be available in the templates
$gravityview_view->setCurrentField(array('form' => $form, 'field_id' => $field_id, 'field' => $field, 'field_settings' => $field_settings, 'value' => $value, 'display_value' => $display_value, 'format' => $format, 'entry' => $entry, 'field_type' => $field_type));
if ($field_exists) {
do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_exists));
ob_start();
load_template($field_exists, false);
$output = ob_get_clean();
} else {
// Backup; the field template doesn't exist.
$output = $display_value;
}
$field_settings = $gravityview_view->getCurrentField('field_settings');
/**
* Link to the single entry by wrapping the output in an anchor tag
*
* Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example.
*
*/
if (!empty($field_settings['show_as_link'])) {
$output = self::entry_link_html($entry, $output, array(), $field_settings);
}
/**
* @filter `gravityview_field_entry_value_{$field_type}` Modify the field value output for a field type. Example: `gravityview_field_entry_value_number`
* @since 1.6
* @param string $output HTML value output
* @param array $entry The GF entry array
* @param array $field_settings Settings for the particular GV field
*/
$output = apply_filters('gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField());
/**
* @filter `gravityview_field_entry_value` Modify the field value output for all field types
* @param string $output HTML value output
* @param array $entry The GF entry array
* @param array $field_settings Settings for the particular GV field
* @param array $field_data {@since 1.6}
*/
$output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField());
return $output;
}
示例10: get_quiz_results
/**
* Return an array of results including HTML formatted data.
*
* @param array $form The current form.
* @param array $lead The current entry.
* @param bool $show_question Indicates if the quiz question (label) should also be included in the markup.
*
* @return array
*/
public function get_quiz_results($form, $lead = array(), $show_question = true)
{
$total_score = 0;
$output['fields'] = array();
$output['summary'] = '<div class="gquiz-container">';
$fields = GFAPI::get_fields_by_type($form, array('quiz'));
$pass_percent = $this->get_form_setting($form, 'passPercent');
$grades = $this->get_form_setting($form, 'grades');
$max_score = $this->get_max_score($form);
foreach ($fields as $field) {
$weighted_score_enabled = $field->gquizWeightedScoreEnabled;
$value = RGFormsModel::get_lead_field_value($lead, $field);
$field_score = 0;
$field_markup = '<div class="gquiz-field">';
if ($show_question) {
$field_markup .= ' <div class="gquiz-field-label">';
$field_markup .= GFCommon::get_label($field);
$field_markup .= ' </div>';
}
$field_markup .= ' <div class="gquiz-field-choice">';
$field_markup .= ' <ul>';
// for checkbox inputs with multiple correct choices
$completely_correct = true;
$choices = $field->choices;
foreach ($choices as $choice) {
$is_choice_correct = isset($choice['gquizIsCorrect']) && $choice['gquizIsCorrect'] == '1' ? true : false;
$choice_weight = isset($choice['gquizWeight']) ? (double) $choice['gquizWeight'] : 1;
$choice_class = $is_choice_correct ? 'gquiz-correct-choice ' : '';
$response_matches_choice = false;
$user_responded = true;
if (is_array($value)) {
foreach ($value as $item) {
if (RGFormsModel::choice_value_match($field, $choice, $item)) {
$response_matches_choice = true;
break;
}
}
} elseif (empty($value)) {
$response_matches_choice = false;
$user_responded = false;
} else {
$response_matches_choice = RGFormsModel::choice_value_match($field, $choice, $value) ? true : false;
}
$is_response_correct = $is_choice_correct && $response_matches_choice;
if ($response_matches_choice && $weighted_score_enabled) {
$field_score += $choice_weight;
}
if ($field->inputType == 'checkbox') {
$is_response_wrong = !$is_choice_correct && $response_matches_choice || $is_choice_correct && !$response_matches_choice || $is_choice_correct && !$user_responded;
} else {
$is_response_wrong = !$is_choice_correct && $response_matches_choice || $is_choice_correct && !$user_responded;
}
$indicator_markup = '';
if ($is_response_correct) {
$indicator_markup = '<img src="' . $this->_correct_indicator_url . '" />';
$choice_class .= 'gquiz-correct-response ';
} elseif ($is_response_wrong) {
$indicator_markup = '<img src="' . $this->_incorrect_indicator_url . '" />';
$completely_correct = false;
$choice_class .= 'gquiz-incorrect-response ';
}
/**
* More control over the indication for any type of answer
*
* @param string $indicator_markup The indicator HTML/text for an answer
* @param array $form The Form object to filter through
* @param array $field The Field Object to filter through
* @param mixed $choice The Choice object for the quiz
* @param array $lead The Lead Object to filter through
* @param bool $is_response_correct True or false if the response is correct, can be used to change indicators
* @param bool $is_response_wrong True or false if the response is incorrect, can be used to change indicators
*/
$indicator_markup = apply_filters('gquiz_answer_indicator', $indicator_markup, $form, $field, $choice, $lead, $is_response_correct, $is_response_wrong);
$choice_class_markup = empty($choice_class) ? '' : 'class="' . $choice_class . '"';
$field_markup .= "<li {$choice_class_markup}>";
$field_markup .= $choice['text'] . $indicator_markup;
$field_markup .= '</li>';
}
// end foreach choice
$field_markup .= ' </ul>';
$field_markup .= ' </div>';
if ($field->gquizShowAnswerExplanation) {
$field_markup .= '<div class="gquiz-answer-explanation">';
$field_markup .= $field->gquizAnswerExplanation;
$field_markup .= '</div>';
}
$field_markup .= '</div>';
if (!$weighted_score_enabled && $completely_correct) {
$field_score += 1;
}
$output['summary'] .= $field_markup;
//.........这里部分代码省略.........
示例11: get_default_field_results
public static function get_default_field_results($form_id, $field, $search_criteria, $offset, $page_size)
{
$field_results = "";
$paging = array('offset' => $offset, 'page_size' => $page_size);
$sorting = array('key' => "date_created", 'direction' => "DESC");
$leads = GFFormsModel::search_leads($form_id, $search_criteria, $sorting, $paging);
foreach ($leads as $lead) {
$value = RGFormsModel::get_lead_field_value($lead, $field);
$content = apply_filters("gform_entries_field_value", $value, $form_id, $field["id"], $lead);
$field_results .= "<li>{$content}</li>";
}
return $field_results;
}
示例12: gpoll_get_data
/**
* Cycles through all entries, counts responses and returns an associative array with the data for each field.
* It's then optionally cached later according to the user settings.
*
* @param int $form_id The form ID.
* @param array $gpoll_data The poll results data.
*
* @return array
*/
public function gpoll_get_data($form_id, $gpoll_data = array())
{
$time_start = microtime(true);
$max_execution_time = 20;
//seconds
$totals = RGFormsModel::get_form_counts($form_id);
$total = $totals['total'];
$form_meta = RGFormsModel::get_form_meta($form_id);
$form_meta = apply_filters("gform_polls_form_pre_results_{$form_id}", apply_filters('gform_polls_form_pre_results', $form_meta));
$poll_fields = array();
foreach ($form_meta['fields'] as $field) {
if ($field->type !== 'poll') {
continue;
}
$poll_fields[] = clone $field;
}
$sort_field_number = 0;
$sort_direction = 'DESC';
$search = '';
$offset = 0;
$page_size = 200;
$star = null;
$read = null;
$is_numeric_sort = false;
$start_date = null;
$end_date = null;
$status = 'active';
$field_counter = 0;
if (empty($gpoll_data)) {
//first build list of fields to count and later count the entries
//it's split up this way to avoid a timeout on large resultsets
foreach ($poll_fields as $poll_field) {
$fieldid = $poll_field->id;
$gpoll_field_data = array('field_label' => $poll_field->label, 'field_id' => $fieldid, 'type' => $poll_field->type, 'inputType' => $poll_field->inputType);
$gpoll_data['fields'][$field_counter] = $gpoll_field_data;
$gpoll_input_data = array();
//for checkboxes
if ($poll_field->inputType == 'checkbox') {
$input_counter = 0;
foreach ($poll_field->inputs as $input) {
$inputid = str_replace('.', '_', $input['id']);
$gpoll_input_data = array('input_id' => "#choice_{$inputid}", 'label' => $input['label']);
$gpoll_data['fields'][$field_counter]['inputs'][$input_counter] = $gpoll_input_data;
$input_counter += 1;
}
} else {
//for radio & dropdowns
$choice_counter = 0;
if ($poll_field->enableOtherChoice) {
$choice_index = count($poll_field->choices);
$choices = $poll_field->choices;
$choices[$choice_index]['text'] = esc_html__('Other', 'gravityformspolls');
$choices[$choice_index]['value'] = 'gpoll_other';
$poll_field->choices = $choices;
}
foreach ($poll_field->choices as $choice) {
$gpoll_input_data = array('input_id' => "#choice_{$fieldid}_{$choice_counter}", 'label' => $choice['text']);
$gpoll_data['fields'][$field_counter]['inputs'][$choice_counter] = $gpoll_input_data;
$choice_counter += 1;
}
}
$field_counter += 1;
$i = $offset;
}
} else {
$i = $gpoll_data['offset'];
unset($gpoll_data['offset']);
}
$precision = apply_filters('gform_polls_percentage_precision', 0, $form_id);
//get leads in groups of $page_size to avoid timeouts
while ($i <= $total) {
$field_counter = 0;
$get_leads_time_start = microtime(true);
$entries = RGFormsModel::get_leads($form_id, $sort_field_number, $sort_direction, $search, $i, $page_size, null, null, false, null, null);
$get_leads_time_end = microtime(true);
$get_leads_time = $get_leads_time_end - $get_leads_time_start;
//loop through each field currently on the form and count the entries for each choice
foreach ($poll_fields as $poll_field) {
if (isset($gpoll_data['fields'][$field_counter]['total_entries'])) {
$field_total_entries = $gpoll_data['fields'][$field_counter]['total_entries'];
} else {
$field_total_entries = 0;
}
foreach ($entries as $entry) {
$entry_value = RGFormsModel::get_lead_field_value($entry, $poll_field);
if (false === empty($entry_value)) {
$field_total_entries++;
}
}
$gpoll_data['fields'][$field_counter]['total_entries'] = $field_total_entries;
$gpoll_input_data = array();
//.........这里部分代码省略.........
示例13: field_value
/**
* Given an entry and a form field id, calculate the entry value for that field.
*
* @access public
* @param array $entry
* @param array $field
* @return null|string
*/
public static function field_value($entry, $field_settings, $format = 'html')
{
if (empty($entry['form_id']) || empty($field_settings['id'])) {
return NULL;
}
$gravityview_view = GravityView_View::getInstance();
$field_id = $field_settings['id'];
$form = $gravityview_view->getForm();
$field = gravityview_get_field($form, $field_id);
if ($field && is_numeric($field_id)) {
// Used as file name of field template in GV.
// Don't use RGFormsModel::get_input_type( $field ); we don't care if it's a radio input; we want to know it's a 'quiz' field
$field_type = $field->type;
$value = RGFormsModel::get_lead_field_value($entry, $field);
} else {
$field = GravityView_Fields::get_associated_field($field_id);
$field_type = $field_id;
// Used as file name of field template in GV
}
// If a Gravity Forms Field is found, get the field display
if ($field) {
// Prevent any PHP warnings that may be generated
ob_start();
$display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format);
if ($errors = ob_get_clean()) {
do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors);
}
$display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form);
// prevent the use of merge_tags for non-admin fields
if (!empty($field->adminOnly)) {
$display_value = self::replace_variables($display_value, $form, $entry);
}
} else {
$value = $display_value = rgar($entry, $field_id);
$display_value = $value;
}
// Check whether the field exists in /includes/fields/{$field_type}.php
// This can be overridden by user template files.
$field_path = $gravityview_view->locate_template("fields/{$field_type}.php");
// Set the field data to be available in the templates
$gravityview_view->setCurrentField(array('form' => $form, 'field_id' => $field_id, 'field' => $field, 'field_settings' => $field_settings, 'value' => $value, 'display_value' => $display_value, 'format' => $format, 'entry' => $entry, 'field_type' => $field_type, 'field_path' => $field_path));
if (!empty($field_path)) {
do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path));
ob_start();
load_template($field_path, false);
$output = ob_get_clean();
} else {
// Backup; the field template doesn't exist.
$output = $display_value;
}
// Get the field settings again so that the field template can override the settings
$field_settings = $gravityview_view->getCurrentField('field_settings');
/**
* @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link`
* @since 1.16
* @param string $output HTML value output
* @param array $entry The GF entry array
* @param array $field_settings Settings for the particular GV field
* @param array $field Field array, as fetched from GravityView_View::getCurrentField()
*/
$output = apply_filters('gravityview_field_entry_value_' . $field_type . '_pre_link', $output, $entry, $field_settings, $gravityview_view->getCurrentField());
/**
* Link to the single entry by wrapping the output in an anchor tag
*
* Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example.
*
*/
if (!empty($field_settings['show_as_link']) && !gv_empty($output, false, false)) {
$link_atts = empty($field_settings['new_window']) ? array() : array('target' => '_blank');
$output = self::entry_link_html($entry, $output, $link_atts, $field_settings);
}
/**
* @filter `gravityview_field_entry_value_{$field_type}` Modify the field value output for a field type. Example: `gravityview_field_entry_value_number`
* @since 1.6
* @param string $output HTML value output
* @param array $entry The GF entry array
* @param array $field_settings Settings for the particular GV field
* @param array $field Current field being displayed
*/
$output = apply_filters('gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField());
/**
* @filter `gravityview_field_entry_value` Modify the field value output for all field types
* @param string $output HTML value output
* @param array $entry The GF entry array
* @param array $field_settings Settings for the particular GV field
* @param array $field_data {@since 1.6}
*/
$output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField());
return $output;
}
示例14:
</h2></div>
</td>
</tr>
<?php
break;
case "captcha":
case "html":
case "password":
//ignore certain fields
break;
case "creditcard":
$content1 = "<tr valign='top'><td class='detail-view'><label class='detail-label'>Credit Card Payment</label></td></tr>";
echo $content1;
break;
default:
$value = RGFormsModel::get_lead_field_value($lead, $field);
$td_id = "field_" . $form_id . "_" . $field_id;
$content = "<tr valign='top'><td class='detail-view' id='{$td_id}'><label class='detail-label'>" . esc_html(GFCommon::get_label($field)) . "</label>" . GFCommon::get_field_input($field, $value, $lead["id"]) . "</td></tr>";
$content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $form["id"]);
echo $content;
break;
}
}
?>
</tbody>
</table>
<br/>
<div class="gform_footer">
<input type="hidden" name="gform_unique_id" value="" />
<input type="hidden" name="gform_uploaded_files" id='gform_uploaded_files_<?php
echo $form_id;
示例15: show_edit_form
//.........这里部分代码省略.........
$creditcard_warning_class = $input_type == "creditcard" && !GFCommon::is_ssl() ? "gfield_creditcard_warning" : "";
$custom_class = IS_ADMIN ? "" : rgget("cssClass", $field);
$css_class = "{$selectable_class} gfield {$error_class} {$section_class} {$admin_only_class} {$custom_class} {$hidden_class} {$html_block_class} {$html_formatted_class} {$html_no_follows_desc_class} {$option_class} {$quantity_class} {$product_class} {$donation_class} {$shipping_class} {$page_class} {$required_class} {$hidden_product_class} {$creditcard_warning_class} {$calculation_class}";
$css_class = apply_filters("gform_field_css_class_" . self::$form["id"], apply_filters("gform_field_css_class", trim($css_class), $field, self::$form), $field, self::$form);
$style = !empty($form) && !IS_ADMIN && RGFormsModel::is_field_hidden(self::$form, $field, $field_values) ? "style='display:none;'" : "";
switch (RGFormsModel::get_input_type($field)) {
case "captcha":
case "html":
case "password":
case "product":
case "coupon":
case "quantity":
case "shipping":
case "donation":
case "total":
case "singleproduct":
case "hiddenproduct":
case "singleshipping":
case "creditcard":
case "page":
case "post_image":
case "fileupload":
//ignore certain fields
continue;
break;
default:
if (isset($field['productField']) && (int) $field['productField'] > 0 || $field['type'] == 'shipping') {
continue;
}
/*
* Ensure our restricted field values stay the same (as they aren't push through the $_POST data)
*/
if (in_array($field_id, $this->atts['restricted_fields'])) {
$value = RGFormsModel::get_lead_field_value($lead, $field);
} else {
/*
* Check if we have POST data, or whether we pull the details from the entry itself
* This is useful when the validation fails
*/
$value = $is_postback ? RGFormsModel::get_field_value($field) : RGFormsModel::get_lead_field_value($lead, $field);
}
$id = "field_" . $form['id'] . "_" . $field_id;
/* $content = " <li id='{$id}' class='$css_class' $style><label class='detail-label'>" . esc_html(GFCommon::get_label($field)) . "</label>" .
GFCommon::get_field_input($field, $value, $lead["id"], $form['id']) . "</li>";
$content = apply_filters("gform_field_content", $content, $field, $value, self::$lead["id"], self::$form["id"]);*/
//$content = "<li id='{$id}' class='$css_class' $style>" . GFFormDisplay::get_field_content($field, $value, true, $form['id']) . '</li>';
$field_content = GFFormDisplay::get_field_content($field, $value, true, $form['id']);
$field_container = "<li id='{$id}' class='{$css_class}' {$style}>{FIELD_CONTENT}</li>";
$field_container = apply_filters('gform_field_container', $field_container, $field, $form, $css_class, $style, $field_content);
$field_container = apply_filters("gform_field_container_{$form['id']}", $field_container, $field, $form, $css_class, $style, $field_content);
$field_container = apply_filters("gform_field_container_{$form['id']}_{$field['id']}", $field_container, $field, $form, $css_class, $style, $field_content);
$field_markup = str_replace('{FIELD_CONTENT}', $field_content, $field_container);
if (in_array($field_id, $this->atts['restricted_fields'])) {
$field_markup = str_replace('<input', '<input disabled', $field_markup);
$field_markup = str_replace('<textarea', '<textarea disabled', $field_markup);
}
echo $field_markup;
break;
}
}
$field_values_str = is_array($field_values) ? http_build_query($field_values) : $field_values;
?>
<input type='hidden' class='gform_hidden' name='is_submit_<?php