コード例 #1
0
 public function admin_init()
 {
     if ('gf_edit_forms' == RGForms::get('page') && 1 == count($_GET)) {
         $this->show_page_on_form_list();
         add_filter('gform_noconflict_scripts', array($this, 'gform_noconflict_scripts'));
     }
 }
コード例 #2
0
ファイル: settings.php プロジェクト: hypenotic/slowfood
    public static function settings_page()
    {
        $addon_name = RGForms::get("addon");
        $icon_path = empty($addon_name) ? "" : self::$addon_pages[$addon_name]["icon"];
        $page_title = empty($addon_name) ? __("Gravity Forms Settings", "gravityforms") : $addon_name . " " . __("Settings", "gravityforms");
        $icon_path = empty($icon_path) ? GFCommon::get_base_url() . "/images/gravity-settings-icon-32.png" : $icon_path;
        echo GFCommon::get_remote_message();
        ?>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" />
        <div class="wrap">
            <img alt="<?php 
        $page_title;
        ?>
" src="<?php 
        echo $icon_path;
        ?>
" style="float:left; margin:15px 7px 0 0;"/>
            <h2><?php 
        echo $page_title;
        ?>
</h2>

        <?php 
        if (!empty(self::$addon_pages)) {
            ?>
            <ul class="subsubsub">
                <li><a href="?page=gf_settings">Gravity Forms</a> |</li>
            <?php 
            $count = sizeof(self::$addon_pages);
            for ($i = 0; $i < $count; $i++) {
                $addon_keys = array_keys(self::$addon_pages);
                $addon = $addon_keys[$i];
                ?>
                <li><a href="?page=gf_settings&addon=<?php 
                echo urlencode($addon);
                ?>
"><?php 
                echo esc_html($addon);
                ?>
</a> <?php 
                echo $i < $count - 1 ? "|" : "";
                ?>
</li>
                <?php 
            }
            ?>
            </ul>
            <br style="clear:both;"/>
            <?php 
        }
        if (empty($addon_name)) {
            self::gravityforms_settings_page();
        } else {
            do_action("gform_settings_" . str_replace(" ", "_", $addon_name));
        }
    }
コード例 #3
0
 public function admin_init()
 {
     if ('gf_edit_forms' == RGForms::get('page') && '' == rgget('view') && is_numeric(rgget('id'))) {
         add_filter('gform_toolbar_menu', array($this, 'gform_toolbar_menu'), 10, 2);
         add_action('gform_editor_js', array($this, 'gform_editor_js'));
         add_filter('gform_noconflict_scripts', array($this, 'gform_noconflict_scripts'));
     }
 }
コード例 #4
0
ファイル: redact.php プロジェクト: jbeyta/joelandsam
 public function add_field_option()
 {
     if (is_admin() && 'gf_edit_forms' == RGForms::get('page')) {
         add_action('gform_field_advanced_settings', array($this, 'gform_field_advanced_settings'), 10, 2);
         add_filter('gform_tooltips', array($this, 'gform_tooltips'));
         add_action('gform_editor_js', array($this, 'gform_editor_js'));
         add_filter('gform_noconflict_scripts', array($this, 'gform_noconflict_scripts'));
     }
 }
コード例 #5
0
 public static function settings_page()
 {
     if (class_exists('RGForms') && RGForms::get("page") == "gf_settings") {
         /* 
          * Tell Gravity Forms to initiate our settings page
          * Using the following Class/Model
          */
         RGForms::add_settings_page('PDF', array(self::$model, 'gfpdf_settings_page'));
     }
 }
コード例 #6
0
ファイル: main.php プロジェクト: jekv/devia
 /**
  * Constructor: setup callbacks and plugin-specific options
  *
  * @author James Inman
  */
 public function __construct()
 {
     parent::__construct();
     // Set the plugin's Clockwork SMS menu to load the contact forms
     $this->plugin_callback = array($this, 'clockwork_gravityforms');
     $this->plugin_dir = basename(dirname(__FILE__));
     // Convert the old settings
     $this->convert_old_settings();
     // Setup all forms into a local variable
     if (!class_exists('RGForms')) {
         require_once dirname(dirname(__FILE__)) . '/gravityforms/gravityforms.php';
     }
     if (!class_exists('RGFormsModel')) {
         require_once dirname(dirname(__FILE__)) . '/gravityforms/forms_model.php';
     }
     $active = RGForms::get('active') == '' ? null : RGForms::get('active');
     $this->forms = RGFormsModel::get_forms($active, 'title');
     // Options and callbacks
     add_action('gform_post_submission', array(&$this, 'do_form_processing'), 10, 2);
 }
コード例 #7
0
ファイル: entry_list.php プロジェクト: sashadt/wp-deploy-test
 public static function all_leads_page()
 {
     if (!GFCommon::ensure_wp_version()) {
         return;
     }
     $forms = RGFormsModel::get_forms(null, "title");
     $id = RGForms::get("id");
     if (sizeof($forms) == 0) {
         ?>
         <div style="margin:50px 0 0 10px;">
             <?php 
         echo sprintf(__("You don't have any active forms. Let's go %screate one%s", "gravityforms"), '<a href="?page=gf_new_form">', '</a>');
         ?>
         </div>
         <?php 
     } else {
         if (empty($id)) {
             $id = $forms[0]->id;
         }
         self::leads_page($id);
     }
 }
コード例 #8
0
ファイル: entry_list.php プロジェクト: kidaak/gravityforms
    public static function all_leads_page()
    {
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        $forms = RGFormsModel::get_forms(null, 'title');
        $form_id = RGForms::get('id');
        if (sizeof($forms) == 0) {
            ?>
			<div style="margin:50px 0 0 10px;">
				<?php 
            echo sprintf(esc_html__("You don't have any active forms. Let's go %screate one%s", 'gravityforms'), '<a href="?page=gf_new_form">', '</a>');
            ?>
			</div>
			<?php 
        } else {
            if (empty($form_id)) {
                $form_id = $forms[0]->id;
            }
            /**
             * Fires before the entry list content is generated.
             *
             * Echoed content would appear above the page title.
             *
             * int $form_id The ID of the form the entry list is being displayed for.
             */
            do_action('gform_pre_entry_list', $form_id);
            self::leads_page($form_id);
            /**
             * Fires after the entry list content is generated.
             *
             * Echoed content would appear after the bulk actions/paging links below the entry list table.
             *
             * int $form_id The ID of the form the entry list is being displayed for.
             */
            do_action('gform_post_entry_list', $form_id);
        }
    }
コード例 #9
0
ファイル: userregistration.php プロジェクト: Inteleck/hwc
 private static function is_user_registration_page()
 {
     $current_page = trim(strtolower(RGForms::get("page")));
     return in_array($current_page, array("gf_user_registration"));
 }
コード例 #10
0
ファイル: class-common.php プロジェクト: roarmoser/gv1
 /**
  * Calculates the Search Criteria used on the self::get_entries / self::get_entry methods
  *
  * @since 1.7.4
  *
  * @param null $passed_criteria array Input Criteria (search_criteria, sorting, paging)
  * @param null $form_ids array Gravity Forms form IDs
  * @return array|mixed|void
  */
 public static function calculate_get_entries_criteria($passed_criteria = null, $form_ids = null)
 {
     $search_criteria_defaults = array('search_criteria' => null, 'sorting' => null, 'paging' => null, 'cache' => isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true);
     $criteria = wp_parse_args($passed_criteria, $search_criteria_defaults);
     if (!empty($criteria['search_criteria']['field_filters'])) {
         foreach ($criteria['search_criteria']['field_filters'] as &$filter) {
             if (!is_array($filter)) {
                 continue;
             }
             // By default, we want searches to be wildcard for each field.
             $filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator'];
             /**
              * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
              * @param string $operator Existing search operator
              * @param array $filter array with `key`, `value`, `operator`, `type` keys
              */
             $filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter);
         }
     }
     /**
      * Prepare date formats to be in Gravity Forms DB format;
      * $passed_criteria may include date formats incompatible with Gravity Forms.
      */
     foreach (array('start_date', 'end_date') as $key) {
         if (!empty($criteria['search_criteria'][$key])) {
             // Use date_create instead of new DateTime so it returns false if invalid date format.
             $date = date_create($criteria['search_criteria'][$key]);
             if ($date) {
                 // Gravity Forms wants dates in the `Y-m-d H:i:s` format.
                 $criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s');
             } else {
                 // If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
                 unset($criteria['search_criteria'][$key]);
                 do_action('gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria['search_criteria'][$key]);
             }
         }
     }
     // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter
     if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->single_entry) {
         $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
     } elseif ('delete' === RGForms::get('action')) {
         $criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null;
     } elseif (!isset($criteria['context_view_id'])) {
         // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
         $criteria['context_view_id'] = null;
     }
     /**
      * @filter `gravityview_search_criteria` Apply final criteria filter (Used by the Advanced Filter extension)
      * @param array $criteria Search criteria used by GravityView
      * @param array $form_ids Forms to search
      * @param int $view_id ID of the view being used to search
      */
     $criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']);
     return $criteria;
 }
コード例 #11
0
 private static function is_campaignmonitor_page()
 {
     $current_page = trim(strtolower(RGForms::get("page")));
     $campaignmonitor_pages = array("gf_campaignmonitor");
     return in_array($current_page, $campaignmonitor_pages);
 }
コード例 #12
0
 public static function get_current_page_url($force_ssl = false)
 {
     $pageURL = 'http';
     if (RGForms::get("HTTPS", $_SERVER) == "on" || $force_ssl) {
         $pageURL .= "s";
     }
     $pageURL .= "://";
     $pageURL .= RGForms::get("HTTP_HOST", $_SERVER) . rgget("REQUEST_URI", $_SERVER);
     return $pageURL;
 }
