本文整理汇总了PHP中RGCurrency类的典型用法代码示例。如果您正苦于以下问题:PHP RGCurrency类的具体用法?PHP RGCurrency怎么用?PHP RGCurrency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RGCurrency类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:BrownBox,项目名称:bb-click-array,代码行数:56,代码来源:gravity-form-field.php
示例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;
}
开发者ID:kidaak,项目名称:gravityforms,代码行数:12,代码来源:class-gf-field-calculation.php
示例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;
}
开发者ID:bself,项目名称:nuimage-wp,代码行数:19,代码来源:class-gf-field-slider.php
示例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'";
//.........这里部分代码省略.........
开发者ID:jordanmaslyn,项目名称:vvv-starter,代码行数:101,代码来源:settings.php
示例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;
}
}
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:101,代码来源:form_display.php
示例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');
}
}
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:17,代码来源:class-gf-field-number.php
示例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");
?>
开发者ID:nikibrown,项目名称:2014-Nerd-presentation,代码行数:67,代码来源:settings.php
示例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) . ';';
}
开发者ID:timk85,项目名称:DIT,代码行数:43,代码来源:form_display.php
示例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") {
//.........这里部分代码省略.........
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:101,代码来源:forms_model.php
示例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") == ".";
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:19,代码来源:pdf-common.php
示例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'));
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:18,代码来源:gravityperks.php
示例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);
//.........这里部分代码省略.........
开发者ID:Garth619,项目名称:Femi9,代码行数:101,代码来源:class-gf-installation-wizard-step-settings.php
示例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(
|
请发表评论