public static function change_input_type()
 {
     check_ajax_referer('rg_change_input_type', 'rg_change_input_type');
     $field_json = stripslashes_deep($_POST["field"]);
     $field = GFCommon::json_decode($field_json, true);
     $id = $field["id"];
     $type = $field["inputType"];
     require_once GFCommon::get_base_path() . "/form_display.php";
     $field_content = GFFormDisplay::get_field_content($field, "");
     die("EndChangeInputType('{$id}', '{$type}', \"{$field_content}\");");
 }
Exemplo n.º 2
0
 public static function refresh_field_preview()
 {
     check_ajax_referer('rg_refresh_field_preview', 'rg_refresh_field_preview');
     $field_json = stripslashes_deep($_POST['field']);
     $field_properties = GFCommon::json_decode($field_json, true);
     $field = GF_Fields::create($field_properties);
     $form_id = absint($_POST['formId']);
     $form = GFFormsModel::get_form_meta($form_id);
     require_once GFCommon::get_base_path() . '/form_display.php';
     $field_content = GFFormDisplay::get_field_content($field, '', true, $form_id, $form);
     $args['fieldString'] = $field_content;
     $args_json = json_encode($args);
     die($args_json);
 }
    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;
    }