コード例 #13
0
ファイル: common.php プロジェクト: novuscory/ACH
 public static function get_field_input($field, $value = "", $lead_id = 0, $form_id = 0)
 {
     $id = $field["id"];
     $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
     $form_id = IS_ADMIN && empty($form_id) ? $_GET["id"] : $form_id;
     $size = $field["size"];
     $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
     $class_suffix = RG_CURRENT_VIEW == "entry" ? "_admin" : "";
     $class = $size . $class_suffix;
     $currency = "";
     if (RG_CURRENT_VIEW == "entry") {
         $lead = RGFormsModel::get_lead($lead_id);
         $post_id = $lead["post_id"];
         $post_link = "";
         if (is_numeric($post_id) && self::is_post_field($field)) {
             $post_link = "You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.";
         }
         $currency = $lead["currency"];
     }
     $field_input = apply_filters("gform_field_input", "", $field, $value, $lead_id, $form_id);
     if ($field_input) {
         return $field_input;
     }
     //product fields are not editable
     if (RG_CURRENT_VIEW == "entry" && self::is_product_field($field["type"])) {
         return "<div class='ginput_container'>" . _e("Product fields are not editable", "gravityforms") . "</div>";
     } else {
         if (RG_CURRENT_VIEW == "entry" && $field["type"] == "donation") {
             return "<div class='ginput_container'>" . _e("Donations are not editable", "gravityforms") . "</div>";
         }
     }
     $max_length = "";
     $html5_attributes = "";
     switch (RGFormsModel::get_input_type($field)) {
         case "total":
             if (RG_CURRENT_VIEW == "entry") {
                 return "<div class='ginput_container'><input type='text' name='input_{$id}' value='{$value}' /></div>";
             } else {
                 return "<div class='ginput_container'><span class='ginput_total ginput_total_{$form_id}'>" . self::to_money("0") . "</span><input type='hidden' name='input_{$id}' id='{$field_id}' class='gform_hidden'/></div>";
             }
             break;
         case "singleproduct":
             $product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
             $price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? $field["basePrice"] : esc_attr($value[$field["id"] . ".2"]);
             $quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "";
             if (empty($price)) {
                 $price = 0;
             }
             $form = RGFormsModel::get_form_meta($form_id);
             $has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
             if ($has_quantity) {
                 $field["disableQuantity"] = true;
             }
             $quantity_field = "";
             if (IS_ADMIN) {
                 $style = $field["disableQuantity"] ? "style='display:none;'" : "";
                 $quantity_field = " <span class='ginput_quantity_label' {$style}>" . __("Quantity:", "gravityformspaypal") . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' />";
             } else {
                 if (!$field["disableQuantity"]) {
                     $tabindex = self::get_tabindex();
                     $quantity_field .= " <span class='ginput_quantity_label'>" . __("Quantity:", "gravityformspaypal") . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' {$tabindex}/>";
                 } else {
                     if (!is_numeric($quantity)) {
                         $quantity = 1;
                     }
                     if (!$has_quantity) {
                         $quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$field["id"]} gform_hidden' />";
                     }
                 }
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' /><span class='ginput_product_price_label'>" . __("Price:", "gravityformspaypal") . "</span> <span class='ginput_product_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span><input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$field["id"]}' class='gform_hidden' value='{$price}'/>{$quantity_field}</div>";
             break;
         case "singleshipping":
             $price = !empty($value) ? $value : $field["basePrice"];
             if (empty($price)) {
                 $price = 0;
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}' value='{$price}' class='gform_hidden'/><span class='ginput_shipping_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span></div>";
             break;
         case "website":
             $is_html5 = RGFormsModel::is_html5_enabled();
             $value = empty($value) && !$is_html5 ? "http://" : $value;
             $html_input_type = $is_html5 ? "url" : "text";
             $html5_attributes = $is_html5 ? "placeholder='http://'" : "";
         case "text":
             if (empty($html_input_type)) {
                 $html_input_type = "text";
             }
             if ($field["enablePasswordInput"] && RG_CURRENT_VIEW != "entry") {
                 $html_input_type = "password";
             }
             if (is_numeric($field["maxLength"])) {
                 $max_length = "maxlength='{$field["maxLength"]}'";
             }
             if (!empty($post_link)) {
                 return $post_link;
             }
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "email":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $html_input_type = RGFormsModel::is_html5_enabled() ? "email" : "text";
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $single_style = $field["emailConfirmEnabled"] ? "style='display:none;'" : "";
                 $confirm_style = $field["emailConfirmEnabled"] ? "" : "style='display:none;'";
                 return "<div class='ginput_container ginput_single_email' {$single_style}><input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' /></div><div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' /><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' /><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
             } else {
                 if ($field["emailConfirmEnabled"] && RG_CURRENT_VIEW != "entry") {
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return "<div class='ginput_complex ginput_container' id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . esc_attr($value) . "' {$first_tabindex} {$disabled_text}/><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='{$_POST["input_" . $id . "_2"]}' {$last_tabindex} {$disabled_text}/><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
                 } else {
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
                 }
             }
             break;
         case "honeypot":
             return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value=''/></div>";
             break;
         case "hidden":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $field_type = IS_ADMIN ? "text" : "hidden";
             $class_attribute = IS_ADMIN ? "" : "class='gform_hidden'";
             return sprintf("<input name='input_%d' id='%s' type='{$field_type}' {$class_attribute} value='%s' %s/>", $id, $field_id, esc_attr($value), $disabled_text);
             break;
         case "html":
             $content = IS_ADMIN ? "<img class='gfield_html_block' src='" . self::get_base_url() . "/images/gf_html_admin_placeholder.jpg' alt='HTML Block'/>" : $field["content"];
             return do_shortcode($content);
             break;
         case "adminonly_hidden":
             if (!is_array($field["inputs"])) {
                 return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, $field_id, esc_attr($value));
             }
             $fields = "";
             foreach ($field["inputs"] as $input) {
                 $fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input["id"], esc_attr($value[$input["id"]]));
             }
             return $fields;
             break;
         case "number":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = "";
             if (!IS_ADMIN) {
                 $min = $field["rangeMin"];
                 $max = $field["rangeMax"];
                 $validation_class = $field["failed_validation"] ? "validation_message" : "";
                 $message = self::get_range_message($field);
                 if (!$field["failed_validation"] && !empty($message) && empty($field["errorMessage"])) {
                     $instruction = "<div class='instruction {$validation_class}'>" . $message . "</div>";
                 }
             }
             $html_input_type = RGFormsModel::is_html5_enabled() ? "number" : "text";
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} %s/>%s</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text, $instruction);
         case "donation":
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "price":
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_amount' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "phone":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = $field["phoneFormat"] == "standard" ? __("Phone format:", "gravityforms") . " (###)###-####" : "";
             $instruction_div = $field["failed_validation"] ? "<div class='instruction validation_message'>{$instruction}</div>" : "";
             $html_input_type = RGFormsModel::is_html5_enabled() ? "tel" : "text";
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} %s/>{$instruction_div}</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "textarea":
             if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
                 $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
             }
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
         case "post_title":
         case "post_tags":
         case "post_custom_field":
             $tabindex = self::get_tabindex();
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "post_content":
         case "post_excerpt":
             if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
                 $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
             }
             $tabindex = self::get_tabindex();
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
             break;
         case "post_category":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if ($field["displayAllCategories"] && !IS_ADMIN) {
                 $default_category = $field["categoryInitialItemEnabled"] ? "-1" : get_option('default_category');
                 $selected = empty($value) ? $default_category : $value;
                 $args = array('echo' => 0, 'selected' => $selected, "class" => esc_attr($class) . " gfield_select", 'hide_empty' => 0, 'name' => "input_{$id}", 'orderby' => 'name', 'hierarchical' => true);
                 if (self::$tab_index > 0) {
                     $args["tab_index"] = self::$tab_index++;
                 }
                 if ($field["categoryInitialItemEnabled"]) {
                     $args["show_option_none"] = empty($field["categoryInitialItem"]) ? " " : $field["categoryInitialItem"];
                 }
                 return "<div class='ginput_container'>" . wp_dropdown_categories($args) . "</div>";
             } else {
                 $tabindex = self::get_tabindex();
                 $choices = self::get_select_choices($field, $value);
                 //Adding first option
                 if ($field["categoryInitialItemEnabled"]) {
                     $selected = empty($value) ? "selected='selected'" : "";
                     $choices = "<option value='-1' {$selected}>{$field["categoryInitialItem"]}</option>" . $choices;
                 }
                 return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' class='%s gfield_select' {$tabindex} %s>%s</select></div>", $id, $field_id, esc_attr($class), $disabled_text, $choices);
             }
             break;
         case "post_image":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $title = esc_attr($value[$field["id"] . ".1"]);
             $caption = esc_attr($value[$field["id"] . ".4"]);
             $description = esc_attr($value[$field["id"] . ".7"]);
             //hidding meta fields for admin
             $hidden_style = "style='display:none;'";
             $title_style = !$field["displayTitle"] && IS_ADMIN ? $hidden_style : "";
             $caption_style = !$field["displayCaption"] && IS_ADMIN ? $hidden_style : "";
             $description_style = !$field["displayDescription"] && IS_ADMIN ? $hidden_style : "";
             $file_label_style = IS_ADMIN && !($field["displayTitle"] || $field["displayCaption"] || $field["displayDescription"]) ? $hidden_style : "";
             $hidden_class = "";
             $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
             if ($file_info) {
                 $hidden_class = " gform_hidden";
                 $file_label_style = $hidden_style;
                 $preview = "<span class='ginput_preview'><strong>{$file_info["uploaded_filename"]}</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
             }
             //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
             $file_label = IS_ADMIN || $field["displayTitle"] || $field["displayCaption"] || $field["displayDescription"] ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . apply_filters("gform_postimage_file_{$form_id}", apply_filters("gform_postimage_file", __("File", "gravityforms"), $form_id), $form_id) . "</label>" : "";
             $tabindex = self::get_tabindex();
             $upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
             $tabindex = self::get_tabindex();
             $title_field = $field["displayTitle"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . apply_filters("gform_postimage_title_{$form_id}", apply_filters("gform_postimage_title", __("Title", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $title, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $caption_field = $field["displayCaption"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s.4' value='%s' {$tabindex} %s/><label for='%s.4'>" . apply_filters("gform_postimage_caption_{$form_id}", apply_filters("gform_postimage_caption", __("Caption", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $caption, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $description_field = $field["displayDescription"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s.7' value='%s' {$tabindex} %s/><label for='%s.7'>" . apply_filters("gform_postimage_description_{$form_id}", apply_filters("gform_postimage_description", __("Description", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $description, $disabled_text, $field_id) : "";
             return "<div class='ginput_complex{$class_suffix} ginput_container'>" . $upload . $title_field . $caption_field . $description_field . "</div>";
             break;
         case "select":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $logic_event = empty($field["conditionalLogicFields"]) || IS_ADMIN ? "" : "onchange='gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ");'";
             $css_class = trim(esc_attr($class) . " gfield_select");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
         case "checkbox":
             return sprintf("<div class='ginput_container'><ul class='gfield_checkbox' id='%s'>%s</ul></div>", $field_id, self::get_checkbox_choices($field, $value, $disabled_text));
         case "radio":
             if (!empty($post_link)) {
                 return $post_link;
             }
             return sprintf("<div class='ginput_container'><ul class='gfield_radio' id='%s'>%s</ul></div>", $field_id, self::get_radio_choices($field, $value, $disabled_text));
         case "password":
             $first_tabindex = self::get_tabindex();
             $last_tabindex = self::get_tabindex();
             $strength_style = !$field["passwordStrengthEnabled"] ? "style='display:none;'" : "";
             $strength = $field["passwordStrengthEnabled"] || IS_ADMIN ? "<div id='{$field_id}_strength_indicator' class='gfield_password_strength' {$strength_style}>" . __("Strength indicator", "gravityforms") . "</div><input type='hidden' class='gform_hidden' id='{$field_id}_strength' name='input_{$id}_strength' />" : "";
             $action = "gformShowPasswordStrength(\"{$field_id}\");";
             $onchange = $field["passwordStrengthEnabled"] ? "onchange='{$action}'" : "";
             $onkeyup = $field["passwordStrengthEnabled"] ? "onkeyup='{$action}'" : "";
             $script = $field["passwordStrengthEnabled"] && !IS_ADMIN ? "<script type=\"text/javascript\">if(window[\"gformShowPasswordStrength\"]) jQuery(document).ready(function(){{$action}});</script>" : "";
             $pass = RGForms::post("input_" . $id . "_2");
             return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}_container'><span id='" . $field_id . "_1_container' class='ginput_left'><input type='password' name='input_%d' id='%s' {$onkeyup} {$onchange} value='%s' {$first_tabindex} %s/><label for='%s'>" . apply_filters("gform_password_{$form_id}", apply_filters("gform_password", __("Enter Password", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_2_container' class='ginput_right'><input type='password' name='input_%d_2' id='%s_2' {$onkeyup} {$onchange} value='%s' {$last_tabindex} %s/><label for='%s_2'>" . apply_filters("gform_password_confirm_{$form_id}", apply_filters("gform_password_confirm", __("Confirm Password", "gravityforms"), $form_id), $form_id) . "</label></span>{$script}</div>{$strength}", $id, $field_id, $value, $disabled_text, $field_id, $id, $field_id, $pass, $disabled_text, $field_id);
         case "name":
             $prefix = "";
             $first = "";
             $last = "";
             $suffix = "";
             if (is_array($value)) {
                 $prefix = esc_attr(RGForms::get($field["id"] . ".2", $value));
                 $first = esc_attr(RGForms::get($field["id"] . ".3", $value));
                 $last = esc_attr(RGForms::get($field["id"] . ".6", $value));
                 $suffix = esc_attr(RGForms::get($field["id"] . ".8", $value));
             }
             switch ($field["nameFormat"]) {
                 case "extended":
                     $prefix_tabindex = self::get_tabindex();
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     $suffix_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_2_container' class='name_prefix'><input type='text' name='input_%d.2' id='%s.2' value='%s' {$prefix_tabindex} %s/><label for='%s.2'>" . apply_filters("gform_name_prefix_{$form_id}", apply_filters("gform_name_prefix", __("Prefix", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_3_container' class='name_first'><input type='text' name='input_%d.3' id='%s.3' value='%s' {$first_tabindex} %s/><label for='%s.3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='name_last'><input type='text' name='input_%d.6' id='%s.6' value='%s' {$last_tabindex} %s/><label for='%s.6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_8_container' class='name_suffix'><input type='text' name='input_%d.8' id='%s.8' value='%s' {$suffix_tabindex} %s/><label for='%s.8'>" . apply_filters("gform_name_suffix_{$form_id}", apply_filters("gform_name_suffix", __("Suffix", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $prefix, $disabled_text, $field_id, $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id, $id, $field_id, $suffix, $disabled_text, $field_id);
                 case "simple":
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
                 default:
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_3_container' class='ginput_left'><input type='text' name='input_%d.3' id='%s.3' value='%s' {$first_tabindex} %s/><label for='%s.3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='ginput_right'><input type='text' name='input_%d.6' id='%s.6' value='%s' {$last_tabindex} %s/><label for='%s.6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id);
             }
         case "address":
             $street_value = "";
             $street2_value = "";
             $city_value = "";
             $state_value = "";
             $zip_value = "";
             $country_value = "";
             if (is_array($value)) {
                 $street_value = esc_attr($value[$field["id"] . ".1"]);
                 $street2_value = esc_attr($value[$field["id"] . ".2"]);
                 $city_value = esc_attr($value[$field["id"] . ".3"]);
                 $state_value = esc_attr($value[$field["id"] . ".4"]);
                 $zip_value = esc_attr($value[$field["id"] . ".5"]);
                 $country_value = esc_attr($value[$field["id"] . ".6"]);
             }
             $address_types = self::get_address_types($form_id);
             $addr_type = empty($field["addressType"]) ? "international" : $field["addressType"];
             $address_type = $address_types[$addr_type];
             $state_label = empty($address_type["state_label"]) ? __("State", "gravityforms") : $address_type["state_label"];
             $zip_label = empty($address_type["zip_label"]) ? __("Zip Code", "gravityforms") : $address_type["zip_label"];
             $hide_country = !empty($address_type["country"]) || $field["hideCountry"];
             if (empty($country_value)) {
                 $country_value = $field["defaultCountry"];
             }
             if (empty($state_value)) {
                 $state_value = $field["defaultState"];
             }
             $country_list = self::get_country_dropdown($country_value);
             //address field
             $tabindex = self::get_tabindex();
             $street_address = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_1_container'><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1' id='" . $field_id . "_1_label'>" . apply_filters("gform_address_street_{$form_id}", apply_filters("gform_address_street", __("Street Address", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street_value, $disabled_text, $field_id);
             //address line 2 field
             $style = IS_ADMIN && $field["hideAddress2"] ? "style='display:none;'" : "";
             if (IS_ADMIN || !$field["hideAddress2"]) {
                 $tabindex = self::get_tabindex();
                 $street_address2 = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_2_container' {$style}><input type='text' name='input_%d.2' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2' id='" . $field_id . "_2_label'>" . apply_filters("gform_address_street2_{$form_id}", apply_filters("gform_address_street2", __("Address Line 2", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street2_value, $disabled_text, $field_id);
             }
             //city field
             $tabindex = self::get_tabindex();
             $city = sprintf("<span class='ginput_left{$class_suffix}' id='" . $field_id . "_3_container'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3' id='{$field_id}.3_label'>" . apply_filters("gform_address_city_{$form_id}", apply_filters("gform_address_city", __("City", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $city_value, $disabled_text, $field_id);
             //state field
             $style = IS_ADMIN && $field["hideState"] ? "style='display:none;'" : "";
             if (IS_ADMIN || !$field["hideState"]) {
                 $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text, $form_id);
                 $state = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_4_container' {$style}>{$state_field}<label for='%s.4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state_{$form_id}", apply_filters("gform_address_state", $state_label, $form_id), $form_id) . "</label></span>", $field_id);
             } else {
                 $state = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.4' id='%s_4' value='%s'/>", $id, $field_id, $state_value);
             }
             //zip field
             $tabindex = self::get_tabindex();
             $zip = sprintf("<span class='ginput_left{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip_{$form_id}", apply_filters("gform_address_zip", $zip_label, $form_id), $form_id) . "</label></span>", $id, $field_id, $zip_value, $disabled_text, $field_id);
             if (IS_ADMIN || !$hide_country) {
                 $style = $hide_country ? "style='display:none;'" : "";
                 $tabindex = self::get_tabindex();
                 $country = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_6_container' {$style}><select name='input_%d.6' id='%s_6' {$tabindex} %s>%s</select><label for='%s_6' id='" . $field_id . "_6_label'>" . apply_filters("gform_address_country_{$form_id}", apply_filters("gform_address_country", __("Country", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $disabled_text, $country_list, $field_id);
             } else {
                 $country = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.6' id='%s_6' value='%s'/>", $id, $field_id, $country_value);
             }
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $street_address . $street_address2 . $city . $state . $zip . $country . "</div>";
         case "date":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $format = empty($field["dateFormat"]) ? "mdy" : esc_attr($field["dateFormat"]);
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $datepicker_display = $field["dateType"] == "datefield" ? "none" : "inline";
                 $dropdown_display = $field["dateType"] == "datefield" ? "inline" : "none";
                 $icon_display = $field["calendarIconType"] == "calendar" ? "inline" : "none";
                 $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$dropdown_display}'><input name='ginput_month' type='text' disabled='disabled'/><label>" . __("MM", "gravityforms") . "</label></div>";
                 $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$dropdown_display}'><input name='ginput_day' type='text' disabled='disabled'/><label>" . __("DD", "gravityforms") . "</label></div>";
                 $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$dropdown_display}'><input type='text' name='ginput_year' disabled='disabled'/><label>" . __("YYYY", "gravityforms") . "</label></div>";
                 $field_string = "<div class='ginput_container' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' /><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
                 $field_string .= $field["dateFormat"] == "dmy" ? $day_field . $month_field . $year_field : $month_field . $day_field . $year_field;
                 return $field_string;
             } else {
                 $date_info = GFCommon::parse_date($value, $format);
                 if ($field["dateType"] == "datefield") {
                     if ($format == "mdy") {
                         $tabindex = self::get_tabindex();
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], $disabled_text, $field_id);
                         $tabindex = self::get_tabindex();
                         $field_str .= sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$tabindex} %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], $disabled_text, $field_id);
                     } else {
                         $tabindex = self::get_tabindex();
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$tabindex} %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], $disabled_text, $field_id);
                         $tabindex = self::get_tabindex();
                         $field_str .= sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], $disabled_text, $field_id);
                     }
                     $tabindex = self::get_tabindex();
                     $field_str .= sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s.3' value='%s' {$tabindex} %s/><label for='%s.3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, $date_info["year"], $disabled_text, $field_id);
                     return $field_str;
                 } else {
                     $value = GFCommon::date_display($value, $format);
                     $icon_class = $field["calendarIconType"] == "none" ? "datepicker_no_icon" : "datepicker_with_icon";
                     $icon_url = empty($field["calendarIconUrl"]) ? GFCommon::get_base_url() . "/images/calendar.png" : $field["calendarIconUrl"];
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='datepicker %s %s %s' {$tabindex} %s/> </div><input type='hidden' id='gforms_calendar_icon_{$field_id}' class='gform_hidden' value='{$icon_url}'/>", $id, $field_id, esc_attr($value), esc_attr($class), $format, $icon_class, $disabled_text);
                 }
             }
         case "time":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) (.*)$/', $value, $matches);
                 $hour = esc_attr($matches[1]);
                 $minute = esc_attr($matches[2]);
                 $am_selected = $matches[3] == "am" ? "selected='selected'" : "";
                 $pm_selected = $matches[3] == "pm" ? "selected='selected'" : "";
             } else {
                 $hour = esc_attr($value[0]);
                 $minute = esc_attr($value[1]);
                 $am_selected = $value[2] == "am" ? "selected='selected'" : "";
                 $pm_selected = $value[2] == "pm" ? "selected='selected'" : "";
             }
             $hour_tabindex = self::get_tabindex();
             $minute_tabindex = self::get_tabindex();
             $ampm_tabindex = self::get_tabindex();
             return sprintf("<div class='clear-multi'><div class='gfield_time_hour ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$hour_tabindex} %s/> : <label for='%s.1'>" . __("HH", "gravityforms") . "</label></div><div class='gfield_time_minute ginput_container'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$minute_tabindex} %s/><label for='%s.2'>" . __("MM", "gravityforms") . "</label></div><div class='gfield_time_ampm ginput_container'><select name='input_%d[]' id='%s.3' {$ampm_tabindex} %s><option value='am' %s>" . __("AM", "gravityforms") . "</option><option value='pm' %s>" . __("PM", "gravityforms") . "</option></select></div></div>", $field_id, $id, $field_id, $hour, $disabled_text, $field_id, $id, $field_id, $minute, $disabled_text, $field_id, $id, $field_id, $disabled_text, $am_selected, $pm_selected);
         case "fileupload":
             $tabindex = self::get_tabindex();
             $upload = sprintf("<input name='input_%d' id='%s' type='file' value='%s' size='20' class='%s' {$tabindex} %s/>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             if (IS_ADMIN && !empty($value)) {
                 $value = esc_attr($value);
                 $preview = sprintf("<div id='preview_%d'><a href='%s' target='_blank' alt='%s' title='%s'>%s</a><a href='%s' target='_blank' alt='" . __("Download file", "gravityforms") . "' title='" . __("Download file", "gravityforms") . "'><img src='%s' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='" . __("Delete file", "gravityforms") . "' title='" . __("Delete file", "gravityforms") . "' onclick='DeleteFile(%d,%d);' ><img src='%s' style='margin-left:10px;'/></a></div>", $id, $value, $value, $value, GFCommon::truncate_url($value), $value, GFCommon::get_base_url() . "/images/download.png", $lead_id, $id, GFCommon::get_base_url() . "/images/delete.png");
                 return $preview . "<div id='upload_{$id}' style='display:none;'>{$upload}</div>";
             } else {
                 $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
                 if ($file_info && !$field["failed_validation"]) {
                     $preview = "<span class='ginput_preview'><strong>{$file_info["uploaded_filename"]}</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
                     return "<div class='ginput_container'>" . str_replace(" class='", " class='gform_hidden ", $upload) . " {$preview}</div>";
                 } else {
                     return "<div class='ginput_container'>{$upload}</div>";
                 }
             }
         case "captcha":
             switch ($field["captchaType"]) {
                 case "simple_captcha":
                     $size = empty($field["simpleCaptchaSize"]) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha = self::get_captcha($field);
                     $tagindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='{$captcha["width"]}' height='{$captcha["height"]}'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='{$captcha["url"]}' alt='' {$dimensions} /><div class='gfield_captcha_input_container simple_captcha_{$size}'><input type='text' name='input_{$id}' id='input_{$field_id}' /><input type='hidden' name='input_captcha_prefix_{$id}' value='{$captcha["prefix"]}' /></div></div>";
                     break;
                 case "math":
                     $size = empty($field["simpleCaptchaSize"]) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha_1 = self::get_math_captcha($field, 1);
                     $captcha_2 = self::get_math_captcha($field, 2);
                     $captcha_3 = self::get_math_captcha($field, 3);
                     $tagindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='{$captcha_1["width"]}' height='{$captcha_1["height"]}'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='{$captcha_1["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_2["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_3["url"]}' alt='' {$dimensions} /><div class='gfield_captcha_input_container math_{$size}'><input type='text' name='input_{$id}' id='input_{$field_id}' /><input type='hidden' name='input_captcha_prefix_{$id}' value='{$captcha_1["prefix"]},{$captcha_2["prefix"]},{$captcha_3["prefix"]}' /></div></div>";
                     break;
                 default:
                     if (!function_exists("recaptcha_get_html")) {
                         require_once GFCommon::get_base_path() . '/recaptchalib.php';
                     }
                     $theme = empty($field["captchaTheme"]) ? "red" : esc_attr($field["captchaTheme"]);
                     $publickey = get_option("rg_gforms_captcha_public_key");
                     $privatekey = get_option("rg_gforms_captcha_private_key");
                     if (IS_ADMIN) {
                         if (empty($publickey) || empty($privatekey)) {
                             return "<div class='captcha_message'>" . __("To use the reCaptcha field you must first do the following:", "gravityforms") . "</div><div class='captcha_message'>1 - <a href='https://admin.recaptcha.net/recaptcha/createsite/?app=php' target='_blank'>" . __(sprintf("Sign up%s for a free reCAPTCHA account", "</a>"), "gravityforms") . "</div><div class='captcha_message'>2 - " . __(sprintf("Enter your reCAPTCHA keys in the %ssettings page%s", "<a href='?page=gf_settings'>", "</a>"), "gravityforms") . "</div>";
                         } else {
                             return "<div class='ginput_container'><img class='gfield_captcha' src='" . GFCommon::get_base_url() . "/images/captcha_{$theme}.jpg' alt='reCAPTCHA' title='reCAPTCHA'/></div>";
                         }
                     } else {
                         $language = empty($field["captchaLanguage"]) ? "en" : esc_attr($field["captchaLanguage"]);
                         $options = "<script type='text/javascript'>var RecaptchaOptions = {theme : '{$theme}', lang : '{$language}'}; if(parseInt('" . self::$tab_index . "') > 0) {RecaptchaOptions.tabindex = " . self::$tab_index++ . ";}</script>";
                         $is_ssl = !empty($_SERVER['HTTPS']);
                         return $options . "<div class='ginput_container' id='{$field_id}'>" . recaptcha_get_html($publickey, null, $is_ssl) . "</div>";
                     }
             }
             break;
     }
 }
コード例 #14
0
ファイル: paypal.php プロジェクト: bryanmonzon/jenjonesdirect
 private static function is_paypal_page()
 {
     $current_page = trim(strtolower(RGForms::get("page")));
     return in_array($current_page, array("gf_paypal"));
 }
コード例 #15
0
 public static function get_current_page_url($force_ssl = false)
 {
     $pageURL = 'http';
     if (RGForms::get('HTTPS', $_SERVER) == 'on' || $force_ssl) {
         $pageURL .= 's';
     }
     $pageURL .= '://';
     $pageURL .= RGForms::get('HTTP_HOST', $_SERVER) . rgget('REQUEST_URI', $_SERVER);
     return $pageURL;
 }
コード例 #16
0
 public function get_field_input($form, $value = '', $entry = null)
 {
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $is_admin = $is_entry_detail || $is_form_editor;
     $form_id = $form['id'];
     $id = intval($this->id);
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id;
     $size = $this->size;
     $class_suffix = RG_CURRENT_VIEW == 'entry' ? '_admin' : '';
     $class = $size . $class_suffix;
     $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
     $class_suffix = $is_entry_detail ? '_admin' : '';
     $form_sub_label_placement = rgar($form, 'subLabelPlacement');
     $field_sub_label_placement = $this->subLabelPlacement;
     $is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
     $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label'" : '';
     $prefix = '';
     $first = '';
     $middle = '';
     $last = '';
     $suffix = '';
     if (is_array($value)) {
         $prefix = esc_attr(RGForms::get($this->id . '.2', $value));
         $first = esc_attr(RGForms::get($this->id . '.3', $value));
         $middle = esc_attr(RGForms::get($this->id . '.4', $value));
         $last = esc_attr(RGForms::get($this->id . '.6', $value));
         $suffix = esc_attr(RGForms::get($this->id . '.8', $value));
     }
     $prefix_input = GFFormsModel::get_input($this, $this->id . '.2');
     $first_input = GFFormsModel::get_input($this, $this->id . '.3');
     $middle_input = GFFormsModel::get_input($this, $this->id . '.4');
     $last_input = GFFormsModel::get_input($this, $this->id . '.6');
     $suffix_input = GFFormsModel::get_input($this, $this->id . '.8');
     $first_placeholder_attribute = GFCommon::get_input_placeholder_attribute($first_input);
     $middle_placeholder_attribute = GFCommon::get_input_placeholder_attribute($middle_input);
     $last_placeholder_attribute = GFCommon::get_input_placeholder_attribute($last_input);
     $suffix_placeholder_attribute = GFCommon::get_input_placeholder_attribute($suffix_input);
     switch ($this->nameFormat) {
         case 'advanced':
         case 'extended':
             $prefix_tabindex = GFCommon::get_tabindex();
             $first_tabindex = GFCommon::get_tabindex();
             $middle_tabindex = GFCommon::get_tabindex();
             $last_tabindex = GFCommon::get_tabindex();
             $suffix_tabindex = GFCommon::get_tabindex();
             $prefix_sub_label = rgar($prefix_input, 'customLabel') != '' ? $prefix_input['customLabel'] : apply_filters("gform_name_prefix_{$form_id}", apply_filters('gform_name_prefix', esc_html__('Prefix', 'gravityforms'), $form_id), $form_id);
             $first_name_sub_label = rgar($first_input, 'customLabel') != '' ? $first_input['customLabel'] : apply_filters("gform_name_first_{$form_id}", apply_filters('gform_name_first', esc_html__('First', 'gravityforms'), $form_id), $form_id);
             $middle_name_sub_label = rgar($middle_input, 'customLabel') != '' ? $middle_input['customLabel'] : apply_filters("gform_name_middle_{$form_id}", apply_filters('gform_name_middle', esc_html__('Middle', 'gravityforms'), $form_id), $form_id);
             $last_name_sub_label = rgar($last_input, 'customLabel') != '' ? $last_input['customLabel'] : apply_filters("gform_name_last_{$form_id}", apply_filters('gform_name_last', esc_html__('Last', 'gravityforms'), $form_id), $form_id);
             $suffix_sub_label = rgar($suffix_input, 'customLabel') != '' ? $suffix_input['customLabel'] : apply_filters("gform_name_suffix_{$form_id}", apply_filters('gform_name_suffix', esc_html__('Suffix', 'gravityforms'), $form_id), $form_id);
             $prefix_markup = '';
             $first_markup = '';
             $middle_markup = '';
             $last_markup = '';
             $suffix_markup = '';
             if ($is_sub_label_above) {
                 $style = $is_admin && rgar($prefix_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($prefix_input, 'isHidden')) {
                     $prefix_select_class = isset($prefix_input['choices']) && is_array($prefix_input['choices']) ? 'name_prefix_select' : '';
                     $prefix_markup = self::get_name_prefix_field($prefix_input, $id, $field_id, $prefix, $disabled_text, $prefix_tabindex);
                     $prefix_markup = "<span id='{$field_id}_2_container' class='name_prefix {$prefix_select_class}' {$style}>\n                                                    <label for='{$field_id}_2' {$sub_label_class_attribute}>{$prefix_sub_label}</label>\n                                                    {$prefix_markup}\n                                                  </span>";
                 }
                 $style = $is_admin && rgar($first_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($first_input, 'isHidden')) {
                     $first_markup = "<span id='{$field_id}_3_container' class='name_first' {$style}>\n                                                    <label for='{$field_id}_3' {$sub_label_class_attribute}>{$first_name_sub_label}</label>\n                                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$first}' {$first_tabindex} {$disabled_text} {$first_placeholder_attribute}/>\n                                                </span>";
                 }
                 $style = $is_admin && (!isset($middle_input['isHidden']) || rgar($middle_input, 'isHidden')) ? "style='display:none;'" : '';
                 if ($is_admin || isset($middle_input['isHidden']) && $middle_input['isHidden'] == false) {
                     $middle_markup = "<span id='{$field_id}_4_container' class='name_middle' {$style}>\n                                                    <label for='{$field_id}_4' {$sub_label_class_attribute}>{$middle_name_sub_label}</label>\n                                                    <input type='text' name='input_{$id}.4' id='{$field_id}_4' value='{$middle}' {$middle_tabindex} {$disabled_text} {$middle_placeholder_attribute}/>\n                                                </span>";
                 }
                 $style = $is_admin && rgar($last_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($last_input, 'isHidden')) {
                     $last_markup = "<span id='{$field_id}_6_container' class='name_last' {$style}>\n                                                            <label for='{$field_id}_6' {$sub_label_class_attribute}>{$last_name_sub_label}</label>\n                                                            <input type='text' name='input_{$id}.6' id='{$field_id}_6' value='{$last}' {$last_tabindex} {$disabled_text} {$last_placeholder_attribute}/>\n                                                        </span>";
                 }
                 $style = $is_admin && rgar($suffix_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($suffix_input, 'isHidden')) {
                     $suffix_select_class = isset($suffix_input['choices']) && is_array($suffix_input['choices']) ? 'name_suffix_select' : '';
                     $suffix_markup = "<span id='{$field_id}_8_container' class='name_suffix {$suffix_select_class}' {$style}>\n                                                        <label for='{$field_id}_8' {$sub_label_class_attribute}>{$suffix_sub_label}</label>\n                                                        <input type='text' name='input_{$id}.8' id='{$field_id}_8' value='{$suffix}' {$suffix_tabindex} {$disabled_text} {$suffix_placeholder_attribute}/>\n                                                    </span>";
                 }
             } else {
                 $style = $is_admin && rgar($prefix_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($prefix_input, 'isHidden')) {
                     $prefix_select_class = isset($prefix_input['choices']) && is_array($prefix_input['choices']) ? 'name_prefix_select' : '';
                     $prefix_markup = self::get_name_prefix_field($prefix_input, $id, $field_id, $prefix, $disabled_text, $prefix_tabindex);
                     $prefix_markup = "<span id='{$field_id}_2_container' class='name_prefix {$prefix_select_class}' {$style}>\n                                                    {$prefix_markup}\n                                                    <label for='{$field_id}_2' {$sub_label_class_attribute}>{$prefix_sub_label}</label>\n                                                  </span>";
                 }
                 $style = $is_admin && rgar($first_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($first_input, 'isHidden')) {
                     $first_markup = "<span id='{$field_id}_3_container' class='name_first' {$style}>\n                                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$first}' {$first_tabindex} {$disabled_text} {$first_placeholder_attribute}/>\n                                                    <label for='{$field_id}_3' {$sub_label_class_attribute}>{$first_name_sub_label}</label>\n                                                </span>";
                 }
                 $style = $is_admin && (!isset($middle_input['isHidden']) || rgar($middle_input, 'isHidden')) ? "style='display:none;'" : '';
                 if ($is_admin || isset($middle_input['isHidden']) && $middle_input['isHidden'] == false) {
                     $middle_markup = "<span id='{$field_id}_4_container' class='name_middle' {$style}>\n                                                    <input type='text' name='input_{$id}.4' id='{$field_id}_4' value='{$middle}' {$middle_tabindex} {$disabled_text} {$middle_placeholder_attribute}/>\n                                                    <label for='{$field_id}_4' {$sub_label_class_attribute}>{$middle_name_sub_label}</label>\n                                                </span>";
                 }
                 $style = $is_admin && rgar($last_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($last_input, 'isHidden')) {
                     $last_markup = "<span id='{$field_id}_6_container' class='name_last' {$style}>\n                                                    <input type='text' name='input_{$id}.6' id='{$field_id}_6' value='{$last}' {$last_tabindex} {$disabled_text} {$last_placeholder_attribute}/>\n                                                    <label for='{$field_id}_6' {$sub_label_class_attribute}>{$last_name_sub_label}</label>\n                                                </span>";
                 }
                 $style = $is_admin && rgar($suffix_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($suffix_input, 'isHidden')) {
                     $suffix_select_class = isset($suffix_input['choices']) && is_array($suffix_input['choices']) ? 'name_suffix_select' : '';
                     $suffix_markup = "<span id='{$field_id}_8_container' class='name_suffix {$suffix_select_class}' {$style}>\n                                                    <input type='text' name='input_{$id}.8' id='{$field_id}_8' value='{$suffix}' {$suffix_tabindex} {$disabled_text} {$suffix_placeholder_attribute}/>\n                                                    <label for='{$field_id}_8' {$sub_label_class_attribute}>{$suffix_sub_label}</label>\n                                                </span>";
                 }
             }
             $css_class = $this->get_css_class();
             return "<div class='ginput_complex{$class_suffix} ginput_container {$css_class}' id='{$field_id}'>\n                            {$prefix_markup}\n                            {$first_markup}\n                            {$middle_markup}\n                            {$last_markup}\n                            {$suffix_markup}\n                        </div>";
         case 'simple':
             $value = esc_attr($value);
             $class = esc_attr($class);
             $tabindex = GFCommon::get_tabindex();
             $placeholder_attribute = GFCommon::get_field_placeholder_attribute($this);
             return "<div class='ginput_container'>\n                                    <input name='input_{$id}' id='{$field_id}' type='text' value='{$value}' class='{$class}' {$tabindex} {$disabled_text} {$placeholder_attribute}/>\n                                </div>";
         default:
             $first_tabindex = GFCommon::get_tabindex();
             $last_tabindex = GFCommon::get_tabindex();
             $first_name_sub_label = rgar($first_input, 'customLabel') != '' ? $first_input['customLabel'] : apply_filters("gform_name_first_{$form_id}", apply_filters('gform_name_first', esc_html__('First', 'gravityforms'), $form_id), $form_id);
             $last_name_sub_label = rgar($last_input, 'customLabel') != '' ? $last_input['customLabel'] : apply_filters("gform_name_last_{$form_id}", apply_filters('gform_name_last', esc_html__('Last', 'gravityforms'), $form_id), $form_id);
             if ($is_sub_label_above) {
                 $first_markup = '';
                 $style = $is_admin && rgar($first_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($first_input, 'isHidden')) {
                     $first_markup = "<span id='{$field_id}_3_container' class='name_first' {$style}>\n                                                    <label for='{$field_id}_3' {$sub_label_class_attribute}>{$first_name_sub_label}</label>\n                                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$first}' {$first_tabindex} {$disabled_text} {$first_placeholder_attribute}/>\n                                                </span>";
                 }
                 $last_markup = '';
                 $style = $is_admin && rgar($last_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($last_input, 'isHidden')) {
                     $last_markup = "<span id='{$field_id}_6_container' class='name_last' {$style}>\n                                                <label for='{$field_id}_6' {$sub_label_class_attribute}>" . $last_name_sub_label . "</label>\n                                                <input type='text' name='input_{$id}.6' id='{$field_id}_6' value='{$last}' {$last_tabindex} {$disabled_text} {$last_placeholder_attribute}/>\n                                            </span>";
                 }
             } else {
                 $first_markup = '';
                 $style = $is_admin && rgar($first_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($first_input, 'isHidden')) {
                     $first_markup = "<span id='{$field_id}_3_container' class='name_first' {$style}>\n                                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$first}' {$first_tabindex} {$disabled_text} {$first_placeholder_attribute}/>\n                                                    <label for='{$field_id}_3' {$sub_label_class_attribute}>{$first_name_sub_label}</label>\n                                               </span>";
                 }
                 $last_markup = '';
                 $style = $is_admin && rgar($last_input, 'isHidden') ? "style='display:none;'" : '';
                 if ($is_admin || !rgar($last_input, 'isHidden')) {
                     $last_markup = "<span id='{$field_id}_6_container' class='name_last' {$style}>\n                                                    <input type='text' name='input_{$id}.6' id='{$field_id}_6' value='{$last}' {$last_tabindex} {$disabled_text} {$last_placeholder_attribute}/>\n                                                    <label for='{$field_id}_6' {$sub_label_class_attribute}>{$last_name_sub_label}</label>\n                                                </span>";
                 }
             }
             $css_class = $this->get_css_class();
             return "<div class='ginput_complex{$class_suffix} ginput_container {$css_class}' id='{$field_id}'>\n                            {$first_markup}\n                            {$last_markup}\n                            <div class='gf_clear gf_clear_complex'></div>\n                        </div>";
     }
 }
