本文整理汇总了PHP中RGFormsModel::insert_form_view方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::insert_form_view方法的具体用法?PHP RGFormsModel::insert_form_view怎么用?PHP RGFormsModel::insert_form_view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::insert_form_view方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_form
public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
{
//looking up form id by form name
if (!is_numeric($form_id)) {
$form_id = RGFormsModel::get_form_id($form_id);
}
//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 = rgar($submission_info, "is_valid") || rgar($submission_info, "is_confirmation");
$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 (rgar($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, $ajax), $ajax);
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", $tabindex, $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 requires login, check if user is logged in
if (rgar($form, "requireLogin")) {
if (!is_user_logged_in()) {
return empty($form["requireLoginMessage"]) ? "<p>" . __("Sorry. You must be logged in to view this form.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["requireLoginMessage"]) . "</p>";
}
}
}
// show the form regardless of the following validations when force display is set to true
if (!$force_display) {
$form_schedule_validation = self::validate_form_schedule($form);
// if form schedule validation fails AND this is not a postback, display the validation error
// if form schedule validation fails AND this is a postback, make sure is not a valid submission (enables display of confirmation message)
if ($form_schedule_validation && !$is_postback || $form_schedule_validation && $is_postback && !$is_valid) {
return $form_schedule_validation;
}
$entry_limit_validation = self::validate_entry_limit($form);
// refer to form schedule condition notes above
if ($entry_limit_validation && !$is_postback || $entry_limit_validation && $is_postback && !$is_valid) {
return $entry_limit_validation;
}
}
$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)) {
$wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper";
if (!$is_valid) {
$wrapper_css_class .= " gform_validation_error";
}
//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'" : "";
$custom_wrapper_css_class = !empty($form["cssClass"]) ? " {$form["cssClass"]}_wrapper" : "";
$form_string .= "\n <div class='{$wrapper_css_class}{$custom_wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . ">";
$action = add_query_arg(array());
$default_anchor = $has_pages || $ajax ? true : false;
$use_anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor));
if ($use_anchor !== false) {
$form_string .= "<a id='gf_{$form_id}' name='gf_{$form_id}' class='gform_anchor' ></a>";
$action .= "#gf_{$form_id}";
}
$target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : "";
//.........这里部分代码省略.........
示例2: get_form
//.........这里部分代码省略.........
* A filter that allows disabling of the form view counter
*
* @param int $form_id The Form ID to filter when disabling the form view counter
* @param bool Default set to false (view counter enabled), can be set to true to disable the counter
*/
$view_counter_disabled = gf_apply_filters(array('gform_disable_view_counter', $form_id), false);
if ($submission_info) {
$is_postback = true;
$is_valid = rgar($submission_info, 'is_valid') || rgar($submission_info, 'is_confirmation');
$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) {
/**
* Fired after form submission
*
* @param array $lead The Entry object
* @param array $form The Form object
*/
gf_do_action(array('gform_post_submission', $form['id']), $lead, $form);
} else {
/**
* Fired after the page changes on a multi-page form
*
* @param array $form The Form object
* @param int $submission_info['source_page_number'] The page that was submitted
* @param int $submission_info['page_number'] The page that the user is being sent to
*/
gf_do_action(array('gform_post_paging', $form['id']), $form, $submission_info['source_page_number'], $submission_info['page_number']);
}
}
} elseif (!current_user_can('administrator') && !$view_counter_disabled) {
RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
}
}
if (rgar($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 = gf_apply_filters(array('gform_pre_render', $form_id), $form, $ajax, $field_values);
if ($form == null) {
return '<p>' . esc_html__('Oops! We could not locate your form.', 'gravityforms') . '</p>';
}
$has_pages = self::has_pages($form);
//calling tab index filter
GFCommon::$tab_index = gf_apply_filters(array('gform_tabindex', $form_id), $tabindex, $form);
//Don't display inactive forms
if (!$force_display && !$is_postback) {
$form_info = RGFormsModel::get_form($form_id);
if (empty($form_info) || !$form_info->is_active) {
return '';
}
// If form requires login, check if user is logged in
if (rgar($form, 'requireLogin')) {
if (!is_user_logged_in()) {
return empty($form['requireLoginMessage']) ? '<p>' . esc_html__('Sorry. You must be logged in to view this form.', 'gravityforms') . '</p>' : '<p>' . GFCommon::gform_do_shortcode($form['requireLoginMessage']) . '</p>';
}
}
}
// show the form regardless of the following validations when force display is set to true
if (!$force_display || $is_postback) {
$form_schedule_validation = self::validate_form_schedule($form);
// if form schedule validation fails AND this is not a postback, display the validation error
// if form schedule validation fails AND this is a postback, make sure is not a valid submission (enables display of confirmation message)
if ($form_schedule_validation && !$is_postback || $form_schedule_validation && $is_postback && !$is_valid) {
示例3: get_form
//.........这里部分代码省略.........
if (isset($_GET['gf_token'])) {
$incomplete_submission_info = GFFormsModel::get_incomplete_submission_values($_GET['gf_token']);
if ($incomplete_submission_info['form_id'] == $form_id) {
$submission_details_json = $incomplete_submission_info['submission'];
$submission_details = json_decode($submission_details_json, true);
$partial_entry = $submission_details['partial_entry'];
$submitted_values = $submission_details['submitted_values'];
$field_values = $submission_details['field_values'];
GFFormsModel::$unique_ids[$form_id] = $submission_details['gform_unique_id'];
GFFormsModel::$uploaded_files[$form_id] = $submission_details['files'];
self::set_submission_if_null($form_id, 'resuming_incomplete_submission', true);
self::set_submission_if_null($form_id, 'form_id', $form_id);
self::set_submission_if_null($form_id, 'page_number', $submission_details['page_number']);
}
}
if (!is_array($partial_entry)) {
$view_counter_disabled = gf_apply_filters('gform_disable_view_counter', $form_id, false);
if ($submission_info) {
$is_postback = true;
$is_valid = rgar($submission_info, 'is_valid') || rgar($submission_info, 'is_confirmation');
$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
gf_do_action('gform_post_submission', $form['id'], $lead, $form);
} else {
//change page hook
gf_do_action('gform_post_paging', $form['id'], $form, $submission_info['source_page_number'], $submission_info['page_number']);
}
}
} elseif (!current_user_can('administrator') && !$view_counter_disabled) {
RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
}
}
if (rgar($form, 'enableHoneypot')) {
$form['fields'][] = self::get_honeypot_field($form);
}
// print test
// echo " submition id " . $form['id'] . '<br>';
//Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
//check this part
$form = gf_apply_filters('gform_pre_render', $form_id, $form, $ajax, $field_values);
// echo "<pre>";
//
// print_r($form);
//
// echo "<pre>";
if ($form == null) {
return '<p>' . esc_html__('Oops! We could not locate your form.', 'gravityforms') . '</p>';
}
$has_pages = self::has_pages($form);
//calling tab index filter
GFCommon::$tab_index = gf_apply_filters('gform_tabindex', $form_id, $tabindex, $form);
//Don't display inactive forms
if (!$force_display && !$is_postback) {
//check here..
$form_info = RGFormsModel::get_form($form_id);
if (empty($form_info) || !$form_info->is_active) {
return '';
}
// If form requires login, check if user is logged in
if (rgar($form, 'requireLogin')) {
if (!is_user_logged_in()) {
return empty($form['requireLoginMessage']) ? '<p>' . esc_html__('Sorry. You must be logged in to view this form.', 'gravityforms') . '</p>' : '<p>' . GFCommon::gform_do_shortcode($form['requireLoginMessage']) . '</p>';
示例4: get_form
public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
{
//looking up form id by form name
if (!is_numeric($form_id)) {
$form_id = RGFormsModel::get_form_id($form_id);
}
//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 (rgar($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", $tabindex, $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 (rgar($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>" . GFCommon::gform_do_shortcode($form["scheduleMessage"]) . "</p>";
}
}
//If form has a limit of entries, check current entry count
if (rgar($form, "limitEntries")) {
$period = rgar($form, "limitEntriesPeriod");
$range = self::get_limit_period_dates($period);
$entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $range["start_date"], $range["end_date"]);
if ($entry_count >= $form["limitEntriesCount"]) {
return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["limitEntriesMessage"]) . "</p>";
}
}
// If form requires login, check if user is logged in
if (rgar($form, "requireLogin")) {
if (!is_user_logged_in()) {
return empty($form["requireLoginMessage"]) ? "<p>" . __("Sorry. You must be logged in to view this form.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["requireLoginMessage"]) . "</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)) {
$wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper";
if (!$is_valid) {
$wrapper_css_class .= " gform_validation_error";
}
//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='{$wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . ">";
$action = add_query_arg(array());
$default_anchor = $has_pages || $ajax ? true : false;
$use_anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor));
//.........这里部分代码省略.........
示例5: get_form
public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null)
{
//reading form metadata
$form = RGFormsModel::get_form_meta($form_id);
//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>";
}
//Don't display inactive forms
if (!$force_display) {
$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>" . $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>" . $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);
//handling postback if form was submitted
$is_postback = $_POST["is_submit_" . $form_id];
$is_valid = true;
if ($is_postback) {
$is_valid = self::validate($form, $field_values);
if ($is_valid) {
//pre submission action
do_action("gform_pre_submission", $form);
//pre submission filter
$form = apply_filters("gform_pre_submission_filter", $form);
//handle submission
$lead = array();
$confirmation_message = self::handle_submission($form, $lead);
//post submission hook
do_action("gform_post_submission", $lead, $form);
}
} else {
//recording form view. Ignores views from administrators
if (!current_user_can("administrator")) {
RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
}
}
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 . ">\n <form method='post' enctype='multipart/form-data' id='gform_{$form_id}' class='" . $form["cssClass"] . "' action=''>";
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 ($is_postback && !$is_valid) {
$validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . "<br /> " . __("Errors have been highlighted below ", "gravityforms") . "</div>";
$form_string .= apply_filters("gform_validation_message", $validation_message, $form);
}
$form_string .= "\n <div class='gform_body'>\n <input type='hidden' class='gform_hidden' name='is_submit_{$form_id}' value='1'/>\n <ul id='gform_fields_{$form_id}' class='gform_fields " . $form['labelPlacement'] . "'>";
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>\n </div>\n <div class='gform_footer " . $form['labelPlacement'] . "'>";
$tabindex = GFCommon::$tab_index++;
if ($form["button"]["type"] == "text" || empty($form["button"]["imageUrl"])) {
$button_text = empty($form["button"]["text"]) ? __("Submit", "gravityforms") : $form["button"]["text"];
$button_input = "<input type='submit' class='button' value='" . esc_attr($button_text) . "' tabindex='{$tabindex}'/>";
} else {
$imageUrl = $form["button"]["imageUrl"];
$button_input = "<input type='image' src='{$imageUrl}' tabindex='{$tabindex}'/>";
}
$button_input = apply_filters("gform_submit_button", $button_input, $form);
$button_input = apply_filters("gform_submit_button_{$form_id}", $button_input, $form);
$form_string .= $button_input;
if (current_user_can("gform_full_access")) {
$form_string .= " <a href='" . get_bloginfo("wpurl") . "/wp-admin/admin.php?page=gf_edit_forms&id=" . $form_id . "'>" . __("Edit this form", "gravityforms") . "</a>";
}
//.........这里部分代码省略.........