本文整理汇总了PHP中RGFormsModel::get_current_page_url方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_current_page_url方法的具体用法?PHP RGFormsModel::get_current_page_url怎么用?PHP RGFormsModel::get_current_page_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::get_current_page_url方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_credit_card_init_script
public static function get_credit_card_init_script($form)
{
$script = "";
foreach ($form["fields"] as $field) {
if ($field['type'] != 'creditcard') {
continue;
}
$field_id = "input_{$form["id"]}_{$field["id"]}";
$field_script = "jQuery(document).ready(function(){ { gformMatchCard(\"{$field_id}_1\"); } } );";
if (rgar($field, "forceSSL") && !GFCommon::is_ssl() && !GFCommon::is_preview()) {
$field_script = "document.location.href='" . esc_js(RGFormsModel::get_current_page_url(true)) . "';";
}
$script .= $field_script;
}
$card_rules = self::get_credit_card_rules();
$script = "if(!window['gf_cc_rules']){window['gf_cc_rules'] = new Array(); } window['gf_cc_rules'] = " . GFCommon::json_encode($card_rules) . "; {$script}";
return $script;
}
示例2: is_preview
public static function is_preview()
{
$url_info = parse_url(RGFormsModel::get_current_page_url());
$file_name = basename($url_info["path"]);
return $file_name == "preview.php" || rgget("gf_page", $_GET) == "preview";
}
示例3: get_form_inline_script_on_page_render
public function get_form_inline_script_on_page_render($form)
{
$field_id = "input_{$form['id']}_{$this->id}";
if ($this->forceSSL && !GFCommon::is_ssl() && !GFCommon::is_preview()) {
$script = "document.location.href='" . esc_js(RGFormsModel::get_current_page_url(true)) . "';";
} else {
$script = "jQuery(document).ready(function(){ { gformMatchCard(\"{$field_id}_1\"); } } );";
}
$card_rules = $this->get_credit_card_rules();
$script = "if(!window['gf_cc_rules']){window['gf_cc_rules'] = new Array(); } window['gf_cc_rules'] = " . GFCommon::json_encode($card_rules) . "; {$script}";
return $script;
}
示例4: replace_variables_prepopulate
public static function replace_variables_prepopulate($text, $url_encode = false)
{
//embed url
$text = str_replace("{embed_url}", $url_encode ? urlencode(RGFormsModel::get_current_page_url()) : RGFormsModel::get_current_page_url(), $text);
$local_timestamp = self::get_local_timestamp(time());
//date (mm/dd/yyyy)
$local_date_mdy = date_i18n("m/d/Y", $local_timestamp, true);
$text = str_replace("{date_mdy}", $url_encode ? urlencode($local_date_mdy) : $local_date_mdy, $text);
//date (dd/mm/yyyy)
$local_date_dmy = date_i18n("d/m/Y", $local_timestamp, true);
$text = str_replace("{date_dmy}", $url_encode ? urlencode($local_date_dmy) : $local_date_dmy, $text);
//ip
$text = str_replace("{ip}", $url_encode ? urlencode($_SERVER['REMOTE_ADDR']) : $_SERVER['REMOTE_ADDR'], $text);
global $post;
$post_array = self::object_to_array($post);
preg_match_all("/\\{embed_post:(.*?)\\}/", $text, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$full_tag = $match[0];
$property = $match[1];
$text = str_replace($full_tag, $url_encode ? urlencode($post_array[$property]) : $post_array[$property], $text);
}
//embed post custom fields
preg_match_all("/\\{custom_field:(.*?)\\}/", $text, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
//embed post info
$post_array = self::get_embed_post();
$full_tag = $match[0];
$custom_field_name = $match[1];
$custom_field_value = !empty($post_array["ID"]) ? get_post_meta($post_array["ID"], $custom_field_name, true) : "";
$text = str_replace($full_tag, $url_encode ? urlencode($custom_field_value) : $custom_field_value, $text);
}
//user agent
$text = str_replace("{user_agent}", $url_encode ? urlencode(RGForms::get("HTTP_USER_AGENT", $_SERVER)) : RGForms::get("HTTP_USER_AGENT", $_SERVER), $text);
//referrer
$text = str_replace("{referer}", $url_encode ? urlencode(RGForms::get("HTTP_REFERER", $_SERVER)) : RGForms::get("HTTP_REFERER", $_SERVER), $text);
//logged in user info
global $userdata;
$user_array = self::object_to_array($userdata);
preg_match_all("/\\{user:(.*?)\\}/", $text, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$full_tag = $match[0];
$property = $match[1];
$text = str_replace($full_tag, $url_encode ? urlencode($user_array[$property]) : $user_array[$property], $text);
}
return $text;
}
示例5: 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;
}
示例6: duplicate_entry_data
/**
* Duplicates the contents of a specified entry id into the specified form
* Adapted from forms_model.php, RGFormsModel::save_lead($Form, $lead) and
* gravity -forms-addons.php for the gravity forms addon plugin
* @param array $form Form object.
* @param array $lead Lead object
* @return void
*/
function duplicate_entry_data($form_change, $current_entry_id)
{
global $wpdb;
$lead_table = GFFormsModel::get_lead_table_name();
$lead_detail_table = GFFormsModel::get_lead_details_table_name();
$lead_meta_table = GFFormsModel::get_lead_meta_table_name();
//pull existing entries information
$current_lead = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$lead_table} WHERE id=%d", $current_entry_id));
$current_fields = $wpdb->get_results($wpdb->prepare("SELECT wp_rg_lead_detail.field_number, wp_rg_lead_detail.value, wp_rg_lead_detail_long.value as long_detail FROM {$lead_detail_table} left outer join wp_rg_lead_detail_long on wp_rg_lead_detail_long.lead_detail_id = wp_rg_lead_detail.id WHERE lead_id=%d", $current_entry_id));
// new lead
$user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
$user_agent = GFCommon::truncate_url($_SERVER["HTTP_USER_AGENT"], 250);
$currency = GFCommon::get_currency();
$source_url = GFCommon::truncate_url(RGFormsModel::get_current_page_url(), 200);
$wpdb->query($wpdb->prepare("INSERT INTO {$lead_table}(form_id, ip, source_url, date_created, user_agent, currency, created_by) VALUES(%d, %s, %s, utc_timestamp(), %s, %s, {$user_id})", $form_change, RGFormsModel::get_ip(), $source_url, $user_agent, $currency));
$lead_id = $wpdb->insert_id;
echo 'Entry ' . $lead_id . ' created in Form ' . $form_change;
//add a note to the new entry
$results = mf_add_note($lead_id, 'Copied Entry ID:' . $current_entry_id . ' into form ' . $form_change . '. New Entry ID =' . $lead_id);
foreach ($current_fields as $row) {
$fieldValue = $row->field_number != 303 ? $row->value : 'Proposed';
$wpdb->query($wpdb->prepare("INSERT INTO {$lead_detail_table}(lead_id, form_id, field_number, value) VALUES(%d, %s, %s, %s)", $lead_id, $form_change, $row->field_number, $fieldValue));
//if detail long is set, add row for new record
if ($row->long_detail != 'NULL') {
$lead_detail_id = $wpdb->insert_id;
$wpdb->query($wpdb->prepare("INSERT INTO wp_rg_lead_detail_long(lead_detail_id, value) VALUES(%d, %s)", $lead_detail_id, $row->long_detail));
}
}
}
示例7: get_form
public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false)
{
//reading form metadata
$form = RGFormsModel::get_form_meta($form_id, true);
$form = RGFormsModel::add_default_properties($form);
//disable ajax if form has a reCAPTCHA field (not supported).
if ($ajax && self::has_recaptcha_field($form)) {
$ajax = false;
}
$is_postback = false;
$is_valid = true;
$confirmation_message = "";
$page_number = 1;
//If form was submitted, read variables set during form submission procedure
$submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
if ($submission_info) {
$is_postback = true;
$is_valid = $submission_info["is_valid"] || rgget("is_confirmation", $submission_info);
$form = $submission_info["form"];
$lead = $submission_info["lead"];
$confirmation_message = rgget("confirmation_message", $submission_info);
if ($is_valid && !RGForms::get("is_confirmation", $submission_info)) {
if ($submission_info["page_number"] == 0) {
//post submission hook
do_action("gform_post_submission", $lead, $form);
do_action("gform_post_submission_{$form["id"]}", $lead, $form);
} else {
//change page hook
do_action("gform_post_paging", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
do_action("gform_post_paging_{$form["id"]}", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
}
}
} else {
if (!current_user_can("administrator")) {
RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
}
}
if ($form["enableHoneypot"]) {
$form["fields"][] = self::get_honeypot_field($form);
}
//Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
$form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form));
if ($form == null) {
return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
}
$has_pages = self::has_pages($form);
//calling tab index filter
GFCommon::$tab_index = apply_filters("gform_tabindex_{$form_id}", apply_filters("gform_tabindex", 1, $form), $form);
//Don't display inactive forms
if (!$force_display && !$is_postback) {
$form_info = RGFormsModel::get_form($form_id);
if (!$form_info->is_active) {
return "";
}
//If form has a schedule, make sure it is within the configured start and end dates
if ($form["scheduleForm"]) {
$local_time_start = sprintf("%s %02d:%02d %s", $form["scheduleStart"], $form["scheduleStartHour"], $form["scheduleStartMinute"], $form["scheduleStartAmpm"]);
$local_time_end = sprintf("%s %02d:%02d %s", $form["scheduleEnd"], $form["scheduleEndHour"], $form["scheduleEndMinute"], $form["scheduleEndAmpm"]);
$timestamp_start = strtotime($local_time_start . ' +0000');
$timestamp_end = strtotime($local_time_end . ' +0000');
$now = current_time("timestamp");
if (!empty($form["scheduleStart"]) && $now < $timestamp_start || !empty($form["scheduleEnd"]) && $now > $timestamp_end) {
return empty($form["scheduleMessage"]) ? "<p>" . __("Sorry. This form is no longer available.", "gravityforms") . "</p>" : "<p>" . do_shortcode($form["scheduleMessage"]) . "</p>";
}
}
//If form has a limit of entries, check current entry count
if ($form["limitEntries"]) {
$entry_count = RGFormsModel::get_lead_count($form_id, "");
if ($entry_count >= $form["limitEntriesCount"]) {
return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . do_shortcode($form["limitEntriesMessage"]) . "</p>";
}
}
}
$form_string = "";
//When called via a template, this will enqueue the proper scripts
//When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
self::enqueue_form_scripts($form, $ajax);
if (empty($confirmation_message)) {
//Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
$style = self::has_conditional_logic($form) ? "style='display:none'" : "";
$form_string .= "\n <div class='gform_wrapper' id='gform_wrapper_{$form_id}' " . $style . ">";
$action = RGFormsModel::get_current_page_url();
$default_anchor = $has_pages ? 1 : 0;
if (apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor))) {
$form_string .= "<a name='gf_{$form_id}' class='gform_anchor' ></a>";
$action .= "#gf_{$form_id}";
}
$target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : "";
$form_string .= apply_filters("gform_form_tag_{$form_id}", apply_filters("gform_form_tag", "<form method='post' enctype='multipart/form-data' {$target} id='gform_{$form_id}' class='" . $form["cssClass"] . "' action='{$action}'>", $form), $form);
if ($display_title || $display_description) {
$form_string .= "\n <div class='gform_heading'>";
if ($display_title) {
$form_string .= "\n <h3 class='gform_title'>" . $form['title'] . "</h3>";
}
if ($display_description) {
$form_string .= "\n <span class='gform_description'>" . $form['description'] . "</span>";
}
$form_string .= "\n </div>";
}
if ($has_pages && !IS_ADMIN) {
//.........这里部分代码省略.........
示例8: save_lead
/**
* Adapted from forms_model.php, RGFormsModel::save_lead($Form, $lead)
* @param array $form Form object.
* @param array $lead Lead object
* @return void
*/
public static function save_lead($form, &$lead)
{
global $wpdb;
if (IS_ADMIN && !GFCommon::current_user_can_any("gravityforms_edit_entries")) {
die(__("You don't have adequate permission to edit entries.", "gravityforms"));
}
$lead_detail_table = RGFormsModel::get_lead_details_table_name();
//Inserting lead if null
if ($lead == null) {
global $current_user;
$user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
$lead_table = RGFormsModel::get_lead_table_name();
$user_agent = RGFormsModel::truncate($_SERVER["HTTP_USER_AGENT"], 250);
$currency = GFCommon::get_currency();
$source_url = RGFormsModel::truncate(RGFormsModel::get_current_page_url(), 200);
$wpdb->query($wpdb->prepare("INSERT INTO {$lead_table}(form_id, ip, source_url, date_created, user_agent, currency, created_by) VALUES(%d, %s, %s, utc_timestamp(), %s, %s, {$user_id})", $form["id"], RGFormsModel::get_ip(), $source_url, $user_agent, $currency));
//reading newly created lead id
$lead_id = $wpdb->insert_id;
$lead = array("id" => $lead_id);
}
$current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead["id"]));
$original_post_id = rgget("post_id", $lead);
$total_fields = array();
$calculation_fields = array();
$recalculate_total = false;
foreach ($form["fields"] as $field) {
//Ignore fields that are marked as display only
if (rgget("displayOnly", $field) && $field["type"] != "password") {
continue;
}
//ignore pricing fields in the entry detail
if (RG_CURRENT_VIEW == "entry" && GFCommon::is_pricing_field($field["type"])) {
continue;
}
//process total field after all fields have been saved
if ($field["type"] == "total") {
$total_fields[] = $field;
continue;
}
//only save fields that are not hidden (except on entry screen)
if (RG_CURRENT_VIEW == "entry" || !RGFormsModel::is_field_hidden($form, $field, array(), $lead)) {
// process calculation fields after all fields have been saved (moved after the is hidden check)
if (GFCommon::has_field_calculation($field)) {
$calculation_fields[] = $field;
continue;
}
if ($field['type'] == 'post_category') {
$field = GFCommon::add_categories_as_choices($field, '');
}
if (isset($field["inputs"]) && is_array($field["inputs"])) {
foreach ($field["inputs"] as $input) {
RGFormsModel::save_input($form, $field, $lead, $current_fields, $input["id"]);
}
} else {
RGFormsModel::save_input($form, $field, $lead, $current_fields, $field["id"]);
}
}
//Refresh lead to support conditionals (not optimal but...)
$lead = RGFormsModel::get_lead($lead['id']);
}
if (!empty($calculation_fields)) {
foreach ($calculation_fields as $calculation_field) {
if (isset($calculation_field["inputs"]) && is_array($calculation_field["inputs"])) {
foreach ($calculation_field["inputs"] as $input) {
RGFormsModel::save_input($form, $calculation_field, $lead, $current_fields, $input["id"]);
RGFormsModel::refresh_lead_field_value($lead["id"], $input["id"]);
}
} else {
RGFormsModel::save_input($form, $calculation_field, $lead, $current_fields, $calculation_field["id"]);
RGFormsModel::refresh_lead_field_value($lead["id"], $calculation_field["id"]);
}
}
RGFormsModel::refresh_product_cache($form, $lead = RGFormsModel::get_lead($lead['id']));
}
//saving total field as the last field of the form.
if (!empty($total_fields)) {
foreach ($total_fields as $total_field) {
GFCommon::log_debug("Saving total field.");
RGFormsModel::save_input($form, $total_field, $lead, $current_fields, $total_field["id"]);
}
}
}
示例9: start_express_checkout
public static function start_express_checkout($confirmation, $form, $entry, $ajax)
{
$config = self::get_config($form);
if (!$config) {
return $confirmation;
}
$product_billing_data = self::get_product_billing_data($form, $entry, $config);
$amount = $product_billing_data["amount"];
$products = $product_billing_data["products"];
$billing = $product_billing_data["billing"];
//TODO: add to settings
$allow_note = "0";
//rgar($gateway_settings, "allownote") ? "1": "0";
//1- send to paypal and get response
$fields = "METHOD=SetExpressCheckout&";
if ($config["meta"]["type"] != "product") {
$fields .= "L_BILLINGTYPE0=RecurringPayments&" . "PAYMENTREQUEST_0_AMT={$amount}&" . "L_BILLINGAGREEMENTDESCRIPTION0=" . urlencode(self::get_recurring_description($config, $product_billing_data)) . "&";
} else {
$fields .= "PAYMENTREQUEST_0_AMT={$amount}&" . "PAYMENTREQUEST_0_CURRENCYCODE=" . GFCommon::get_currency() . "&" . "REQCONFIRMSHIPPING=0&" . "ALLOWNOTE={$allow_note}&" . "NOSHIPPING=1&";
for ($i = 0; $i < $product_billing_data["line_items"]; $i++) {
$fields .= "L_PAYMENTREQUEST_0_NAME{$i}=" . urlencode($billing["L_NAME{$i}"]) . "&" . "L_PAYMENTREQUEST_0_AMT{$i}=" . $billing["L_AMT{$i}"] . "&" . "L_PAYMENTREQUEST_0_QTY{$i}=" . $billing["L_QTY{$i}"] . "&";
}
}
$cancel_url = rgempty("cancel_url", $config) ? RGFormsModel::get_current_page_url() : rgar($config, "cancel_url");
$fields .= "CANCELURL=" . urlencode($cancel_url) . "&" . "RETURNURL=" . urlencode(RGFormsModel::get_current_page_url()) . "&" . "PAGESTYLE=" . urlencode(rgar($config, "page_style")) . "&" . "LOCALECODE=" . urlencode(rgar($config, "locale")) . "&" . "EMAIL=" . urlencode(rgar($data, "user_email"));
$response = array();
$success = self::send_request($config, $fields, $response, $form, $entry);
if (!$success) {
//GCCommon::log_error("paypalpro", "Error on SetExpressCheckout call \n\nFields:\n {$fields} \n\nResponse:\n " . print_r($response, true));
return __("There was an error while contacting PayPal. Your payment could not be processed. Please try again later", "gravityformspaypalpro");
} else {
//Getting Url (Production or Sandbox)
$url = rgar($config, "mode") == "production" ? self::$production_express_checkout_url : self::$sandbox_express_checkout_url;
$url .= "?cmd=_express-checkout&token={$response["TOKEN"]}";
gform_update_meta($entry["id"], "paypalpro_express_checkout_token", $response["TOKEN"]);
//Redirecting to paypal
return array("redirect" => $url);
}
}