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


PHP RGCurrency::to_money方法代码示例

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


在下文中一共展示了RGCurrency::to_money方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: to_money

 public static function to_money($number, $currency_code = "")
 {
     if (!class_exists("RGCurrency")) {
         require_once "currency.php";
     }
     if (empty($currency_code)) {
         $currency_code = self::get_currency();
     }
     $currency = new RGCurrency($currency_code);
     return $currency->to_money($number);
 }
开发者ID:ipman3,项目名称:Mediassociates-wp,代码行数:11,代码来源:common.php

示例5: 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;
//.........这里部分代码省略.........
开发者ID:BisongT,项目名称:Myevent_website,代码行数:101,代码来源:forms_model.php


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