public static function gform_footer($form, $class, $ajax, $field_values, $previous_button, $display_title, $display_description, $tabindex = 1) { $form_id = absint($form['id']); $footer = "\n <div class='" . esc_attr($class) . "'>"; $button_input = self::get_form_button($form['id'], "gform_submit_button_{$form['id']}", $form['button'], __('Submit', 'gravityforms'), 'gform_button', __('Submit', 'gravityforms'), 0); $button_input = gf_apply_filters(array('gform_submit_button', $form_id), $button_input, $form); $save_button = rgars($form, 'save/enabled') ? self::get_form_button($form_id, "gform_save_{$form_id}", $form['save']['button'], rgars($form, 'save/button/text'), 'gform_save_link', rgars($form, 'save/button/text'), 0, "jQuery(\"#gform_save_{$form_id}\").val(1);") : ''; $footer .= $previous_button . ' ' . $button_input . ' ' . $save_button; $tabindex = (int) $tabindex; if ($ajax) { $footer .= "<input type='hidden' name='gform_ajax' value='" . esc_attr("form_id={$form_id}&title={$display_title}&description={$display_description}&tabindex={$tabindex}") . "' />"; } $current_page = self::get_current_page($form_id); $next_page = $current_page + 1; $next_page = $next_page > self::get_max_page_number($form) ? 0 : $next_page; $field_values_str = is_array($field_values) ? http_build_query($field_values) : $field_values; $files_input = ''; if (GFCommon::has_multifile_fileupload_field($form) || !empty(RGFormsModel::$uploaded_files[$form_id])) { $files = !empty(RGFormsModel::$uploaded_files[$form_id]) ? GFCommon::json_encode(RGFormsModel::$uploaded_files[$form_id]) : ''; $files_input = "<input type='hidden' name='gform_uploaded_files' id='gform_uploaded_files_{$form_id}' value='" . str_replace("'", ''', $files) . "' />"; } $save_inputs = ''; if (rgars($form, 'save/enabled')) { $resume_token = isset($_POST['gform_resume_token']) ? $_POST['gform_resume_token'] : rgget('gf_token'); $resume_token = sanitize_key($resume_token); $save_inputs = "<input type='hidden' class='gform_hidden' name='gform_save' id='gform_save_{$form_id}' value='' />\n <input type='hidden' class='gform_hidden' name='gform_resume_token' id='gform_resume_token_{$form_id}' value='{$resume_token}' />"; } if (rgar($form, 'requireLogin')) { $footer .= wp_nonce_field('gform_submit_' . $form_id, '_gform_submit_nonce_' . $form_id, true, false); } $unique_id = isset(self::$submission[$form_id]) && rgar(self::$submission[$form_id], 'resuming_incomplete_submission') == true ? rgar(GFFormsModel::$unique_ids, $form_id) : GFFormsModel::get_form_unique_id($form_id); $footer .= "\n <input type='hidden' class='gform_hidden' name='is_submit_{$form_id}' value='1' />\n <input type='hidden' class='gform_hidden' name='gform_submit' value='{$form_id}' />\n {$save_inputs}\n <input type='hidden' class='gform_hidden' name='gform_unique_id' value='" . esc_attr($unique_id) . "' />\n <input type='hidden' class='gform_hidden' name='state_{$form_id}' value='" . self::get_state($form, $field_values) . "' />\n <input type='hidden' class='gform_hidden' name='gform_target_page_number_{$form_id}' id='gform_target_page_number_{$form_id}' value='" . esc_attr($next_page) . "' />\n <input type='hidden' class='gform_hidden' name='gform_source_page_number_{$form_id}' id='gform_source_page_number_{$form_id}' value='" . esc_attr($current_page) . "' />\n <input type='hidden' name='gform_field_values' value='" . esc_attr($field_values_str) . "' />\n {$files_input}\n </div>"; return $footer; }
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; }
private static function gform_footer($form, $class, $ajax, $field_values, $previous_button, $display_title, $display_description) { $form_id = $form["id"]; $footer = "\n <div class='" . $class . "'><div class='btn_container'>"; $button_input = self::get_form_button($form["id"], "gform_submit_button_{$form["id"]}", $form["button"], __("Submit", "gravityforms"), "button gform_button", __("Submit", "gravityforms"), 0); $button_input = apply_filters("gform_submit_button", $button_input, $form); $button_input = apply_filters("gform_submit_button_{$form_id}", $button_input, $form); $footer .= $previous_button . " " . $button_input; if ($ajax) { $footer .= "<input type='hidden' name='gform_ajax' value='" . esc_attr("form_id={$form_id}&title={$display_title}&description={$display_description}") . "' />"; } $current_page = self::get_current_page($form_id); $next_page = $current_page + 1; $next_page = $next_page > self::get_max_page_number($form) ? 0 : $next_page; $field_values_str = is_array($field_values) ? http_build_query($field_values) : $field_values; $files_input = ""; if (!empty(RGFormsModel::$uploaded_files[$form_id])) { $files = GFCommon::json_encode(RGFormsModel::$uploaded_files[$form_id]); $files_input = "<input type='hidden' name='gform_uploaded_files' id='gform_uploaded_files_{$form_id}' value='" . str_replace("'", "'", $files) . "' />"; } $footer .= "\n <input type='hidden' class='gform_hidden' name='is_submit_{$form_id}' value='1' />\n <input type='hidden' class='gform_hidden' name='gform_submit' value='{$form_id}' />\n <input type='hidden' class='gform_hidden' name='gform_unique_id' value='" . esc_attr(GFFormsModel::get_form_unique_id($form_id)) . "' />\n <input type='hidden' class='gform_hidden' name='state_{$form_id}' value='" . self::get_state($form, $field_values) . "' />\n <input type='hidden' class='gform_hidden' name='gform_target_page_number_{$form_id}' id='gform_target_page_number_{$form_id}' value='" . $next_page . "' />\n <input type='hidden' class='gform_hidden' name='gform_source_page_number_{$form_id}' id='gform_source_page_number_{$form_id}' value='" . $current_page . "' />\n <input type='hidden' name='gform_field_values' value='" . esc_attr($field_values_str) . "' />\n {$files_input}\n </div></div>"; return $footer; }
/** * process recurring payments * @param array $data an array with elements is_valid (boolean) and form (array of form elements) * @param GFEwayFormData $formData pre-parsed data from $data * @return array */ protected function processRecurringPayment($data, $formData) { try { $eway = new GFEwayRecurringPayment($this->getCustomerID(), !$this->options['useTest']); $eway->sslVerifyPeer = $this->options['sslVerifyPeer']; if (empty($formData->firstName) && empty($formData->lastName)) { $eway->firstName = '-'; // no first name, $eway->lastName = $formData->ccName; // pick up card holder's name for last name } else { $eway->title = $formData->namePrefix; $eway->firstName = $formData->firstName; $eway->lastName = $formData->lastName; } $eway->emailAddress = $formData->email; $eway->address = $formData->address_street; $eway->suburb = $formData->address_suburb; $eway->state = $formData->address_state; $eway->postcode = $formData->postcode; $eway->country = $formData->address_country; $eway->phone = $formData->phone; $eway->customerReference = $data['form']['id']; $eway->invoiceReference = $data['form']['id']; $eway->invoiceDescription = get_bloginfo('name') . " -- {$data['form']['title']}"; $eway->cardHoldersName = $formData->ccName; $eway->cardNumber = $formData->ccNumber; $eway->cardExpiryMonth = $formData->ccExpMonth; $eway->cardExpiryYear = $formData->ccExpYear; $eway->amountInit = $formData->recurring['amountInit']; $eway->dateInit = $formData->recurring['dateInit']; $eway->amountRecur = $formData->recurring['amountRecur']; $eway->dateStart = $formData->recurring['dateStart']; $eway->dateEnd = $formData->recurring['dateEnd']; $eway->intervalSize = $formData->recurring['intervalSize']; $eway->intervalType = $formData->recurring['intervalType']; // allow plugins/themes to modify invoice description and reference, and set option fields $eway->invoiceDescription = apply_filters('gfeway_invoice_desc', $eway->invoiceDescription, $data['form']); $eway->customerReference = apply_filters('gfeway_invoice_ref', $eway->customerReference, $data['form']); $eway->invoiceReference = apply_filters('gfeway_invoice_trans_number', $eway->invoiceReference, $data['form']); $eway->customerComments = apply_filters('gfeway_invoice_cust_comments', '', $data['form']); self::log_debug(sprintf('%s: %s gateway, invoice ref: %s, customer ref: %s, init amount: %s, recurring amount: %s, date start: %s, date end: %s, interval size: %s, interval type: %s, cc: %s', __FUNCTION__, $eway->isLiveSite ? 'live' : 'test', $eway->invoiceReference, $eway->customerReference, $eway->amountInit, $eway->amountRecur, $eway->dateStart->format('Y-m-d'), $eway->dateEnd->format('Y-m-d'), $eway->intervalSize, $eway->intervalType, $eway->cardNumber)); // record basic transaction data, for updating the entry with later $this->txResult = array('payment_gateway' => 'gfeway', 'gfeway_unique_id' => GFFormsModel::get_form_unique_id($data['form']['id'])); $response = $eway->processPayment(); if ($response->status) { // transaction was successful, so record transaction number and continue $this->txResult['payment_status'] = 'Approved'; $this->txResult['payment_date'] = date('Y-m-d H:i:s'); $this->txResult['transaction_type'] = 1; self::log_debug(sprintf('%s: success, date = %s, status = %s', __FUNCTION__, $this->txResult['payment_date'], $this->txResult['payment_status'])); } else { $data['is_valid'] = false; $formData->ccField['failed_validation'] = true; $formData->ccField['validation_message'] = nl2br($this->getErrMsg(GFEWAY_ERROR_EWAY_FAIL) . ":\n{$response->error}"); $this->txResult['payment_status'] = 'Failed'; self::log_debug(sprintf('%s: failed; %s', __FUNCTION__, $response->error)); } } catch (GFEwayException $e) { $data['is_valid'] = false; $formData->ccField['failed_validation'] = true; $formData->ccField['validation_message'] = nl2br($this->getErrMsg(GFEWAY_ERROR_EWAY_FAIL) . ":\n{$e->getMessage()}"); $this->txResult['payment_status'] = 'Failed'; self::log_error(__METHOD__ . ": " . $e->getMessage()); } return $data; }