本文整理汇总了PHP中GFCommon::get_currency方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::get_currency方法的具体用法?PHP GFCommon::get_currency怎么用?PHP GFCommon::get_currency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::get_currency方法的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: preview_special_merge_tags
/**
* Adds special support for file upload, post image and multi input merge tags.
*/
public static function preview_special_merge_tags($value, $input_id, $merge_tag, $field)
{
// added to prevent overriding :noadmin filter (and other filters that remove fields)
if (!$value) {
return $value;
}
$input_type = RGFormsModel::get_input_type($field);
$is_upload_field = in_array($input_type, array('post_image', 'fileupload'));
$is_multi_input = is_array(rgar($field, 'inputs'));
$is_input = intval($input_id) != $input_id;
if (!$is_upload_field && !$is_multi_input) {
return $value;
}
// if is individual input of multi-input field, return just that input value
if ($is_input) {
return $value;
}
$form = RGFormsModel::get_form_meta($field['formId']);
$lead = self::create_lead($form);
$currency = GFCommon::get_currency();
if (is_array(rgar($field, 'inputs'))) {
$value = RGFormsModel::get_lead_field_value($lead, $field);
return GFCommon::get_lead_field_display($field, $value, $currency);
}
switch ($input_type) {
case 'fileupload':
$value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead);
$value = self::preview_image_display($field, $form, $value);
break;
default:
$value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead);
$value = GFCommon::get_lead_field_display($field, $value, $currency);
break;
}
return $value;
}
示例5: process_capture
protected function process_capture($authorization, $feed, $submission_data, $form, $entry)
{
$payment = rgar($authorization, "captured_payment");
if (empty($payment)) {
return;
}
if ($payment["is_success"]) {
$entry["transaction_id"] = $payment["transaction_id"];
$entry["transaction_type"] = "1";
$entry["is_fulfilled"] = true;
$entry["currency"] = GFCommon::get_currency();
$entry["payment_amount"] = $payment["amount"];
$entry["payment_status"] = "Paid";
$entry["payment_date"] = gmdate("Y-m-d H:i:s");
$entry["payment_method"] = $payment["payment_method"];
$this->insert_transaction($entry["id"], "payment", $entry["transaction_id"], $entry["payment_amount"]);
GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Payment has been captured successfully. Amount: %s. Transaction Id: %s", "gravityforms"), GFCommon::to_money($payment["amount"], $entry["currency"]), $payment["transaction_id"]));
} else {
$entry["payment_status"] = "Failed";
GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Payment failed to be captured. Reason: %s", "gravityforms"), $payment["error_message"]));
}
GFAPI::update_entry($entry);
return $entry;
}
示例6: add_entry
/**
* Adds a single Entry object.
*
* Intended to be used for importing an entry object. The usual hooks that are triggered while saving entries are not fired here.
* Checks that the form id, field ids and entry meta exist and ignores legacy values (i.e. values for fields that no longer exist).
*
* @since 1.8
* @access public
* @static
*
* @param array $entry The Entry object
*
* @return mixed Either the new Entry ID or a WP_Error instance
*/
public static function add_entry($entry)
{
global $wpdb;
if (!is_array($entry)) {
return new WP_Error("invalid_entry_object", __("The entry object must be an array", "gravityforms"));
}
// make sure the form id exists
$form_id = rgar($entry, "form_id");
if (empty($form_id)) {
return new WP_Error("empty_form_id", __("The form id must be specified", "gravityforms"));
}
if (false === self::form_id_exists($form_id)) {
return new WP_Error("invalid_form_id", __("The form for this entry does not exist", "gravityforms"));
}
// use values in the entry object if present
$post_id = isset($entry["post_id"]) ? intval($entry["post_id"]) : 'NULL';
$date_created = isset($entry["date_created"]) && $entry["date_created"] != "" ? sprintf("'%s'", mysql_real_escape_string($entry["date_created"])) : "utc_timestamp()";
$is_starred = isset($entry["is_starred"]) ? $entry["is_starred"] : 0;
$is_read = isset($entry["is_read"]) ? $entry["is_read"] : 0;
$ip = isset($entry["ip"]) ? $entry["ip"] : GFFormsModel::get_ip();
$source_url = isset($entry["source_url"]) ? $entry["source_url"] : GFFormsModel::get_current_page_url();
$user_agent = isset($entry["user_agent"]) ? $entry["user_agent"] : "API";
$currency = isset($entry["currency"]) ? $entry["currency"] : GFCommon::get_currency();
$payment_status = isset($entry["payment_status"]) ? sprintf("'%s'", mysql_real_escape_string($entry["payment_status"])) : 'NULL';
$payment_date = strtotime(rgar($entry, "payment_date")) ? sprintf("'%s'", gmdate('Y-m-d H:i:s', strtotime("{$entry["payment_date"]}"))) : "NULL";
$payment_amount = isset($entry["payment_amount"]) ? (double) $entry["payment_amount"] : 'NULL';
$payment_method = isset($entry["payment_method"]) ? $entry["payment_method"] : '';
$transaction_id = isset($entry["transaction_id"]) ? sprintf("'%s'", mysql_real_escape_string($entry["transaction_id"])) : 'NULL';
$is_fulfilled = isset($entry["is_fulfilled"]) ? intval($entry["is_fulfilled"]) : 'NULL';
$status = isset($entry["status"]) ? $entry["status"] : "active";
global $current_user;
$user_id = isset($entry["created_by"]) ? mysql_real_escape_string($entry["created_by"]) : "";
if (empty($user_id)) {
$user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
}
$transaction_type = isset($entry["transaction_type"]) ? intval($entry["transaction_type"]) : 'NULL';
$lead_table = GFFormsModel::get_lead_table_name();
$result = $wpdb->query($wpdb->prepare("\n INSERT INTO {$lead_table}\n (form_id, post_id, date_created, is_starred, is_read, ip, source_url, user_agent, currency, payment_status, payment_date, payment_amount, transaction_id, is_fulfilled, created_by, transaction_type, status, payment_method)\n VALUES\n (%d, {$post_id}, {$date_created}, %d, %d, %s, %s, %s, %s, {$payment_status}, {$payment_date}, {$payment_amount}, {$transaction_id}, {$is_fulfilled}, {$user_id}, {$transaction_type}, %s, %s)\n ", $form_id, $is_starred, $is_read, $ip, $source_url, $user_agent, $currency, $status, $payment_method));
if (false === $result) {
return new WP_Error("insert_entry_properties_failed", __("There was a problem while inserting the entry properties", "gravityforms"), $wpdb->last_error);
}
// reading newly created lead id
$entry_id = $wpdb->insert_id;
$entry["id"] = $entry_id;
// only save field values for fields that currently exist in the form
$form = GFFormsModel::get_form_meta($form_id);
foreach ($form["fields"] as $field) {
if (in_array($field["type"], array("html", "page", "section"))) {
continue;
}
if (isset($field["inputs"]) && is_array($field["inputs"])) {
foreach ($field["inputs"] as $input) {
$input_id = $input["id"];
if (isset($entry[(string) $input_id])) {
$result = GFFormsModel::update_lead_field_value($form, $entry, $field, 0, $input_id, $entry[(string) $input_id]);
if (false === $result) {
return new WP_Error("insert_input_value_failed", __("There was a problem while inserting one of the input values for the entry", "gravityforms"), $wpdb->last_error);
}
}
}
} else {
$field_id = $field["id"];
$field_value = isset($entry[(string) $field_id]) ? $entry[(string) $field_id] : "";
$result = GFFormsModel::update_lead_field_value($form, $entry, $field, 0, $field_id, $field_value);
if (false === $result) {
return new WP_Error("insert_field_values_failed", __("There was a problem while inserting the field values", "gravityforms"), $wpdb->last_error);
}
}
}
// add save the entry meta values - only for the entry meta currently available for the form, ignore the rest
$entry_meta = GFFormsModel::get_entry_meta($form_id);
if (is_array($entry_meta)) {
foreach (array_keys($entry_meta) as $key) {
if (isset($entry[$key])) {
gform_update_meta($entry_id, $key, $entry[$key]);
}
}
}
return $entry_id;
}
示例7: RGFormsModel
/**
*
* @global type $wpdb
*/
function entries_import()
{
$wform = $_REQUEST['form'];
$gform = $_REQUEST['gform'];
$entry_index = $_REQUEST['entry_index'];
$this->init();
$field_map = maybe_unserialize(get_site_option('rt_wufoo_' . $wform . '_field_map'));
$f = new RGFormsModel();
$c = new GFCommon();
$gform_meta = RGFormsModel::get_form_meta($gform);
try {
$entries = $this->wufoo->getEntries($wform, 'forms', 'pageStart=' . $entry_index . '&pageSize=' . RT_WUFOO_IMPORT_PAGE_SIZE);
} catch (Exception $rt_importer_e) {
$this->error($rt_importer_e);
}
$this->op = array();
foreach ($entries as $index => $entry) {
$lead_exists_id = $this->is_imported($entry->EntryId);
print_r($lead_exists_id);
if (!$lead_exists_id) {
foreach ($field_map as $g_id => $w_id) {
if (isset($w_id) && $w_id != '') {
$this->op[$g_id] = '';
$field_meta = RGFormsModel::get_field($gform_meta, $g_id);
if ($field_meta['type'] == 'fileupload') {
$this->op[$g_id] = $this->import_file_upload($entry, $w_id);
} else {
$this->import_regular_field($wform, $entry, $g_id, $w_id, $field_meta);
}
}
}
$currency = $c->get_currency();
$ip = $f->get_ip();
$page = $f->get_current_page_url();
$lead_table = $f->get_lead_table_name();
$lead_id = $this->insert_lead($entry, $lead_table, $ip, $currency, $page, $wform, $gform);
}
if ($lead_id) {
foreach ($this->op as $inputid => $value) {
$this->insert_fields($lead_id, $gform, $inputid, $value);
}
//Insert comments as notes for the corresponding user map
$comments = $this->get_comments_by_entry($wform, $entry->EntryId);
if (isset($comments) && !empty($comments)) {
foreach ($comments as $comment) {
$this->move_comments_for_entry($comment, $f->get_lead_notes_table_name(), $lead_id, $wform);
}
}
} else {
$lead_id = $lead_exists_id;
}
gform_update_meta($lead_id, 'rt_wufoo_entry_id', $entry->EntryId);
}
//update_site_option('rt_wufoo_' . $wform . '_entry_complete_count','0');
echo count($entries) + $entry_index;
die;
}
示例8: stats_page
//.........这里部分代码省略.........
function showTooltip(x, y, contents) {
jQuery('<div id="authorizenet_graph_tooltip">' + contents + '<div class="tooltip_tip"></div></div>').css( {
position: 'absolute',
display: 'none',
opacity: 0.90,
width:'150px',
height:'<?php
echo $config["meta"]["type"] == "subscription" ? "75px" : "60px";
?>
',
top: y - <?php
echo $config["meta"]["type"] == "subscription" ? "100" : "89";
?>
,
left: x - 79
}).appendTo("body").fadeIn(200);
}
function convertToMoney(number){
var currency = getCurrentCurrency();
return currency.toMoney(number);
}
function formatWeeks(number){
number = number + "";
return "<?php
_e("Week ", "gravityformsauthorizenet");
?>
" + number.substring(number.length-2);
}
function getCurrentCurrency(){
<?php
if (!class_exists("RGCurrency")) {
require_once ABSPATH . "/" . PLUGINDIR . "/gravityforms/currency.php";
}
$current_currency = RGCurrency::get_currency(GFCommon::get_currency());
?>
var currency = new Currency(<?php
echo GFCommon::json_encode($current_currency);
?>
);
return currency;
}
</script>
<?php
}
$payment_totals = RGFormsModel::get_form_payment_totals($config["form_id"]);
$transaction_totals = GFAuthorizeNetData::get_transaction_totals($config["form_id"]);
switch ($config["meta"]["type"]) {
case "product":
$total_sales = $payment_totals["orders"];
$sales_label = __("Total Orders", "gravityformsauthorizenet");
break;
case "donation":
$total_sales = $payment_totals["orders"];
$sales_label = __("Total Donations", "gravityformsauthorizenet");
break;
case "subscription":
$total_sales = $payment_totals["active"];
$sales_label = __("Active Subscriptions", "gravityformsauthorizenet");
break;
}
$total_revenue = empty($transaction_totals["payment"]["revenue"]) ? 0 : $transaction_totals["payment"]["revenue"];
?>
<div class="authorizenet_summary_container">
<div class="authorizenet_summary_item">
<div class="authorizenet_summary_title"><?php
_e("Total Revenue", "gravityformsauthorizenet");
示例9: complete_payment
public function complete_payment($entry, $action)
{
if (!rgar($action, 'payment_status')) {
$action['payment_status'] = 'Paid';
}
if (!rgar($action, 'transaction_type')) {
$action['transaction_type'] = 'payment';
}
if (!rgar($action, 'payment_date')) {
$action['payment_date'] = gmdate('y-m-d H:i:s');
}
//set is_fulfilled in process_capture by gateways that are not url redirects
//url redirects should not have this set yet, happens in post_callback for them
$entry['is_fulfilled'] = "1";
$entry['transaction_id'] = rgar($action, 'transaction_id');
$entry['transaction_type'] = "1";
$entry['payment_status'] = $action['payment_status'];
$entry['payment_amount'] = rgar($action, 'amount');
$entry['payment_date'] = $action['payment_date'];
$entry['payment_method'] = rgar($action, 'payment_method');
$entry['currency'] = GFCommon::get_currency();
if (!rgar($action, 'note')) {
$amount_formatted = GFCommon::to_money($action['amount'], $entry['currency']);
$action['note'] = sprintf(__('Payment has been completed. Amount: %s. Transaction Id: %s.', 'gravityforms'), $amount_formatted, $action['transaction_id']);
}
GFAPI::update_entry($entry);
$this->insert_transaction($entry['id'], $action['transaction_type'], $action['transaction_id'], $action['amount']);
$this->add_note($entry['id'], $action['note'], "success");
do_action("gform_post_payment_completed", $entry, $action);
return true;
}
示例10: 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") {
//.........这里部分代码省略.........
示例11: gf_vars
public static function gf_vars($echo = true)
{
if (!class_exists('RGCurrency')) {
require_once 'currency.php';
}
$gf_vars = array();
$gf_vars['active'] = esc_attr__('Active', 'gravityforms');
$gf_vars['inactive'] = esc_attr__('Inactive', 'gravityforms');
$gf_vars['save'] = esc_html__('Save', 'gravityforms');
$gf_vars['update'] = esc_html__('Update', 'gravityforms');
$gf_vars['previousLabel'] = esc_html__('Previous', 'gravityforms');
$gf_vars['selectFormat'] = esc_html__('Select a format', 'gravityforms');
$gf_vars['editToViewAll'] = esc_html__('5 of %d items shown. Edit field to view all', 'gravityforms');
$gf_vars['enterValue'] = esc_html__('Enter a value', 'gravityforms');
$gf_vars['formTitle'] = esc_html__('Untitled Form', 'gravityforms');
$gf_vars['formDescription'] = esc_html__('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'] = esc_html__('Thanks for contacting us! We will get in touch with you shortly.', 'gravityforms');
$gf_vars['buttonText'] = esc_html__('Submit', 'gravityforms');
$gf_vars['loading'] = esc_html__('Loading...', 'gravityforms');
$gf_vars['thisFieldIf'] = esc_html__('this field if', 'gravityforms');
$gf_vars['thisPage'] = esc_html__('this page', 'gravityforms');
$gf_vars['thisFormButton'] = esc_html__('this form button if', 'gravityforms');
$gf_vars['show'] = esc_html__('Show', 'gravityforms');
$gf_vars['hide'] = esc_html__('Hide', 'gravityforms');
$gf_vars['all'] = esc_html(_x('All', 'Conditional Logic', 'gravityforms'));
$gf_vars['any'] = esc_html(_x('Any', 'Conditional Logic', 'gravityforms'));
$gf_vars['ofTheFollowingMatch'] = esc_html('of the following match:', 'gravityforms');
$gf_vars['is'] = esc_html('is', 'gravityforms');
$gf_vars['isNot'] = esc_html('is not', 'gravityforms');
$gf_vars['greaterThan'] = esc_html('greater than', 'gravityforms');
$gf_vars['lessThan'] = esc_html('less than', 'gravityforms');
$gf_vars['contains'] = esc_html('contains', 'gravityforms');
$gf_vars['startsWith'] = esc_html('starts with', 'gravityforms');
$gf_vars['endsWith'] = esc_html('ends with', 'gravityforms');
$gf_vars['thisConfirmation'] = esc_html('Use this confirmation if', 'gravityforms');
$gf_vars['thisNotification'] = esc_html('Send this notification if', 'gravityforms');
$gf_vars['confirmationSave'] = esc_html('Save', 'gravityforms');
$gf_vars['confirmationSaving'] = esc_html('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>' . esc_html__('Merge Tags', 'gravityforms') . '</h6>' . esc_html__('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['isFormTrash'] = false;
$gf_vars['currentlyAddingField'] = false;
$gf_vars['addFieldFilter'] = esc_html__('Add a condition', 'gravityforms');
$gf_vars['removeFieldFilter'] = esc_html__('Remove a condition', 'gravityforms');
$gf_vars['filterAndAny'] = esc_html__('Include results if {0} match:', 'gravityforms');
$gf_vars['customChoices'] = esc_html__('Custom Choices', 'gravityforms');
$gf_vars['predefinedChoices'] = esc_html__('Predefined Choices', 'gravityforms');
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;
}
}
示例12: complete_payment
public function complete_payment(&$entry, $action)
{
$this->log_debug(__METHOD__ . '(): Processing request.');
if (!rgar($action, 'payment_status')) {
$action['payment_status'] = 'Paid';
}
if (!rgar($action, 'transaction_type')) {
$action['transaction_type'] = 'payment';
}
if (!rgar($action, 'payment_date')) {
$action['payment_date'] = gmdate('y-m-d H:i:s');
}
$entry['is_fulfilled'] = '1';
$entry['transaction_id'] = rgar($action, 'transaction_id');
$entry['transaction_type'] = '1';
$entry['payment_status'] = $action['payment_status'];
$entry['payment_amount'] = rgar($action, 'amount');
$entry['payment_date'] = $action['payment_date'];
$entry['payment_method'] = rgar($action, 'payment_method');
$entry['currency'] = GFCommon::get_currency();
if (!rgar($action, 'note')) {
$amount_formatted = GFCommon::to_money($action['amount'], $entry['currency']);
$action['note'] = sprintf(__('Payment has been completed. Amount: %s. Transaction Id: %s.', 'gravityforms'), $amount_formatted, $action['transaction_id']);
}
GFAPI::update_entry($entry);
$this->insert_transaction($entry['id'], $action['transaction_type'], $action['transaction_id'], $action['amount']);
$this->add_note($entry['id'], $action['note'], 'success');
do_action('gform_post_payment_completed', $entry, $action);
if (has_filter('gform_post_payment_completed')) {
$this->log_debug(__METHOD__ . '(): Executing functions hooked to gform_post_payment_completed.');
}
return true;
}
示例13: send_to_paypal
public static function send_to_paypal($confirmation, $form, $entry, $ajax)
{
// ignore requests that are not the current form's submissions
if (RGForms::post("gform_submit") != $form["id"]) {
return $confirmation;
}
$config = self::get_active_config($form);
if (!$config) {
self::log_debug("NOT sending to PayPal: No PayPal setup was located for form_id = {$form['id']}.");
return $confirmation;
}
// updating entry meta with current feed id
gform_update_meta($entry["id"], "paypal_feed_id", $config["id"]);
// updating entry meta with current payment gateway
gform_update_meta($entry["id"], "payment_gateway", "paypal");
//updating lead's payment_status to Processing
RGFormsModel::update_lead_property($entry["id"], "payment_status", 'Processing');
//Getting Url (Production or Sandbox)
$url = $config["meta"]["mode"] == "production" ? self::$production_url : self::$sandbox_url;
$invoice_id = apply_filters("gform_paypal_invoice", "", $form, $entry);
$invoice = empty($invoice_id) ? "" : "&invoice={$invoice_id}";
//Current Currency
$currency = GFCommon::get_currency();
//Customer fields
$customer_fields = self::customer_query_string($config, $entry);
//Page style
$page_style = !empty($config["meta"]["style"]) ? "&page_style=" . urlencode($config["meta"]["style"]) : "";
//Continue link text
$continue_text = !empty($config["meta"]["continue_text"]) ? "&cbt=" . urlencode($config["meta"]["continue_text"]) : "&cbt=" . __("Click here to continue", "gravityformspaypal");
//If page is HTTPS, set return mode to 2 (meaning PayPal will post info back to page)
//If page is not HTTPS, set return mode to 1 (meaning PayPal will redirect back to page) to avoid security warning
$return_mode = GFCommon::is_ssl() ? "2" : "1";
$return_url = "&return=" . urlencode(self::return_url($form["id"], $entry["id"])) . "&rm={$return_mode}";
//Cancel URL
$cancel_url = !empty($config["meta"]["cancel_url"]) ? "&cancel_return=" . urlencode($config["meta"]["cancel_url"]) : "";
//Don't display note section
$disable_note = !empty($config["meta"]["disable_note"]) ? "&no_note=1" : "";
//Don't display shipping section
$disable_shipping = !empty($config["meta"]["disable_shipping"]) ? "&no_shipping=1" : "";
//URL that will listen to notifications from PayPal
$ipn_url = urlencode(get_bloginfo("url") . "/?page=gf_paypal_ipn");
$business_email = urlencode(trim($config["meta"]["email"]));
$custom_field = $entry["id"] . "|" . wp_hash($entry["id"]);
$url .= "?notify_url={$ipn_url}&charset=UTF-8¤cy_code={$currency}&business={$business_email}&custom={$custom_field}{$invoice}{$customer_fields}{$page_style}{$continue_text}{$cancel_url}{$disable_note}{$disable_shipping}{$return_url}";
$query_string = "";
switch ($config["meta"]["type"]) {
case "product":
$query_string = self::get_product_query_string($form, $entry);
break;
case "donation":
$query_string = self::get_donation_query_string($form, $entry);
break;
case "subscription":
$query_string = self::get_subscription_query_string($config, $form, $entry);
break;
}
$query_string = apply_filters("gform_paypal_query_{$form['id']}", apply_filters("gform_paypal_query", $query_string, $form, $entry), $form, $entry);
if (!$query_string) {
self::log_debug("NOT sending to PayPal: The price is either zero or the gform_paypal_query filter was used to remove the querystring that is sent to PayPal.");
return $confirmation;
}
$url .= $query_string;
$url = apply_filters("gform_paypal_request_{$form['id']}", apply_filters("gform_paypal_request", $url, $form, $entry), $form, $entry);
self::log_debug("Sending to PayPal: {$url}");
if (headers_sent() || $ajax) {
$confirmation = "<script>function gformRedirect(){document.location.href='{$url}';}";
if (!$ajax) {
$confirmation .= "gformRedirect();";
}
$confirmation .= "</script>";
} else {
$confirmation = array("redirect" => $url);
}
return $confirmation;
}
示例14: subscribe
/**
* Subscribe the user to a Stripe plan. This process works like so:
*
* 1 - Get existing plan or create new plan (plan ID generated by feed name, id and recurring amount).
* 2 - Create new customer.
* 3 - Create new subscription by subscribing custerom to plan.
*
* @param [type] $auth [description]
* @param [type] $feed [description]
* @param [type] $submission_data [description]
* @param [type] $form [description]
* @param [type] $entry [description]
*
* @return [type] [description]
*/
public function subscribe($feed, $submission_data, $form, $entry)
{
$this->populate_credit_card_last_four($form);
$this->include_stripe_api();
if ($this->get_stripe_js_error()) {
return $this->authorization_error($this->get_stripe_js_error());
}
$payment_amount = $submission_data['payment_amount'];
$single_payment_amount = $submission_data['setup_fee'];
$trial_period_days = rgars($feed, 'meta/trialPeriod') ? rgars($feed, 'meta/trialPeriod') : null;
$plan_id = $this->get_subscription_plan_id($feed, $payment_amount);
$plan = $this->get_plan($plan_id);
if (rgar($plan, 'error_message')) {
return $plan;
}
try {
if (!$plan) {
$plan = Stripe_Plan::create(array('interval' => $feed['meta']['billingCycle_unit'], 'interval_count' => $feed['meta']['billingCycle_length'], 'name' => $feed['meta']['feedName'], 'currency' => GFCommon::get_currency(), 'id' => $plan_id, 'amount' => $payment_amount * 100, 'trial_period_days' => $trial_period_days));
}
$stripe_response = $this->get_stripe_js_response();
$email = $this->get_mapped_field_value('customerInformation_email', $form, $entry, $feed['meta']);
$description = $this->get_mapped_field_value('customerInformation_description', $form, $entry, $feed['meta']);
$customer = Stripe_Customer::create(array('description' => $description, 'email' => $email, 'card' => $stripe_response->id, 'account_balance' => $single_payment_amount * 100));
$subscription = $customer->updateSubscription(array('plan' => $plan->id));
} catch (Stripe_Error $e) {
return $this->authorization_error($e->getMessage());
}
return array('is_success' => true, 'subscription_id' => $subscription->id, 'customer_id' => $customer->id, 'amount' => $payment_amount);
}
示例15: 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;
}
}