本文整理汇总了PHP中GFCommon::format_number方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::format_number方法的具体用法?PHP GFCommon::format_number怎么用?PHP GFCommon::format_number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::format_number方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: try_convert_float
private static function try_convert_float($text)
{
global $wp_locale;
$number_format = $wp_locale->number_format['decimal_point'] == ',' ? 'decimal_comma' : 'decimal_dot';
if (is_numeric($text) && $number_format == 'decimal_comma') {
return GFCommon::format_number($text, 'decimal_comma');
} else {
if (GFCommon::is_numeric($text, $number_format)) {
return GFCommon::clean_number($text, $number_format);
}
}
return $text;
}
示例2: get_lead_field_display
//.........这里部分代码省略.........
return $value;
break;
case "date":
return GFCommon::date_display($value, rgar($field, "dateFormat"));
break;
case "radio":
case "select":
return GFCommon::selection_display($value, $field, $currency, $use_text);
break;
case "multiselect":
if (empty($value) || $format == "text") {
return $value;
}
$value = explode(",", $value);
$items = '';
foreach ($value as $item) {
$items .= "<li>" . GFCommon::selection_display($item, $field, $currency, $use_text) . "</li>";
}
return "<ul class='bulleted'>{$items}</ul>";
break;
case "calculation":
case "singleproduct":
if (is_array($value)) {
$product_name = trim($value[$field["id"] . ".1"]);
$price = trim($value[$field["id"] . ".2"]);
$quantity = trim($value[$field["id"] . ".3"]);
$product = $product_name . ", " . __("Qty: ", "gravityforms") . $quantity . ", " . __("Price: ", "gravityforms") . $price;
return $product;
} else {
return "";
}
break;
case "number":
return GFCommon::format_number($value, rgar($field, "numberFormat"));
break;
case "singleshipping":
case "donation":
case "total":
case "price":
return GFCommon::to_money($value, $currency);
case "list":
if (empty($value)) {
return "";
}
$value = unserialize($value);
$has_columns = is_array($value[0]);
if (!$has_columns) {
$items = '';
foreach ($value as $key => $item) {
if (!empty($item)) {
switch ($format) {
case "text":
$items .= $item . ", ";
break;
case "url":
$items .= $item . ",";
break;
default:
if ($media == "email") {
$items .= "<li>{$item}</li>";
} else {
$items .= "<li>{$item}</li>";
}
break;
}
}
示例3: leads_page
//.........这里部分代码省略.........
}
}
$file_path = $value;
if (!empty($file_path)) {
//displaying thumbnail (if file is an image) or an icon based on the extension
$thumb = self::get_icon_url($file_path);
$file_path = esc_attr($file_path);
$value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
}
break;
case "source_url":
$value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) . "' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
break;
case "textarea":
case "post_content":
case "post_excerpt":
$value = esc_html($value);
break;
case "date_created":
case "payment_date":
$value = GFCommon::format_date($value, false);
break;
case "date":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::date_display($value, rgar($field, "dateFormat"));
break;
case "radio":
case "select":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::selection_display($value, $field, $lead["currency"]);
break;
case "number":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::format_number($value, rgar($field, "numberFormat"));
break;
case "total":
case "payment_amount":
$value = GFCommon::to_money($value, $lead["currency"]);
break;
case "created_by":
if (!empty($value)) {
$userdata = get_userdata($value);
if (!empty($userdata)) {
$value = $userdata->user_login;
}
}
break;
case "multiselect":
// add space after comma-delimited values
$value = implode(', ', explode(',', $value));
break;
default:
$value = esc_html($value);
}
$value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
/* ^ maybe move to function */
$query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_qs}{$filter_qs}&paged=" . ($page_index + 1);
if ($is_first_column) {
?>
<td class="column-title" >
<a href="admin.php?page=gf_entries&view=entry&id=<?php
echo $form_id;
?>
&lid=<?php
echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
?>
示例4: get_value_merge_tag
public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format)
{
return GFCommon::format_number($value, $this->numberFormat);
}
示例5: get_value_merge_tag
public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br)
{
$include_thousands_sep = apply_filters('gform_include_thousands_sep_pre_format_number', $modifier != 'value', $this);
return GFCommon::format_number($value, $this->numberFormat, rgar($entry, 'currency'), $include_thousands_sep);
}
示例6: leads_page
//.........这里部分代码省略.........
break;
case "fileupload":
$file_path = $value;
if (!empty($file_path)) {
//displaying thumbnail (if file is an image) or an icon based on the extension
$thumb = self::get_icon_url($file_path);
$file_path = esc_attr($file_path);
$value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
}
break;
case "source_url":
$value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) . "' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
break;
case "textarea":
case "post_content":
case "post_excerpt":
$value = esc_html($value);
break;
case "date_created":
case "payment_date":
$value = GFCommon::format_date($value, false);
break;
case "date":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::date_display($value, $field["dateFormat"]);
break;
case "radio":
case "select":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::selection_display($value, $field, $lead["currency"]);
break;
case "number":
$field = RGFormsModel::get_field($form, $field_id);
$value = GFCommon::format_number($value, rgar($field, "numberFormat"));
break;
case "total":
case "payment_amount":
$value = GFCommon::to_money($value, $lead["currency"]);
break;
case "created_by":
if (!empty($value)) {
$userdata = get_userdata($value);
$value = $userdata->user_login;
}
break;
default:
$value = esc_html($value);
}
$value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
$query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_qs}&paged=" . ($page_index + 1);
if ($is_first_column) {
?>
<td class="column-title" >
<a href="admin.php?page=gf_entries&view=entry&id=<?php
echo $form_id;
?>
&lid=<?php
echo $lead["id"] . $search_qs . $sort_qs . $dir_qs;
?>
&paged=<?php
echo $page_index + 1;
?>
"><?php
echo $value;
?>
</a>
示例7: pdf_get_lead_field_display
//.........这里部分代码省略.........
case 'date':
return GFCommon::date_display($value, rgar($field, 'dateFormat'));
break;
case 'radio':
case 'select':
return GFCommon::selection_display($value, $field, $currency, true);
break;
case 'multiselect':
if (empty($value) || $format == 'text') {
return $value;
}
if (!is_array($value)) {
$value = explode(',', $value);
}
$items = '';
foreach ($value as $item) {
$items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
}
return '<ul class="bulleted">' . $items . '</ul>';
break;
case 'calculation':
case 'singleproduct':
if (is_array($value)) {
$product_name = trim($value[$field['id'] . '.1']);
$price = trim($value[$field['id'] . '.2']);
$quantity = trim($value[$field['id'] . '.3']);
$product = $product_name . ', ' . __('Qty: ', 'gravityforms') . $quantity . ', ' . __('Price: ', 'gravityforms') . $price;
return $product;
} else {
return '';
}
break;
case 'number':
return GFCommon::format_number($value, rgar($field, 'numberFormat'));
break;
case 'singleshipping':
case 'donation':
case 'total':
case 'price':
return GFCommon::to_money($value, $currency);
case 'list':
if (empty($value)) {
return '';
}
$value = unserialize($value);
$has_columns = is_array($value[0]);
if (!$has_columns) {
$items = '';
foreach ($value as $key => $item) {
if (!empty($item)) {
switch ($format) {
case 'text':
$items .= $item . ', ';
break;
case 'url':
$items .= $item . ',';
break;
default:
if ($media == 'email') {
$items .= '<li>' . htmlspecialchars($item) . '</li>';
} else {
$items .= '<li>' . htmlspecialchars($item) . '</li>';
}
break;
}
}
示例8: validate
//.........这里部分代码省略.........
}
}
}
}
}
break;
case "email":
if (!rgblank($value) && !GFCommon::is_valid_email($value)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid email address.", "gravityforms") : $field["errorMessage"];
} else {
if (rgget("emailConfirmEnabled", $field) && !empty($value)) {
$confirm = rgpost("input_" . $field["id"] . "_2");
if ($confirm != $value) {
$field["failed_validation"] = true;
$field["validation_message"] = __("Your emails do not match.", "gravityforms");
}
}
}
break;
case "donation":
case "price":
if (!class_exists("RGCurrency")) {
require_once "currency.php";
}
$donation = GFCommon::to_number($value);
if (!rgblank($value) && ($donation === false || $donation < 0)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid amount.", "gravityforms") : $field["errorMessage"];
}
break;
case "number":
if ($field["numberFormat"] == "decimal_comma") {
$value = GFCommon::format_number($value, $field["numberFormat"]);
}
$value = GFCommon::maybe_add_leading_zero($value);
if (!rgblank($value) && !self::validate_range($field, $value) && !GFCommon::has_field_calculation($field)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? GFCommon::get_range_message($field) : $field["errorMessage"];
} else {
if ($field["type"] == "quantity" && intval($value) != $value) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid quantity. Quantity cannot contain decimals.", "gravityforms") : $field["errorMessage"];
}
}
break;
case "phone":
$regex = '/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/';
if ($field["phoneFormat"] == "standard" && $value !== "" && $value !== 0 && !preg_match($regex, $value)) {
$field["failed_validation"] = true;
if (!empty($field["errorMessage"])) {
$field["validation_message"] = $field["errorMessage"];
}
}
break;
case "date":
if (is_array($value) && rgempty(0, $value) && rgempty(1, $value) && rgempty(2, $value)) {
$value = null;
}
if (!empty($value)) {
$format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
$date = GFCommon::parse_date($value, $format);
if (empty($date) || !self::checkdate($date["month"], $date["day"], $date["year"])) {
$field["failed_validation"] = true;
$format_name = "";
switch ($format) {
示例9: gsf_pre_submission_filter
function gsf_pre_submission_filter($form)
{
// Loop through form fields
foreach ($form['fields'] as &$field) {
// If a slider is found
if ('slider' == $field['type']) {
// Set default min/max values, if they do not exist for the field
$min = isset($field['rangeMin']) && '' != $field['rangeMin'] ? $field['rangeMin'] : 0;
$max = isset($field['rangeMax']) && '' != $field['rangeMax'] ? $field['rangeMax'] : 10;
// If min/max relations exist, append them to the field label
if ('' != $field['slider_min_value_relation'] || '' != $field['slider_max_value_relation']) {
$field['label'] = $field['label'] . ' (' . GFCommon::format_number($min, $field['numberFormat']) . ': ' . $field['slider_min_value_relation'] . ', ' . GFCommon::format_number($max, $field['numberFormat']) . ': ' . $field['slider_max_value_relation'] . ')';
}
}
}
return $form;
}
示例10: get_value_merge_tag
public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format)
{
$include_thousands_sep = $modifier == 'value' ? false : true;
return GFCommon::format_number($value, $this->numberFormat, rgar($entry, 'currency'), $include_thousands_sep);
}
示例11: try_convert_float
private static function try_convert_float($text){
global $wp_locale;
$number_format = $wp_locale->number_format['decimal_point'] == "," ? "decimal_comma" : "decimal_dot";
if(is_numeric($text) && $number_format == "decimal_comma"){
return GFCommon::format_number($text, "decimal_comma");
}
else if(GFCommon::is_numeric($text, $number_format)){
return GFCommon::clean_number($text, $number_format);
}
return $text;
}
示例12: gformReplaceMergeTags
/**
* replace custom merge tags
* @param string $text
* @param array $form
* @param array $lead
* @param bool $url_encode
* @param bool $esc_html
* @param bool $nl2br
* @param string $format
* @return string
*/
public function gformReplaceMergeTags($text, $form, $lead, $url_encode, $esc_html, $nl2br, $format)
{
if (self::isEwayForm($form['id'], $form['fields'])) {
if (is_null($this->txResult)) {
// lead loaded from database, get values from lead meta
$transaction_id = isset($lead['transaction_id']) ? $lead['transaction_id'] : '';
$payment_amount = isset($lead['payment_amount']) ? $lead['payment_amount'] : '';
$payment_status = isset($lead['payment_status']) ? $lead['payment_status'] : '';
$authcode = (string) gform_get_meta($lead['id'], 'authcode');
$beagle_score = (string) gform_get_meta($lead['id'], 'beagle_score');
} else {
// lead not yet saved, get values from transaction results
$transaction_id = isset($this->txResult['transaction_id']) ? $this->txResult['transaction_id'] : '';
$payment_amount = isset($this->txResult['payment_amount']) ? $this->txResult['payment_amount'] : '';
$payment_status = isset($this->txResult['payment_status']) ? $this->txResult['payment_status'] : '';
$authcode = isset($this->txResult['authcode']) ? $this->txResult['authcode'] : '';
$beagle_score = isset($this->txResult['beagle_score']) ? $this->txResult['beagle_score'] : '';
}
// format payment amount as currency
$payment_amount = GFCommon::format_number($payment_amount, 'currency');
$tags = array('{transaction_id}', '{payment_amount}', '{payment_status}', '{authcode}', '{beagle_score}');
$values = array($transaction_id, $payment_amount, $payment_status, $authcode, $beagle_score);
$text = str_replace($tags, $values, $text);
}
return $text;
}