本文整理汇总了PHP中RGCurrency类的典型用法代码示例。如果您正苦于以下问题:PHP RGCurrency类的具体用法?PHP RGCurrency怎么用?PHP RGCurrency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RGCurrency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bb_click_array_field_input
function bb_click_array_field_input($input, $field, $value, $lead_id, $form_id)
{
if ($field["type"] == "bb_click_array") {
$field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
$input_name = $form_id . '_' . $field["id"];
$css = isset($field['cssClass']) ? $field['cssClass'] : "";
$disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
$amount = '';
$clicked = '';
if (is_array($value)) {
$amount = esc_attr(rgget($field["id"] . ".1", $value));
$clicked = rgget($field["id"] . ".5", $value);
}
$html = "<div id='{$field_id}' class='ginput_container bb-click-array-" . count($field['choices']) . " " . esc_attr($css) . "'>" . "\n";
if (is_array($field["choices"])) {
$choice_id = 0;
$tabindex = GFCommon::get_tabindex();
foreach ($field["choices"] as $choice) {
$id = $field["id"] . '_' . $choice_id;
$field_value = !empty($choice["value"]) || rgar($field, "enableChoiceValue") ? $choice["value"] : $choice["text"];
if (rgblank($amount) && RG_CURRENT_VIEW != "entry") {
$active = rgar($choice, "isSelected") ? "checked='checked'" : "";
} else {
$active = RGFormsModel::choice_value_match($field, $choice, $amount) ? "checked='checked'" : "";
}
if ($active) {
$amount = $field_value;
}
$field_class = $active ? 's-active' : 's-passive';
if (rgar($field, 'field_bb_click_array_is_product')) {
require_once GFCommon::get_base_path() . '/currency.php';
$currency = new RGCurrency(GFCommon::get_currency());
$field_value = $currency->to_money($field_value);
$field_class .= ' s-currency';
}
$html .= sprintf('<div data-clickarray-value="%s" data-choice-id="%s" class="s-html-wrapper %s" id="%s">', esc_attr($field_value), $choice_id, $field_class, $id);
$html .= sprintf('<div class="s-html-value">%s</div>', $field_value);
$html .= sprintf("<label for='choice_%s' id='label_%s'>%s</label>", $id, $id, $choice["text"]);
$html .= '</div>';
$choice_id++;
}
$onblur = !IS_ADMIN ? 'if(jQuery(this).val().replace(" ", "") == "") { jQuery(this).val("' . $other_default_value . '"); }' : '';
$onkeyup = empty($field["conditionalLogicFields"]) || IS_ADMIN ? '' : "onchange='gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ");' onkeyup='clearTimeout(__gf_timeout_handle); __gf_timeout_handle = setTimeout(\"gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ")\", 300);'";
$value_exists = RGFormsModel::choices_value_match($field, $field["choices"], $value);
$other_label = empty($field['field_bb_click_array_other_label']) ? 'My Best Gift' : $field['field_bb_click_array_other_label'];
$other_class = rgar($field, 'enableOtherChoice') ? '' : 'hide';
$html .= "<label for='input_{$field["formId"]}_{$field["id"]}_1' class='ginput_bb_click_array_other_label " . $other_class . "'>" . $other_label . "</label>";
$other_class .= rgar($field, 'field_bb_click_array_is_product') ? ' ginput_amount gfield_price gfield_price_' . $field['formId'] . '_' . $field['id'] . '_1 gfield_product_' . $field['formId'] . '_' . $field['id'] . '_1' : '';
$html .= "<input id='input_{$field["formId"]}_{$field["id"]}_1' name='input_{$field["id"]}_1' type='text' value='" . esc_attr($amount) . "' class='ginput_bb ginput_click_array_other " . $other_class . " " . $field['size'] . "' onblur='{$onblur}' {$tabindex} {$onkeyup} {$disabled_text}>";
$html .= "<input id='input_{$field["formId"]}_{$field["id"]}_5' name='input_{$field["id"]}_5' type='hidden' value='" . esc_attr($clicked) . "' class='ginput_bb ginput_click_array_clicked'>";
}
$html .= "</div>";
return $html;
}
return $input;
}
示例2: get_value_save_entry
public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead)
{
// ignore submitted value and recalculate price in backend
list($prefix, $field_id, $input_id) = rgexplode('_', $input_name, 3);
if ($input_id == 2) {
require_once GFCommon::get_base_path() . '/currency.php';
$currency = new RGCurrency(GFCommon::get_currency());
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = $currency->to_money(GFCommon::calculate($this, $form, $lead));
}
return $value;
}
示例3: get_value_submission
public function get_value_submission($field_values, $get_from_post_global_var = true)
{
$value = $this->get_input_value_submission('input_' . $this->id, $this->inputName, $field_values, $get_from_post_global_var);
$value = trim($value);
if ($this->numberFormat == 'currency') {
require_once GFCommon::get_base_path() . '/currency.php';
$currency = new RGCurrency(GFCommon::get_currency());
$value = $currency->to_number($value);
} else {
if ($this->numberFormat == 'decimal_comma') {
$value = GFCommon::clean_number($value, 'decimal_comma');
} else {
if ($this->numberFormat == 'decimal_dot') {
$value = GFCommon::clean_number($value, 'decimal_dot');
}
}
}
return $value;
}
示例4: gravityforms_settings_page
public static function gravityforms_settings_page()
{
global $wpdb;
if (!GFCommon::ensure_wp_version()) {
return;
}
if (isset($_GET['setup'])) {
//forcing setup
RGForms::setup(true);
}
require_once 'currency.php';
if (isset($_POST['submit'])) {
check_admin_referer('gforms_update_settings', 'gforms_update_settings');
if (!GFCommon::current_user_can_any('gravityforms_edit_settings')) {
die(esc_html__("You don't have adequate permission to edit settings.", 'gravityforms'));
}
RGFormsModel::save_key(sanitize_text_field($_POST['gforms_key']));
update_option('rg_gforms_disable_css', (bool) rgpost('gforms_disable_css'));
update_option('rg_gforms_enable_html5', (bool) rgpost('gforms_enable_html5'));
update_option('gform_enable_noconflict', (bool) rgpost('gform_enable_noconflict'));
update_option('gform_enable_background_updates', (bool) rgpost('gform_enable_background_updates'));
update_option('rg_gforms_enable_akismet', self::get_posted_akismet_setting());
// do not cast to bool, option is enabled by default; need a "1" or a "0"
update_option('rg_gforms_captcha_public_key', sanitize_text_field(rgpost('gforms_captcha_public_key')));
update_option('rg_gforms_captcha_private_key', sanitize_text_field(rgpost('gforms_captcha_private_key')));
if (!rgempty('gforms_currency') && in_array(rgpost('gforms_currency'), array_keys(RGCurrency::get_currencies()))) {
update_option('rg_gforms_currency', rgpost('gforms_currency'));
}
//Updating message because key could have been changed
GFCommon::cache_remote_message();
//Re-caching version info
$version_info = GFCommon::get_version_info(false);
?>
<div class="updated fade" style="padding:6px;">
<?php
esc_html_e('Settings Updated', 'gravityforms');
?>
.
</div>
<?php
}
if (!isset($version_info)) {
$version_info = GFCommon::get_version_info();
}
self::page_header(__('General Settings', 'gravityforms'), '');
?>
<form method="post">
<?php
wp_nonce_field('gforms_update_settings', 'gforms_update_settings');
?>
<h3><span><i class="fa fa-cogs"></i> <?php
esc_html_e('General Settings', 'gravityforms');
?>
</span></h3>
<table class="form-table">
<tr valign="top">
<th scope="row">
<label for="gforms_key"><?php
esc_html_e('Support License Key', 'gravityforms');
?>
</label> <?php
gform_tooltip('settings_license_key');
?>
</th>
<td>
<?php
$key = GFCommon::get_key();
$key_field = '<input type="password" name="gforms_key" id="gforms_key" style="width:350px;" value="' . $key . '" />';
if (!rgempty('is_error', $version_info)) {
$key_field .= " <img src='" . GFCommon::get_base_url() . "/images/exclamation.png' class='gf_keystatus_error gf_tooltip' alt='There was an error validating your key' title='<h6>" . esc_attr__('Validation Error', 'gravityforms') . '</h6>' . esc_attr__('There was an error while validating your license key. Gravity Forms will continue to work, but automatic upgrades will not be available. Please contact support to resolve this issue.', 'gravityforms') . "'/>";
} else {
if (rgar($version_info, 'is_valid_key')) {
$key_field .= " <i class='fa fa-check gf_keystatus_valid'></i> <span class='gf_keystatus_valid_text'>" . esc_html__('Valid Key : Your license key has been successfully validated.', 'gravityforms') . '</span>';
} else {
if (!empty($key)) {
$key_field .= " <i class='fa fa-times gf_keystatus_invalid'></i> <span class='gf_keystatus_invalid_text'>" . esc_html__('Invalid or Expired Key : Please make sure you have entered the correct value and that your key is not expired.', 'gravityforms') . '</span>';
}
}
}
echo apply_filters('gform_settings_key_field', $key_field);
?>
<br />
<span class="gf_settings_description"><?php
esc_html_e('The license key is used for access to automatic upgrades and support.', 'gravityforms');
?>
</span>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="gforms_disable_css"><?php
esc_html_e('Output CSS', 'gravityforms');
?>
</label> <?php
gform_tooltip('settings_output_css');
?>
</th>
<td>
<input type="radio" name="gforms_disable_css" value="0" id="gforms_css_output_enabled" <?php
echo get_option('rg_gforms_disable_css') == 1 ? '' : "checked='checked'";
//.........这里部分代码省略.........
示例5: get_form
//.........这里部分代码省略.........
$color = $style == "custom" ? " color:{$form["pagination"]["color"]};" : "";
$bgcolor = $style == "custom" ? " background-color:{$form["pagination"]["backgroundColor"]};" : "";
$form_string .= "\n <div id='gf_progressbar_wrapper_{$form_id}' class='gf_progressbar_wrapper'>\n <h3 class='gf_progressbar_title'>" . __("Step", "gravityforms") . " {$current_page} " . __("of", "gravityforms") . " {$page_count}{$page_name}</h3>\n <div class='gf_progressbar'>\n <div class='gf_progressbar_percentage percentbar_{$style}' style='width:{$percent};{$color}{$bgcolor}'><span>{$percent}</span></div>\n </div>\n </div>";
} else {
if ($form["pagination"]["type"] == "steps") {
$form_string .= "\n <div id='gf_page_steps_{$form_id}' class='gf_page_steps'>";
for ($i = 0, $count = sizeof($form["pagination"]["pages"]); $i < $count; $i++) {
$step_number = $i + 1;
$active_class = $step_number == $current_page ? " gf_step_active" : "";
$first_class = $i == 0 ? " gf_step_first" : "";
$last_class = $i + 1 == $count ? " gf_step_last" : "";
$complete_class = $step_number < $current_page ? " gf_step_completed" : "";
$previous_class = $step_number + 1 == $current_page ? " gf_step_previous" : "";
$next_class = $step_number - 1 == $current_page ? " gf_step_next" : "";
$pending_class = $step_number > $current_page ? " gf_step_pending" : "";
$classes = "gf_step" . $active_class . $first_class . $last_class . $complete_class . $previous_class . $next_class . $pending_class;
$classes = GFCommon::trim_all($classes);
$form_string .= "\n <div id='gf_step_{$form_id}_{$step_number}' class='{$classes}'><span class='gf_step_number'>{$step_number}</span> {$form["pagination"]["pages"][$i]}</div>";
}
$form_string .= "\n <div class='gf_step_clear'></div>\n </div>";
}
}
}
if ($is_postback && !$is_valid) {
$validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . " " . __("Errors have been highlighted below.", "gravityforms") . "</div>";
$form_string .= apply_filters("gform_validation_message_{$form["id"]}", apply_filters("gform_validation_message", $validation_message, $form), $form);
}
$form_string .= "\n <div class='gform_body'>";
//add first page if this form has any page fields
if ($has_pages) {
$style = self::is_page_active($form_id, 1) ? "" : "style='display:none;'";
$class = !empty($form["firstPageCssClass"]) ? " {$form["firstPageCssClass"]}" : "";
$form_string .= "<div id='gform_page_{$form_id}_1' class='gform_page{$class}' {$style}>\n <div class='gform_page_fields'>";
}
$description_class = rgar($form, "descriptionPlacement") == "above" ? "description_above" : "description_below";
$form_string .= "\n <ul id='gform_fields_{$form_id}' class='gform_fields {$form['labelPlacement']} {$description_class}'>";
if (is_array($form['fields'])) {
foreach ($form['fields'] as $field) {
$field["conditionalLogicFields"] = self::get_conditional_logic_fields($form, $field["id"]);
$form_string .= self::get_field($field, RGFormsModel::get_field_value($field, $field_values), false, $form, $field_values);
}
}
$form_string .= "\n </ul>";
if ($has_pages) {
$previous_button = self::get_form_button($form["id"], "gform_previous_button_{$form["id"]}", $form["lastPageButton"], __("Previous", "gravityforms"), "button gform_previous_button", __("Previous Page", "gravityforms"), self::get_current_page($form_id) - 1);
$form_string .= "</div>" . self::gform_footer($form, "gform_page_footer " . $form['labelPlacement'], $ajax, $field_values, $previous_button, $display_title, $display_description, $is_postback) . "\n </div>";
//closes gform_page
}
$form_string .= "</div>";
//closes gform_body
//suppress form footer for multi-page forms (footer will be included on the last page
if (!$has_pages) {
$form_string .= self::gform_footer($form, "gform_footer " . $form['labelPlacement'], $ajax, $field_values, "", $display_title, $display_description, $is_postback);
}
$form_string .= "\n </form>\n </div>";
//adding conditional logic script if conditional logic is configured for this form.
//get_conditional_logic also adds the chosen script for the enhanced dropdown option.
//if this form does not have conditional logic, add chosen script separately
if (self::has_conditional_logic($form)) {
$form_string .= self::get_conditional_logic($form);
} else {
if (self::has_enhanced_dropdown($form)) {
$form_string .= "<script type='text/javascript'>//<![CDATA[\n" . self::get_chosen_init_script($form) . "\n//]]></script>";
}
}
//adding currency config if there are any product fields in the form
if (self::has_price_field($form)) {
if (!class_exists("RGCurrency")) {
require_once "currency.php";
}
$form_string .= "<script type='text/javascript'>//<![CDATA[\n if(window[\"gformInitPriceFields\"]) jQuery(document).ready(function(){gformInitPriceFields();}); window['gf_currency_config'] = " . GFCommon::json_encode(RGCurrency::get_currency(GFCommon::get_currency())) . "; \n//]]></script>";
}
if (self::has_password_strength($form)) {
$form_string .= "<script type='text/javascript'>//<![CDATA[\nif(!window['gf_text']){window['gf_text'] = new Array();} window['gf_text']['password_blank'] = '" . __("Strength indicator", "gravityforms") . "'; window['gf_text']['password_mismatch'] = '" . __("Mismatch", "gravityforms") . "';window['gf_text']['password_bad'] = '" . __("Bad", "gravityforms") . "'; window['gf_text']['password_short'] = '" . __("Short", "gravityforms") . "'; window['gf_text']['password_good'] = '" . __("Good", "gravityforms") . "'; window['gf_text']['password_strong'] = '" . __("Strong", "gravityforms") . "';\n//]]></script>";
}
if (GFCommon::has_credit_card_field($form)) {
$card_rules = self::get_credit_card_rules();
$form_string .= "<script type='text/javascript'>//<![CDATA[\n if(!window['gf_cc_rules']){window['gf_cc_rules'] = new Array(); } window['gf_cc_rules'] = " . GFCommon::json_encode($card_rules) . "; \n//]]></script>";
}
if ($ajax && $is_postback) {
global $wp_scripts;
$form_string = "<!DOCTYPE html><html><head>" . "<script type='text/javascript' src='" . $wp_scripts->base_url . $wp_scripts->registered["jquery"]->src . "'></script>" . "<script type='text/javascript' src='" . GFCommon::get_base_url() . "/js/conditional_logic.js'></script>" . "<meta charset='UTF-8' /></head><body>" . $form_string . "</body></html>";
}
if ($ajax && !$is_postback) {
$spinner_url = apply_filters("gform_ajax_spinner_url_{$form_id}", apply_filters("gform_ajax_spinner_url", GFCommon::get_base_url() . "/images/spinner.gif", $form), $form);
$scroll_position = array('default' => '', 'confirmation' => '');
if ($use_anchor !== false) {
$scroll_position['default'] = is_numeric($use_anchor) ? "jQuery(document).scrollTop(" . intval($use_anchor) . ");" : "jQuery(document).scrollTop(jQuery('#gform_wrapper_{$form_id}').offset().top);";
$scroll_position['confirmation'] = is_numeric($use_anchor) ? "jQuery(document).scrollTop(" . intval($use_anchor) . ");" : "jQuery(document).scrollTop(jQuery('#gforms_confirmation_message').offset().top);";
}
$form_string .= "\n <iframe style='display:none;width:0px; height:0px;' src='about:blank' name='gform_ajax_frame_{$form_id}' id='gform_ajax_frame_{$form_id}'></iframe>\n <script type='text/javascript'>//<![CDATA[\n" . "function gformInitSpinner(){" . "jQuery('#gform_{$form_id}').submit(function(){" . "jQuery('#gform_submit_button_{$form_id}').attr('disabled', true).after('<' + 'img id=\"gform_ajax_spinner_{$form_id}\" class=\"gform_ajax_spinner\" src=\"{$spinner_url}\" alt=\"\" />');" . "jQuery('#gform_wrapper_{$form_id} .gform_previous_button').attr('disabled', true); " . "jQuery('#gform_wrapper_{$form_id} .gform_next_button').attr('disabled', true).after('<' + 'img id=\"gform_ajax_spinner_{$form_id}\" class=\"gform_ajax_spinner\" src=\"{$spinner_url}\" alt=\"\" />');" . "});" . "}" . "jQuery(document).ready(function(\$){" . "gformInitSpinner();" . "jQuery('#gform_ajax_frame_{$form_id}').load( function(){" . "var form_content = jQuery(this).contents().find('#gform_wrapper_{$form_id}');" . "var confirmation_content = jQuery(this).contents().find('#gforms_confirmation_message');" . "jQuery('#gform_submit_button_{$form_id}').removeAttr('disabled');" . "if(form_content.length > 0){" . "jQuery('#gform_wrapper_{$form_id}').html(form_content.html());" . "{$scroll_position['default']}" . "if(window['gformInitDatepicker']) {gformInitDatepicker();}" . "if(window['gformInitPriceFields']) {gformInitPriceFields();}" . "var current_page = jQuery('#gform_source_page_number_{$form_id}').val();" . "gformInitSpinner();" . "jQuery(document).trigger('gform_page_loaded', [{$form_id}, current_page]);" . "}" . "else if(confirmation_content.length > 0){" . "setTimeout(function(){" . "jQuery('#gform_wrapper_{$form_id}').replaceWith('<' + 'div id=\\'gforms_confirmation_message\\' class=\\'gform_confirmation_message_{$form_id}\\'' + '>' + confirmation_content.html() + '<' + '/div' + '>');" . "{$scroll_position['confirmation']}" . "jQuery(document).trigger('gform_confirmation_loaded', [{$form_id}]);" . "}, 50);" . "}" . "else{" . "jQuery('#gform_{$form_id}').append(jQuery(this).contents().find('*').html());" . "if(window['gformRedirect']) gformRedirect();" . "}" . "jQuery(document).trigger('gform_post_render', [{$form_id}, current_page]);" . "});" . "});" . "\n//]]></script>";
}
return apply_filters('gform_get_form_filter', $form_string);
} else {
if ($ajax) {
$confirmation_message = "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body>" . $confirmation_message . "</body></html>";
}
return $confirmation_message;
}
}
示例6: sanitize_settings
public function sanitize_settings()
{
parent::sanitize_settings();
$this->enableCalculation = (bool) $this->enableCalculation;
if ($this->numberFormat == 'currency') {
require_once GFCommon::get_base_path() . '/currency.php';
$currency = new RGCurrency(GFCommon::get_currency());
$this->rangeMin = $currency->to_number($this->rangeMin);
$this->rangeMax = $currency->to_number($this->rangeMax);
} elseif ($this->numberFormat == 'decimal_comma') {
$this->rangeMin = GFCommon::clean_number($this->rangeMin, 'decimal_comma');
$this->rangeMax = GFCommon::clean_number($this->rangeMax, 'decimal_comma');
} elseif ($this->numberFormat == 'decimal_dot') {
$this->rangeMin = GFCommon::clean_number($this->rangeMin, 'decimal_dot');
$this->rangeMin = GFCommon::clean_number($this->rangeMin, 'decimal_dot');
}
}
示例7: gravityforms_settings_page
//.........这里部分代码省略.........
/> <?php
_e("No", "gravityforms");
?>
<br />
<?php
_e("Protect your form entries from spam using Akismet.", "gravityforms");
?>
</td>
</tr>
<?php
}
?>
<tr valign="top">
<th scope="row"><label for="gforms_currency"><?php
_e("Currency", "gravityforms");
?>
</label> <?php
gform_tooltip("settings_currency");
?>
</th>
<td>
<?php
$disabled = apply_filters("gform_currency_disabled", false) ? "disabled='disabled'" : "";
?>
<select id="gforms_currency" name="gforms_currency" <?php
echo $disabled;
?>
>
<?php
require_once "currency.php";
$current_currency = GFCommon::get_currency();
foreach (RGCurrency::get_currencies() as $code => $currency) {
?>
<option value="<?php
echo $code;
?>
" <?php
echo $current_currency == $code ? "selected='selected'" : "";
?>
><?php
echo $currency["name"];
?>
</option>
<?php
}
?>
</select>
<?php
do_action("gform_currency_setting_message", "");
?>
</td>
</tr>
</table>
<div class="hr-divider"></div>
<h3><?php
_e("reCAPTCHA Settings", "gravityforms");
?>
</h3>
<p style="text-align: left;"><?php
_e("Gravity Forms integrates with reCAPTCHA, a free CAPTCHA service that helps to digitize books while protecting your forms from spam bots. ", "gravityforms");
?>
示例8: get_number_formats_script
/**
* Generates a map of fields IDs and their corresponding number formats used by the GFCalc JS object for correctly
* converting field values to clean numbers.
*
* - Number fields have a 'numberFormat' setting (w/ UI).
* - Single-input product fields (i.e. 'singleproduct', 'calculation', 'price' and 'hiddenproduct') should default to
* the number format of the configured currency.
* - All other product fields will default to 'decimal_dot' for the number format.
* - All other fields will have no format (false) and inherit the format of the formula field when the formula is
* calculated.
*
* @param mixed $form
* @return string
*/
public static function get_number_formats_script($form)
{
require_once GFCommon::get_base_path() . '/currency.php';
$number_formats = array();
$currency = RGCurrency::get_currency(GFCommon::get_currency());
foreach ($form['fields'] as $field) {
// default format is false, fields with no format will inherit the format of the formula field when calculated
$format = false;
switch (GFFormsModel::get_input_type($field)) {
case 'number':
$format = $field->numberFormat ? $field->numberFormat : 'decimal_dot';
break;
case 'singleproduct':
case 'calculation':
case 'price':
case 'hiddenproduct':
case 'singleshipping':
$format = $currency['decimal_separator'] == ',' ? 'decimal_comma' : 'decimal_dot';
break;
default:
// we check above for all single-input product types, for all other products, assume decimal format
if (in_array($field->type, array('product', 'option', 'shipping'))) {
$format = 'decimal_dot';
}
}
$number_formats[$field->id] = $format;
}
return 'gf_global["number_formats"][' . $form['id'] . '] = ' . json_encode($number_formats) . ';';
}
示例9: prepare_value
/**
* Prepare the value before saving it to the lead.
*
* @param mixed $form
* @param mixed $field
* @param mixed $value
* @param mixed $input_name
* @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations)
* @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function
*/
public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array())
{
$form_id = $form["id"];
$input_type = self::get_input_type($field);
switch ($input_type) {
case "total":
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = GFCommon::get_order_total($form, $lead);
break;
case "calculation":
// ignore submitted value and recalculate price in backend
list(, , $input_id) = rgexplode("_", $input_name, 3);
if ($input_id == 2) {
require_once GFCommon::get_base_path() . '/currency.php';
$currency = new RGCurrency(GFCommon::get_currency());
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = $currency->to_money(GFCommon::calculate($field, $form, $lead));
}
break;
case "phone":
if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
$value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
}
break;
case "time":
if (!is_array($value) && !empty($value)) {
preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
$value = array();
$value[0] = $matches[1];
$value[1] = $matches[2];
$value[2] = rgar($matches, 3);
}
$hour = empty($value[0]) ? "0" : strip_tags($value[0]);
$minute = empty($value[1]) ? "0" : strip_tags($value[1]);
$ampm = strip_tags(rgar($value, 2));
if (!empty($ampm)) {
$ampm = " {$ampm}";
}
if (!(empty($hour) && empty($minute))) {
$value = sprintf("%02d:%02d%s", $hour, $minute, $ampm);
} else {
$value = "";
}
break;
case "date":
$value = self::prepare_date($field["dateFormat"], $value);
break;
case "post_image":
$url = self::get_fileupload_value($form_id, $input_name);
$image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : "";
$image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : "";
$image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : "";
$value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
break;
case "fileupload":
$value = self::get_fileupload_value($form_id, $input_name);
break;
case "number":
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = GFCommon::has_field_calculation($field) ? GFCommon::round_number(GFCommon::calculate($field, $form, $lead), rgar($field, "calculationRounding")) : GFCommon::clean_number($value, rgar($field, "numberFormat"));
//return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false
if (GFCommon::has_field_calculation($field) && $value == 0) {
$value = "0";
}
break;
case "website":
if ($value == "http://") {
$value = "";
}
break;
case "list":
if (GFCommon::is_empty_array($value)) {
$value = "";
} else {
$value = self::create_list_array($field, $value);
$value = serialize($value);
}
break;
case "radio":
if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') {
$value = rgpost("input_{$field['id']}_other");
}
break;
case "multiselect":
$value = empty($value) ? "" : implode(",", $value);
break;
case "creditcard":
//saving last 4 digits of credit card
list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3);
if ($input_id == "1") {
//.........这里部分代码省略.........
示例10: is_currency_decimal_dot
/**
* Add backwards compatibility to users running Gravity Forms 1.8.3 or below
* which don't have this function built in.
* Once support is dropped for Gravity Forms 1.8.x this function can be removed.
* Added in v3.7.1
* @param Array $currency A currency type
* @return String Whether currency should be displayed as 'decimal_dot' or 'decimal_comma'
*/
public static function is_currency_decimal_dot($currency = null)
{
if ($currency == null) {
$code = GFCommon::get_currency();
if (empty($code)) {
$code = "USD";
}
$currency = RGCurrency::get_currency($code);
}
return rgar($currency, "decimal_separator") == ".";
}
示例11: register_scripts
/**
* Register scripts and init the gperk object
*
*/
public static function register_scripts()
{
wp_register_style('gwp-admin', self::get_base_url() . '/styles/admin.css');
wp_register_script('gwp-common', self::get_base_url() . '/scripts/common.js', array('jquery'), GravityPerks::$version);
wp_register_script('gwp-admin', self::get_base_url() . '/scripts/admin.js', array('jquery', 'gwp-common'), GravityPerks::$version);
wp_register_script('gwp-frontend', self::get_base_url() . '/scripts/frontend.js', array('jquery', 'gwp-common'), GravityPerks::$version);
wp_register_script('gwp-repeater', self::get_base_url() . '/scripts/repeater.js', array('jquery'), GravityPerks::$version);
// register our scripts with Gravity Forms so they are not blocked when noconflict mode is enabled
add_filter('gform_noconflict_scripts', create_function('$scripts', 'return array_merge($scripts, array("gwp-admin", "gwp-frontend", "gwp-common"));'));
add_filter('gform_noconflict_styles', create_function('$styles', 'return array_merge($styles, array("gwp-admin"));'));
require_once GFCommon::get_base_path() . '/currency.php';
wp_localize_script('gwp-common', 'gperk', array('baseUrl' => self::get_base_url(), 'gformBaseUrl' => GFCommon::get_base_url(), 'currency' => RGCurrency::get_currency(GFCommon::get_currency())));
add_action('admin_enqueue_scripts', array('GWPerks', 'enqueue_scripts'));
}
示例12: display
function display()
{
$disabled = apply_filters('gform_currency_disabled', false) ? "disabled='disabled'" : '';
?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<label for="gforms_currency"><?php
esc_html_e('Currency', 'gravityforms');
?>
</label> <?php
gform_tooltip('settings_currency');
?>
</th>
<td>
<?php
$disabled = apply_filters('gform_currency_disabled', false) ? "disabled='disabled'" : '';
?>
<select id="gforms_currency" name="currency" <?php
echo $disabled;
?>
>
<option value=""><?php
esc_html_e('Select a Currency', 'gravityforms');
?>
</option>
<?php
require_once GFCommon::get_base_path() . '/currency.php';
$current_currency = $this->currency;
foreach (RGCurrency::get_currencies() as $code => $currency) {
?>
<option value="<?php
echo esc_attr($code);
?>
" <?php
echo $current_currency == $code ? "selected='selected'" : '';
?>
><?php
echo esc_html($currency['name']);
?>
</option>
<?php
}
?>
</select>
<?php
do_action('gform_currency_setting_message', '');
?>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="gform_enable_noconflict"><?php
esc_html_e('No-Conflict Mode', 'gravityforms');
?>
</label> <?php
gform_tooltip('settings_noconflict');
?>
</th>
<td>
<input type="radio" name="enable_noconflict" value="1" <?php
echo $this->enable_noconflict == 1 ? "checked='checked'" : '';
?>
id="gform_enable_noconflict" /> <?php
esc_html_e('On', 'gravityforms');
?>
<input type="radio" name="enable_noconflict" value="0" <?php
echo $this->enable_noconflict == 1 ? '' : "checked='checked'";
?>
id="gform_disable_noconflict" /> <?php
esc_html_e('Off', 'gravityforms');
?>
<br />
<span class="gf_settings_description"><?php
esc_html_e('Set this to ON to prevent extraneous scripts and styles from being printed on Gravity Forms admin pages, reducing conflicts with other plugins and themes.', 'gravityforms');
?>
</span>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="gform_enable_toolbar_menu"><?php
esc_html_e('Toolbar Menu', 'gravityforms');
?>
</label> <?php
gform_tooltip('settings_toolbar_menu');
?>
</th>
<td>
<input type="radio" name="enable_toolbar_menu" value="1" <?php
checked($this->enable_toolbar_menu, true);
?>
id="gform_enable_toolbar_menu" /> <?php
esc_html_e('On', 'gravityforms');
?>
<input type="radio" name="enable_toolbar_menu" value="0" <?php
checked($this->enable_toolbar_menu, false);
//.........这里部分代码省略.........
示例13: prepare_value
/**
* Prepare the value before saving it to the lead.
*
* @param mixed $form
* @param mixed $field
* @param mixed $value
* @param mixed $input_name
* @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations)
* @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function
*/
public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array())
{
$form_id = $form["id"];
$input_type = self::get_input_type($field);
switch ($input_type) {
case "total":
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = GFCommon::get_order_total($form, $lead);
break;
case "calculation":
// ignore submitted value and recalculate price in backend
list(, , $input_id) = rgexplode("_", $input_name, 3);
if ($input_id == 2) {
require_once GFCommon::get_base_path() . '/currency.php';
$currency = new RGCurrency(GFCommon::get_currency());
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = $currency->to_money(GFCommon::calculate($field, $form, $lead));
}
break;
case "phone":
if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
$value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
}
break;
case "time":
if (!is_array($value) && !empty($value)) {
preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
$value = array();
$value[0] = $matches[1];
$value[1] = $matches[2];
$value[2] = rgar($matches, 3);
}
$hour = empty($value[0]) ? "0" : strip_tags($value[0]);
$minute = empty($value[1]) ? "0" : strip_tags($value[1]);
$ampm = strip_tags(rgar($value, 2));
if (!empty($ampm)) {
$ampm = " {$ampm}";
}
if (!(empty($hour) && empty($minute))) {
$value = sprintf("%02d:%02d%s", $hour, $minute, $ampm);
} else {
$value = "";
}
break;
case "date":
$value = self::prepare_date(rgar($field, 'dateFormat'), $value);
break;
case "post_image":
$url = self::get_fileupload_value($form_id, $input_name);
$image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : "";
$image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : "";
$image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : "";
$value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
break;
case "fileupload":
if (rgar($field, "multipleFiles")) {
global $_gf_uploaded_files;
if (isset($_gf_uploaded_files[$input_name])) {
$value = $_gf_uploaded_files[$input_name];
} else {
if (isset(GFFormsModel::$uploaded_files[$form_id][$input_name])) {
$uploaded_temp_files = GFFormsModel::$uploaded_files[$form_id][$input_name];
$uploaded_files = array();
foreach ($uploaded_temp_files as $i => $file_info) {
$temp_filepath = self::get_upload_path($form_id) . '/tmp/' . $file_info['temp_filename'];
if ($file_info && file_exists($temp_filepath)) {
$uploaded_files[$i] = self::move_temp_file($form_id, $file_info);
}
}
if (!empty($value)) {
// merge with existing files (admin edit entry)
$value = json_decode($value, true);
$value = array_merge($value, $uploaded_files);
$value = json_encode($value);
} else {
$value = json_encode($uploaded_files);
}
} else {
$value = '';
}
$_gf_uploaded_files[$input_name] = $value;
}
} else {
$value = self::get_fileupload_value($form_id, $input_name);
}
break;
case "number":
$value = GFCommon::maybe_add_leading_zero($value);
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
//.........这里部分代码省略.........
示例14: settings_coupon_amount_type
/**
* Renders the couponAmountType setting.
*
* @param array $field The setting properties.
* @param bool|true $echo
*
* @return string
*/
public function settings_coupon_amount_type($field, $echo = true)
{
require_once GFCommon::get_base_path() . '/currency.php';
$currency = RGCurrency::get_currency(GFCommon::get_currency());
$currency_symbol = !empty($currency['symbol_left']) ? $currency['symbol_left'] : $currency['symbol_right'];
wp_enqueue_script(array('jquery-ui-datepicker'));
$styles = '<style type="text/css">
td img.ui-datepicker-trigger {
position: relative;
top: 4px;
}
</style>';
$js_script = '<script type="text/javascript">
var currency_config = ' . json_encode(RGCurrency::get_currency(GFCommon::get_currency())) . ';
var form = Array();
jQuery(document).on(\'change\', \'.gf_format_money\', function(){
var cur = new Currency(currency_config)
jQuery(this).val(cur.toMoney(jQuery(this).val()));
});
jQuery(document).on(\'change\', \'.gf_format_percentage\', function(event){
var cur = new Currency(currency_config)
var value = cur.toNumber(jQuery(this).val()) ? cur.toNumber(jQuery(this).val()) + \'%\' : \'\';
jQuery(this).val( value );
});
function SetCouponType(elem) {
var type = elem.val();
var formatClass = type == \'flat\' ? \'gf_format_money\' : \'gf_format_percentage\';
jQuery(\'#couponAmount\').removeClass(\'gf_format_money gf_format_percentage\').addClass(formatClass).trigger(\'change\');
var placeholderText = type == \'flat\' ? \'' . html_entity_decode(GFCommon::to_money(1)) . '\' : \'1%\';
jQuery(\'#couponAmount\').attr("placeholder",placeholderText);
}
jQuery(document).ready(function($){
//set placeholder text for initial load
var type = jQuery(\'#couponAmountType\').val();
var placeholderText = type == \'flat\' ? \'' . html_entity_decode(GFCommon::to_money(1)) . '\' : \'1%\';
jQuery(\'#couponAmount\').attr("placeholder",placeholderText);
//format initial coupon amount value when there is one and it is currency
var currency_config = ' . json_encode(RGCurrency::get_currency(GFCommon::get_currency())) . ';
var cur = new Currency(currency_config);
couponAmount = jQuery(\'#couponAmount\').val();
if ( couponAmount ){
if (type == \'flat\'){
couponAmount = cur.toMoney(couponAmount);
}
else{
couponAmount = cur.toNumber(couponAmount) + \'%\';
}
jQuery(\'#couponAmount\').val(couponAmount);
}
jQuery(\'.datepicker\').each(
function (){
var image = "' . $this->get_base_url() . '/images/calendar.png";
jQuery(this).datepicker({showOn: "both", buttonImage: image, buttonImageOnly: true, dateFormat: "mm/dd/yy" });
}
);
});
</script>';
$field['type'] = 'select';
$field['choices'] = array(array('label' => esc_html__('Flat', 'gravityformscoupons') . '(' . $currency_symbol . ')', 'name' => 'flat', 'value' => 'flat'), array('label' => esc_html__('Percentage(%)', 'gravityformscoupons'), 'name' => 'percentage', 'value' => 'percentage'));
$field['onchange'] = 'SetCouponType(jQuery(this))';
$html = $this->settings_select($field, false);
$field2 = array();
$field2['type'] = 'text';
$field2['name'] = 'couponAmount';
$field2['required'] = true;
$field2['class'] = $this->get_setting('couponAmountType') == 'percentage' ? 'gf_format_percentage' : 'gf_format_money';
$html2 = $this->settings_text($field2, false);
if ($echo) {
echo $styles . $js_script . $html . $html2;
}
return $styles . $js_script . $html . $html2;
}
示例15: gf_vars
public static function gf_vars($echo = true)
{
if (!class_exists("RGCurrency")) {
require_once "currency.php";
}
$gf_vars = array();
$gf_vars["active"] = __("Active", "gravityforms");
$gf_vars["inactive"] = __("Inactive", "gravityforms");
$gf_vars["save"] = __("Save", "gravityforms");
$gf_vars["update"] = __("Update", "gravityforms");
$gf_vars["previousLabel"] = __("Previous", "gravityforms");
$gf_vars["selectFormat"] = __("Select a format", "gravityforms");
$gf_vars["editToViewAll"] = __("5 of %d items shown. Edit field to view all", "gravityforms");
$gf_vars["enterValue"] = __("Enter a value", "gravityforms");
$gf_vars["formTitle"] = __("Untitled Form", "gravityforms");
$gf_vars["formDescription"] = __("We would love to hear from you! Please fill out this form and we will get in touch with you shortly.", "gravityforms");
$gf_vars["formConfirmationMessage"] = __("Thanks for contacting us! We will get in touch with you shortly.", "gravityforms");
$gf_vars["buttonText"] = __("Submit", "gravityforms");
$gf_vars["loading"] = __("Loading...", "gravityforms");
$gf_vars["thisFieldIf"] = __('this field if', 'gravityforms');
$gf_vars["thisPage"] = __("this page", "gravityforms");
$gf_vars["thisFormButton"] = __('this form button', 'gravityforms');
$gf_vars["show"] = __('Show', 'gravityforms');
$gf_vars["hide"] = __('Hide', 'gravityforms');
$gf_vars["all"] = __('All', 'gravityforms');
$gf_vars["any"] = __('Any', 'gravityforms');
$gf_vars["ofTheFollowingMatch"] = __('of the following match:', 'gravityforms');
$gf_vars["is"] = __('is', 'gravityforms');
$gf_vars["isNot"] = __('is not', 'gravityforms');
$gf_vars["greaterThan"] = __('greater than', 'gravityforms');
$gf_vars["lessThan"] = __('less than', 'gravityforms');
$gf_vars["contains"] = __('contains', 'gravityforms');
$gf_vars["startsWith"] = __('starts with', 'gravityforms');
$gf_vars["endsWith"] = __('ends with', 'gravityforms');
$gf_vars["thisConfirmation"] = __('Use this confirmation if', 'gravityforms');
$gf_vars["thisNotification"] = __('Send this notification if', 'gravityforms');
$gf_vars["confirmationSave"] = __('Save', 'gravityforms');
$gf_vars["confirmationSaving"] = __('Saving...', 'gravityforms');
$gf_vars["confirmationAreYouSure"] = __('Are you sure you wish to cancel these changes?', 'gravityforms');
$gf_vars["confirmationIssueSaving"] = __('There was an issue saving this confirmation.', 'gravityforms');
$gf_vars["confirmationConfirmDelete"] = __('Are you sure you wish to delete this confirmation?', 'gravityforms');
$gf_vars["confirmationIssueDeleting"] = __('There was an issue deleting this confirmation.', 'gravityforms');
$gf_vars["confirmationConfirmDiscard"] = __('There are unsaved changes to the current confirmation. Would you like to discard these changes?', 'gravityforms');
$gf_vars["confirmationDefaultName"] = __('Untitled Confirmation', 'gravityforms');
$gf_vars["confirmationDefaultMessage"] = __('Thanks for contacting us! We will get in touch with you shortly.', 'gravityforms');
$gf_vars["confirmationInvalidPageSelection"] = __('Please select a page.', "gravityforms");
$gf_vars["confirmationInvalidRedirect"] = __('Please enter a URL.', "gravityforms");
$gf_vars["confirmationInvalidName"] = __('Please enter a confirmation name.', "gravityforms");
$gf_vars["conditionalLogicDependency"] = __('This form contains conditional logic dependent upon this field. Are you sure you want to delete this field? \'OK\' to delete, \'Cancel\' to abort.', 'gravityforms');
$gf_vars["conditionalLogicDependencyChoice"] = __('This form contains conditional logic dependent upon this choice. Are you sure you want to delete this choice? \'OK\' to delete, \'Cancel\' to abort.', 'gravityforms');
$gf_vars["conditionalLogicDependencyChoiceEdit"] = __('This form contains conditional logic dependent upon this choice. Are you sure you want to modify this choice? \'OK\' to delete, \'Cancel\' to abort.', 'gravityforms');
$gf_vars["mergeTagsTooltip"] = __('<h6>Merge Tags</h6>Merge tags allow you to dynamically populate submitted field values in your form content wherever this merge tag icon is present.', 'gravityforms');
$gf_vars["baseUrl"] = GFCommon::get_base_url();
$gf_vars["gf_currency_config"] = RGCurrency::get_currency(GFCommon::get_currency());
$gf_vars["otherChoiceValue"] = GFCommon::get_other_choice_value();
$gf_vars["isFormDelete"] = false;
if (is_admin() && rgget('id')) {
$form = RGFormsModel::get_form_meta(rgget('id'));
$gf_vars["mergeTags"] = GFCommon::get_merge_tags($form['fields'], '', false);
}
$gf_vars_json = 'var gf_vars = ' . json_encode($gf_vars) . ';';
if (!$echo) {
return $gf_vars_json;
} else {
echo $gf_vars_json;
}
}