コード例 #17
0
ファイル: common.php プロジェクト: ipman3/Mediassociates-wp
 public static function get_field_input($field, $value = "", $lead_id = 0, $form_id = 0)
 {
     $id = $field["id"];
     $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
     $form_id = IS_ADMIN && empty($form_id) ? rgget("id") : $form_id;
     $size = rgar($field, "size");
     $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
     $class_suffix = RG_CURRENT_VIEW == "entry" ? "_admin" : "";
     $class = $size . $class_suffix;
     $currency = "";
     if (RG_CURRENT_VIEW == "entry") {
         $lead = RGFormsModel::get_lead($lead_id);
         $post_id = $lead["post_id"];
         $post_link = "";
         if (is_numeric($post_id) && self::is_post_field($field)) {
             $post_link = "You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.";
         }
         $currency = $lead["currency"];
     }
     $field_input = apply_filters("gform_field_input", "", $field, $value, $lead_id, $form_id);
     if ($field_input) {
         return $field_input;
     }
     //product fields are not editable
     if (RG_CURRENT_VIEW == "entry" && self::is_product_field($field["type"])) {
         return "<div class='ginput_container'>" . __("Product fields are not editable", "gravityforms") . "</div>";
     } else {
         if (RG_CURRENT_VIEW == "entry" && $field["type"] == "donation") {
             return "<div class='ginput_container'>" . __("Donations are not editable", "gravityforms") . "</div>";
         }
     }
     // add categories as choices for Post Category field
     if ($field['type'] == 'post_category') {
         $field = self::add_categories_as_choices($field, $value);
     }
     $max_length = "";
     $html5_attributes = "";
     switch (RGFormsModel::get_input_type($field)) {
         case "total":
             if (RG_CURRENT_VIEW == "entry") {
                 return "<div class='ginput_container'><input type='text' name='input_{$id}' value='{$value}' /></div>";
             } else {
                 return "<div class='ginput_container'><span class='ginput_total ginput_total_{$form_id}'>" . self::to_money("0") . "</span><input type='hidden' name='input_{$id}' id='{$field_id}' class='gform_hidden'/></div>";
             }
             break;
         case "calculation":
         case "singleproduct":
             $product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
             $price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
             $quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "";
             if (empty($price)) {
                 $price = 0;
             }
             $form = RGFormsModel::get_form_meta($form_id);
             $has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
             if ($has_quantity) {
                 $field["disableQuantity"] = true;
             }
             $quantity_field = "";
             if (IS_ADMIN) {
                 $style = rgget("disableQuantity", $field) ? "style='display:none;'" : "";
                 $quantity_field = " <span class='ginput_quantity_label' {$style}>" . apply_filters("gform_product_quantity_{$form_id}", apply_filters("gform_product_quantity", __("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' />";
             } else {
                 if (!rgget("disableQuantity", $field)) {
                     $tabindex = self::get_tabindex();
                     $quantity_field .= " <span class='ginput_quantity_label'>" . apply_filters("gform_product_quantity_{$form_id}", apply_filters("gform_product_quantity", __("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' {$tabindex}/>";
                 } else {
                     if (!is_numeric($quantity)) {
                         $quantity = 1;
                     }
                     if (!$has_quantity) {
                         $quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$field["id"]} gform_hidden' />";
                     }
                 }
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' /><span class='ginput_product_price_label'>" . apply_filters("gform_product_price_{$form_id}", apply_filters("gform_product_price", __("Price", "gravityforms"), $form_id), $form_id) . ":</span> <span class='ginput_product_price' id='{$field_id}'>" . esc_html(GFCommon::to_money($price, $currency)) . "</span><input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$field["id"]}' class='gform_hidden' value='" . esc_attr($price) . "'/>{$quantity_field}</div>";
             break;
         case "hiddenproduct":
             $form = RGFormsModel::get_form_meta($form_id);
             $has_quantity_field = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
             $product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
             $quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "1";
             $price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
             if (empty($price)) {
                 $price = 0;
             }
             $quantity_field = $has_quantity_field ? "" : "<input type='hidden' name='input_{$id}.3' value='" . esc_attr($quantity) . "' id='ginput_quantity_{$form_id}_{$field["id"]}' class='gform_hidden' />";
             $product_name_field = "<input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' />";
             $field_type = IS_ADMIN ? "text" : "hidden";
             return $quantity_field . $product_name_field . sprintf("<input name='input_%d.2' id='ginput_base_price_{$form_id}_{$field["id"]}' type='{$field_type}' value='%s' class='gform_hidden ginput_amount' %s/>", $id, esc_attr($price), $disabled_text);
             break;
         case "singleshipping":
             $price = !empty($value) ? $value : rgget("basePrice", $field);
             if (empty($price)) {
                 $price = 0;
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}' value='{$price}' class='gform_hidden'/><span class='ginput_shipping_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span></div>";
             break;
         case "website":
             $is_html5 = RGFormsModel::is_html5_enabled();
             $value = empty($value) && !$is_html5 ? "http://" : $value;
             $html_input_type = $is_html5 ? "url" : "text";
             $html5_attributes = $is_html5 ? "placeholder='http://'" : "";
         case "text":
             if (empty($html_input_type)) {
                 $html_input_type = "text";
             }
             if (rgget("enablePasswordInput", $field) && RG_CURRENT_VIEW != "entry") {
                 $html_input_type = "password";
             }
             if (is_numeric(rgget("maxLength", $field))) {
                 $max_length = "maxlength='{$field["maxLength"]}'";
             }
             if (!empty($post_link)) {
                 return $post_link;
             }
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$logic_event} {$html5_attributes} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "email":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $html_input_type = RGFormsModel::is_html5_enabled() ? "email" : "text";
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $single_style = rgget("emailConfirmEnabled", $field) ? "style='display:none;'" : "";
                 $confirm_style = rgget("emailConfirmEnabled", $field) ? "" : "style='display:none;'";
                 return "<div class='ginput_container ginput_single_email' {$single_style}><input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' /></div><div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' /><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' /><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
             } else {
                 $logic_event = self::get_logic_event($field, "keyup");
                 if (rgget("emailConfirmEnabled", $field) && RG_CURRENT_VIEW != "entry") {
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return "<div class='ginput_complex ginput_container' id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . esc_attr($value) . "' {$first_tabindex} {$logic_event} {$disabled_text}/><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . esc_attr(rgpost("input_" . $id . "_2")) . "' {$last_tabindex} {$disabled_text}/><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
                 } else {
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} {$logic_event} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
                 }
             }
             break;
         case "honeypot":
             $autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : "";
             return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value='' {$autocomplete}/></div>";
             break;
         case "hidden":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $field_type = IS_ADMIN ? "text" : "hidden";
             $class_attribute = IS_ADMIN ? "" : "class='gform_hidden'";
             return sprintf("<input name='input_%d' id='%s' type='{$field_type}' {$class_attribute} value='%s' %s/>", $id, $field_id, esc_attr($value), $disabled_text);
             break;
         case "html":
             $content = IS_ADMIN ? "<img class='gfield_html_block' src='" . self::get_base_url() . "/images/gf_html_admin_placeholder.jpg' alt='HTML Block'/>" : $field["content"];
             $content = GFCommon::replace_variables_prepopulate($content);
             //adding support for merge tags
             $content = do_shortcode($content);
             //adding support for shortcodes
             return $content;
             break;
         case "adminonly_hidden":
             if (!is_array($field["inputs"])) {
                 return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, $field_id, esc_attr($value));
             }
             $fields = "";
             foreach ($field["inputs"] as $input) {
                 $fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input["id"], esc_attr(rgar($value, $input["id"])));
             }
             return $fields;
             break;
         case "number":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = "";
             $read_only = "";
             if (!IS_ADMIN) {
                 if (GFCommon::has_field_calculation($field)) {
                     // calculation-enabled fields should be read only
                     $read_only = 'readonly="readonly"';
                 } else {
                     $message = self::get_range_message($field);
                     $validation_class = $field["failed_validation"] ? "validation_message" : "";
                     if (!$field["failed_validation"] && !empty($message) && empty($field["errorMessage"])) {
                         $instruction = "<div class='instruction {$validation_class}'>" . $message . "</div>";
                     }
                 }
             }
             $is_html5 = RGFormsModel::is_html5_enabled();
             $html_input_type = $is_html5 && !GFCommon::has_field_calculation($field) ? "number" : "text";
             // chrome does not allow number fields to have commas, calculations display numbers with commas
             $step_attr = $is_html5 ? "step='any'" : "";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' {$step_attr} value='%s' class='%s' {$tabindex} {$logic_event} {$read_only} %s/>%s</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text, $instruction);
         case "donation":
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_donation_amount' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "price":
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_amount' {$tabindex} {$logic_event} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "phone":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = $field["phoneFormat"] == "standard" ? __("Phone format:", "gravityforms") . " (###)###-####" : "";
             $instruction_div = rgget("failed_validation", $field) ? "<div class='instruction validation_message'>{$instruction}</div>" : "";
             $html_input_type = RGFormsModel::is_html5_enabled() ? "tel" : "text";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} {$logic_event} %s/>{$instruction_div}</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "textarea":
             $max_chars = "";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} {$logic_event} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
         case "post_title":
         case "post_tags":
         case "post_custom_field":
             $tabindex = self::get_tabindex();
             $logic_event = self::get_logic_event($field, "keyup");
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} {$logic_event} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "post_content":
         case "post_excerpt":
             $max_chars = "";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} {$logic_event} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
             break;
         case "post_category":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if (rgget("displayAllCategories", $field) && !IS_ADMIN) {
                 $default_category = rgget("categoryInitialItemEnabled", $field) ? "-1" : get_option('default_category');
                 $selected = empty($value) ? $default_category : $value;
                 $args = array('echo' => 0, 'selected' => $selected, "class" => esc_attr($class) . " gfield_select", 'hide_empty' => 0, 'name' => "input_{$id}", 'orderby' => 'name', 'hierarchical' => true);
                 if (self::$tab_index > 0) {
                     $args["tab_index"] = self::$tab_index++;
                 }
                 if (rgget("categoryInitialItemEnabled", $field)) {
                     $args["show_option_none"] = empty($field["categoryInitialItem"]) ? " " : $field["categoryInitialItem"];
                 }
                 return "<div class='ginput_container'>" . wp_dropdown_categories($args) . "</div>";
             } else {
                 $tabindex = self::get_tabindex();
                 if (is_array(rgar($field, "choices"))) {
                     usort($field["choices"], create_function('$a,$b', 'return strcmp($a["text"], $b["text"]);'));
                 }
                 $choices = self::get_select_choices($field, $value);
                 //Adding first option
                 if (rgget("categoryInitialItemEnabled", $field)) {
                     $selected = empty($value) ? "selected='selected'" : "";
                     $choices = "<option value='-1' {$selected}>{$field["categoryInitialItem"]}</option>" . $choices;
                 }
                 return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' class='%s gfield_select' {$tabindex} %s>%s</select></div>", $id, $field_id, esc_attr($class), $disabled_text, $choices);
             }
             break;
         case "post_image":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $title = esc_attr(rgget($field["id"] . ".1", $value));
             $caption = esc_attr(rgget($field["id"] . ".4", $value));
             $description = esc_attr(rgget($field["id"] . ".7", $value));
             //hidding meta fields for admin
             $hidden_style = "style='display:none;'";
             $title_style = !rgget("displayTitle", $field) && IS_ADMIN ? $hidden_style : "";
             $caption_style = !rgget("displayCaption", $field) && IS_ADMIN ? $hidden_style : "";
             $description_style = !rgget("displayDescription", $field) && IS_ADMIN ? $hidden_style : "";
             $file_label_style = IS_ADMIN && !(rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field)) ? $hidden_style : "";
             $hidden_class = $preview = "";
             $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
             if ($file_info) {
                 $hidden_class = " gform_hidden";
                 $file_label_style = $hidden_style;
                 $preview = "<span class='ginput_preview'><strong>" . esc_html($file_info["uploaded_filename"]) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
             }
             //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
             $file_label = IS_ADMIN || rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field) ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . apply_filters("gform_postimage_file_{$form_id}", apply_filters("gform_postimage_file", __("File", "gravityforms"), $form_id), $form_id) . "</label>" : "";
             $tabindex = self::get_tabindex();
             $upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
             $tabindex = self::get_tabindex();
             $title_field = rgget("displayTitle", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . apply_filters("gform_postimage_title_{$form_id}", apply_filters("gform_postimage_title", __("Title", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $title, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $caption_field = rgget("displayCaption", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s_4' value='%s' {$tabindex} %s/><label for='%s_4'>" . apply_filters("gform_postimage_caption_{$form_id}", apply_filters("gform_postimage_caption", __("Caption", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $caption, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $description_field = rgget("displayDescription", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s_7' value='%s' {$tabindex} %s/><label for='%s_7'>" . apply_filters("gform_postimage_description_{$form_id}", apply_filters("gform_postimage_description", __("Description", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $description, $disabled_text, $field_id) : "";
             return "<div class='ginput_complex{$class_suffix} ginput_container'>" . $upload . $title_field . $caption_field . $description_field . "</div>";
             break;
         case "multiselect":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $placeholder = rgar($field, "enableEnhancedUI") ? "data-placeholder='" . esc_attr(apply_filters("gform_multiselect_placeholder_{$form_id}", apply_filters("gform_multiselect_placeholder", __("Click to select...", "gravityforms"), $form_id), $form_id)) . "'" : "";
             $logic_event = self::get_logic_event($field, "keyup");
             $css_class = trim(esc_attr($class) . " gfield_select");
             $size = rgar($field, "multiSelectSize");
             if (empty($size)) {
                 $size = 7;
             }
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select multiple='multiple' {$placeholder} size='{$size}' name='input_%d[]' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
             break;
         case "select":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $logic_event = self::get_logic_event($field, "change");
             $css_class = trim(esc_attr($class) . " gfield_select");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
         case "checkbox":
             if (!empty($post_link)) {
                 return $post_link;
             }
             return sprintf("<div class='ginput_container'><ul class='gfield_checkbox' id='%s'>%s</ul></div>", $field_id, self::get_checkbox_choices($field, $value, $disabled_text));
         case "radio":
             if (!empty($post_link)) {
                 return $post_link;
             }
             return sprintf("<div class='ginput_container'><ul class='gfield_radio' id='%s'>%s</ul></div>", $field_id, self::get_radio_choices($field, $value, $disabled_text));
         case "password":
             $first_tabindex = self::get_tabindex();
             $last_tabindex = self::get_tabindex();
             $strength_style = !rgar($field, "passwordStrengthEnabled") ? "style='display:none;'" : "";
             $strength = rgar($field, "passwordStrengthEnabled") || IS_ADMIN ? "<div id='{$field_id}_strength_indicator' class='gfield_password_strength' {$strength_style}>" . __("Strength indicator", "gravityforms") . "</div><input type='hidden' class='gform_hidden' id='{$field_id}_strength' name='input_{$id}_strength' />" : "";
             $action = !IS_ADMIN ? "gformShowPasswordStrength(\"{$field_id}\");" : "";
             $onchange = rgar($field, "passwordStrengthEnabled") ? "onchange='{$action}'" : "";
             $onkeyup = rgar($field, "passwordStrengthEnabled") ? "onkeyup='{$action}'" : "";
             $pass = RGForms::post("input_" . $id . "_2");
             return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}_container'><span id='" . $field_id . "_1_container' class='ginput_left'><input type='password' name='input_%d' id='%s' {$onkeyup} {$onchange} value='%s' {$first_tabindex} %s/><label for='%s'>" . apply_filters("gform_password_{$form_id}", apply_filters("gform_password", __("Enter Password", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_2_container' class='ginput_right'><input type='password' name='input_%d_2' id='%s_2' {$onkeyup} {$onchange} value='%s' {$last_tabindex} %s/><label for='%s_2'>" . apply_filters("gform_password_confirm_{$form_id}", apply_filters("gform_password_confirm", __("Confirm Password", "gravityforms"), $form_id), $form_id) . "</label></span></div>{$strength}", $id, $field_id, esc_attr($value), $disabled_text, $field_id, $id, $field_id, esc_attr($pass), $disabled_text, $field_id);
         case "name":
             $prefix = "";
             $first = "";
             $last = "";
             $suffix = "";
             if (is_array($value)) {
                 $prefix = esc_attr(RGForms::get($field["id"] . ".2", $value));
                 $first = esc_attr(RGForms::get($field["id"] . ".3", $value));
                 $last = esc_attr(RGForms::get($field["id"] . ".6", $value));
                 $suffix = esc_attr(RGForms::get($field["id"] . ".8", $value));
             }
             switch (rgget("nameFormat", $field)) {
                 case "extended":
                     $prefix_tabindex = self::get_tabindex();
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     $suffix_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_2_container' class='name_prefix'><input type='text' name='input_%d.2' id='%s_2' value='%s' {$prefix_tabindex} %s/><label for='%s_2'>" . apply_filters("gform_name_prefix_{$form_id}", apply_filters("gform_name_prefix", __("Prefix", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_3_container' class='name_first'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$first_tabindex} %s/><label for='%s_3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='name_last'><input type='text' name='input_%d.6' id='%s_6' value='%s' {$last_tabindex} %s/><label for='%s_6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_8_container' class='name_suffix'><input type='text' name='input_%d.8' id='%s_8' value='%s' {$suffix_tabindex} %s/><label for='%s_8'>" . apply_filters("gform_name_suffix_{$form_id}", apply_filters("gform_name_suffix", __("Suffix", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $prefix, $disabled_text, $field_id, $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id, $id, $field_id, $suffix, $disabled_text, $field_id);
                 case "simple":
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
                 default:
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_3_container' class='ginput_left'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$first_tabindex} %s/><label for='%s_3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='ginput_right'><input type='text' name='input_%d.6' id='%s_6' value='%s' {$last_tabindex} %s/><label for='%s_6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id);
             }
         case "address":
             $street_value = "";
             $street2_value = "";
             $city_value = "";
             $state_value = "";
             $zip_value = "";
             $country_value = "";
             if (is_array($value)) {
                 $street_value = esc_attr(rgget($field["id"] . ".1", $value));
                 $street2_value = esc_attr(rgget($field["id"] . ".2", $value));
                 $city_value = esc_attr(rgget($field["id"] . ".3", $value));
                 $state_value = esc_attr(rgget($field["id"] . ".4", $value));
                 $zip_value = esc_attr(rgget($field["id"] . ".5", $value));
                 $country_value = esc_attr(rgget($field["id"] . ".6", $value));
             }
             $address_types = self::get_address_types($form_id);
             $addr_type = empty($field["addressType"]) ? "international" : $field["addressType"];
             $address_type = $address_types[$addr_type];
             $state_label = empty($address_type["state_label"]) ? __("State", "gravityforms") : $address_type["state_label"];
             $zip_label = empty($address_type["zip_label"]) ? __("Zip Code", "gravityforms") : $address_type["zip_label"];
             $hide_country = !empty($address_type["country"]) || rgget("hideCountry", $field);
             if (empty($country_value)) {
                 $country_value = rgget("defaultCountry", $field);
             }
             if (empty($state_value)) {
                 $state_value = rgget("defaultState", $field);
             }
             $country_list = self::get_country_dropdown($country_value);
             //changing css classes based on field format to ensure proper display
             $address_display_format = apply_filters("gform_address_display_format", "default");
             $city_location = $address_display_format == "zip_before_city" ? "right" : "left";
             $zip_location = $address_display_format != "zip_before_city" && rgar($field, "hideState") ? "right" : "left";
             $state_location = $address_display_format == "zip_before_city" ? "left" : "right";
             $country_location = rgar($field, "hideState") ? "left" : "right";
             //address field
             $tabindex = self::get_tabindex();
             $street_address = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_1_container'><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1' id='" . $field_id . "_1_label'>" . apply_filters("gform_address_street_{$form_id}", apply_filters("gform_address_street", __("Street Address", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street_value, $disabled_text, $field_id);
             //address line 2 field
             $street_address2 = "";
             $style = IS_ADMIN && rgget("hideAddress2", $field) ? "style='display:none;'" : "";
             if (IS_ADMIN || !rgget("hideAddress2", $field)) {
                 $tabindex = self::get_tabindex();
                 $street_address2 = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_2_container' {$style}><input type='text' name='input_%d.2' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2' id='" . $field_id . "_2_label'>" . apply_filters("gform_address_street2_{$form_id}", apply_filters("gform_address_street2", __("Address Line 2", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street2_value, $disabled_text, $field_id);
             }
             if ($address_display_format == "zip_before_city") {
                 //zip field
                 $tabindex = self::get_tabindex();
                 $zip = sprintf("<span class='ginput_{$zip_location}{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip_{$form_id}", apply_filters("gform_address_zip", $zip_label, $form_id), $form_id) . "</label></span>", $id, $field_id, $zip_value, $disabled_text, $field_id);
                 //city field
                 $tabindex = self::get_tabindex();
                 $city = sprintf("<span class='ginput_{$city_location}{$class_suffix}' id='" . $field_id . "_3_container'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3' id='{$field_id}.3_label'>" . apply_filters("gform_address_city_{$form_id}", apply_filters("gform_address_city", __("City", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $city_value, $disabled_text, $field_id);
                 //state field
                 $style = IS_ADMIN && rgget("hideState", $field) ? "style='display:none;'" : "";
                 if (IS_ADMIN || !rgget("hideState", $field)) {
                     $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text, $form_id);
                     $state = sprintf("<span class='ginput_{$state_location}{$class_suffix}' id='" . $field_id . "_4_container' {$style}>{$state_field}<label for='%s_4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state_{$form_id}", apply_filters("gform_address_state", $state_label, $form_id), $form_id) . "</label></span>", $field_id);
                 } else {
                     $state = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.4' id='%s_4' value='%s'/>", $id, $field_id, $state_value);
                 }
             } else {
                 //city field
                 $tabindex = self::get_tabindex();
                 $city = sprintf("<span class='ginput_{$city_location}{$class_suffix}' id='" . $field_id . "_3_container'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3' id='{$field_id}.3_label'>" . apply_filters("gform_address_city_{$form_id}", apply_filters("gform_address_city", __("City", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $city_value, $disabled_text, $field_id);
                 //state field
                 $style = IS_ADMIN && rgget("hideState", $field) ? "style='display:none;'" : "";
                 if (IS_ADMIN || !rgget("hideState", $field)) {
                     $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text, $form_id);
                     $state = sprintf("<span class='ginput_{$state_location}{$class_suffix}' id='" . $field_id . "_4_container' {$style}>{$state_field}<label for='%s_4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state_{$form_id}", apply_filters("gform_address_state", $state_label, $form_id), $form_id) . "</label></span>", $field_id);
                 } else {
                     $state = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.4' id='%s_4' value='%s'/>", $id, $field_id, $state_value);
                 }
                 //zip field
                 $tabindex = self::get_tabindex();
                 $zip = sprintf("<span class='ginput_{$zip_location}{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip_{$form_id}", apply_filters("gform_address_zip", $zip_label, $form_id), $form_id) . "</label></span>", $id, $field_id, $zip_value, $disabled_text, $field_id);
             }
             if (IS_ADMIN || !$hide_country) {
                 $style = $hide_country ? "style='display:none;'" : "";
                 $tabindex = self::get_tabindex();
                 $country = sprintf("<span class='ginput_{$country_location}{$class_suffix}' id='" . $field_id . "_6_container' {$style}><select name='input_%d.6' id='%s_6' {$tabindex} %s>%s</select><label for='%s_6' id='" . $field_id . "_6_label'>" . apply_filters("gform_address_country_{$form_id}", apply_filters("gform_address_country", __("Country", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $disabled_text, $country_list, $field_id);
             } else {
                 $country = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.6' id='%s_6' value='%s'/>", $id, $field_id, $country_value);
             }
             $inputs = $address_display_format == "zip_before_city" ? $street_address . $street_address2 . $zip . $city . $state . $country : $street_address . $street_address2 . $city . $state . $zip . $country;
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $inputs . "</div>";
         case "date":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $format = empty($field["dateFormat"]) ? "mdy" : esc_attr($field["dateFormat"]);
             $field_position = substr($format, 0, 3);
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $datepicker_display = in_array(rgget("dateType", $field), array("datefield", "datedropdown")) ? "none" : "inline";
                 $datefield_display = rgget("dateType", $field) == "datefield" ? "inline" : "none";
                 $dropdown_display = rgget("dateType", $field) == "datedropdown" ? "inline" : "none";
                 $icon_display = rgget("calendarIconType", $field) == "calendar" ? "inline" : "none";
                 $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$datefield_display}'><input name='ginput_month' type='text' disabled='disabled'/><label>" . __("MM", "gravityforms") . "</label></div>";
                 $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$datefield_display}'><input name='ginput_day' type='text' disabled='disabled'/><label>" . __("DD", "gravityforms") . "</label></div>";
                 $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$datefield_display}'><input type='text' name='ginput_year' disabled='disabled'/><label>" . __("YYYY", "gravityforms") . "</label></div>";
                 $month_dropdown = "<div class='gfield_date_dropdown_month ginput_date_dropdown' id='gfield_dropdown_date_month' style='display:{$dropdown_display}'>" . self::get_month_dropdown("", "", "", "", "disabled='disabled'") . "</div>";
                 $day_dropdown = "<div class='gfield_date_dropdown_day ginput_date_dropdown' id='gfield_dropdown_date_day' style='display:{$dropdown_display}'>" . self::get_day_dropdown("", "", "", "", "disabled='disabled'") . "</div>";
                 $year_dropdown = "<div class='gfield_date_dropdown_year ginput_date_dropdown' id='gfield_dropdown_date_year' style='display:{$dropdown_display}'>" . self::get_year_dropdown("", "", "", "", "disabled='disabled'") . "</div>";
                 $field_string = "<div class='ginput_container' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' /><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
                 switch ($field_position) {
                     case "dmy":
                         $field_string .= $day_field . $month_field . $year_field . $day_dropdown . $month_dropdown . $year_dropdown;
                         break;
                     case "ymd":
                         $field_string .= $year_field . $month_field . $day_field . $year_dropdown . $month_dropdown . $day_dropdown;
                         break;
                     default:
                         $field_string .= $month_field . $day_field . $year_field . $month_dropdown . $day_dropdown . $year_dropdown;
                         break;
                 }
                 return $field_string;
             } else {
                 $date_info = self::parse_date($value, $format);
                 $date_type = rgget("dateType", $field);
                 if (in_array($date_type, array("datefield", "datedropdown"))) {
                     switch ($field_position) {
                         case "dmy":
                             $tabindex = self::get_tabindex();
                             $field_str = $date_type == "datedropdown" ? "<div class='clear-multi'><div class='gfield_date_dropdown_day ginput_container' id='{$field_id}'>" . self::get_day_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "day"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='clear-multi'><div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgget("day", $date_info), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_month ginput_container' id='{$field_id}'>" . self::get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "month"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgget("month", $date_info), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_year ginput_container' id='{$field_id}'>" . self::get_year_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "year"), $tabindex, $disabled_text) . "</div></div>" : sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, rgget("year", $date_info), $disabled_text, $field_id);
                             break;
                         case "ymd":
                             $tabindex = self::get_tabindex();
                             $field_str = $date_type == "datedropdown" ? "<div class='clear-multi'><div class='gfield_date_dropdown_year ginput_container' id='{$field_id}'>" . self::get_year_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "year"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='clear-multi'><div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3'>" . __("YYYY", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgget("year", $date_info), $disabled_text, $field_id);
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_month ginput_container' id='{$field_id}'>" . self::get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "month"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgar($date_info, "month"), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_day ginput_container' id='{$field_id}'>" . self::get_day_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "day"), $tabindex, $disabled_text) . "</div></div>" : sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2'>" . __("DD", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, rgar($date_info, "day"), $disabled_text, $field_id);
                             break;
                         default:
                             $tabindex = self::get_tabindex();
                             $field_str = $date_type == "datedropdown" ? "<div class='clear-multi'><div class='gfield_date_dropdown_month ginput_container' id='{$field_id}'>" . self::get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "month"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='clear-multi'><div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgar($date_info, "month"), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_day ginput_container' id='{$field_id}'>" . self::get_day_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "day"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgar($date_info, "day"), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_year ginput_container' id='{$field_id}'>" . self::get_year_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "year"), $tabindex, $disabled_text) . "</div></div>" : sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, rgget("year", $date_info), $disabled_text, $field_id);
                             break;
                     }
                     return $field_str;
                 } else {
                     $value = GFCommon::date_display($value, $format);
                     $icon_class = $field["calendarIconType"] == "none" ? "datepicker_no_icon" : "datepicker_with_icon";
                     $icon_url = empty($field["calendarIconUrl"]) ? GFCommon::get_base_url() . "/images/calendar.png" : $field["calendarIconUrl"];
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='datepicker %s %s %s' {$tabindex} %s/> </div><input type='hidden' id='gforms_calendar_icon_{$field_id}' class='gform_hidden' value='{$icon_url}'/>", $id, $field_id, esc_attr($value), esc_attr($class), $format, $icon_class, $disabled_text);
                 }
             }
         case "time":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $hour = $minute = $am_selected = $pm_selected = "";
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
                 $hour = esc_attr($matches[1]);
                 $minute = esc_attr($matches[2]);
                 $am_selected = rgar($matches, 3) == "am" ? "selected='selected'" : "";
                 $pm_selected = rgar($matches, 3) == "pm" ? "selected='selected'" : "";
             } else {
                 if (is_array($value)) {
                     $hour = esc_attr($value[0]);
                     $minute = esc_attr($value[1]);
                     $am_selected = rgar($value, 2) == "am" ? "selected='selected'" : "";
                     $pm_selected = rgar($value, 2) == "pm" ? "selected='selected'" : "";
                 }
             }
             $hour_tabindex = self::get_tabindex();
             $minute_tabindex = self::get_tabindex();
             $ampm_tabindex = self::get_tabindex();
             $ampm_field_style = is_admin() && rgar($field, "timeFormat") == "24" ? "style='display:none;'" : "";
             $ampm_field = is_admin() || rgar($field, "timeFormat") != "24" ? "<div class='gfield_time_ampm ginput_container' {$ampm_field_style}><select name='input_{$id}[]' id='{$field_id}_3' {$ampm_tabindex} {$disabled_text}><option value='am' {$am_selected}>" . __("AM", "gravityforms") . "</option><option value='pm' {$pm_selected}>" . __("PM", "gravityforms") . "</option></select></div>" : "";
             return sprintf("<div class='clear-multi'><div class='gfield_time_hour ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$hour_tabindex} %s/> : <label for='%s_1'>" . __("HH", "gravityforms") . "</label></div><div class='gfield_time_minute ginput_container'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$minute_tabindex} %s/><label for='%s_2'>" . __("MM", "gravityforms") . "</label></div>{$ampm_field}</div>", $field_id, $id, $field_id, $hour, $disabled_text, $field_id, $id, $field_id, $minute, $disabled_text, $field_id);
         case "fileupload":
             $tabindex = self::get_tabindex();
             $upload = sprintf("<input name='input_%d' id='%s' type='file' value='%s' size='20' class='%s' {$tabindex} %s/>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             if (IS_ADMIN && !empty($value)) {
                 $value = esc_attr($value);
                 $preview = sprintf("<div id='preview_%d'><a href='%s' target='_blank' alt='%s' title='%s'>%s</a><a href='%s' target='_blank' alt='" . __("Download file", "gravityforms") . "' title='" . __("Download file", "gravityforms") . "'><img src='%s' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='" . __("Delete file", "gravityforms") . "' title='" . __("Delete file", "gravityforms") . "' onclick='DeleteFile(%d,%d);' ><img src='%s' style='margin-left:10px;'/></a></div>", $id, $value, $value, $value, GFCommon::truncate_url($value), $value, GFCommon::get_base_url() . "/images/download.png", $lead_id, $id, GFCommon::get_base_url() . "/images/delete.png");
                 return $preview . "<div id='upload_{$id}' style='display:none;'>{$upload}</div>";
             } else {
                 $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
                 if ($file_info && !$field["failed_validation"]) {
                     $preview = "<span class='ginput_preview'><strong>" . esc_html($file_info["uploaded_filename"]) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
                     return "<div class='ginput_container'>" . str_replace(" class='", " class='gform_hidden ", $upload) . " {$preview}</div>";
                 } else {
                     return "<div class='ginput_container'>{$upload}</div>";
                 }
             }
         case "captcha":
             switch (rgget("captchaType", $field)) {
                 case "simple_captcha":
                     $size = rgempty("simpleCaptchaSize", $field) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha = self::get_captcha($field);
                     $tabindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='" . rgar($captcha, "width") . "' height='" . rgar($captcha, "height") . "'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='" . rgar($captcha, "url") . "' alt='' {$dimensions} /><div class='gfield_captcha_input_container simple_captcha_{$size}'><input type='text' name='input_{$id}' id='{$field_id}' {$tabindex}/><input type='hidden' name='input_captcha_prefix_{$id}' value='" . rgar($captcha, "prefix") . "' /></div></div>";
                     break;
                 case "math":
                     $size = empty($field["simpleCaptchaSize"]) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha_1 = self::get_math_captcha($field, 1);
                     $captcha_2 = self::get_math_captcha($field, 2);
                     $captcha_3 = self::get_math_captcha($field, 3);
                     $tabindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='{$captcha_1["width"]}' height='{$captcha_1["height"]}'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='{$captcha_1["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_2["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_3["url"]}' alt='' {$dimensions} /><div class='gfield_captcha_input_container math_{$size}'><input type='text' name='input_{$id}' id='input_{$field_id}' {$tabindex}/><input type='hidden' name='input_captcha_prefix_{$id}' value='{$captcha_1["prefix"]},{$captcha_2["prefix"]},{$captcha_3["prefix"]}' /></div></div>";
                     break;
                 default:
                     if (!function_exists("recaptcha_get_html")) {
                         require_once GFCommon::get_base_path() . '/recaptchalib.php';
                     }
                     $theme = empty($field["captchaTheme"]) ? "red" : esc_attr($field["captchaTheme"]);
                     $publickey = get_option("rg_gforms_captcha_public_key");
                     $privatekey = get_option("rg_gforms_captcha_private_key");
                     if (IS_ADMIN) {
                         if (empty($publickey) || empty($privatekey)) {
                             return "<div class='captcha_message'>" . __("To use the reCaptcha field you must first do the following:", "gravityforms") . "</div><div class='captcha_message'>1 - <a href='http://www.google.com/recaptcha/whyrecaptcha' target='_blank'>" . sprintf(__("Sign up%s for a free reCAPTCHA account", "gravityforms"), "</a>") . "</div><div class='captcha_message'>2 - " . sprintf(__("Enter your reCAPTCHA keys in the %ssettings page%s", "gravityforms"), "<a href='?page=gf_settings'>", "</a>") . "</div>";
                         } else {
                             return "<div class='ginput_container'><img class='gfield_captcha' src='" . GFCommon::get_base_url() . "/images/captcha_{$theme}.jpg' alt='reCAPTCHA' title='reCAPTCHA'/></div>";
                         }
                     } else {
                         $language = empty($field["captchaLanguage"]) ? "en" : esc_attr($field["captchaLanguage"]);
                         $options = "<script type='text/javascript'>" . apply_filters("gform_cdata_open", "") . " var RecaptchaOptions = {theme : '{$theme}'}; if(parseInt('" . self::$tab_index . "') > 0) {RecaptchaOptions.tabindex = " . self::$tab_index++ . ";}" . apply_filters("gform_recaptcha_init_script", "", $form_id, $field) . apply_filters("gform_cdata_close", "") . "</script>";
                         $is_ssl = !empty($_SERVER['HTTPS']);
                         return $options . "<div class='ginput_container' id='{$field_id}'>" . recaptcha_get_html($publickey, null, $is_ssl, $language) . "</div>";
                     }
             }
             break;
         case "creditcard":
             $card_number = "";
             $card_name = "";
             $expiration_date = "";
             $expiration_month = "";
             $expiration_year = "";
             $security_code = "";
             if (is_array($value)) {
                 $card_number = esc_attr(rgget($field["id"] . ".1", $value));
                 $card_name = esc_attr(rgget($field["id"] . ".5", $value));
                 $expiration_date = rgget($field["id"] . ".2", $value);
                 if (!is_array($expiration_date) && !empty($expiration_date)) {
                     $expiration_date = explode("/", $expiration_date);
                 }
                 if (is_array($expiration_date) && count($expiration_date) == 2) {
                     $expiration_month = $expiration_date[0];
                     $expiration_year = $expiration_date[1];
                 }
                 $security_code = esc_attr(rgget($field["id"] . ".3", $value));
             }
             $action = !IS_ADMIN ? "gformMatchCard(\"{$field_id}_1\");" : "";
             $onchange = "onchange='{$action}'";
             $onkeyup = "onkeyup='{$action}'";
             $card_icons = '';
             $cards = GFCommon::get_card_types();
             $card_style = rgar($field, 'creditCardStyle') ? rgar($field, 'creditCardStyle') : 'style1';
             foreach ($cards as $card) {
                 $style = "";
                 if (self::is_card_supported($field, $card["slug"])) {
                     $print_card = true;
                 } else {
                     if (IS_ADMIN) {
                         $print_card = true;
                         $style = "style='display:none;'";
                     } else {
                         $print_card = false;
                     }
                 }
                 if ($print_card) {
                     $card_icons .= "<div class='gform_card_icon gform_card_icon_{$card['slug']}' {$style}>{$card['name']}</div>";
                 }
             }
             $card_icons = "<div class='gform_card_icon_container gform_card_icon_{$card_style}'>{$card_icons}</div>";
             //card number fields
             $tabindex = self::get_tabindex();
             $card_field = sprintf("<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container'>{$card_icons}<input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s {$onchange} {$onkeyup} /><label for='%s_1' id='{$field_id}_1_label'>" . apply_filters("gform_card_number_{$form_id}", apply_filters("gform_card_number", __("Card Number", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $card_number, $disabled_text, $field_id);
             //expiration date field
             $expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>" . "<span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_container'>" . "<span class='ginput_card_expiration_container'>" . "<select name='input_{$id}.2[]' id='{$field_id}_2_month' " . self::get_tabindex() . " {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>" . self::get_expiration_months($expiration_month) . "</select>" . "<select name='input_{$id}.2[]' id='{$field_id}_2_year' " . self::get_tabindex() . " {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>" . self::get_expiration_years($expiration_year) . "</select>" . "<label for='{$field_id}_2_month' >" . apply_filters("gform_card_expiration_{$form_id}", apply_filters("gform_card_expiration", __("Expiration Date", "gravityforms"), $form_id), $form_id) . "</label>" . "</span>" . "</span>";
             //security code field
             $tabindex = self::get_tabindex();
             $security_field = "<span class='ginput_cardinfo_right{$class_suffix}' id='{$field_id}_2_container'>" . "<input type='text' name='input_{$id}.3' id='{$field_id}_3' {$tabindex} {$disabled_text} class='ginput_card_security_code' value='{$security_code}' />" . "<span class='ginput_card_security_code_icon'>&nbsp;</span>" . "<label for='{$field_id}_3' >" . apply_filters("gform_card_security_code_{$form_id}", apply_filters("gform_card_security_code", __("Security Code", "gravityforms"), $form_id), $form_id) . "</label>" . "</span>" . "</span>";
             $tabindex = self::get_tabindex();
             $card_name_field = sprintf("<span class='ginput_full{$class_suffix}' id='{$field_id}_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s /><label for='%s_5' id='{$field_id}_5_label'>" . apply_filters("gform_card_name_{$form_id}", apply_filters("gform_card_name", __("Cardholder Name", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $card_name, $disabled_text, $field_id);
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $card_field . $expiration_field . $security_field . $card_name_field . " </div>";
             break;
         case "list":
             if (!empty($value)) {
                 $value = maybe_unserialize($value);
             }
             if (!is_array($value)) {
                 $value = array(array());
             }
             $has_columns = is_array(rgar($field, "choices"));
             $columns = $has_columns ? rgar($field, "choices") : array(array());
             $list = "<div class='ginput_container ginput_list'>" . "<table class='gfield_list'>";
             $class_attr = "";
             if ($has_columns) {
                 $list .= "<colgroup>";
                 $colnum = 1;
                 foreach ($columns as $column) {
                     $odd_even = $colnum % 2 == 0 ? "even" : "odd";
                     $list .= "<col id='gfield_list_{$field["id"]}_col{$colnum}' class='gfield_list_col_{$odd_even}'></col>";
                     $colnum++;
                 }
                 $list .= "</colgroup>";
                 $list .= "<thead><tr>";
                 foreach ($columns as $column) {
                     $list .= "<th>" . esc_html($column["text"]) . "</th>";
                 }
                 $list .= "<th>&nbsp;</th></tr></thead>";
             } else {
                 $list .= "<colgroup><col id='gfield_list_{$field["id"]}_col1' class='gfield_list_col_odd'></col></colgroup>";
             }
             $delete_display = count($value) == 1 ? "visibility:hidden;" : "";
             $maxRow = intval(rgar($field, "maxRows"));
             $disabled_icon_class = !empty($maxRow) && count($value) >= $maxRow ? "gfield_icon_disabled" : "";
             $list .= "<tbody>";
             $rownum = 1;
             foreach ($value as $item) {
                 $odd_even = $rownum % 2 == 0 ? "even" : "odd";
                 $list .= "<tr class='gfield_list_row_{$odd_even}'>";
                 $colnum = 1;
                 foreach ($columns as $column) {
                     //getting value. taking into account columns being added/removed from form meta
                     if (is_array($item)) {
                         if ($has_columns) {
                             $val = rgar($item, $column["text"]);
                         } else {
                             $vals = array_values($item);
                             $val = rgar($vals, 0);
                         }
                     } else {
                         $val = $colnum == 1 ? $item : "";
                     }
                     $list .= "<td class='gfield_list_cell gfield_list_{$field["id"]}_cell{$colnum}'>" . self::get_list_input($field, $has_columns, $column, $val, $form_id) . "</td>";
                     $colnum++;
                 }
                 $add_icon = !rgempty("addIconUrl", $field) ? $field["addIconUrl"] : GFCommon::get_base_url() . "/images/add.png";
                 $delete_icon = !rgempty("deleteIconUrl", $field) ? $field["deleteIconUrl"] : GFCommon::get_base_url() . "/images/remove.png";
                 $on_click = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "" : "onclick='gformAddListItem(this, {$maxRow})'";
                 if (rgar($field, "maxRows") != 1) {
                     $list .= "<td class='gfield_list_icons'>";
                     $list .= "   <img src='{$add_icon}' class='add_list_item {$disabled_icon_class}' {$disabled_text} title='" . __("Add a row", "gravityforms") . "' alt='" . __("Add a row", "gravityforms") . "' {$on_click} style='cursor:pointer; margin:0 3px;' />" . "   <img src='{$delete_icon}' {$disabled_text} title='" . __("Remove this row", "gravityforms") . "' alt='" . __("Remove this row", "gravityforms") . "' class='delete_list_item' style='cursor:pointer; {$delete_display}' onclick='gformDeleteListItem(this, {$maxRow})' />";
                     $list .= "</td>";
                 }
                 $list .= "</tr>";
                 if (!empty($maxRow) && $rownum >= $maxRow) {
                     break;
                 }
                 $rownum++;
             }
             $list .= "</tbody></table></div>";
             return $list;
             break;
     }
 }
コード例 #18
0
 function add_scripts_and_styles($hook)
 {
     if (!class_exists('RGForms')) {
         do_action('gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.');
         return;
     }
     // enqueue styles & scripts gf_entries
     // But only if we're on the main Entries page, not on reports pages
     if (RGForms::get_page() === 'entry_list') {
         $form_id = RGForms::get('id');
         // If there are no forms identified, use the first form. That's how GF does it.
         if (empty($form_id) && class_exists('RGFormsModel')) {
             $forms = gravityview_get_forms();
             if (!empty($forms)) {
                 $form_id = $forms[0]['id'];
             }
         }
         $approvedcolumn = self::get_approved_column($form_id);
         wp_register_style('gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version);
         wp_enqueue_style('gravityview_entries_list');
         $script_debug = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_register_script('gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version);
         wp_enqueue_script('gravityview_gf_entries_scripts');
         wp_localize_script('gravityview_gf_entries_scripts', 'gvGlobals', array('nonce' => wp_create_nonce('gravityview_ajaxgfentries'), 'form_id' => $form_id, 'show_column' => (int) $this->show_approve_entry_column($form_id), 'add_bulk_action' => (int) GVCommon::has_cap('gravityview_moderate_entries'), 'label_approve' => __('Approve', 'gravityview'), 'label_disapprove' => __('Disapprove', 'gravityview'), 'bulk_message' => $this->bulk_update_message, 'approve_title' => __('Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'), 'unapprove_title' => __('Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'), 'column_title' => __('Show entry in directory view?', 'gravityview'), 'column_link' => esc_url(add_query_arg(array('sort' => $approvedcolumn)))));
     }
 }
コード例 #19
0
 /**
  *
  * @return boolean
  */
 function get_gravity_forms()
 {
     $active = RGForms::get("active") == "" ? null : RGForms::get("active");
     $forms = RGFormsModel::get_forms($active, "title");
     if (isset($forms) && !empty($forms)) {
         foreach ($forms as $form) {
             $return[$form->id] = $form->title;
         }
         return $return;
     } else {
         return false;
     }
 }
コード例 #20
0
 /**
  * Is the current page an Edit Entry page?
  * @return boolean
  */
 public function is_edit_entry()
 {
     $gf_page = 'entry' === RGForms::get('view');
     return $gf_page && isset($_GET['edit']) || RGForms::post('action') === 'update';
 }
コード例 #21
0
    public function pending_completed_entries_screen()
    {
        $forms = RGFormsModel::get_forms(null, 'title');
        $id = RGForms::get('id');
        if (sizeof($forms) == 0) {
            ?>
					<div style="margin:50px 0 0 10px;">
					<?php 
            echo sprintf(__("You don't have any active forms. Let's go %screate one%s", "gravityforms"), '<a href="?page=gravityforms.php&id=0">', '</a>');
            ?>
					</div>
				<?php 
            return;
        } else {
            if (empty($id)) {
                $form_id = $forms[0]->id;
            } else {
                $form_id = $id;
            }
        }
        $form = RGFormsModel::get_form_meta($form_id);
        if (isset($_GET['clear'])) {
            check_admin_referer('gfstate-clear');
            $this->cleanup_saved_entries($form['id']);
            /* cleanup while we're here */
        }
        ?>
				<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" type="text/css" />
				<div class="wrap">
					<div class="icon32" id="gravity-entry-icon"><br></div>
					<h2><?php 
        _e('Pending/Completed Entries for ', self::$textdomain);
        echo $form['title'];
        ?>
</h2>

					<script type="text/javascript">
						function GF_ReplaceQuery(key, newValue){
							var new_query = "";
							var query = document.location.search.substring(1);
							var ary = query.split("&");
							var has_key=false;
							for (i=0; i < ary.length; i++) {
								var key_value = ary[i].split("=");

								if (key_value[0] == key){
									new_query += key + "=" + newValue + "&";
									has_key = true;
								}
								else if(key_value[0] != "display_settings"){
									new_query += key_value[0] + "=" + key_value[1] + "&";
								}
							}

							if(new_query.length > 0)
								new_query = new_query.substring(0, new_query.length-1);

							if(!has_key)
								new_query += new_query.length > 0 ? "&" + key + "=" + newValue : "?" + key + "=" + newValue;

							return new_query;
						}
						function GF_SwitchForm(id){
							if(id.length > 0){
								query = GF_ReplaceQuery("id", id);
								query = query.replace("gf_new_form", "gf_edit_forms");
								document.location = "?" + query;
							}
						}
					</script>

					<div id="gf_form_toolbar">
						<ul id="gf_form_toolbar_links">
							<li class="gf_form_switcher">
								<label for="export_form"><?php 
        _e('Select A Form', 'gravityforms');
        ?>
</label>

								<?php 
        if (RG_CURRENT_VIEW != 'entry') {
            ?>
									<select name="form_switcher" id="form_switcher" onchange="GF_SwitchForm(jQuery(this).val());">
										<option value=""><?php 
            _e('Switch Form', 'gravityforms');
            ?>
</option>
										<?php 
            foreach ($forms as $form_info) {
                ?>
											<option value="<?php 
                echo $form_info->id;
                ?>
"><?php 
                echo $form_info->title;
                ?>
</option>
										<?php 
            }
            ?>
									</select>
								<?php 
        }
        ?>

							</li>
						</ul>
					</div>

				<div>
					<?php 
        if (!isset($form['enableFormState']) || !$form['enableFormState']) {
            ?>
						<div style="margin:50px 0 0 10px;">
							<?php 
            _e(sprintf('This form does not have persistent state keeping for users. Enable the feature by <a href="%s">edit this form\'s</a> settings.', 'admin.php?page=gf_edit_forms&id=' . $form['id']), self::$textdomain);
            ?>
						</div>
					<?php 
        } else {
            ?>
						<h3>Users who have completed this form</h3>
						<ul>
							<?php 
            $users_completed = $this->get_users($form['id'], true);
            ?>
							<?php 
            if (!sizeof($users_completed)) {
                ?>
								<li>No users have completed this form yet.</li>
							<?php 
            } else {
                foreach ($users_completed as $user) {
                    ?>
								<li><a href="user-edit.php?user_id=<?php 
                    echo $user->ID;
                    ?>
"><?php 
                    echo $user->display_name;
                    ?>
</a></li>
							<?php 
                }
            }
            ?>
						</ul>
						<hr />
						<h3>Users who have saved this form for later</h3>
						<ul>
							<?php 
            $users_pending = $this->get_users($form['id'], false);
            ?>
							<?php 
            if (!sizeof($users_pending)) {
                ?>
								<li>No users who have saved this form for later.</li>
							<?php 
            } else {
                foreach ($users_pending as $user) {
                    ?>
								<li><a href="user-edit.php?user_id=<?php 
                    echo $user->ID;
                    ?>
"><?php 
                    echo $user->display_name;
                    ?>
</a></li>
							<?php 
                }
            }
            ?>
						</ul>
						<hr />
						<a class="gfstate-clear" href="<?php 
            echo wp_nonce_url(add_query_arg('clear', true), 'gfstate-clear');
            ?>
">clear all pending entries</a>
						<script type="text/javascript">
							jQuery( 'a.gfstate-clear' ).click( function( e ) {
								if ( !confirm( <?php 
            echo json_encode(__('Are you sure you want to do this?', self::$textdomain));
            ?>
 ) )
									e.preventDefault();
							} );
						</script>
					<?php 
        }
        ?>
				</div>
				</div> <!-- /wrap -->
			<?php 
    }
コード例 #22
0
ファイル: export.php プロジェクト: hypenotic/slowfood
 private function cleanup(&$forms)
 {
     unset($forms["version"]);
     //adding checkboxes "inputs" property based on "choices". (they were removed from the export
     //to provide a cleaner xml format
     foreach ($forms as &$form) {
         if (!is_array($form["fields"])) {
             continue;
         }
         foreach ($form["fields"] as &$field) {
             $input_type = RGFormsModel::get_input_type($field);
             if (in_array($input_type, array("checkbox", "radio", "select"))) {
                 //creating inputs array for checkboxes
                 if ($input_type == "checkbox" && !isset($field["inputs"])) {
                     $field["inputs"] = array();
                 }
                 for ($i = 1, $count = sizeof($field["choices"]); $i <= $count; $i++) {
                     if (!RGForms::get("enableChoiceValue", $field)) {
                         $field["choices"][$i - 1]["value"] = $field["choices"][$i - 1]["text"];
                     }
                     if ($input_type == "checkbox") {
                         $field["inputs"][] = array("id" => $field["id"] . "." . $i, "label" => $field["choices"][$i - 1]["text"]);
                     }
                 }
             }
         }
     }
 }
コード例 #23
0
ファイル: form_display.php プロジェクト: timk85/DIT
 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
 {
     /**
      * Provides the ability to modify the options used to display the form
      *
      * @param array An array of Form Arguments when adding it to a page/post (Like the ID, Title, AJAX or not, etc)
      */
     $form_args = apply_filters('gform_form_args', compact('form_id', 'display_title', 'display_description', 'force_display', 'field_values', 'ajax', 'tabindex'));
     extract($form_args);
     //looking up form id by form name
     if (!is_numeric($form_id)) {
         $form_id = RGFormsModel::get_form_id($form_id);
     }
     //reading form metadata
     $form = GFAPI::get_form($form_id);
     $form = self::maybe_add_review_page($form);
     $action = remove_query_arg('gf_token');
     //disable ajax if form has a reCAPTCHA field (not supported).
     if ($ajax && self::has_recaptcha_field($form)) {
         $ajax = false;
     }
     if (isset($_POST['gform_send_resume_link'])) {
         $save_email_confirmation = self::handle_save_email_confirmation($form, $ajax);
         if (is_wp_error($save_email_confirmation)) {
             // Failed email validation
             $resume_token = rgpost('gform_resume_token');
             $resume_token = sanitize_key($resume_token);
             $incomplete_submission_info = GFFormsModel::get_incomplete_submission_values($resume_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'];
                 $form = self::update_confirmation($form, $partial_entry, 'form_saved');
                 $confirmation_message = rgar($form['confirmation'], 'message');
                 $nl2br = rgar($form['confirmation'], 'disableAutoformat') ? false : true;
                 $confirmation_message = GFCommon::replace_variables($confirmation_message, $form, $partial_entry, false, true, $nl2br);
                 return self::handle_save_confirmation($form, $resume_token, $confirmation_message, $ajax);
             }
         } else {
             return $save_email_confirmation;
         }
     }
     $is_postback = false;
     $is_valid = true;
     $confirmation_message = '';
     //If form was submitted, read variables set during form submission procedure
     $submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
     if (rgar($submission_info, 'saved_for_later') == true) {
         $resume_token = $submission_info['resume_token'];
         $confirmation_message = rgar($submission_info, 'confirmation_message');
         return self::handle_save_confirmation($form, $resume_token, $confirmation_message, $ajax);
     }
     $partial_entry = $submitted_values = false;
     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);
             $max_page_number = self::get_max_page_number($form);
             $page_number = $submission_details['page_number'] > $max_page_number ? $max_page_number : $submission_details['page_number'];
             self::set_submission_if_null($form_id, 'page_number', $page_number);
         }
     }
     if (!is_array($partial_entry)) {
         /**
          * 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) {
             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);
     $is_form_editor = GFCommon::is_form_editor();
     $is_entry_detail = GFCommon::is_entry_detail();
     $is_admin = $is_form_editor || $is_entry_detail;
     if (empty($confirmation_message)) {
         $wrapper_css_class = GFCommon::get_browser_class() . ' gform_wrapper';
         if (!$is_valid) {
             $wrapper_css_class .= ' gform_validation_error';
         }
         $form_css_class = esc_attr(rgar($form, 'cssClass'));
         //Hiding 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_css_class) ? " {$form_css_class}_wrapper" : '';
         $form_string .= "\n                <div class='{$wrapper_css_class}{$custom_wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . '>';
         $default_anchor = $has_pages || $ajax ? true : false;
         $use_anchor = gf_apply_filters(array('gform_confirmation_anchor', $form_id), $default_anchor);
         if ($use_anchor !== false) {
             $form_string .= "<a id='gf_{$form_id}' class='gform_anchor' ></a>";
             $action .= "#gf_{$form_id}";
         }
         $target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : '';
         $form_css_class = !empty($form['cssClass']) ? "class='{$form_css_class}'" : '';
         $action = esc_url($action);
         $form_string .= gf_apply_filters(array('gform_form_tag', $form_id), "<form method='post' enctype='multipart/form-data' {$target} id='gform_{$form_id}' {$form_css_class} action='{$action}'>", $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'>" . rgar($form, 'description') . '</span>';
             }
             $form_string .= '
                     </div>';
         }
         $current_page = self::get_current_page($form_id);
         if ($has_pages && !$is_admin) {
             if ($form['pagination']['type'] == 'percentage') {
                 $form_string .= self::get_progress_bar($form, $form_id, $confirmation_message);
             } else {
                 if ($form['pagination']['type'] == 'steps') {
                     $form_string .= "\n                    <div id='gf_page_steps_{$form_id}' class='gf_page_steps'>";
                     $pages = isset($form['pagination']['pages']) ? $form['pagination']['pages'] : array();
                     for ($i = 0, $count = sizeof($pages); $i < $count; $i++) {
                         $step_number = $i + 1;
                         $active_class = $step_number == $current_page ? ' gf_step_active' : '';
                         $first_class = $i == 0 ? ' gf_step_first' : '';
                         $last_class = $i + 1 == $count ? ' gf_step_last' : '';
                         $complete_class = $step_number < $current_page ? ' gf_step_completed' : '';
                         $previous_class = $step_number + 1 == $current_page ? ' gf_step_previous' : '';
                         $next_class = $step_number - 1 == $current_page ? ' gf_step_next' : '';
                         $pending_class = $step_number > $current_page ? ' gf_step_pending' : '';
                         $classes = 'gf_step' . $active_class . $first_class . $last_class . $complete_class . $previous_class . $next_class . $pending_class;
                         $classes = GFCommon::trim_all($classes);
                         $form_string .= "\n                        <div id='gf_step_{$form_id}_{$step_number}' class='{$classes}'><span class='gf_step_number'>{$step_number}</span>&nbsp;<span class='gf_step_label'>{$pages[$i]}</span></div>";
                     }
                     $form_string .= "\n                        <div class='gf_step_clear'></div>\n                    </div>";
                 }
             }
         }
         if ($is_postback && !$is_valid) {
             $validation_message = "<div class='validation_error'>" . esc_html__('There was a problem with your submission.', 'gravityforms') . ' ' . esc_html__('Errors have been highlighted below.', 'gravityforms') . '</div>';
             $form_string .= gf_apply_filters(array('gform_validation_message', $form_id), $validation_message, $form);
         }
         $form_string .= "\n                        <div class='gform_body'>";
         //add first page if this form has any page fields
         if ($has_pages) {
             $style = self::is_page_active($form_id, 1) ? '' : "style='display:none;'";
             $class = !empty($form['firstPageCssClass']) ? " {$form['firstPageCssClass']}" : '';
             $class = esc_attr($class);
             $form_string .= "<div id='gform_page_{$form_id}_1' class='gform_page{$class}' {$style}>\n                                    <div class='gform_page_fields'>";
         }
         $description_class = rgar($form, 'descriptionPlacement') == 'above' ? 'description_above' : 'description_below';
         $sublabel_class = rgar($form, 'subLabelPlacement') == 'above' ? 'form_sublabel_above' : 'form_sublabel_below';
         $form_string .= "<ul id='gform_fields_{$form_id}' class='" . GFCommon::get_ul_classes($form) . "'>";
         if (is_array($form['fields'])) {
             foreach ($form['fields'] as $field) {
                 /* @var GF_Field $field */
                 $field->conditionalLogicFields = self::get_conditional_logic_fields($form, $field->id);
                 if (is_array($submitted_values)) {
                     $field_value = rgar($submitted_values, $field->id);
                 } else {
                     $field_value = GFFormsModel::get_field_value($field, $field_values);
                 }
                 $form_string .= self::get_field($field, $field_value, false, $form, $field_values);
             }
         }
         $form_string .= '
                         </ul>';
         if ($has_pages) {
             $previous_button_alt = rgempty('imageAlt', $form['lastPageButton']) ? __('Previous Page', 'gravityforms') : $form['lastPageButton']['imageAlt'];
             $previous_button = self::get_form_button($form['id'], "gform_previous_button_{$form['id']}", $form['lastPageButton'], __('Previous', 'gravityforms'), 'gform_previous_button', $previous_button_alt, self::get_current_page($form_id) - 1);
             /**
              * Filter through the form previous button when paged
              *
              * @param int $form_id The Form ID to filter through
              * @param string $previous_button The HTML rendered button (rendered with the form ID and the function get_form_button)
              * @param array $form The Form object to filter through
              */
             $previous_button = gf_apply_filters(array('gform_previous_button', $form_id), $previous_button, $form);
             $form_string .= '</div>' . self::gform_footer($form, 'gform_page_footer ' . $form['labelPlacement'], $ajax, $field_values, $previous_button, $display_title, $display_description, $is_postback) . '
                     </div>';
             //closes gform_page
         }
         $form_string .= '</div>';
         //closes gform_body
         //suppress form footer for multi-page forms (footer will be included on the last page
         if (!$has_pages) {
             $form_string .= self::gform_footer($form, 'gform_footer ' . $form['labelPlacement'], $ajax, $field_values, '', $display_title, $display_description, $tabindex);
         }
         $form_string .= '
                     </form>
                     </div>';
         if ($ajax && $is_postback) {
             global $wp_scripts;
             $form_string = apply_filters('gform_ajax_iframe_content', '<!DOCTYPE html><html><head>' . "<meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $form_string . '</body></html>');
         }
         if ($ajax && !$is_postback) {
             $spinner_url = gf_apply_filters(array('gform_ajax_spinner_url', $form_id), GFCommon::get_base_url() . '/images/spinner.gif', $form);
             $scroll_position = array('default' => '', 'confirmation' => '');
             if ($use_anchor !== false) {
                 $scroll_position['default'] = is_numeric($use_anchor) ? 'jQuery(document).scrollTop(' . intval($use_anchor) . ');' : "jQuery(document).scrollTop(jQuery('#gform_wrapper_{$form_id}').offset().top);";
                 $scroll_position['confirmation'] = is_numeric($use_anchor) ? 'jQuery(document).scrollTop(' . intval($use_anchor) . ');' : "jQuery(document).scrollTop(jQuery('#gforms_confirmation_message_{$form_id}').offset().top);";
             }
             $iframe_style = defined('GF_DEBUG') && GF_DEBUG ? 'display:block;width:600px;height:300px;border:1px solid #eee;' : 'display:none;width:0px;height:0px;';
             $is_html5 = RGFormsModel::is_html5_enabled();
             $iframe_title = $is_html5 ? " title='Ajax Frame'" : '';
             $form_string .= "\n                <iframe style='{$iframe_style}' src='about:blank' name='gform_ajax_frame_{$form_id}' id='gform_ajax_frame_{$form_id}'" . $iframe_title . "></iframe>\n                <script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . '' . 'jQuery(document).ready(function($){' . "gformInitSpinner( {$form_id}, '{$spinner_url}' );" . "jQuery('#gform_ajax_frame_{$form_id}').load( function(){" . "var contents = jQuery(this).contents().find('*').html();" . "var is_postback = contents.indexOf('GF_AJAX_POSTBACK') >= 0;" . 'if(!is_postback){return;}' . "var form_content = jQuery(this).contents().find('#gform_wrapper_{$form_id}');" . "var is_confirmation = jQuery(this).contents().find('#gform_confirmation_wrapper_{$form_id}').length > 0;" . "var is_redirect = contents.indexOf('gformRedirect(){') >= 0;" . 'var is_form = form_content.length > 0 && ! is_redirect && ! is_confirmation;' . 'if(is_form){' . "jQuery('#gform_wrapper_{$form_id}').html(form_content.html());" . "setTimeout( function() { /* delay the scroll by 50 milliseconds to fix a bug in chrome */ {$scroll_position['default']} }, 50 );" . "if(window['gformInitDatepicker']) {gformInitDatepicker();}" . "if(window['gformInitPriceFields']) {gformInitPriceFields();}" . "var current_page = jQuery('#gform_source_page_number_{$form_id}').val();" . "gformInitSpinner( {$form_id}, '{$spinner_url}' );" . "jQuery(document).trigger('gform_page_loaded', [{$form_id}, current_page]);" . "window['gf_submitting_{$form_id}'] = false;" . '}' . 'else if(!is_redirect){' . "var confirmation_content = jQuery(this).contents().find('#gforms_confirmation_message_{$form_id}').html();" . 'if(!confirmation_content){' . 'confirmation_content = contents;' . '}' . 'setTimeout(function(){' . "jQuery('#gform_wrapper_{$form_id}').replaceWith('<' + 'div id=\\'gforms_confirmation_message_{$form_id}\\' class=\\'gform_confirmation_message_{$form_id} gforms_confirmation_message\\'' + '>' + confirmation_content + '<' + '/div' + '>');" . "{$scroll_position['confirmation']}" . "jQuery(document).trigger('gform_confirmation_loaded', [{$form_id}]);" . "window['gf_submitting_{$form_id}'] = false;" . '}, 50);' . '}' . 'else{' . "jQuery('#gform_{$form_id}').append(contents);" . "if(window['gformRedirect']) {gformRedirect();}" . '}' . "jQuery(document).trigger('gform_post_render', [{$form_id}, current_page]);" . '} );' . '} );' . apply_filters('gform_cdata_close', '') . '</script>';
         }
         $is_first_load = !$is_postback;
         if (!$ajax || $is_first_load) {
             self::register_form_init_scripts($form, $field_values, $ajax);
             if (apply_filters('gform_init_scripts_footer', false)) {
                 add_action('wp_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'), 20);
                 add_action('gform_preview_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'));
             } else {
                 $form_string .= self::get_form_init_scripts($form);
                 $form_string .= "<script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . " jQuery(document).ready(function(){jQuery(document).trigger('gform_post_render', [{$form_id}, {$current_page}]) } ); " . apply_filters('gform_cdata_close', '') . '</script>';
             }
         }
         return gf_apply_filters(array('gform_get_form_filter', $form_id), $form_string, $form);
     } else {
         $progress_confirmation = '';
         //check admin setting for whether the progress bar should start at zero
         $start_at_zero = rgars($form, 'pagination/display_progressbar_on_confirmation');
         $start_at_zero = apply_filters('gform_progressbar_start_at_zero', $start_at_zero, $form);
         //show progress bar on confirmation
         if ($start_at_zero && $has_pages && !$is_admin && ($form['confirmation']['type'] == 'message' && $form['pagination']['type'] == 'percentage')) {
             $progress_confirmation = self::get_progress_bar($form, $form_id, $confirmation_message);
             if ($ajax) {
                 $progress_confirmation = apply_filters('gform_ajax_iframe_content', "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $progress_confirmation . '</body></html>');
             }
         } else {
             //return regular confirmation message
             if ($ajax) {
                 $progress_confirmation = apply_filters('gform_ajax_iframe_content', "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $confirmation_message . '</body></html>');
             } else {
                 $progress_confirmation = $confirmation_message;
             }
         }
         return $progress_confirmation;
     }
 }
コード例 #24
0
ファイル: form_list.php プロジェクト: nhainam/wordpress4
    public static function form_list_page()
    {
        global $wpdb;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $action = RGForms::post('action');
        $bulk_action = RGForms::post('bulk_action');
        $bulk_action = !empty($bulk_action) ? $bulk_action : RGForms::post('bulk_action2');
        if ($action == 'trash') {
            check_admin_referer('gforms_update_forms', 'gforms_update_forms');
            $form_id = RGForms::post('action_argument');
            RGFormsModel::trash_form($form_id);
            $message = __('Form moved to the trash.', 'gravityforms');
        } else {
            if ($action == 'restore') {
                check_admin_referer('gforms_update_forms', 'gforms_update_forms');
                $form_id = RGForms::post('action_argument');
                RGFormsModel::restore_form($form_id);
                $message = __('Form restored.', 'gravityforms');
            } else {
                if ($action == 'delete') {
                    check_admin_referer('gforms_update_forms', 'gforms_update_forms');
                    $form_id = RGForms::post('action_argument');
                    if (GFCommon::current_user_can_any('gravityforms_delete_forms')) {
                        RGFormsModel::delete_form($form_id);
                        $message = __('Form deleted.', 'gravityforms');
                    } else {
                        $message = __("You don't have adequate permission to delete forms.", 'gravityforms');
                    }
                } else {
                    if ($action == 'duplicate') {
                        check_admin_referer('gforms_update_forms', 'gforms_update_forms');
                        $form_id = RGForms::post('action_argument');
                        RGFormsModel::duplicate_form($form_id);
                        $message = __('Form duplicated.', 'gravityforms');
                    }
                }
            }
        }
        if ($bulk_action) {
            check_admin_referer('gforms_update_forms', 'gforms_update_forms');
            $form_ids = is_array(rgpost('form')) ? rgpost('form') : array();
            $form_count = count($form_ids);
            switch ($bulk_action) {
                case 'trash':
                    GFFormsModel::trash_forms($form_ids);
                    $message = _n('%s form moved to the trash.', '%s forms moved to the trash.', $form_count, 'gravityforms');
                    break;
                case 'restore':
                    GFFormsModel::restore_forms($form_ids);
                    $message = _n('%s form restored.', '%s forms restored.', $form_count, 'gravityforms');
                    break;
                case 'delete':
                    if (GFCommon::current_user_can_any('gravityforms_delete_forms')) {
                        GFFormsModel::delete_forms($form_ids);
                        $message = _n('%s form deleted.', '%s forms deleted.', $form_count, 'gravityforms');
                    } else {
                        $message = __("You don't have adequate permissions to delete forms.", 'gravityforms');
                    }
                    break;
                case 'reset_views':
                    foreach ($form_ids as $form_id) {
                        GFFormsModel::delete_views($form_id);
                    }
                    $message = _n('Views for %s form have been reset.', 'Views for %s forms have been reset.', $form_count, 'gravityforms');
                    break;
                case 'delete_entries':
                    if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                        foreach ($form_ids as $form_id) {
                            GFFormsModel::delete_leads_by_form($form_id);
                        }
                        $message = _n('Entries for %s form have been deleted.', 'Entries for %s forms have been deleted.', $form_count, 'gravityforms');
                    } else {
                        $message = __("You don't have adequate permission to delete entries.", 'gravityforms');
                    }
                    break;
                case 'activate':
                    foreach ($form_ids as $form_id) {
                        GFFormsModel::update_form_active($form_id, 1);
                    }
                    $message = _n('%s form has been marked as active.', '%s forms have been marked as active.', $form_count, 'gravityforms');
                    break;
                case 'deactivate':
                    foreach ($form_ids as $form_id) {
                        GFFormsModel::update_form_active($form_id, 0);
                    }
                    $message = _n('%s form has been marked as inactive.', '%s forms have been marked as inactive.', $form_count, 'gravityforms');
                    break;
            }
            if (isset($message)) {
                $message = sprintf($message, $form_count);
            }
        }
        $sort_column = empty($_GET['sort']) ? 'title' : $_GET['sort'];
        $db_columns = GFFormsModel::get_form_db_columns();
        if (!in_array(strtolower($sort_column), $db_columns)) {
            $sort_column = 'title';
        }
        $sort_direction = empty($_GET['dir']) ? 'ASC' : $_GET['dir'];
        $active = RGForms::get('active') == '' ? null : (bool) RGForms::get('active');
        $trash = RGForms::get('trash') == '' ? false : (bool) RGForms::get('trash');
        $forms = RGFormsModel::get_forms($active, $sort_column, $sort_direction, $trash);
        $form_count = RGFormsModel::get_form_count();
        wp_print_styles(array('thickbox'));
        add_action('admin_print_footer_scripts', array(__CLASS__, 'output_form_list_script_block'), 20);
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>

		<script type="text/javascript">
			// checked by the ToggleActive method to prevent errors when form status icon is clicked before page has fully loaded
			var gfPageLoaded = false;
		</script>

		<style type="text/css">
			body div#TB_window[style] {
				width: 405px !important;
				height: 340px !important;
				margin-left: -202px !important;
			}

			body #TB_ajaxContent {
				height: 290px !important;
				overflow: hidden;
			}

			.gf_new_form_modal_container {
				padding: 30px;
			}

			.gf_new_form_modal_container .setting-row {
				margin: 0 0 10px;
			}

			.gf_new_form_modal_container .setting-row label {
				line-height: 24px;
			}

			.gf_new_form_modal_container .setting-row input,
			.gf_new_form_modal_container .setting-row textarea {
				display: block;
				width: 100%;
			}

			.gf_new_form_modal_container .setting-row textarea {
				height: 110px;
			}

			.gf_new_form_modal_container .submit-row {
				margin-top: 18px;
			}

			.gf_new_form_modal_container #gf_new_form_error_message {
				margin: 0 0 18px 5px !important;
				color: #BC0B0B;
			}

			.gf_new_form_modal_container img.gfspinner {
				position: relative;
				top: 5px;
				left: 5px;
			}

			.gf_not_ready { opacity: 0.25; }

		</style>

		<?php 
        if (GFCommon::current_user_can_any('gravityforms_create_form')) {
            ?>

		<div id="gf_new_form_modal" style="display:none;">
			<div class="gf_new_form_modal_container">

				<div class="setting-row">
					<label for="new_form_title"><?php 
            esc_html_e('Form Title', 'gravityforms');
            ?>
						<span class="gfield_required">*</span></label><br />
					<input type="text" class="regular-text" value="" id="new_form_title" tabindex="9000">
				</div>

				<div class="setting-row">
					<label for="new_form_description"><?php 
            esc_html_e('Form Description', 'gravityforms');
            ?>
</label><br />
					<textarea class="regular-text" id="new_form_description" tabindex="9001"></textarea>
				</div>

				<div class="submit-row">

					<?php 
            /**
             * Allows for modification of the "New Form" button HTML
             *
             * @param string The HTML rendered for the "New Form" button.
             */
            echo apply_filters('gform_new_form_button', '<input id="save_new_form" type="button" class="button button-large button-primary" value="' . esc_html__('Create Form', 'gravityforms') . '" onclick="saveNewForm();" tabindex="9002" />');
            ?>
					<div id="gf_new_form_error_message" style="display:inline-block;"></div>
				</div>

			</div>
		</div>

		<?php 
        }
        // - end of new form modal - //
        ?>

		<script text="text/javascript">
			function TrashForm(form_id) {
				jQuery("#action_argument").val(form_id);
				jQuery("#action").val("trash");
				jQuery("#forms_form")[0].submit();
			}

			function RestoreForm(form_id) {
				jQuery("#action_argument").val(form_id);
				jQuery("#action").val("restore");
				jQuery("#forms_form")[0].submit();
			}

			function DeleteForm(form_id) {
				jQuery("#action_argument").val(form_id);
				jQuery("#action").val("delete");
				jQuery("#forms_form")[0].submit();
			}

			function ConfirmDeleteForm(form_id){
				if( confirm(<?php 
        echo json_encode(__('WARNING: You are about to delete this form and ALL entries associated with it. ', 'gravityforms') . esc_html__('Cancel to stop, OK to delete.', 'gravityforms'));
        ?>
) ){
					DeleteForm(form_id);
				}
			}

			function DuplicateForm(form_id) {
				jQuery("#action_argument").val(form_id);
				jQuery("#action").val("duplicate");
				jQuery("#forms_form")[0].submit();
			}

			function ToggleActive(img, form_id) {

				if( ! gfPageLoaded ) {
					return;
				}

				var is_active = img.src.indexOf("active1.png") >= 0
				if (is_active) {
					img.src = img.src.replace("active1.png", 'active0.png');
					jQuery(img).attr('title', <?php 
        echo json_encode(esc_attr__('Inactive', 'gravityforms'));
        ?>
).attr('alt', <?php 
        echo json_encode(esc_attr__('Inactive', 'gravityforms'));
        ?>
);
				}
				else {
					img.src = img.src.replace("active0.png", 'active1.png');
					jQuery(img).attr('title', <?php 
        echo json_encode(esc_attr__('Active', 'gravityforms'));
        ?>
).attr('alt', <?php 
        echo json_encode(esc_attr__('Active', 'gravityforms'));
        ?>
);
				}

				UpdateCount("active_count", is_active ? -1 : 1);
				UpdateCount("inactive_count", is_active ? 1 : -1);

				var mysack = new sack(<?php 
        echo json_encode(admin_url('admin-ajax.php'));
        ?>
);
				mysack.execute = 1;
				mysack.method = 'POST';
				mysack.setVar("action", "rg_update_form_active");
				mysack.setVar("rg_update_form_active", <?php 
        echo json_encode(wp_create_nonce('rg_update_form_active'));
        ?>
);
				mysack.setVar("form_id", form_id);
				mysack.setVar("is_active", is_active ? 0 : 1);
				mysack.onError = function () {
					alert(<?php 
        echo json_encode(__('Ajax error while updating form', 'gravityforms'));
        ?>
)
				};
				mysack.runAJAX();

				return true;
			}
			function UpdateCount(element_id, change) {
				var element = jQuery("#" + element_id);
				var count = parseInt(element.html()) + change
				element.html(count + "");
			}

			function gfConfirmBulkAction(element_id) {
				var element = "#" + element_id;
				if (jQuery(element).val() == 'delete')
					return confirm(<?php 
        echo json_encode(__('WARNING: You are about to delete these forms and ALL entries associated with them. ', 'gravityforms') . __("'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
        ?>
);
				else if (jQuery(element).val() == 'reset_views')
					return confirm(<?php 
        echo json_encode(__('Are you sure you would like to reset the Views for the selected forms? ', 'gravityforms') . __("'Cancel' to stop, 'OK' to reset.", 'gravityforms'));
        ?>
);
				else if (jQuery(element).val() == 'delete_entries')
					return confirm(<?php 
        echo json_encode(__('WARNING: You are about to delete ALL entries associated with the selected forms. ', 'gravityforms') . __("'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
        ?>
);

				return true;
			}
		</script>

		<link rel="stylesheet" href="<?php 
        echo esc_url(GFCommon::get_base_url());
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css"/>
		<div class="wrap <?php 
        echo sanitize_html_class(GFCommon::get_browser_class());
        ?>
">

		<h2>
			<?php 
        esc_html_e('Forms', 'gravityforms');
        if (GFCommon::current_user_can_any('gravityforms_create_form')) {
            echo '<a class="add-new-h2" href="" onclick="return loadNewFormModal();">' . esc_html__('Add New', 'gravityforms') . '</a>';
        }
        ?>
		</h2>

		<?php 
        if (isset($message)) {
            ?>
			<div class="updated below-h2" id="message"><p><?php 
            echo esc_html($message);
            ?>
</p></div>
		<?php 
        }
        ?>

		<form id="forms_form" method="post">
		<?php 
        wp_nonce_field('gforms_update_forms', 'gforms_update_forms');
        ?>
		<input type="hidden" id="action" name="action" />
		<input type="hidden" id="action_argument" name="action_argument" />

		<ul class="subsubsub">
			<li>
				<a class="<?php 
        echo $active === null ? 'current' : '';
        ?>
" href="?page=gf_edit_forms"><?php 
        echo esc_html(_x('All', 'Form List', 'gravityforms'));
        ?>
					<span class="count">(<span id="all_count"><?php 
        echo $form_count['total'];
        ?>
</span>)</span></a> |
			</li>
			<li>
				<a class="<?php 
        echo $active == '1' ? 'current' : '';
        ?>
" href="?page=gf_edit_forms&active=1"><?php 
        echo esc_html(_x('Active', 'Form List', 'gravityforms'));
        ?>
					<span class="count">(<span id="active_count"><?php 
        echo $form_count['active'];
        ?>
</span>)</span></a> |
			</li>
			<li>
				<a class="<?php 
        echo $active == '0' ? 'current' : '';
        ?>
" href="?page=gf_edit_forms&active=0"><?php 
        echo esc_html(_x('Inactive', 'Form List', 'gravityforms'));
        ?>
					<span class="count">(<span id="inactive_count"><?php 
        echo $form_count['inactive'];
        ?>
</span>)</span></a> |
			</li>
			<li>
				<a class="<?php 
        echo $active == '0' ? 'current' : '';
        ?>
" href="?page=gf_edit_forms&trash=1"><?php 
        esc_html_e('Trash', 'gravityforms');
        ?>
					<span class="count">(<span id="trash_count"><?php 
        echo $form_count['trash'];
        ?>
</span>)</span></a>
			</li>
		</ul>

		<?php 
        if (GFCommon::current_user_can_any('gravityforms_delete_forms')) {
            ?>
			<div class="tablenav">
				<div class="alignleft actions" style="padding:8px 0 7px 0;">

					<label class="hidden" for="bulk_action"><?php 
            esc_html_e('Bulk action', 'gravityforms');
            ?>
</label>
					<select name="bulk_action" id="bulk_action">
						<option value=''> <?php 
            esc_html_e('Bulk action', 'gravityforms');
            ?>
 </option>
						<?php 
            if ($trash) {
                ?>
							<option value='restore'><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</option>
							<option value='delete'><?php 
                esc_html_e('Delete permanently', 'gravityforms');
                ?>
</option>
						<?php 
            } else {
                ?>
							<option value='activate'><?php 
                esc_html_e('Mark as Active', 'gravityforms');
                ?>
</option>
							<option value='deactivate'><?php 
                esc_html_e('Mark as Inactive', 'gravityforms');
                ?>
</option>
							<option value='reset_views'><?php 
                esc_html_e('Reset Views', 'gravityforms');
                ?>
</option>
							<option value='delete_entries'><?php 
                esc_html_e('Permanently Delete Entries', 'gravityforms');
                ?>
</option>
							<option value='trash'><?php 
                esc_html_e('Move to trash', 'gravityforms');
                ?>
</option>
						<?php 
            }
            ?>
					</select>
					<?php 
            $apply_button = '<input type="submit" class="button" value="' . __('Apply', 'gravityforms') . '" onclick="return gfConfirmBulkAction(\'bulk_action\');"/>';
            /**
             * A filter that allows for modification of the form "Apply" button
             *
             * @param string $apply_button The HTML for the "Apply" Button
             */
            echo apply_filters('gform_form_apply_button', $apply_button);
            ?>

					<br class="clear" />

				</div>
			</div>
		<?php 
        }
        ?>

		<table class="widefat fixed" cellspacing="0">
			<thead>
			<tr>
				<?php 
        if (GFCommon::current_user_can_any('gravityforms_delete_forms')) {
            ?>
					<th scope="col" id="cb" class="manage-column column-cb check-column" style="">
						<input type="checkbox" name="form_bulk_check_all" onclick="jQuery('.gform_list_checkbox').attr('checked', this.checked);" />
					</th>
				<?php 
        }
        $dir = $sort_column == 'is_active' && $sort_direction == 'ASC' ? 'DESC' : 'ASC';
        $url_active = admin_url("admin.php?page=gf_edit_forms&sort=is_active&dir={$dir}&trash={$trash}");
        ?>
				<th scope="col" id="active" class="manage-column column-cb check-column" style="width:50px;cursor:pointer;" onclick="document.location='<?php 
        echo esc_url($url_active);
        ?>
'"></th>
				<?php 
        $dir = $sort_column == 'id' && $sort_direction == 'ASC' ? 'DESC' : 'ASC';
        $url_id = admin_url("admin.php?page=gf_edit_forms&sort=id&dir={$dir}&trash={$trash}");
        ?>
				<th scope="col" id="id" class="manage-column" style="width:50px;cursor:pointer;" onclick="document.location='<?php 
        echo $url_id;
        ?>
'"><?php 
        esc_html_e('Id', 'gravityforms');
        ?>
</th>
				<?php 
        $dir = $sort_column == 'title' && $sort_direction == 'ASC' ? 'DESC' : 'ASC';
        $url_title = admin_url("admin.php?page=gf_edit_forms&sort=title&dir={$dir}&trash={$trash}");
        ?>
				<th width="410" scope="col" id="title" class="manage-column column-title" style="cursor:pointer;" onclick="document.location='<?php 
        echo $url_title;
        ?>
'"><?php 
        esc_html_e('Title', 'gravityforms');
        ?>
</th>
				<th scope="col" id="author" class="manage-column column-author" style=""><?php 
        esc_html_e('Views', 'gravityforms');
        ?>
</th>
				<th scope="col" id="template" class="manage-column" style=""><?php 
        esc_html_e('Entries', 'gravityforms');
        ?>
</th>
				<th scope="col" id="template" class="manage-column" style=""><?php 
        esc_html_e('Conversion', 'gravityforms');
        ?>
 <?php 
        gform_tooltip('entries_conversion', 'tooltip_left');
        ?>
 </th>
			</tr>
			</thead>

			<tfoot>
			<tr>
				<?php 
        if (GFCommon::current_user_can_any('gravityforms_delete_forms')) {
            ?>
					<th scope="col" id="cb" class="manage-column column-cb check-column" style="">
						<input type="checkbox" name="form_bulk_check_all" onclick="jQuery('.gform_list_checkbox').attr('checked', this.checked);" />
					</th>
				<?php 
        }
        ?>
				<th scope="col" id="active" class="manage-column column-cb check-column"></th>
				<th scope="col" id="id" class="manage-column" style="cursor:pointer;" onclick="document.location='<?php 
        echo $url_id;
        ?>
'"><?php 
        esc_html_e('Id', 'gravityforms');
        ?>
</th>
				<th width="410" scope="col" id="title" style="cursor:pointer;" class="manage-column column-title" onclick="document.location='<?php 
        echo $url_title;
        ?>
'"><?php 
        esc_html_e('Title', 'gravityforms');
        ?>
</th>
				<th scope="col" id="author" class="manage-column column-author" style=""><?php 
        esc_html_e('Views', 'gravityforms');
        ?>
</th>
				<th scope="col" id="template" class="manage-column" style=""><?php 
        esc_html_e('Entries', 'gravityforms');
        ?>
</th>
				<th scope="col" id="template" class="manage-column" style=""><?php 
        esc_html_e('Conversion', 'gravityforms');
        ?>
</th>
			</tr>
			</tfoot>

			<tbody class="list:user user-list">
			<?php 
        if (sizeof($forms) > 0) {
            $alternate_row = false;
            foreach ($forms as $form) {
                $conversion = '0%';
                if ($form->view_count > 0) {
                    $conversion = number_format($form->lead_count / $form->view_count, 3) * 100 . '%';
                }
                $gf_form_locking = new GFFormLocking();
                ?>
					<tr class='author-self status-inherit <?php 
                $gf_form_locking->list_row_class($form->id);
                ?>
 <?php 
                echo ($alternate_row = !$alternate_row) ? 'alternate' : '';
                ?>
' valign="top" data-id="<?php 
                echo absint($form->id);
                ?>
">
						<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_forms')) {
                    ?>
							<th scope="row" class="check-column">
								<input type="checkbox" name="form[]" value="<?php 
                    echo absint($form->id);
                    ?>
" class="gform_list_checkbox" /><?php 
                    $gf_form_locking->lock_indicator();
                    ?>
							</th>
						<?php 
                }
                ?>

						<td>
							<?php 
                if (!$trash) {
                    ?>
								<img class="gform_active_icon gf_not_ready" src="<?php 
                    echo esc_url(GFCommon::get_base_url());
                    ?>
/images/active<?php 
                    echo intval($form->is_active);
                    ?>
.png" style="cursor: pointer;" alt="<?php 
                    echo $form->is_active ? esc_attr__('Active', 'gravityforms') : esc_attr__('Inactive', 'gravityforms');
                    ?>
" title="<?php 
                    echo $form->is_active ? esc_attr__('Active', 'gravityforms') : esc_attr__('Inactive', 'gravityforms');
                    ?>
" onclick="ToggleActive(this, <?php 
                    echo absint($form->id);
                    ?>
); " />
							<?php 
                }
                ?>
						</td>
						<td class="column-id"><?php 
                echo absint($form->id);
                ?>
</td>
						<td class="column-title">
							<?php 
                if ($trash) {
                    echo esc_html($form->title);
                } else {
                    ?>
								<strong><a class="row-title" disabled="<?php 
                    disabled(true, $trash);
                    ?>
"
										   href="admin.php?page=gf_edit_forms&id=<?php 
                    echo absint($form->id);
                    ?>
"
										   title="<?php 
                    esc_attr_e('Edit', 'gravityforms');
                    ?>
"><?php 
                    echo esc_html($form->title);
                    ?>
</a></strong>
								<?php 
                    $gf_form_locking->lock_info($form->id);
                }
                ?>
							<div class="row-actions">
								<?php 
                if ($trash) {
                    $form_actions['restore'] = array('label' => __('Restore', 'gravityforms'), 'title' => __('Restore', 'gravityforms'), 'url' => '#', 'onclick' => 'RestoreForm(' . absint($form->id) . ');', 'capabilities' => 'gravityforms_delete_forms', 'priority' => 600);
                    $form_actions['delete'] = array('label' => __('Delete permanently', 'gravityforms'), 'title' => __('Delete permanently', 'gravityforms'), 'menu_class' => 'delete', 'url' => '#', 'onclick' => 'ConfirmDeleteForm(' . absint($form->id) . ');', 'capabilities' => 'gravityforms_delete_forms', 'priority' => 500);
                } else {
                    require_once GFCommon::get_base_path() . '/form_settings.php';
                    $form_actions = GFForms::get_toolbar_menu_items($form->id, true);
                    $form_actions['duplicate'] = array('label' => __('Duplicate', 'gravityforms'), 'title' => __('Duplicate this form', 'gravityforms'), 'url' => '#', 'onclick' => 'DuplicateForm(' . absint($form->id) . ');return false;', 'capabilities' => 'gravityforms_create_form', 'priority' => 600);
                    $form_actions['trash'] = array('label' => __('Trash', 'gravityforms'), 'title' => __('Move this form to the trash', 'gravityforms'), 'url' => '#', 'onclick' => 'TrashForm(' . absint($form->id) . ');return false;', 'capabilities' => 'gravityforms_delete_forms', 'menu_class' => 'trash', 'priority' => 500);
                }
                $form_actions = apply_filters('gform_form_actions', $form_actions, $form->id);
                echo GFForms::format_toolbar_menu_items($form_actions, true);
                ?>

							</div>
						</td>
						<td class="column-date"><strong><?php 
                echo absint($form->view_count);
                ?>
</strong></td>
						<td class="column-date">
							<strong>
								<?php 
                if ($form->lead_count > 0 && !$trash) {
                    ?>
									<a href="<?php 
                    echo esc_url(admin_url('admin.php?page=gf_entries&view=entries&id=' . absint($form->id)));
                    ?>
"><?php 
                    echo absint($form->lead_count);
                    ?>
</a>
								<?php 
                } else {
                    echo absint($form->lead_count);
                }
                ?>
							</strong>
						</td>
						<td class="column-date"><?php 
                echo esc_html($conversion);
                ?>
</td>
					</tr>
				<?php 
            }
        } else {
            ?>
				<tr>
					<td colspan="6" style="padding:20px;">
						<?php 
            if ($trash) {
                esc_html_e('There are no forms in the trash.', 'gravityforms');
            } else {
                printf(esc_html__("You don't have any forms. Let's go %screate one%s!", 'gravityforms'), '<a href="admin.php?page=gf_new_form">', '</a>');
            }
            ?>
					</td>
				</tr>
			<?php 
        }
        ?>
			</tbody>
		</table>
		<div class="tablenav">
			<div class="alignleft actions" style="padding:8px 0 7px 0;">
				<?php 
        if (GFCommon::current_user_can_any('gravityforms_delete_forms')) {
            ?>
					<label class="hidden" for="bulk_action2"><?php 
            esc_html_e('Bulk action', 'gravityforms');
            ?>
</label>
					<select name="bulk_action2" id="bulk_action2">
						<option value=''> <?php 
            esc_html_e('Bulk action', 'gravityforms');
            ?>
 </option>
						<?php 
            if ($trash) {
                ?>
							<option value='restore'><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</option>
							<option value='delete'><?php 
                esc_html_e('Delete permanently', 'gravityforms');
                ?>
</option>
						<?php 
            } else {
                ?>
							<option value='activate'><?php 
                esc_html_e('Mark as Active', 'gravityforms');
                ?>
</option>
							<option value='deactivate'><?php 
                esc_html_e('Mark as Inactive', 'gravityforms');
                ?>
</option>
							<option value='reset_views'><?php 
                esc_html_e('Reset Views', 'gravityforms');
                ?>
</option>
							<option value='delete_entries'><?php 
                esc_html_e('Permanently Delete Entries', 'gravityforms');
                ?>
</option>
							<option value='trash'><?php 
                esc_html_e('Move to trash', 'gravityforms');
                ?>
</option>
						<?php 
            }
            ?>
					</select>
					<?php 
            $apply_button = '<input type="submit" class="button" value="' . esc_attr__('Apply', 'gravityforms') . '" onclick="return gfConfirmBulkAction(\'bulk_action2\');"/>';
            /**
             * A filter that allows for modification of the form "Apply" button
             *
             * @param string $apply_button The HTML for the "Apply" Button
             */
            echo apply_filters('gform_form_apply_button', $apply_button);
        }
        ?>
				<br class="clear" />
			</div>
		</div>
		</form>
		</div>
	<?php 
    }
コード例 #25
0
ファイル: class-gf-field.php プロジェクト: timk85/DIT
 /**
  * Retrieve the field value on submission.
  *
  * @param array $field_values The dynamic population parameter names with their corresponding values to be populated.
  * @param bool|true $get_from_post_global_var Whether to get the value from the $_POST array as opposed to $field_values.
  *
  * @return array|string
  */
 public function get_value_submission($field_values, $get_from_post_global_var = true)
 {
     $inputs = $this->get_entry_inputs();
     if (is_array($inputs)) {
         $value = array();
         foreach ($inputs as $input) {
             $value[strval($input['id'])] = $this->get_input_value_submission('input_' . str_replace('.', '_', strval($input['id'])), RGForms::get('name', $input), $field_values, $get_from_post_global_var);
         }
     } else {
         $value = $this->get_input_value_submission('input_' . $this->id, $this->inputName, $field_values, $get_from_post_global_var);
     }
     return $value;
 }
コード例 #26
0
 private static function get_conditional_logic($form)
 {
     $logics = "";
     $dependents = "";
     $fields_with_logic = array();
     foreach ($form["fields"] as $field) {
         //use section's logic if one exists
         $section = RGFormsModel::get_section($form, $field["id"]);
         $section_logic = !empty($section) ? rgar($section, "conditionalLogic") : null;
         $field_logic = $field["type"] != "page" ? RGForms::get("conditionalLogic", $field) : null;
         //page break conditional logic will be handled during the next button click
         $next_button_logic = isset($field["nextButton"]) && isset($field["nextButton"]["conditionalLogic"]) ? $field["nextButton"]["conditionalLogic"] : null;
         if (!empty($field_logic) || !empty($next_button_logic)) {
             $field_section_logic = array("field" => $field_logic, "nextButton" => $next_button_logic, "section" => $section_logic);
             $logics .= $field["id"] . ": " . GFCommon::json_encode($field_section_logic) . ",";
             $fields_with_logic[] = $field["id"];
             $peers = $field["type"] == "section" ? GFCommon::get_section_fields($form, $field["id"]) : array($field);
             $peer_ids = array();
             foreach ($peers as $peer) {
                 $peer_ids[] = $peer["id"];
             }
             $dependents .= $field["id"] . ": " . GFCommon::json_encode($peer_ids) . ",";
         }
     }
     $button_conditional_script = "";
     //adding form button conditional logic if enabled
     if (isset($form["button"]["conditionalLogic"])) {
         $logics .= "0: " . GFCommon::json_encode(array("field" => $form["button"]["conditionalLogic"], "section" => null)) . ",";
         $dependents .= "0: " . GFCommon::json_encode(array(0)) . ",";
         $fields_with_logic[] = 0;
         $button_conditional_script = "jQuery('#gform_{$form['id']}').submit(" . "function(event, isButtonPress){" . "    var visibleButton = jQuery('.gform_next_button:visible, .gform_button:visible, .gform_image_button:visible');" . "    return visibleButton.length > 0 || isButtonPress == true;" . "}" . ");";
     }
     if (!empty($logics)) {
         $logics = substr($logics, 0, strlen($logics) - 1);
     }
     //removing last comma;
     if (!empty($dependents)) {
         $dependents = substr($dependents, 0, strlen($dependents) - 1);
     }
     //removing last comma;
     $animation = rgar($form, "enableAnimation") ? "1" : "0";
     $chosen_init = self::has_enhanced_dropdown($form) ? self::get_chosen_init_script($form) : '';
     $str = "<script type='text/javascript'>//<![CDATA[\n" . "if(window['jQuery']){" . "jQuery(document).ready(function(){" . "gf_apply_rules({$form['id']}, " . GFCommon::json_encode($fields_with_logic) . ", true);" . "jQuery('#gform_wrapper_{$form['id']}').show(0, function(){" . $chosen_init . "if(window['gformCalculateTotalPrice']){" . "window['gformCalculateTotalPrice']({$form['id']});} " . "});" . $button_conditional_script . "});" . "if(!window['gf_form_conditional_logic'])" . "window['gf_form_conditional_logic'] = new Array();" . "window['gf_form_conditional_logic'][{$form['id']}] = {'logic' : {" . $logics . " }, 'dependents' : {" . $dependents . " }, 'animation' : " . $animation . " }; " . "} \n//]]></script>";
     return $str;
 }
コード例 #27
0
 private static function get_conditional_logic($form, $field_values = array())
 {
     $logics = "";
     $dependents = "";
     $fields_with_logic = array();
     $default_values = array();
     foreach ($form["fields"] as $field) {
         //use section's logic if one exists
         $section = RGFormsModel::get_section($form, $field["id"]);
         $section_logic = !empty($section) ? rgar($section, "conditionalLogic") : null;
         $field_logic = $field["type"] != "page" ? RGForms::get("conditionalLogic", $field) : null;
         //page break conditional logic will be handled during the next button click
         $next_button_logic = isset($field["nextButton"]) && isset($field["nextButton"]["conditionalLogic"]) ? $field["nextButton"]["conditionalLogic"] : null;
         if (!empty($field_logic) || !empty($next_button_logic)) {
             $field_section_logic = array("field" => $field_logic, "nextButton" => $next_button_logic, "section" => $section_logic);
             $logics .= $field["id"] . ": " . GFCommon::json_encode($field_section_logic) . ",";
             $fields_with_logic[] = $field["id"];
             $peers = $field["type"] == "section" ? GFCommon::get_section_fields($form, $field["id"]) : array($field);
             $peer_ids = array();
             foreach ($peers as $peer) {
                 $peer_ids[] = $peer["id"];
             }
             $dependents .= $field["id"] . ": " . GFCommon::json_encode($peer_ids) . ",";
         }
         //-- Saving default values so that they can be restored when toggling conditional logic ---
         $field_val = "";
         $input_type = RGFormsModel::get_input_type($field);
         //get parameter value if pre-populate is enabled
         if (rgar($field, "allowsPrepopulate")) {
             if (is_array(rgar($field, "inputs"))) {
                 $field_val = array();
                 foreach ($field["inputs"] as $input) {
                     $field_val["input_{$input["id"]}"] = RGFormsModel::get_parameter_value(rgar($input, "name"), $field, $field_values);
                 }
             } else {
                 if ($input_type == "time") {
                     $parameter_val = RGFormsModel::get_parameter_value(rgar($field, "inputName"), $field, $field_values);
                     if (!empty($parameter_val) && preg_match('/^(\\d*):(\\d*) ?(.*)$/', $parameter_val, $matches)) {
                         $field_val = array();
                         $field_val[] = esc_attr($matches[1]);
                         //hour
                         $field_val[] = esc_attr($matches[2]);
                         //minute
                         $field_val[] = rgar($matches, 3);
                         //am or pm
                     }
                 } else {
                     if ($input_type == "list") {
                         $parameter_val = RGFormsModel::get_parameter_value(rgar($field, "inputName"), $field, $field_values);
                         $field_val = explode(",", str_replace("|", ",", $parameter_val));
                     } else {
                         $field_val = RGFormsModel::get_parameter_value(rgar($field, "inputName"), $field, $field_values);
                     }
                 }
             }
         }
         //use default value if pre-populated value is empty
         $field_val = self::default_if_empty($field, $field_val);
         if (is_array(rgar($field, "choices")) && $input_type != "list") {
             //radio buttons start at 0 and checkboxes start at 1
             $choice_index = $input_type == "radio" ? 0 : 1;
             foreach ($field["choices"] as $choice) {
                 if (rgar($choice, "isSelected") && $input_type == "select") {
                     $val = isset($choice["price"]) ? $choice["value"] . "|" . GFCommon::to_number($choice["price"]) : $choice["value"];
                     $default_values[$field["id"]] = $val;
                 } else {
                     if (rgar($choice, "isSelected")) {
                         if (!isset($default_values[$field["id"]])) {
                             $default_values[$field["id"]] = array();
                         }
                         $default_values[$field["id"]][] = "choice_{$field["id"]}_{$choice_index}";
                     }
                 }
                 $choice_index++;
             }
         } else {
             if (!empty($field_val)) {
                 $default_values[$field["id"]] = $field_val;
             }
         }
     }
     $button_conditional_script = "";
     //adding form button conditional logic if enabled
     if (isset($form["button"]["conditionalLogic"])) {
         $logics .= "0: " . GFCommon::json_encode(array("field" => $form["button"]["conditionalLogic"], "section" => null)) . ",";
         $dependents .= "0: " . GFCommon::json_encode(array(0)) . ",";
         $fields_with_logic[] = 0;
         $button_conditional_script = "jQuery('#gform_{$form['id']}').submit(" . "function(event, isButtonPress){" . "    var visibleButton = jQuery('.gform_next_button:visible, .gform_button:visible, .gform_image_button:visible');" . "    return visibleButton.length > 0 || isButtonPress == true;" . "}" . ");";
     }
     if (!empty($logics)) {
         $logics = substr($logics, 0, strlen($logics) - 1);
     }
     //removing last comma;
     if (!empty($dependents)) {
         $dependents = substr($dependents, 0, strlen($dependents) - 1);
     }
     //removing last comma;
     $animation = rgar($form, "enableAnimation") ? "1" : "0";
     global $wp_locale;
     $number_format = $wp_locale->number_format['decimal_point'] == "," ? "decimal_comma" : "decimal_dot";
     $str = "if(window['jQuery']){" . "if(!window['gf_form_conditional_logic'])" . "window['gf_form_conditional_logic'] = new Array();" . "window['gf_form_conditional_logic'][{$form['id']}] = {'logic' : {" . $logics . " }, 'dependents' : {" . $dependents . " }, 'animation' : " . $animation . " , 'defaults' : " . json_encode($default_values) . " }; " . "if(!window['gf_number_format'])" . "window['gf_number_format'] = '" . $number_format . "';" . "jQuery(document).ready(function(){" . "gf_apply_rules({$form['id']}, " . json_encode($fields_with_logic) . ", true);" . "jQuery('#gform_wrapper_{$form['id']}').show();" . "jQuery(document).trigger('gform_post_conditional_logic', [{$form['id']}, null, true]);" . $button_conditional_script . "} );" . "} ";
     return $str;
 }
コード例 #28
0
    public static function form_list_page()
    {
        global $wpdb;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $action = RGForms::post("action");
        $bulk_action = RGForms::post("bulk_action");
        $bulk_action = !empty($bulk_action) ? $bulk_action : RGForms::post("bulk_action2");
        if ($action == "trash") {
            check_admin_referer('gforms_update_forms', 'gforms_update_forms');
            $form_id = RGForms::post("action_argument");
            RGFormsModel::trash_form($form_id);
            $message = __('Form moved to the trash.', 'gravityforms');
        } else {
            if ($action == "restore") {
                check_admin_referer('gforms_update_forms', 'gforms_update_forms');
                $form_id = RGForms::post("action_argument");
                RGFormsModel::restore_form($form_id);
                $message = __('Form restored.', 'gravityforms');
            } else {
                if ($action == "delete") {
                    check_admin_referer('gforms_update_forms', 'gforms_update_forms');
                    $form_id = RGForms::post("action_argument");
                    if (GFCommon::current_user_can_any("gravityforms_delete_forms")) {
                        RGFormsModel::delete_form($form_id);
                        $message = __('Form deleted.', 'gravityforms');
                    } else {
                        $message = __("You don't have adequate permissions to delete forms.", 'gravityforms');
                    }
                } else {
                    if ($action == "duplicate") {
                        check_admin_referer('gforms_update_forms', 'gforms_update_forms');
                        $form_id = RGForms::post("action_argument");
                        RGFormsModel::duplicate_form($form_id);
                        $message = __('Form duplicated.', 'gravityforms');
                    }
                }
            }
        }
        if ($bulk_action) {
            check_admin_referer('gforms_update_forms', 'gforms_update_forms');
            $form_ids = is_array(rgpost('form')) ? rgpost('form') : array();
            $form_count = count($form_ids);
            switch ($bulk_action) {
                case 'trash':
                    GFFormsModel::trash_forms($form_ids);
                    $message = _n('%s form moved to the trash.', '%s forms moved to the trash.', $form_count, 'gravityforms');
                    break;
                case 'restore':
                    GFFormsModel::restore_forms($form_ids);
                    $message = _n('%s form restored.', '%s forms restored.', $form_count, 'gravityforms');
                    break;
                case 'delete':
                    if (GFCommon::current_user_can_any("gravityforms_delete_forms")) {
                        GFFormsModel::delete_forms($form_ids);
                        $message = _n('%s form deleted.', '%s forms deleted.', $form_count, 'gravityforms');
                    } else {
                        $message = __("You don't have adequate permissions to delete forms.", 'gravityforms');
                    }
                    break;
                case 'reset_views':
                    foreach ($form_ids as $form_id) {
                        GFFormsModel::delete_views($form_id);
                    }
                    $message = _n('Views for %s form have been reset.', 'Views for %s forms have been reset.', $form_count, 'gravityforms');
                    break;
                case 'delete_entries':
                    if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                        foreach ($form_ids as $form_id) {
                            GFFormsModel::delete_leads_by_form($form_id);
                        }
                        $message = _n('Entries for %s form have been deleted.', 'Entries for %s forms have been deleted.', $form_count, 'gravityforms');
                    } else {
                        $message = __("You don't have adequate permissions to delete entries.", "gravityforms");
                    }
                    break;
                case 'activate':
                    foreach ($form_ids as $form_id) {
                        GFFormsModel::update_form_active($form_id, 1);
                    }
                    $message = _n('%s form has been marked as active.', '%s forms have been marked as active.', $form_count, 'gravityforms');
                    break;
                case 'deactivate':
                    foreach ($form_ids as $form_id) {
                        GFFormsModel::update_form_active($form_id, 0);
                    }
                    $message = _n('%s form has been marked as inactive.', '%s forms have been marked as inactive.', $form_count, 'gravityforms');
                    break;
            }
            if (isset($message)) {
                $message = sprintf($message, $form_count);
            }
        }
        $sort_column = empty($_GET["sort"]) ? "title" : $_GET["sort"];
        $sort_direction = empty($_GET["dir"]) ? "ASC" : $_GET["dir"];
        $active = RGForms::get("active") == "" ? null : RGForms::get("active");
        $trash = RGForms::get("trash") == "" ? false : RGForms::get("trash");
        $trash = esc_attr($trash);
        $forms = RGFormsModel::get_forms($active, $sort_column, $sort_direction, $trash);
        $form_count = RGFormsModel::get_form_count();
        // - new form modal - //
        wp_print_styles(array('thickbox'));
        /*wp_enqueue_script( 'form_admin' );
          wp_print_scripts( array( 'form_admin' ) );*/
        ?>

        <script type="text/javascript">

            jQuery(document).ready(function($) {

                <?php 
        if (rgget('page') == 'gf_new_form') {
            ?>
                loadNewFormModal();
                <?php 
        }
        ?>

                $('.gf_form_action_has_submenu').hover(function(){
                    var l = jQuery(this).offset().left;
                    jQuery(this).find('.gf_submenu')
                        .toggle()
                        .offset({ left: l });
                }, function(){
                    jQuery(this).find('.gf_submenu').hide();
                });


            });

            function loadNewFormModal() {
                resetNewFormModal();
                tb_show('<?php 
        _e('Create a New Form', 'gravityforms');
        ?>
', '#TB_inline?width=375&amp;inlineId=gf_new_form_modal');
                jQuery('#new_form_title').focus();
                return false;
            }

            function saveNewForm() {

                var createButton = jQuery('#save_new_form');
                var spinner = new gfAjaxSpinner(createButton, gf_vars.baseUrl + '/images/spinner.gif');

                // clear error message
                jQuery('#gf_new_form_error_message').html('');

                var origVal = createButton.val();
                createButton.val('<?php 
        _e('Creating Form...', 'gravityforms');
        ?>
');

                var form = {
                    title: jQuery('#new_form_title').val(),
                    description: jQuery('#new_form_description').val(),
                    labelPlacement:'top_label',
                    descriptionPlacement:'below',
                    button: {
                        type: 'text',
                        text: '<?php 
        _e("Submit", "gravityforms");
        ?>
',
                        imageUrl : ''
                    },
                    fields:[]
                }

                jQuery.post(ajaxurl, {
                    form: jQuery.toJSON(form),
                    action: 'gf_save_new_form',
                    gf_save_new_form: '<?php 
        echo wp_create_nonce('gf_save_new_form');
        ?>
'
                }, function(response){

                    spinner.destroy();

                    var respData = jQuery.parseJSON(response);

                    if(respData['error']) {
                        // adding class later otherwise WP moves box up to the top of the page
                        jQuery('#gf_new_form_error_message').html( respData.error );
                        addInputErrorIcon( '#new_form_title' );
                        createButton.val(origVal);
                    } else {
                        location.href = respData.redirect;
                        createButton.val('<?php 
        _e('Saved! Redirecting...', 'gravityforms');
        ?>
');
                    }

                });

            }

            function resetNewFormModal() {
                jQuery('#new_form_title').val('');
                jQuery('#new_form_description').val('');
                jQuery('#gf_new_form_error_message').html('');
                removeInputErrorIcons( '.gf_new_form_modal_container' );
            }

            function addInputErrorIcon( elem ) {
                var elem = jQuery(elem);
                elem.before( '<span class="gf_input_error_icon"></span>');
            }

            function removeInputErrorIcons( elem ) {
                var elem = jQuery(elem);
                elem.find('span.gf_input_error_icon').remove();
            }

        </script>

        <style type="text/css">
        body div#TB_window[style] { width: 405px !important; height:340px !important; margin-left: -202px !important; }
        body #TB_ajaxContent { height: 290px !important; overflow: hidden; }
        .gf_new_form_modal_container { padding: 30px; }
        .gf_new_form_modal_container .setting-row { margin: 0 0 10px; }
        .gf_new_form_modal_container .setting-row label { line-height: 24px; }
        .gf_new_form_modal_container .setting-row input,
        .gf_new_form_modal_container .setting-row textarea { display: block; width: 100%; }
        .gf_new_form_modal_container .setting-row textarea { height: 110px; }
        .gf_new_form_modal_container .submit-row { margin-top: 18px; }
        .gf_new_form_modal_container #gf_new_form_error_message { margin: 0 0 18px 5px !important; color: #BC0B0B; }
        .gf_new_form_modal_container img.gfspinner { position: relative; top: 5px; left: 5px; }
        </style>

        <div id="gf_new_form_modal" style="display:none;">
            <div class="gf_new_form_modal_container">

                <div class="setting-row">
                    <label for="new_form_title"><?php 
        _e('Form Title', 'gravityforms');
        ?>
<span class="gfield_required">*</span></label><br />
                    <input type="text" class="regular-text" value="" id="new_form_title" tabindex="9000">
                </div>

                <div class="setting-row">
                    <label for="new_form_description"><?php 
        _e('Form Description', 'gravityforms');
        ?>
</label><br />
                    <textarea class="regular-text" id="new_form_description" tabindex="9001"></textarea>
                </div>

                <div class="submit-row">
                    <?php 
        echo apply_filters("gform_new_form_button", '<input id="save_new_form" type="button" class="button button-large button-primary" value="' . __('Create Form', 'gravityforms') . '" onclick="saveNewForm();" tabindex="9002" />');
        ?>
                    <div id="gf_new_form_error_message" style="display:inline-block;"></div>
                </div>

            </div>
        </div>

        <?php 
        // - end of new form modal - //
        ?>

        <script text="text/javascript">
            function TrashForm(form_id){
                jQuery("#action_argument").val(form_id);
                jQuery("#action").val("trash");
                jQuery("#forms_form")[0].submit();
            }

            function RestoreForm(form_id){
                jQuery("#action_argument").val(form_id);
                jQuery("#action").val("restore");
                jQuery("#forms_form")[0].submit();
            }

            function DeleteForm(form_id){
                jQuery("#action_argument").val(form_id);
                jQuery("#action").val("delete");
                jQuery("#forms_form")[0].submit();
            }

            function DuplicateForm(form_id){
                jQuery("#action_argument").val(form_id);
                jQuery("#action").val("duplicate");
                jQuery("#forms_form")[0].submit();
            }

            function ToggleActive(img, form_id){
                var is_active = img.src.indexOf("active1.png") >=0
                if(is_active){
                    img.src = img.src.replace("active1.png", "active0.png");
                    jQuery(img).attr('title','<?php 
        _e("Inactive", "gravityforms");
        ?>
').attr('alt', '<?php 
        _e("Inactive", "gravityforms");
        ?>
');
                }
                else{
                    img.src = img.src.replace("active0.png", "active1.png");
                    jQuery(img).attr('title','<?php 
        _e("Active", "gravityforms");
        ?>
').attr('alt', '<?php 
        _e("Active", "gravityforms");
        ?>
');
                }

                UpdateCount("active_count", is_active ? -1 : 1);
                UpdateCount("inactive_count", is_active ? 1 : -1);

                var mysack = new sack("<?php 
        echo admin_url("admin-ajax.php");
        ?>
" );
                mysack.execute = 1;
                mysack.method = 'POST';
                mysack.setVar( "action", "rg_update_form_active" );
                mysack.setVar( "rg_update_form_active", "<?php 
        echo wp_create_nonce("rg_update_form_active");
        ?>
" );
                mysack.setVar( "form_id", form_id);
                mysack.setVar( "is_active", is_active ? 0 : 1);
                mysack.onError = function() { alert('<?php 
        echo esc_js(__("Ajax error while updating form", "gravityforms"));
        ?>
' )};
                mysack.runAJAX();

                return true;
            }
            function UpdateCount(element_id, change){
                var element = jQuery("#" + element_id);
                var count = parseInt(element.html()) + change
                element.html(count + "");
            }

            function gfConfirmBulkAction(element_id){
                var element = "#" + element_id;
                if(jQuery(element).val() == 'delete')
                    return confirm('<?php 
        echo __("WARNING: You are about to delete these forms and ALL entries associated with them. ", "gravityforms") . __("\\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
        ?>
');
                else if(jQuery(element).val() == 'reset_views')
                    return confirm('<?php 
        echo __("Are you sure you would like to reset the Views for the selected forms? ", "gravityforms") . __("\\'Cancel\\' to stop, \\'OK\\' to reset.", "gravityforms");
        ?>
');
                else if(jQuery(element).val() == 'delete_entries')
                    return confirm('<?php 
        echo __("WARNING: You are about to delete ALL entries associated with the selected forms. ", "gravityforms") . __("\\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
        ?>
');

                return true;
            }
        </script>

        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" />
        <div class="wrap <?php 
        echo GFCommon::get_browser_class();
        ?>
">

            <h2>
                <?php 
        _e("Forms", "gravityforms");
        ?>
                <a class="add-new-h2" href="" onclick="return loadNewFormModal();"><?php 
        _e("Add New", "gravityforms");
        ?>
</a>
            </h2>

            <?php 
        if (isset($message)) {
            ?>
            <div class="updated below-h2" id="message"><p><?php 
            echo $message;
            ?>
</p></div>
            <?php 
        }
        ?>

            <form id="forms_form" method="post">
                <?php 
        wp_nonce_field('gforms_update_forms', 'gforms_update_forms');
        ?>
                <input type="hidden" id="action" name="action"/>
                <input type="hidden" id="action_argument" name="action_argument"/>

                <ul class="subsubsub">
                    <li><a class="<?php 
        echo $active === null ? "current" : "";
        ?>
" href="?page=gf_edit_forms"><?php 
        _e("All", "gravityforms");
        ?>
 <span class="count">(<span id="all_count"><?php 
        echo $form_count["total"];
        ?>
</span>)</span></a> | </li>
                    <li><a class="<?php 
        echo $active == "1" ? "current" : "";
        ?>
" href="?page=gf_edit_forms&active=1"><?php 
        _e("Active", "gravityforms");
        ?>
 <span class="count">(<span id="active_count"><?php 
        echo $form_count["active"];
        ?>
</span>)</span></a> | </li>
                    <li><a class="<?php 
        echo $active == "0" ? "current" : "";
        ?>
" href="?page=gf_edit_forms&active=0"><?php 
        _e("Inactive", "gravityforms");
        ?>
 <span class="count">(<span id="inactive_count"><?php 
        echo $form_count["inactive"];
        ?>
</span>)</span></a> | </li>
                    <li><a class="<?php 
        echo $active == "0" ? "current" : "";
        ?>
" href="?page=gf_edit_forms&trash=1"><?php 
        _e("Trash", "gravityforms");
        ?>
 <span class="count">(<span id="trash_count"><?php 
        echo $form_count["trash"];
        ?>
</span>)</span></a></li>
                </ul>

                <?php 
        if (GFCommon::current_user_can_any("gravityforms_delete_forms")) {
            ?>
                    <div class="tablenav">
                        <div class="alignleft actions" style="padding:8px 0 7px 0;">

                            <label class="hidden" for="bulk_action"><?php 
            _e("Bulk action", "gravityforms");
            ?>
</label>
                            <select name="bulk_action" id="bulk_action">
                                <option value=''> <?php 
            _e("Bulk action", "gravityforms");
            ?>
 </option>
                                <?php 
            if ($trash) {
                ?>
                                    <option value='restore'><?php 
                _e("Restore", "gravityforms");
                ?>
</option>
                                    <option value='delete'><?php 
                _e("Delete permanently", "gravityforms");
                ?>
</option>
                                <?php 
            } else {
                ?>
                                    <option value='activate'><?php 
                _e("Mark as Active", "gravityforms");
                ?>
</option>
                                    <option value='deactivate'><?php 
                _e("Mark as Inactive", "gravityforms");
                ?>
</option>
                                    <option value='reset_views'><?php 
                _e("Reset Views", "gravityforms");
                ?>
</option>
                                    <option value='delete_entries'><?php 
                _e("Permanently Delete Entries", "gravityforms");
                ?>
</option>
                                    <option value='trash'><?php 
                _e("Move to trash", "gravityforms");
                ?>
</option>
                                <?php 
            }
            ?>
                            </select>
                            <?php 
            $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="return gfConfirmBulkAction(\'bulk_action\');"/>';
            echo apply_filters("gform_form_apply_button", $apply_button);
            ?>

                            <br class="clear" />

                        </div>
                    </div>
                <?php 
        }
        ?>

                <table class="widefat fixed" cellspacing="0">
                    <thead>
                        <tr>
                            <?php 
        if (GFCommon::current_user_can_any("gravityforms_delete_forms")) {
            ?>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" name="form_bulk_check_all" onclick="jQuery('.gform_list_checkbox').attr('checked', this.checked);" /></th>
                            <?php 
        }
        $dir = $sort_column == "is_active" && $sort_direction == "ASC" ? "DESC" : "ASC";
        $url_active = admin_url("admin.php?page=gf_edit_forms&sort=is_active&dir={$dir}&trash={$trash}");
        ?>
                            <th scope="col" id="active" class="manage-column column-cb check-column" style="width:50px;cursor:pointer;" onclick="document.location='<?php 
        echo $url_active;
        ?>
'"></th>
                                <?php 
        $dir = $sort_column == "id" && $sort_direction == "ASC" ? "DESC" : "ASC";
        $url_id = admin_url("admin.php?page=gf_edit_forms&sort=id&dir={$dir}&trash={$trash}");
        ?>
                            <th scope="col" id="id" class="manage-column" style="width:50px;cursor:pointer;" onclick="document.location='<?php 
        echo $url_id;
        ?>
'"><?php 
        _e("Id", "gravityforms");
        ?>
</th>
                                <?php 
        $dir = $sort_column == "title" && $sort_direction == "ASC" ? "DESC" : "ASC";
        $url_title = admin_url("admin.php?page=gf_edit_forms&sort=title&dir={$dir}&trash={$trash}");
        ?>
                            <th width="410" scope="col" id="title" class="manage-column column-title" style="cursor:pointer;" onclick="document.location='<?php 
        echo $url_title;
        ?>
'"><?php 
        _e("Title", "gravityforms");
        ?>
</th>
                            <th scope="col" id="author" class="manage-column column-author" style=""><?php 
        _e("Views", "gravityforms");
        ?>
</th>
                            <th scope="col" id="template" class="manage-column" style=""><?php 
        _e("Entries", "gravityforms");
        ?>
</th>
                            <th scope="col" id="template" class="manage-column" style=""><?php 
        _e("Conversion", "gravityforms");
        ?>
 <?php 
        gform_tooltip("entries_conversion", "tooltip_left");
        ?>
 </th>
                        </tr>
                    </thead>

                    <tfoot>
                        <tr>
                            <?php 
        if (GFCommon::current_user_can_any("gravityforms_delete_forms")) {
            ?>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" name="form_bulk_check_all" onclick="jQuery('.gform_list_checkbox').attr('checked', this.checked);" /></th>
                            <?php 
        }
        ?>
                            <th scope="col" id="active" class="manage-column column-cb check-column"></th>
                            <th scope="col" id="id" class="manage-column" style="cursor:pointer;" onclick="document.location='<?php 
        echo $url_id;
        ?>
'"><?php 
        _e("Id", "gravityforms");
        ?>
</th>
                            <th width="410" scope="col" id="title" style="cursor:pointer;" class="manage-column column-title" onclick="document.location='<?php 
        echo $url_title;
        ?>
'"><?php 
        _e("Title", "gravityforms");
        ?>
</th>
                            <th scope="col" id="author" class="manage-column column-author" style=""><?php 
        _e("Views", "gravityforms");
        ?>
</th>
                            <th scope="col" id="template" class="manage-column" style=""><?php 
        _e("Entries", "gravityforms");
        ?>
</th>
                            <th scope="col" id="template" class="manage-column" style=""><?php 
        _e("Conversion", "gravityforms");
        ?>
</th>
                        </tr>
                    </tfoot>

                    <tbody class="list:user user-list">
                        <?php 
        if (sizeof($forms) > 0) {
            $alternate_row = false;
            foreach ($forms as $form) {
                $conversion = "0%";
                if ($form->view_count > 0) {
                    $conversion = number_format($form->lead_count / $form->view_count, 3) * 100 . "%";
                }
                $gf_form_locking = new GFFormLocking();
                ?>
                                <tr class='author-self status-inherit <?php 
                $gf_form_locking->list_row_class($form->id);
                ?>
 <?php 
                echo ($alternate_row = !$alternate_row) ? 'alternate' : '';
                ?>
' valign="top" data-id="<?php 
                echo esc_attr($form->id);
                ?>
">
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_forms")) {
                    ?>
                                        <th scope="row" class="check-column"><input type="checkbox" name="form[]" value="<?php 
                    echo $form->id;
                    ?>
" class="gform_list_checkbox"/><?php 
                    $gf_form_locking->lock_indicator();
                    ?>
</th>
                                    <?php 
                }
                ?>

                                    <td>
                                        <?php 
                if (!$trash) {
                    ?>
                                        <img class="gform_active_icon" src="<?php 
                    echo GFCommon::get_base_url();
                    ?>
/images/active<?php 
                    echo intval($form->is_active);
                    ?>
.png" style="cursor: pointer;" alt="<?php 
                    echo $form->is_active ? __("Active", "gravityforms") : __("Inactive", "gravityforms");
                    ?>
" title="<?php 
                    echo $form->is_active ? __("Active", "gravityforms") : __("Inactive", "gravityforms");
                    ?>
" onclick="ToggleActive(this, <?php 
                    echo $form->id;
                    ?>
); " />
                                        <?php 
                }
                ?>
                                    </td>
                                    <td class="column-id"><?php 
                echo $form->id;
                ?>
</td>
                                    <td class="column-title">
                                        <?php 
                if ($trash) {
                    echo $form->title;
                } else {
                    ?>
                                            <strong><a class="row-title" disabled="<?php 
                    disabled(true, $trash);
                    ?>
"
                                                       href="admin.php?page=gf_edit_forms&id=<?php 
                    echo $form->id;
                    ?>
"
                                                       title="<?php 
                    _e("Edit", "gravityforms");
                    ?>
"><?php 
                    echo $form->title;
                    ?>
</a></strong>
                                            <?php 
                    $gf_form_locking->lock_info($form->id);
                }
                ?>
                                        <div class="row-actions">

                                            <?php 
                if ($trash) {
                    $form_actions['restore'] = array('label' => __("Restore", "gravityforms"), 'title' => __("Restore", "gravityforms"), 'url' => 'javascript:RestoreForm(' . $form->id . ');', 'capabilities' => "gravityforms_delete_forms", 'priority' => 600);
                    $form_actions['delete'] = array('label' => __("Delete permanently", "gravityforms"), 'title' => __("Delete permanently", "gravityforms"), 'menu_class' => 'delete', 'url' => 'javascript: if(confirm("' . __("WARNING: You are about to delete this form and ALL entries associated with it. ", "gravityforms") . __('\\"Cancel\\" to stop, \\"OK\\" to delete.', "gravityforms") . '")){ DeleteForm(' . $form->id . ');}', 'capabilities' => "gravityforms_delete_forms", 'priority' => 500);
                } else {
                    require_once GFCommon::get_base_path() . '/form_settings.php';
                    $form_actions = GFForms::get_toolbar_menu_items($form->id, true);
                    $form_actions['duplicate'] = array('label' => __("Duplicate", "gravityforms"), 'title' => __("Duplicate this form", "gravityforms"), 'url' => 'javascript:DuplicateForm(' . $form->id . ');', 'capabilities' => "gravityforms_create_form", 'priority' => 600);
                    $form_actions['trash'] = array('label' => __("Trash", "gravityforms"), 'title' => __("Move this form to the trash", "gravityforms"), 'url' => 'javascript:TrashForm(' . $form->id . ');', 'capabilities' => "gravityforms_delete_forms", 'menu_class' => 'trash', 'priority' => 500);
                }
                $form_actions = apply_filters("gform_form_actions", $form_actions, $form->id);
                echo GFForms::format_toolbar_menu_items($form_actions, true);
                ?>

                                        </div>
                                    </td>
                                    <td class="column-date"><strong><?php 
                echo $form->view_count;
                ?>
</strong></td>
                                    <td class="column-date">
                                        <strong>
                                            <?php 
                if ($form->lead_count > 0 && !$trash) {
                    ?>
                                                <a href="<?php 
                    echo admin_url("admin.php?page=gf_entries&view=entries&id={$form->id}");
                    ?>
"><?php 
                    echo $form->lead_count;
                    ?>
</a>
                                            <?php 
                } else {
                    echo $form->lead_count;
                }
                ?>
                                        </strong>
                                    </td>
                                    <td class="column-date"><?php 
                echo $conversion;
                ?>
</td>
                                </tr>
                                <?php 
            }
        } else {
            ?>
                            <tr>
                                <td colspan="6" style="padding:20px;">
                                    <?php 
            if ($trash) {
                echo __("There are no forms in the trash.", "gravityforms");
            } else {
                echo sprintf(__("You don't have any forms. Let's go %screate one%s!", "gravityforms"), '<a href="admin.php?page=gf_new_form">', "</a>");
            }
            ?>
                                </td>
                            </tr>
                            <?php 
        }
        ?>
                    </tbody>
                </table>
                <div class="tablenav">
                    <div class="alignleft actions" style="padding:8px 0 7px 0;">
                        <?php 
        if (GFCommon::current_user_can_any("gravityforms_delete_forms")) {
            ?>
                            <label class="hidden" for="bulk_action2"><?php 
            _e("Bulk action", "gravityforms");
            ?>
</label>
                            <select name="bulk_action2" id="bulk_action2">
                                <option value=''> <?php 
            _e("Bulk action", "gravityforms");
            ?>
 </option>
                                <?php 
            if ($trash) {
                ?>
                                    <option value='restore'><?php 
                _e("Restore", "gravityforms");
                ?>
</option>
                                    <option value='delete'><?php 
                _e("Delete permanently", "gravityforms");
                ?>
</option>
                                <?php 
            } else {
                ?>
                                    <option value='activate'><?php 
                _e("Mark as Active", "gravityforms");
                ?>
</option>
                                    <option value='deactivate'><?php 
                _e("Mark as Inactive", "gravityforms");
                ?>
</option>
                                    <option value='reset_views'><?php 
                _e("Reset Views", "gravityforms");
                ?>
</option>
                                    <option value='delete_entries'><?php 
                _e("Permanently Delete Entries", "gravityforms");
                ?>
</option>
                                    <option value='trash'><?php 
                _e("Move to trash", "gravityforms");
                ?>
</option>
                                <?php 
            }
            ?>
                            </select>
                            <?php 
            $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="return gfConfirmBulkAction(\'bulk_action2\');"/>';
            echo apply_filters("gform_form_apply_button", $apply_button);
        }
        ?>
                        <br class="clear" />
                    </div>
                </div>
            </form>
        </div>
        <?php 
    }
コード例 #29
0
ファイル: gravityforms.php プロジェクト: kidaak/gravityforms
 public static function forms()
 {
     if (!GFCommon::ensure_wp_version()) {
         return;
     }
     if (self::maybe_display_installation_wizard()) {
         return;
     }
     $id = RGForms::get('id');
     $view = RGForms::get('view');
     if ($view == 'entries') {
         require_once GFCommon::get_base_path() . '/entry_list.php';
         GFEntryList::leads_page($id);
     } else {
         if ($view == 'entry') {
             require_once GFCommon::get_base_path() . '/entry_detail.php';
             GFEntryDetail::lead_detail_page();
         } else {
             if ($view == 'notification') {
                 require_once GFCommon::get_base_path() . '/notification.php';
                 //GFNotification::notification_page($id);
             } else {
                 if ($view == 'settings') {
                     require_once GFCommon::get_base_path() . '/form_settings.php';
                     GFFormSettings::form_settings_page($id);
                 } else {
                     if (empty($view)) {
                         if (is_numeric($id)) {
                             self::forms_page($id);
                         } else {
                             self::form_list_page();
                         }
                     }
                 }
             }
         }
     }
     do_action('gform_view', $view, $id);
 }
コード例 #30
0
 public static function forms()
 {
     if (!GFCommon::ensure_wp_version()) {
         return;
     }
     $id = RGForms::get("id");
     $view = RGForms::get("view");
     if ($view == "entries") {
         require_once GFCommon::get_base_path() . "/entry_list.php";
         GFEntryList::leads_page($id);
     } else {
         if ($view == "entry") {
             require_once GFCommon::get_base_path() . "/entry_detail.php";
             GFEntryDetail::lead_detail_page();
         } else {
             if ($view == "notification") {
                 require_once GFCommon::get_base_path() . "/notification.php";
                 GFNotification::notification_page($id);
             } else {
                 if (is_numeric($id)) {
                     self::forms_page($id);
                 } else {
                     self::form_list_page();
                 }
             }
         }
     }
 }