public function get_value_entry_detail($value, $currency = '', $use_text = false, $format = 'html', $media = 'screen') { $output = ''; if (!empty($value)) { $output_arr = array(); $file_paths = $this->multipleFiles ? json_decode($value) : array($value); foreach ($file_paths as $file_path) { $info = pathinfo($file_path); if (GFCommon::is_ssl() && strpos($file_path, 'http:') !== false) { $file_path = str_replace('http:', 'https:', $file_path); } $file_path = esc_attr(str_replace(' ', '%20', $file_path)); $base_name = $info['basename']; $click_to_view_text = esc_attr__('Click to view', 'gravityforms'); $output_arr[] = $format == 'text' ? $file_path . PHP_EOL : "<li><a href='{$file_path}' target='_blank' title='{$click_to_view_text}'>{$base_name}</a></li>"; } $output = join(PHP_EOL, $output_arr); } $output = empty($output) || $format == 'text' ? $output : sprintf('<ul>%s</ul>', $output); return $output; }
/** * @param GF_Field $field * @param string $value * @param bool $force_frontend_label * @param int $form_id * @param null|array $form * * @return string */ public static function get_field_content($field, $value = '', $force_frontend_label = false, $form_id = 0, $form = null) { $field_label = $field->get_field_label($form, $value); $admin_buttons = $field->get_admin_buttons(); $input_type = GFFormsModel::get_input_type($field); $is_form_editor = GFCommon::is_form_editor(); $is_entry_detail = GFCommon::is_entry_detail(); $is_admin = $is_form_editor || $is_entry_detail; if ($input_type == 'adminonly_hidden') { $field_content = !$is_admin ? '{FIELD}' : sprintf("%s<label class='gfield_label' >%s</label>{FIELD}", $admin_buttons, esc_html($field_label)); } else { $field_content = $field->get_field_content($value, $force_frontend_label, $form); } if ($input_type == 'creditcard' && !GFCommon::is_ssl() && !$is_admin) { $field_content = "<div class='gfield_creditcard_warning_message'><span>" . esc_html__('This page is unsecured. Do not enter a real credit card number! Use this field only for testing purposes. ', 'gravityforms') . '</span></div>' . $field_content; } $value = $field->get_value_default_if_empty($value); $field_content = str_replace('{FIELD}', GFCommon::get_field_input($field, $value, 0, $form_id, $form), $field_content); $field_content = apply_filters('gform_field_content', $field_content, $field, $value, 0, $form_id); return $field_content; }
public static function get_field_content($field, $value = "", $force_frontend_label = false, $form_id = 0) { $id = $field["id"]; $size = rgar($field, "size"); $validation_message = rgget("failed_validation", $field) && !empty($field["validation_message"]) ? sprintf("<div class='gfield_description validation_message'>%s</div>", $field["validation_message"]) : ""; $duplicate_disabled = array('captcha', 'post_title', 'post_content', 'post_excerpt', 'total', 'shipping', 'creditcard'); $duplicate_field_link = !in_array($field['type'], $duplicate_disabled) ? "<a class='field_duplicate_icon' id='gfield_duplicate_{$id}' title='" . __("click to duplicate this field", "gravityforms") . "' href='#' onclick='StartDuplicateField(this); return false;'>" . __("Duplicate", "gravityforms") . "</a>" : ""; $duplicate_field_link = apply_filters("gform_duplicate_field_link", $duplicate_field_link); $delete_field_link = "<a class='field_delete_icon' id='gfield_delete_{$id}' title='" . __("click to delete this field", "gravityforms") . "' href='#' onclick='StartDeleteField(this); return false;'>" . __("Delete", "gravityforms") . "</a>"; $delete_field_link = apply_filters("gform_delete_field_link", $delete_field_link); $field_type_title = GFCommon::get_field_type_title($field["type"]); $admin_buttons = IS_ADMIN ? "<div class='gfield_admin_icons'><div class='gfield_admin_header_title'>{$field_type_title} : " . __("Field ID", "gravityforms") . " {$field["id"]}</div>" . $delete_field_link . $duplicate_field_link . "<a class='field_edit_icon edit_icon_collapsed' title='" . __("click to edit this field", "gravityforms") . "'>" . __("Edit", "gravityforms") . "</a></div>" : ""; $field_label = $force_frontend_label ? $field["label"] : GFCommon::get_label($field); if (rgar($field, "inputType") == "singleproduct" && !rgempty($field["id"] . ".1", $value)) { $field_label = rgar($value, $field["id"] . ".1"); } $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}"; $required_div = IS_ADMIN || rgar($field, "isRequired") ? sprintf("<span class='gfield_required'>%s</span>", $field["isRequired"] ? "*" : "") : ""; $target_input_id = ""; $is_description_above = rgar($field, "descriptionPlacement") == "above"; switch (RGFormsModel::get_input_type($field)) { case "section": $description = self::get_description(rgget("description", $field), "gsection_description"); $field_content = sprintf("%s<h2 class='gsection_title'>%s</h2>%s", $admin_buttons, esc_html($field_label), $description); break; case "page": //only executed on the form editor in the admin $page_label = __("Page Break", "gravityforms"); $src = GFCommon::get_base_url() . "/images/gf_pagebreak_inline.png"; $field_content = "{$admin_buttons} <label class='gfield_label'> </label><img src='{$src}' alt='{$page_label}' title='{$page_label}' />"; break; case "adminonly_hidden": case "hidden": case "html": $field_content = !IS_ADMIN ? "{FIELD}" : ($field_content = sprintf("%s<label class='gfield_label' for='%s'>%s</label>{FIELD}", $admin_buttons, $field_id, esc_html($field_label))); break; case "checkbox": case "radio": $description = self::get_description(rgget("description", $field), "gfield_description"); if ($is_description_above) { $field_content = sprintf("%s<label class='gfield_label'>%s%s</label>%s{FIELD}%s", $admin_buttons, esc_html($field_label), $required_div, $description, $validation_message); } else { $field_content = sprintf("%s<label class='gfield_label'>%s%s</label>{FIELD}%s%s", $admin_buttons, esc_html($field_label), $required_div, $description, $validation_message); } break; case "name": switch (rgar($field, "nameFormat")) { case "simple": $target_input_id = $field_id; break; case "extended": $target_input_id = $field_id . "_2"; break; default: $target_input_id = $field_id . "_3"; } case "address": if (empty($target_input_id)) { $target_input_id = $field_id . "_1"; } default: if (empty($target_input_id)) { $target_input_id = $field_id; } $description = self::get_description(rgget("description", $field), "gfield_description"); if ($is_description_above) { $field_content = sprintf("%s<label class='gfield_label' for='%s'>%s%s</label>%s{FIELD}%s", $admin_buttons, $target_input_id, esc_html($field_label), $required_div, $description, $validation_message); } else { $field_content = sprintf("%s<label class='gfield_label' for='%s'>%s%s</label>{FIELD}%s%s", $admin_buttons, $target_input_id, esc_html($field_label), $required_div, $description, $validation_message); } break; } if (RGFormsModel::get_input_type($field) == "creditcard" && !GFCommon::is_ssl() && !IS_ADMIN) { $field_content = "<div class='gfield_creditcard_warning_message'>" . __("This page is unsecured. Do not enter a real credit card number. Use this field only for testing purposes. ", "gravityforms") . "</div>" . $field_content; } $value = self::default_if_empty($field, $value); $field_content = str_replace("{FIELD}", GFCommon::get_field_input($field, $value, 0, $form_id), $field_content); $field_content = apply_filters("gform_field_content", $field_content, $field, $value, 0, $form_id); return $field_content; }
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; }
private static function return_url($form_id, $lead_id) { $pageURL = GFCommon::is_ssl() ? "https://" : "http://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } $ids_query = "ids={$form_id}|{$lead_id}"; $ids_query .= "&hash=" . wp_hash($ids_query); return add_query_arg("gf_paypal_return", base64_encode($ids_query), $pageURL); }
public function get_math_captcha($pos) { if (!class_exists('ReallySimpleCaptcha')) { return array(); } $captcha = $this->get_simple_captcha(); //If captcha folder does not exist and can't be created, return an empty captcha if (!wp_mkdir_p($captcha->tmp_dir)) { return array(); } $captcha->char_length = 1; if ($pos == 1 || $pos == 3) { $captcha->chars = '0123456789'; } else { $captcha->chars = '+'; } switch ($this->simpleCaptchaSize) { case 'small': $captcha->img_size = array(23, 28); $captcha->font_size = 18; $captcha->base = array(6, 20); $captcha->font_char_width = 17; break; case 'large': $captcha->img_size = array(36, 56); $captcha->font_size = 32; $captcha->base = array(10, 42); $captcha->font_char_width = 35; break; default: $captcha->img_size = array(30, 42); $captcha->font_size = 26; $captcha->base = array(9, 32); $captcha->font_char_width = 25; break; } if (!empty($this->simpleCaptchaFontColor)) { $captcha->fg = $this->hex2rgb($this->simpleCaptchaFontColor); } if (!empty($this->simpleCaptchaBackgroundColor)) { $captcha->bg = $this->hex2rgb($this->simpleCaptchaBackgroundColor); } $word = $captcha->generate_random_word(); $prefix = mt_rand(); $filename = $captcha->generate_image($prefix, $word); $url = RGFormsModel::get_upload_url('captcha') . '/' . $filename; $path = $captcha->tmp_dir . $filename; if (GFCommon::is_ssl() && strpos($url, 'http:') !== false) { $url = str_replace('http:', 'https:', $url); } return array('path' => $path, 'url' => $url, 'height' => $captcha->img_size[1], 'width' => $captcha->img_size[0], 'prefix' => $prefix); }
public function return_url($form_id, $lead_id) { $pageURL = GFCommon::is_ssl() ? 'https://' : 'http://'; $server_port = apply_filters('gform_paypal_return_url_port', $_SERVER['SERVER_PORT']); if ($server_port != '80') { $pageURL .= $_SERVER['SERVER_NAME'] . ':' . $server_port . $_SERVER['REQUEST_URI']; } else { $pageURL .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; } $ids_query = "ids={$form_id}|{$lead_id}"; $ids_query .= '&hash=' . wp_hash($ids_query); $url = add_query_arg('gf_paypal_return', base64_encode($ids_query), $pageURL); $query = 'gf_paypal_return=' . base64_encode($ids_query); /** * Filters PayPal's return URL, which is the URL that users will be sent to after completing the payment on PayPal's site. * Useful when URL isn't created correctly (could happen on some server configurations using PROXY servers). * * @since 2.4.5 * * @param string $url The URL to be filtered. * @param int $form_id The ID of the form being submitted. * @param int $entry_id The ID of the entry that was just created. * @param string $query The query string portion of the URL. */ return apply_filters('gform_paypal_return_url', $url, $form_id, $lead_id, $query); }
public function return_url($form_id, $lead_id) { $pageURL = GFCommon::is_ssl() ? 'https://' : 'http://'; $server_port = apply_filters('gform_paypal_return_url_port', $_SERVER['SERVER_PORT']); if ($server_port != '80') { $pageURL .= $_SERVER['SERVER_NAME'] . ':' . $server_port . $_SERVER['REQUEST_URI']; } else { $pageURL .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; } $ids_query = "ids={$form_id}|{$lead_id}"; $ids_query .= '&hash=' . wp_hash($ids_query); return add_query_arg('gf_paypal_return', base64_encode($ids_query), $pageURL); }
private function show_edit_form() { /* * The user created the entry, so show them the form! */ if (self::$allowed_edit === false) { /* * TODO add error log message here */ return false; } ob_start(); $form = self::$form; $lead = self::$lead; $form_id = $form['id']; $field_values = array(); $is_postback = false; /* * Validate form, if submitted */ if (isset($_POST['gform_submit'])) { $is_postback = true; $is_valid = $this->validate($form, $field_values); if ($is_valid) { /* * TODO, save the form and show an update message */ if ($this->update_entry($form, $lead)) { GFPDFEWidgetsAndShortcode_PDFDisplay::$message = __('Your entry and PDF(s) has been successfully updated.', 'pdfextended'); } else { GFPDFEWidgetsAndShortcode_PDFDisplay::$error = __('There was a problem updating your entry. Please try again.', 'pdfextended'); } return false; } } ?> <div id="gform_wrapper_<?php echo self::$form['id']; ?> " class='gform_wrapper'> <form id="gform_<?php echo self::$form['id']; ?> " method="post"> <div id='gform_page_<?php echo self::$form['id']; ?> _1'> <div class='gform_page_fields'> <?php 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>"; echo apply_filters("gform_validation_message_{$form["id"]}", apply_filters("gform_validation_message", $validation_message, $form), $form); } ?> <ul id='gform_fields_<?php echo self::$form['id']; ?> ' class='gform_fields'> <?php foreach ($form["fields"] as $field) { $field_id = $field["id"]; /* * If $field_id should be hidden... */ if (in_array($field_id, $this->atts['hidden_fields'])) { continue; } $field["conditionalLogicFields"] = GFFormDisplay::get_conditional_logic_fields($form, $field["id"]); $input_type = RGFormsModel::get_input_type($field); $error_class = rgget("failed_validation", $field) ? "gfield_error" : ""; $admin_only_class = rgget("adminOnly", $field) ? "field_admin_only" : ""; $selectable_class = IS_ADMIN ? "selectable" : ""; $hidden_class = in_array($input_type, array("hidden", "hiddenproduct")) ? "gform_hidden" : ""; $section_class = $field["type"] == "section" ? "gsection" : ""; $page_class = $field["type"] == "page" ? "gpage" : ""; $html_block_class = $field["type"] == "html" ? "gfield_html" : ""; $html_formatted_class = $field["type"] == "html" && !IS_ADMIN && !rgget("disableMargins", $field) ? "gfield_html_formatted" : ""; $html_no_follows_desc_class = $field["type"] == "html" && !IS_ADMIN && !self::prev_field_has_description(self::$form, $field["id"]) ? "gfield_no_follows_desc" : ""; $calculation_class = RGFormsModel::get_input_type($field) == 'number' && GFCommon::has_field_calculation($field) ? 'gfield_calculation' : ''; $calculation_class = RGFormsModel::get_input_type($field) == 'calculation' ? 'gfield_calculation' : ''; $product_suffix = '_' . self::$form['id'] . '_' . rgget("productField", $field); $option_class = $field["type"] == "option" ? "gfield_price gfield_price{$product_suffix} gfield_option{$product_suffix}" : ""; $quantity_class = $field["type"] == "quantity" ? "gfield_price gfield_price{$product_suffix} gfield_quantity{$product_suffix}" : ""; $shipping_class = $field["type"] == "shipping" ? "gfield_price gfield_shipping gfield_shipping_{$form["id"]}" : ""; $product_class = $field["type"] == "product" ? "gfield_price gfield_price_{$form["id"]}_{$field["id"]} gfield_product_{$form["id"]}_{$field["id"]}" : ""; $hidden_product_class = $input_type == "hiddenproduct" ? "gfield_hidden_product" : ""; $donation_class = $field["type"] == "donation" ? "gfield_price gfield_price_{$form["id"]}_{$field["id"]} gfield_donation_{$form["id"]}_{$field["id"]}" : ""; $required_class = rgar($field, "isRequired") ? "gfield_contains_required" : ""; $creditcard_warning_class = $input_type == "creditcard" && !GFCommon::is_ssl() ? "gfield_creditcard_warning" : ""; $custom_class = IS_ADMIN ? "" : rgget("cssClass", $field); $css_class = "{$selectable_class} gfield {$error_class} {$section_class} {$admin_only_class} {$custom_class} {$hidden_class} {$html_block_class} {$html_formatted_class} {$html_no_follows_desc_class} {$option_class} {$quantity_class} {$product_class} {$donation_class} {$shipping_class} {$page_class} {$required_class} {$hidden_product_class} {$creditcard_warning_class} {$calculation_class}"; $css_class = apply_filters("gform_field_css_class_" . self::$form["id"], apply_filters("gform_field_css_class", trim($css_class), $field, self::$form), $field, self::$form); $style = !empty($form) && !IS_ADMIN && RGFormsModel::is_field_hidden(self::$form, $field, $field_values) ? "style='display:none;'" : ""; switch (RGFormsModel::get_input_type($field)) { case "captcha": case "html": case "password": case "product": case "coupon": case "quantity": case "shipping": case "donation": case "total": case "singleproduct": case "hiddenproduct": case "singleshipping": case "creditcard": case "page": case "post_image": case "fileupload": //ignore certain fields continue; break; default: if (isset($field['productField']) && (int) $field['productField'] > 0 || $field['type'] == 'shipping') { continue; } /* * Ensure our restricted field values stay the same (as they aren't push through the $_POST data) */ if (in_array($field_id, $this->atts['restricted_fields'])) { $value = RGFormsModel::get_lead_field_value($lead, $field); } else { /* * Check if we have POST data, or whether we pull the details from the entry itself * This is useful when the validation fails */ $value = $is_postback ? RGFormsModel::get_field_value($field) : RGFormsModel::get_lead_field_value($lead, $field); } $id = "field_" . $form['id'] . "_" . $field_id; /* $content = " <li id='{$id}' class='$css_class' $style><label class='detail-label'>" . esc_html(GFCommon::get_label($field)) . "</label>" . GFCommon::get_field_input($field, $value, $lead["id"], $form['id']) . "</li>"; $content = apply_filters("gform_field_content", $content, $field, $value, self::$lead["id"], self::$form["id"]);*/ //$content = "<li id='{$id}' class='$css_class' $style>" . GFFormDisplay::get_field_content($field, $value, true, $form['id']) . '</li>'; $field_content = GFFormDisplay::get_field_content($field, $value, true, $form['id']); $field_container = "<li id='{$id}' class='{$css_class}' {$style}>{FIELD_CONTENT}</li>"; $field_container = apply_filters('gform_field_container', $field_container, $field, $form, $css_class, $style, $field_content); $field_container = apply_filters("gform_field_container_{$form['id']}", $field_container, $field, $form, $css_class, $style, $field_content); $field_container = apply_filters("gform_field_container_{$form['id']}_{$field['id']}", $field_container, $field, $form, $css_class, $style, $field_content); $field_markup = str_replace('{FIELD_CONTENT}', $field_content, $field_container); if (in_array($field_id, $this->atts['restricted_fields'])) { $field_markup = str_replace('<input', '<input disabled', $field_markup); $field_markup = str_replace('<textarea', '<textarea disabled', $field_markup); } echo $field_markup; break; } } $field_values_str = is_array($field_values) ? http_build_query($field_values) : $field_values; ?> <input type='hidden' class='gform_hidden' name='is_submit_<?php echo $form['id']; ?> ' value='1' /> <input type='hidden' class='gform_hidden' name='gform_submit' value='<?php echo $form['id']; ?> ' /> <input type='hidden' class='gform_hidden' name='gform_unique_id' value='<?php echo esc_attr(GFFormsModel::get_form_unique_id($form['id'])); ?> ' /> <input type='hidden' class='gform_hidden' name='state_<?php echo $form['id']; ?> ' value='<?php GFFormDisplay::get_state($form, $field_values); ?> ' /> <input type='hidden' name='gform_field_values' value='<?php echo esc_attr($field_values_str); ?> ' /> <?php $button_input = self::get_form_button($form["id"], "gform_submit_button_{$form["id"]}", $form["button"], __("Submit", "gravityforms"), "button gform_button", __("Submit", "gravityforms")); echo $button_input; ?> </ul> </div> </div> </form> </div> <?php $html = ob_get_contents(); ob_end_clean(); return $html; }
protected function return_url($form_id, $lead_id) { $pageURL = GFCommon::is_ssl() ? 'https://' : 'http://'; if ($_SERVER['SERVER_PORT'] != '80') { $pageURL .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; } else { $pageURL .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; } $ids_query = "ids={$form_id}|{$lead_id}"; $ids_query .= '&hash=' . wp_hash($ids_query); return add_query_arg('gf_paypal_return', base64_encode($ids_query), $pageURL); }