Exemplo n.º 1
0
 /**
  * Acquirrer field input
  *
  * @param string $field_content
  * @param string $field
  * @param string $value
  * @param string $lead_id
  * @param string $form_id
  */
 public static function acquirer_field_input($field_content, $field, $value, $lead_id, $form_id)
 {
     $type = RGFormsModel::get_input_type($field);
     if (Pronamic_WP_Pay_Extensions_GravityForms_IssuerDropDown::TYPE === $type) {
         $id = $field['id'];
         $field_id = IS_ADMIN || 0 === $form_id ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
         $class_suffix = RG_CURRENT_VIEW === 'entry' ? '_admin' : '';
         $size = rgar($field, 'size');
         $class = $size . $class_suffix;
         $css_class = trim(esc_attr($class) . ' gfield_ideal_acquirer_select');
         $tab_index = GFCommon::get_tabindex();
         $disabled_text = IS_ADMIN && 'entry' !== RG_CURRENT_VIEW ? "disabled='disabled'" : '';
         $html = '';
         $feed = get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, true);
         /**
          * Developing warning:
          * Don't use single quotes in the HTML you output, it is buggy in combination with SACK
          */
         if (IS_ADMIN) {
             if (null === $feed) {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", add_query_arg('post_type', 'pronamic_pay_gf', admin_url('post-new.php')), __('Create iDEAL feed', 'pronamic_ideal'));
             } else {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", get_edit_post_link($feed->id), __('Edit iDEAL feed', 'pronamic_ideal'));
             }
         }
         $html_input = '';
         $html_error = '';
         if (null !== $feed) {
             $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
             if ($gateway) {
                 $issuer_field = $gateway->get_issuer_field();
                 $error = $gateway->get_error();
                 if (is_wp_error($error)) {
                     $html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
                     $html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
                 } elseif ($issuer_field) {
                     $choices = $issuer_field['choices'];
                     $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices, $value);
                     // Double quotes are not working, se we replace them with an single quote
                     $options = str_replace('"', '\'', $options);
                     $html_input = '';
                     $html_input .= sprintf("<select name='input_%d' id='%s' class='%s' %s %s>", $id, $field_id, $css_class, $tab_index, $disabled_text);
                     $html_input .= sprintf('%s', $options);
                     $html_input .= sprintf('</select>');
                 }
             }
         }
         if ($html_error) {
             $html .= sprintf("<div class='gfield_description validation_message'>");
             $html .= sprintf('%s', $html_error);
             $html .= sprintf('</div>');
         } else {
             $html .= sprintf("<div class='ginput_container ginput_ideal'>");
             $html .= sprintf('%s', $html_input);
             $html .= sprintf('</div>');
         }
         $field_content = $html;
     }
     return $field_content;
 }
 public function get_field_content($value, $force_frontend_label, $form)
 {
     if (is_admin()) {
         $admin_buttons = $this->get_admin_buttons();
         $field_content = "{$admin_buttons}\n\t\t\t\t\t\t\t<div class=\"gf-pagebreak-end gf-pagebreak-container gf-repeater-end\">\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-before\">end repeater</div>\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-main\"><span>REPEATER</span></div>\n\t\t\t\t\t\t\t\t<div class=\"gf-pagebreak-text-after\">end of repeater</div>\n\t\t\t\t\t\t\t</div>";
     } else {
         $add_html = $this->add;
         $remove_html = $this->remove;
         $hideButtons = $this->hideButtons;
         $tabindex = GFCommon::get_tabindex();
         if (empty($add_html)) {
             $add_html = "<img class=\"gf_repeater_add_default\" alt=\"+\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\">";
         }
         if (empty($remove_html)) {
             $remove_html = "<img class=\"gf_repeater_remove_default\" alt=\"-\" src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\">";
         }
         $field_content = "<div class=\"ginput_container ginput_container_repeater-end\">\n";
         if (!$hideButtons) {
             $field_content .= "<span class=\"gf_repeater_remove\" {$tabindex}>{$remove_html}</span>";
             $field_content .= "<span class=\"gf_repeater_add\" {$tabindex}>{$add_html}</span>";
         }
         $field_content .= "</div>";
     }
     return $field_content;
 }
function bb_click_array_field_input($input, $field, $value, $lead_id, $form_id)
{
    if ($field["type"] == "bb_click_array") {
        $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
        $input_name = $form_id . '_' . $field["id"];
        $css = isset($field['cssClass']) ? $field['cssClass'] : "";
        $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
        $amount = '';
        $clicked = '';
        if (is_array($value)) {
            $amount = esc_attr(rgget($field["id"] . ".1", $value));
            $clicked = rgget($field["id"] . ".5", $value);
        }
        $html = "<div id='{$field_id}' class='ginput_container bb-click-array-" . count($field['choices']) . " " . esc_attr($css) . "'>" . "\n";
        if (is_array($field["choices"])) {
            $choice_id = 0;
            $tabindex = GFCommon::get_tabindex();
            foreach ($field["choices"] as $choice) {
                $id = $field["id"] . '_' . $choice_id;
                $field_value = !empty($choice["value"]) || rgar($field, "enableChoiceValue") ? $choice["value"] : $choice["text"];
                if (rgblank($amount) && RG_CURRENT_VIEW != "entry") {
                    $active = rgar($choice, "isSelected") ? "checked='checked'" : "";
                } else {
                    $active = RGFormsModel::choice_value_match($field, $choice, $amount) ? "checked='checked'" : "";
                }
                if ($active) {
                    $amount = $field_value;
                }
                $field_class = $active ? 's-active' : 's-passive';
                if (rgar($field, 'field_bb_click_array_is_product')) {
                    require_once GFCommon::get_base_path() . '/currency.php';
                    $currency = new RGCurrency(GFCommon::get_currency());
                    $field_value = $currency->to_money($field_value);
                    $field_class .= ' s-currency';
                }
                $html .= sprintf('<div data-clickarray-value="%s" data-choice-id="%s" class="s-html-wrapper %s" id="%s">', esc_attr($field_value), $choice_id, $field_class, $id);
                $html .= sprintf('<div class="s-html-value">%s</div>', $field_value);
                $html .= sprintf("<label for='choice_%s' id='label_%s'>%s</label>", $id, $id, $choice["text"]);
                $html .= '</div>';
                $choice_id++;
            }
            $onblur = !IS_ADMIN ? 'if(jQuery(this).val().replace(" ", "") == "") { jQuery(this).val("' . $other_default_value . '"); }' : '';
            $onkeyup = empty($field["conditionalLogicFields"]) || IS_ADMIN ? '' : "onchange='gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ");' onkeyup='clearTimeout(__gf_timeout_handle); __gf_timeout_handle = setTimeout(\"gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ")\", 300);'";
            $value_exists = RGFormsModel::choices_value_match($field, $field["choices"], $value);
            $other_label = empty($field['field_bb_click_array_other_label']) ? 'My Best Gift' : $field['field_bb_click_array_other_label'];
            $other_class = rgar($field, 'enableOtherChoice') ? '' : 'hide';
            $html .= "<label for='input_{$field["formId"]}_{$field["id"]}_1' class='ginput_bb_click_array_other_label " . $other_class . "'>" . $other_label . "</label>";
            $other_class .= rgar($field, 'field_bb_click_array_is_product') ? ' ginput_amount gfield_price gfield_price_' . $field['formId'] . '_' . $field['id'] . '_1 gfield_product_' . $field['formId'] . '_' . $field['id'] . '_1' : '';
            $html .= "<input id='input_{$field["formId"]}_{$field["id"]}_1' name='input_{$field["id"]}_1' type='text' value='" . esc_attr($amount) . "' class='ginput_bb ginput_click_array_other " . $other_class . " " . $field['size'] . "' onblur='{$onblur}' {$tabindex} {$onkeyup} {$disabled_text}>";
            $html .= "<input id='input_{$field["formId"]}_{$field["id"]}_5' name='input_{$field["id"]}_5' type='hidden' value='" . esc_attr($clicked) . "' class='ginput_bb ginput_click_array_clicked'>";
        }
        $html .= "</div>";
        return $html;
    }
    return $input;
}
Exemplo n.º 4
0
function wps_tos_field_input($input, $field, $value, $lead_id, $form_id)
{
    if ($field["type"] == "tos") {
        $max_chars = "";
        if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
            $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
        }
        $input_name = $form_id . '_' . $field["id"];
        $tabindex = GFCommon::get_tabindex();
        $css = isset($field['cssClass']) ? $field['cssClass'] : '';
        return sprintf("<div class='ginput_container'><textarea readonly name='input_%s' id='%s' class='textarea gform_tos %s' {$tabindex} rows='10' cols='50'>%s</textarea></div>{$max_chars}", $field["id"], 'tos-' . $field['id'], $field["type"] . ' ' . esc_attr($css) . ' ' . $field['size'], esc_html($value));
    }
    return $input;
}
 function wysiwyg_field_input($input, $field, $value, $lead_id, $form_id)
 {
     if ($this->is_wysiwyg($field)) {
         $input_id = 'input_' . $form_id . '_' . $field["id"];
         if (is_admin()) {
             $tabindex = GFCommon::get_tabindex();
             return sprintf("<div class='ginput_container'><textarea readonly name='input_%s' id='input_%s' class='textarea gform_wysiwyg' {$tabindex} rows='10' cols='50'>WYSIWYG editor</textarea></div>", $field["id"], 'wysiwyg-' . $field['id']);
         } else {
             if (array_key_exists($field["id"], $this->_wysiwygs)) {
                 return $this->_wysiwygs[$field["id"]];
             }
             return "";
         }
     }
     return false;
 }
 function wysiwyg_field_input($input, $field, $value, $lead_id, $form_id)
 {
     if ($this->is_wysiwyg($field)) {
         $input_id = 'input_' . $form_id . '_' . $field["id"];
         if (is_admin()) {
             $tabindex = GFCommon::get_tabindex();
             return sprintf("<div class='ginput_container'><textarea readonly name='input_%s' id='input_%s' class='textarea gform_wysiwyg' {$tabindex} rows='10' cols='50'>WYSIWYG editor</textarea></div>", $field["id"], 'wysiwyg-' . $field['id']);
         } else {
             $media_buttons = strpos($field["cssClass"], 'media_buttons') !== false;
             $args = array('textarea_name' => 'input_' . $field["id"], 'wpautop' => true, 'media_buttons' => $media_buttons, 'editor_class' => 'frontend', 'textarea_rows' => 5, 'tabindex' => 0);
             ob_start();
             wp_editor($value, $input_id, $args);
             $html = ob_get_contents();
             ob_end_clean();
             return "<div class='ginput_container'>" . $html . "</div>";
         }
     }
     return false;
 }
function deprecated_envoy_field_field_input($input, $field, $value, $lead_id, $form_id)
{
    if ($field["type"] == "envoyrecharge") {
        $max_chars = "";
        if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
            $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
        }
        $input_name = $form_id . '_' . $field["id"];
        $tabindex = GFCommon::get_tabindex();
        $css = isset($field['cssClass']) ? $field['cssClass'] : "";
        //add a variable to disable a select field if admin  dashboard is opened
        if (IS_ADMIN) {
            $disabled = 'disabled';
        } else {
            $disabled = '';
        }
        $amount = '';
        $frequency = '';
        $recurring = '';
        if (is_array($value)) {
            $amount = esc_attr(rgget($field["id"] . ".1", $value));
            $frequency = rgget($field["id"] . ".2", $value);
            $recurring = rgget('input_' . $field['id'] . '.5') == "recurring" ? "checked='checked'" : "";
        }
        $recur_label = empty($field['field_envoyrecharge_recur_label']) ? 'Yes, I want to make a recurring donation' : $field['field_envoyrecharge_recur_label'];
        $recur_hidden = !empty($field['field_envoyrecharge_recurring_disabled']) ? ' style="display: none;"' : '';
        $html = "<div class='ginput_container'>" . "\n";
        $html .= '<input name="input_' . $field['id'] . '.1" id="input_' . $input_name . '_1" class="gform_ech ginput_amount ' . $field["type"] . ' ' . esc_attr($css) . ' ' . $field['size'] . '" type="text" ' . $disabled . ' value="' . $amount . '">';
        $html .= '<div class="gform_envoyrecharge_recurring envoyrecharge_recur_setting"' . $recur_hidden . '><input name="input_' . $field['id'] . '.5" id="ginput_envoyrecharge_recurring_' . $field['id'] . '" type="checkbox" ' . $disabled . ' value="recurring" ' . $recurring . ' onclick="EnvoyToggleRecurring(jQuery(this));">
            <label class="ginput_envoyrecharge_label" id="ginput_envoyrecharge_label_' . $field['id'] . '" for="ginput_envoyrecharge_recurring_' . $field['id'] . '">' . $recur_label . '</label></div>';
        $html .= "\n    <select {$disabled} data-checkbox='ginput_envoyrecharge_recurring_" . $field['id'] . "' name='input_" . $field['id'] . ".2' id='input_" . $input_name . "_2' class='select envoyrecharge_recur_setting envoyrecharge_recur_frequency gform_ech " . $field["type"] . ' ' . esc_attr($css) . ' ' . $field['size'] . "'{$recur_hidden}>" . GFCommon::get_select_choices($field, $value) . "</select>";
        $html .= "</div>";
        return $html;
    }
    return $input;
}
Exemplo n.º 8
0
 private static function get_list_input($field, $has_columns, $column, $value, $form_id)
 {
     $tabindex = GFCommon::get_tabindex();
     $column_index = 1;
     if ($has_columns && is_array(rgar($field, "choices"))) {
         foreach ($field["choices"] as $choice) {
             if ($choice["text"] == $column["text"]) {
                 break;
             }
             $column_index++;
         }
     }
     $input_info = array("type" => "text");
     $input_info = apply_filters("gform_column_input_{$form_id}_{$field["id"]}_{$column_index}", apply_filters("gform_column_input", $input_info, $field, rgar($column, "text"), $value, $form_id), $field, rgar($column, "text"), $value, $form_id);
     switch ($input_info["type"]) {
         case "select":
             $input = "<select name='input_{$field["id"]}[]' {$tabindex} >";
             if (!is_array($input_info["choices"])) {
                 $input_info["choices"] = explode(",", $input_info["choices"]);
             }
             foreach ($input_info["choices"] as $choice) {
                 if (is_array($choice)) {
                     $choice_value = $choice["value"];
                     $choice_text = $choice["text"];
                     $choice_selected = $choice["isSelected"];
                 } else {
                     $choice_value = $choice;
                     $choice_text = $choice;
                     $choice_selected = false;
                 }
                 $is_selected = empty($value) ? $choice_selected : $choice_value == $value;
                 $selected = $is_selected ? "selected='selected'" : "";
                 $input .= "<option value='" . esc_attr($choice_value) . "' {$selected}>" . esc_html($choice_text) . "</option>";
             }
             $input .= "</select>";
             break;
         default:
             $input = "<input type='text' name='input_{$field["id"]}[]' value='" . esc_attr($value) . "' {$tabindex}/>";
             break;
     }
     return apply_filters("gform_column_input_content_{$form_id}_{$field["id"]}_{$column_index}", apply_filters("gform_column_input_content", $input, $input_info, $field, rgar($column, "text"), $value, $form_id), $input_info, $field, rgar($column, "text"), $value, $form_id);
 }
Exemplo n.º 9
0
 private static function get_form_button($form_id, $button_input_id, $button, $default_text, $class, $alt, $target_page_number)
 {
     $tabindex = GFCommon::get_tabindex();
     $input_type = 'submit';
     $onclick = "";
     if (!empty($target_page_number)) {
         //$onclick = "onclick='jQuery(\"#gform_target_page_number_{$form_id}\").val(\"{$target_page_number}\"); jQuery(\"#gform_{$form_id}\").trigger(\"submit\",[true]); '";
         $input_type = 'button';
     } else {
         //to prevent multiple form submissions when button is pressed multiple times
         if (GFFormsModel::is_html5_enabled()) {
             $set_submitting = "if( jQuery(this).hasClass(\".disabled\") ){ window[\"gf_submitting_{$form_id}\"]=true;}";
         } else {
             $set_submitting = "window[\"gf_submitting_{$form_id}\"]=true;";
         }
         //$onclick="onclick='if(window[\"gf_submitting_{$form_id}\"]){return false;}  $set_submitting '";
     }
     if ($button["type"] == "text" || empty($button["imageUrl"])) {
         $button_text = !empty($button["text"]) ? $button["text"] : $default_text;
         if (function_exists('qtranxf_getLanguage') && !empty($button["text"])) {
             $button_text = apply_filters('the_title', $button_text);
         }
         $button_input = "<input type='{$input_type}' id='{$button_input_id}' class='{$class} btn btn-default' value='" . esc_attr($button_text) . "' {$tabindex} {$onclick}/>";
     } else {
         $imageUrl = $button["imageUrl"];
         $button_input = "<input type='image' src='{$imageUrl}' id='{$button_input_id}' class='gform_image_button' alt='{$alt}' {$tabindex} {$onclick}/>";
     }
     return $button_input;
 }
Exemplo n.º 10
0
    private static function get_form_button($form_id, $button_input_id, $button, $default_text, $class, $alt, $target_page_number){
        $tabindex = GFCommon::get_tabindex();
        $input_type='submit';
        $onclick="";
        if(!empty($target_page_number)){
            $onclick = "onclick='jQuery(\"#gform_target_page_number_{$form_id}\").val(\"{$target_page_number}\"); jQuery(\"#gform_{$form_id}\").trigger(\"submit\",[true]); '";
            $input_type='button';
        }
        else{
            //to prevent multiple form submissions when button is pressed multiple times
            if(GFFormsModel::is_html5_enabled())
                $set_submitting = "if( !jQuery(\"#gform_{$form_id}\")[0].checkValidity || jQuery(\"#gform_{$form_id}\")[0].checkValidity()){window[\"gf_submitting_{$form_id}\"]=true;}";
            else
                $set_submitting = "window[\"gf_submitting_{$form_id}\"]=true;";

            $onclick="onclick='if(window[\"gf_submitting_{$form_id}\"]){return false;}  $set_submitting '";
        }

        if($button["type"] == "text" || empty($button["imageUrl"])){
            $button_text = !empty($button["text"]) ? $button["text"] : $default_text;
            $button_input = "<input type='{$input_type}' id='{$button_input_id}' class='{$class}' value='" . esc_attr($button_text) . "' {$tabindex} {$onclick}/>";
        }
        else{
            $imageUrl = $button["imageUrl"];
            $button_input= "<input type='image' src='{$imageUrl}' id='{$button_input_id}' class='gform_image_button' alt='{$alt}' {$tabindex} {$onclick}/>";
        }
        return $button_input;
    }
 public function get_list_input($has_columns, $column, $value, $form_id)
 {
     $tabindex = GFCommon::get_tabindex();
     $disabled = $this->is_form_editor() ? 'disabled' : '';
     $column_index = 1;
     if ($has_columns && is_array($this->choices)) {
         foreach ($this->choices as $choice) {
             if ($choice['text'] == $column['text']) {
                 break;
             }
             $column_index++;
         }
     }
     $input_info = array('type' => 'text');
     $input_info = apply_filters("gform_column_input_{$form_id}_{$this->id}_{$column_index}", apply_filters('gform_column_input', $input_info, $this, rgar($column, 'text'), $value, $form_id), $this, rgar($column, 'text'), $value, $form_id);
     switch ($input_info['type']) {
         case 'select':
             $input = "<select name='input_{$this->id}[]' {$tabindex} {$disabled} >";
             if (!is_array($input_info['choices'])) {
                 $input_info['choices'] = explode(',', $input_info['choices']);
             }
             foreach ($input_info['choices'] as $choice) {
                 if (is_array($choice)) {
                     $choice_value = $choice['value'];
                     $choice_text = $choice['text'];
                     $choice_selected = array_key_exists('isSelected', $choice) ? $choice['isSelected'] : false;
                 } else {
                     $choice_value = $choice;
                     $choice_text = $choice;
                     $choice_selected = false;
                 }
                 $is_selected = empty($value) ? $choice_selected : $choice_value == $value;
                 $selected = $is_selected ? "selected='selected'" : '';
                 $input .= "<option value='" . esc_attr($choice_value) . "' {$selected}>" . esc_html($choice_text) . '</option>';
             }
             $input .= '</select>';
             break;
         default:
             $input = "<input type='text' name='input_{$this->id}[]' value='" . esc_attr($value) . "' {$tabindex} {$disabled}/>";
             break;
     }
     return apply_filters("gform_column_input_content_{$form_id}_{$this->id}_{$column_index}", apply_filters('gform_column_input_content', $input, $input_info, $this, rgar($column, 'text'), $value, $form_id), $input_info, $this, rgar($column, 'text'), $value, $form_id);
 }
Exemplo n.º 12
0
    /**
     * pluploader_field_input
     * 
     * Called by 'gform_field_input' gravity forms action.
     * Add html required to render custom field
     * 
     * @access 	public
     * @author	Ben Moody
     */
    public function pluploader_field_input($input, $field, $value, $lead_id, $form_id)
    {
        //Init vars
        $max_chars = NULL;
        $container = NULL;
        $plupload_container = NULL;
        if ($field["type"] == "prso_gform_pluploader") {
            if (!empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
                $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
            }
            $input_name = $form_id . '_' . $field["id"];
            $tabindex = GFCommon::get_tabindex();
            $css = isset($field['cssClass']) ? $field['cssClass'] : '';
            //Cache the hidden field taht will store data on uploaded files
            if (is_admin()) {
                $input = "<div class='ginput_container prso_plupload'><span class='gform_drop_instructions'>Advanced Uploader</span></div>";
            } else {
                ob_start();
                ?>
				<div class='ginput_container prso_plupload'><input name='input_%s' id='%s' type='hidden' /></div>
				<?php 
                echo $this->get_exisiting_file_input_html($field["id"]);
                $input = ob_get_contents();
                ob_end_clean();
            }
            $input = sprintf($input, $field["id"], 'prso_form_pluploader_' . $field['id']);
            //Cache the div element used by pluploader jquery plugin
            if (!is_admin()) {
                switch ($this->user_interface) {
                    case 'custom':
                        ob_start();
                        ?>
						<div id="filelist"><?php 
                        _ex("Your browser doesn't have Flash, Silverlight or HTML5 support.", 'user alert message', 'prso_gform_pluploader');
                        ?>
</div>
						<div id='pluploader_%s'>
							<a id="pickfiles" href="javascript:;">[Select files]</a> 
						    <a id="uploadfiles" href="javascript:;">[Upload files]</a>
						</div>
						<?php 
                        $container = ob_get_contents();
                        ob_end_clean();
                        break;
                    default:
                        ob_start();
                        ?>
						<div id="filelist"><?php 
                        _ex("Your browser doesn't have Flash, Silverlight or HTML5 support.", 'user alert message', 'prso_gform_pluploader');
                        ?>
</div>
						<div id='pluploader_%s'></div>
						<?php 
                        $container = ob_get_contents();
                        ob_end_clean();
                        break;
                }
                $plupload_container = sprintf($container, $field["id"]);
            }
            //Run through filter to allow devs to move the div outside the form it they wish
            $input .= apply_filters('prso_gform_pluploader_container', $plupload_container, $field, $form_id);
        }
        return $input;
    }
Exemplo n.º 13
0
 private static function get_form_button($form_id, $button_input_id, $button, $default_text, $class, $alt, $target_page_number)
 {
     $tabindex = GFCommon::get_tabindex();
     $input_type = 'submit';
     $onclick = "";
     if (!empty($target_page_number)) {
         $onclick = "onclick='jQuery(\"#gform_target_page_number_{$form_id}\").val(\"{$target_page_number}\"); jQuery(\"#gform_{$form_id}\").trigger(\"submit\",[true]); '";
         $input_type = 'button';
     }
     if ($button["type"] == "text" || empty($button["imageUrl"])) {
         $button_text = !empty($button["text"]) ? $button["text"] : $default_text;
         $button_input = "<input type='{$input_type}' id='{$button_input_id}' class='{$class}' value='" . esc_attr($button_text) . "' {$tabindex} {$onclick}/>";
     } else {
         $imageUrl = $button["imageUrl"];
         $button_input = "<input type='image' src='{$imageUrl}' id='{$button_input_id}' class='gform_image_button' alt='{$alt}' {$tabindex} {$onclick}/>";
     }
     return $button_input;
 }
Exemplo n.º 14
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;
     $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'" : '';
     $street_value = '';
     $street2_value = '';
     $city_value = '';
     $state_value = '';
     $zip_value = '';
     $country_value = '';
     if (is_array($value)) {
         $street_value = esc_attr(rgget($this->id . '.1', $value));
         $street2_value = esc_attr(rgget($this->id . '.2', $value));
         $city_value = esc_attr(rgget($this->id . '.3', $value));
         $state_value = esc_attr(rgget($this->id . '.4', $value));
         $zip_value = esc_attr(rgget($this->id . '.5', $value));
         $country_value = esc_attr(rgget($this->id . '.6', $value));
     }
     //Inputs
     $address_street_field_input = GFFormsModel::get_input($this, $this->id . '.1');
     $address_street2_field_input = GFFormsModel::get_input($this, $this->id . '.2');
     $address_city_field_input = GFFormsModel::get_input($this, $this->id . '.3');
     $address_state_field_input = GFFormsModel::get_input($this, $this->id . '.4');
     $address_zip_field_input = GFFormsModel::get_input($this, $this->id . '.5');
     $address_country_field_input = GFFormsModel::get_input($this, $this->id . '.6');
     //Placeholders
     $street_placeholder_attribute = GFCommon::get_input_placeholder_attribute($address_street_field_input);
     $street2_placeholder_attribute = GFCommon::get_input_placeholder_attribute($address_street2_field_input);
     $city_placeholder_attribute = GFCommon::get_input_placeholder_attribute($address_city_field_input);
     $zip_placeholder_attribute = GFCommon::get_input_placeholder_attribute($address_zip_field_input);
     $address_types = $this->get_address_types($form_id);
     $addr_type = empty($this->addressType) ? 'international' : $this->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']) || $this->hideCountry || rgar($address_country_field_input, 'isHidden');
     if (empty($country_value)) {
         $country_value = $this->defaultCountry;
     }
     if (empty($state_value)) {
         $state_value = $this->defaultState;
     }
     $country_placeholder = GFCommon::get_input_placeholder_value($address_country_field_input);
     $country_list = $this->get_country_dropdown($country_value, $country_placeholder);
     //changing css classes based on field format to ensure proper display
     $address_display_format = apply_filters('gform_address_display_format', 'default', $this);
     $city_location = $address_display_format == 'zip_before_city' ? 'right' : 'left';
     $zip_location = $address_display_format != 'zip_before_city' && ($this->hideState || rgar($address_state_field_input, 'isHidden')) ? 'right' : 'left';
     // support for $this->hideState legacy property
     $state_location = $address_display_format == 'zip_before_city' ? 'left' : 'right';
     $country_location = $this->hideState || rgar($address_state_field_input, 'isHidden') ? 'left' : 'right';
     // support for $this->hideState legacy property
     //labels
     $address_street_sub_label = rgar($address_street_field_input, 'customLabel') != '' ? $address_street_field_input['customLabel'] : __('Street Address', 'gravityforms');
     $address_street_sub_label = apply_filters('gform_address_street_{$form_id}', apply_filters('gform_address_street', $address_street_sub_label, $form_id), $form_id);
     $address_street2_sub_label = rgar($address_street2_field_input, 'customLabel') != '' ? $address_street2_field_input['customLabel'] : __('Address Line 2', 'gravityforms');
     $address_street2_sub_label = apply_filters("gform_address_street2_{$form_id}", apply_filters('gform_address_street2', $address_street2_sub_label, $form_id), $form_id);
     $address_zip_sub_label = rgar($address_zip_field_input, 'customLabel') != '' ? $address_zip_field_input['customLabel'] : $zip_label;
     $address_zip_sub_label = apply_filters("gform_address_zip_{$form_id}", apply_filters('gform_address_zip', $address_zip_sub_label, $form_id), $form_id);
     $address_city_sub_label = rgar($address_city_field_input, 'customLabel') != '' ? $address_city_field_input['customLabel'] : __('City', 'gravityforms');
     $address_city_sub_label = apply_filters("gform_address_city_{$form_id}", apply_filters('gform_address_city', $address_city_sub_label, $form_id), $form_id);
     $address_state_sub_label = rgar($address_state_field_input, 'customLabel') != '' ? $address_state_field_input['customLabel'] : $state_label;
     $address_state_sub_label = apply_filters("gform_address_state_{$form_id}", apply_filters('gform_address_state', $address_state_sub_label, $form_id), $form_id);
     $address_country_sub_label = rgar($address_country_field_input, 'customLabel') != '' ? $address_country_field_input['customLabel'] : __('Country', 'gravityforms');
     $address_country_sub_label = apply_filters("gform_address_country_{$form_id}", apply_filters('gform_address_country', $address_country_sub_label, $form_id), $form_id);
     //address field
     $street_address = '';
     $tabindex = $this->get_tabindex();
     $style = $is_admin && rgar($address_street_field_input, 'isHidden') ? "style='display:none;'" : '';
     if ($is_admin || !rgar($address_street_field_input, 'isHidden')) {
         if ($is_sub_label_above) {
             $street_address = " <span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' {$style}>\n                                                <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$address_street_sub_label}</label>\n                                                <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$street_value}' {$tabindex} {$disabled_text} {$street_placeholder_attribute}/>\n                                            </span>";
         } else {
             $street_address = " <span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' {$style}>\n                                                <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$street_value}' {$tabindex} {$disabled_text} {$street_placeholder_attribute}/>\n                                                <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$address_street_sub_label}</label>\n                                            </span>";
         }
     }
     //address line 2 field
     $street_address2 = '';
     $style = $is_admin && ($this->hideAddress2 || rgar($address_street2_field_input, 'isHidden')) ? "style='display:none;'" : '';
     // support for $this->hideAddress2 legacy property
     if ($is_admin || !$this->hideAddress2 && !rgar($address_street2_field_input, 'isHidden')) {
         $tabindex = $this->get_tabindex();
         if ($is_sub_label_above) {
             $street_address2 = "<span class='ginput_full{$class_suffix}' id='{$field_id}_2_container' {$style}>\n                                                <label for='{$field_id}_2' id='{$field_id}_2_label' {$sub_label_class_attribute}>{$address_street2_sub_label}</label>\n                                                <input type='text' name='input_{$id}.2' id='{$field_id}_2' value='{$street2_value}' {$tabindex} {$disabled_text} {$street2_placeholder_attribute}/>\n                                            </span>";
         } else {
             $street_address2 = "<span class='ginput_full{$class_suffix}' id='{$field_id}_2_container' {$style}>\n                                                <input type='text' name='input_{$id}.2' id='{$field_id}_2' value='{$street2_value}' {$tabindex} {$disabled_text} {$street2_placeholder_attribute}/>\n                                                <label for='{$field_id}_2' id='{$field_id}_2_label' {$sub_label_class_attribute}>{$address_street2_sub_label}</label>\n                                            </span>";
         }
     }
     if ($address_display_format == 'zip_before_city') {
         //zip field
         $zip = '';
         $tabindex = $this->get_tabindex();
         $style = $is_admin && rgar($address_zip_field_input, 'isHidden') ? "style='display:none;'" : '';
         if ($is_admin || !rgar($address_zip_field_input, 'isHidden')) {
             if ($is_sub_label_above) {
                 $zip = "<span class='ginput_{$zip_location}{$class_suffix}' id='{$field_id}_5_container' {$style}>\n                                    <label for='{$field_id}_5' id='{$field_id}_5_label' {$sub_label_class_attribute}>{$address_zip_sub_label}</label>\n                                    <input type='text' name='input_{$id}.5' id='{$field_id}_5' value='{$zip_value}' {$tabindex} {$disabled_text} {$zip_placeholder_attribute}/>\n                                </span>";
             } else {
                 $zip = "<span class='ginput_{$zip_location}{$class_suffix}' id='{$field_id}_5_container' {$style}>\n                                    <input type='text' name='input_{$id}.5' id='{$field_id}_5' value='{$zip_value}' {$tabindex} {$disabled_text} {$zip_placeholder_attribute}/>\n                                    <label for='{$field_id}_5' id='{$field_id}_5_label' {$sub_label_class_attribute}>{$address_zip_sub_label}</label>\n                                </span>";
             }
         }
         //city field
         $city = '';
         $tabindex = $this->get_tabindex();
         $style = $is_admin && rgar($address_city_field_input, 'isHidden') ? "style='display:none;'" : '';
         if ($is_admin || !rgar($address_city_field_input, 'isHidden')) {
             if ($is_sub_label_above) {
                 $city = "<span class='ginput_{$city_location}{$class_suffix}' id='{$field_id}_3_container' {$style}>\n                                    <label for='{$field_id}_3' id='{$field_id}_3_label' {$sub_label_class_attribute}>{$address_city_sub_label}</label>\n                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$city_value}' {$tabindex} {$disabled_text} {$city_placeholder_attribute}/>\n                                 </span>";
             } else {
                 $city = "<span class='ginput_{$city_location}{$class_suffix}' id='{$field_id}_3_container' {$style}>\n                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$city_value}' {$tabindex} {$disabled_text} {$city_placeholder_attribute}/>\n                                    <label for='{$field_id}_3' id='{$field_id}_3_label' {$sub_label_class_attribute}>{$address_city_sub_label}</label>\n                                 </span>";
             }
         }
         //state field
         $style = $is_admin && ($this->hideState || rgar($address_state_field_input, 'isHidden')) ? "style='display:none;'" : '';
         // support for $this->hideState legacy property
         if ($is_admin || !$this->hideState && !rgar($address_state_field_input, 'isHidden')) {
             $state_field = $this->get_state_field($id, $field_id, $state_value, $disabled_text, $form_id);
             if ($is_sub_label_above) {
                 $state = "<span class='ginput_{$state_location}{$class_suffix}' id='{$field_id}_4_container' {$style}>\n                                           <label for='{$field_id}_4' id='{$field_id}_4_label' {$sub_label_class_attribute}>{$address_state_sub_label}</label>\n                                           {$state_field}\n                                      </span>";
             } else {
                 $state = "<span class='ginput_{$state_location}{$class_suffix}' id='{$field_id}_4_container' {$style}>\n                                           {$state_field}\n                                           <label for='{$field_id}_4' id='{$field_id}_4_label' {$sub_label_class_attribute}>{$address_state_sub_label}</label>\n                                      </span>";
             }
         } 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
         $city = '';
         $tabindex = $this->get_tabindex();
         $style = $is_admin && rgar($address_city_field_input, 'isHidden') ? "style='display:none;'" : '';
         if ($is_admin || !rgar($address_city_field_input, 'isHidden')) {
             if ($is_sub_label_above) {
                 $city = "<span class='ginput_{$city_location}{$class_suffix}' id='{$field_id}_3_container' {$style}>\n                                    <label for='{$field_id}_3' id='{$field_id}_3_label' {$sub_label_class_attribute}>{$address_city_sub_label}</label>\n                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$city_value}' {$tabindex} {$disabled_text} {$city_placeholder_attribute}/>\n                                 </span>";
             } else {
                 $city = "<span class='ginput_{$city_location}{$class_suffix}' id='{$field_id}_3_container' {$style}>\n                                    <input type='text' name='input_{$id}.3' id='{$field_id}_3' value='{$city_value}' {$tabindex} {$disabled_text} {$city_placeholder_attribute}/>\n                                    <label for='{$field_id}_3' id='{$field_id}_3_label' {$sub_label_class_attribute}>{$address_city_sub_label}</label>\n                                 </span>";
             }
         }
         //state field
         $style = $is_admin && ($this->hideState || rgar($address_state_field_input, 'isHidden')) ? "style='display:none;'" : '';
         // support for $this->hideState legacy property
         if ($is_admin || !$this->hideState && !rgar($address_state_field_input, 'isHidden')) {
             $state_field = $this->get_state_field($id, $field_id, $state_value, $disabled_text, $form_id);
             if ($is_sub_label_above) {
                 $state = "<span class='ginput_{$state_location}{$class_suffix}' id='{$field_id}_4_container' {$style}>\n                                        <label for='{$field_id}_4' id='{$field_id}_4_label' {$sub_label_class_attribute}>{$address_state_sub_label}</label>\n                                        {$state_field}\n                                      </span>";
             } else {
                 $state = "<span class='ginput_{$state_location}{$class_suffix}' id='{$field_id}_4_container' {$style}>\n                                        {$state_field}\n                                        <label for='{$field_id}_4' id='{$field_id}_4_label' {$sub_label_class_attribute}>{$address_state_sub_label}</label>\n                                      </span>";
             }
         } 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
         $zip = '';
         $tabindex = GFCommon::get_tabindex();
         $style = $is_admin && rgar($address_zip_field_input, 'isHidden') ? "style='display:none;'" : '';
         if ($is_admin || !rgar($address_zip_field_input, 'isHidden')) {
             if ($is_sub_label_above) {
                 $zip = "<span class='ginput_{$zip_location}{$class_suffix}' id='{$field_id}_5_container' {$style}>\n                                    <label for='{$field_id}_5' id='{$field_id}_5_label' {$sub_label_class_attribute}>{$address_zip_sub_label}</label>\n                                    <input type='text' name='input_{$id}.5' id='{$field_id}_5' value='{$zip_value}' {$tabindex} {$disabled_text} {$zip_placeholder_attribute}/>\n                                </span>";
             } else {
                 $zip = "<span class='ginput_{$zip_location}{$class_suffix}' id='{$field_id}_5_container' {$style}>\n                                    <input type='text' name='input_{$id}.5' id='{$field_id}_5' value='{$zip_value}' {$tabindex} {$disabled_text} {$zip_placeholder_attribute}/>\n                                    <label for='{$field_id}_5' id='{$field_id}_5_label' {$sub_label_class_attribute}>{$address_zip_sub_label}</label>\n                                </span>";
             }
         }
     }
     if ($is_admin || !$hide_country) {
         $style = $hide_country ? "style='display:none;'" : '';
         $tabindex = $this->get_tabindex();
         if ($is_sub_label_above) {
             $country = "<span class='ginput_{$country_location}{$class_suffix}' id='{$field_id}_6_container' {$style}>\n                                        <label for='{$field_id}_6' id='{$field_id}_6_label' {$sub_label_class_attribute}>{$address_country_sub_label}</label>\n                                        <select name='input_{$id}.6' id='{$field_id}_6' {$tabindex} {$disabled_text}>{$country_list}</select>\n                                    </span>";
         } else {
             $country = "<span class='ginput_{$country_location}{$class_suffix}' id='{$field_id}_6_container' {$style}>\n                                        <select name='input_{$id}.6' id='{$field_id}_6' {$tabindex} {$disabled_text}>{$country_list}</select>\n                                        <label for='{$field_id}_6' id='{$field_id}_6_label' {$sub_label_class_attribute}>{$address_country_sub_label}</label>\n                                    </span>";
         }
     } 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;
     $copy_values_option = '';
     $input_style = '';
     if (($this->enableCopyValuesOption || $is_form_editor) && !$is_entry_detail) {
         $copy_values_style = $is_form_editor && !$this->enableCopyValuesOption ? "style='display:none;'" : '';
         $copy_values_is_checked = isset($value[$this->id . '_copy_values_activated']) ? $value[$this->id . '_copy_values_activated'] == true : $this->copyValuesOptionDefault == true;
         $copy_values_checked = checked(true, $copy_values_is_checked, false);
         $copy_values_option = "<div id='{$field_id}_copy_values_option_container' class='copy_values_option_container' {$copy_values_style}>\n                                        <input type='checkbox' id='{$field_id}_copy_values_activated' class='copy_values_activated' value='1' name='input_{$id}_copy_values_activated' {$disabled_text} {$copy_values_checked}/>\n                                        <label for='{$field_id}_copy_values_activated' id='{$field_id}_copy_values_option_label' class='copy_values_option_label inline'>{$this->copyValuesOptionLabel}</label>\n                                    </div>";
         if ($copy_values_is_checked) {
             $input_style = "style='display:none;'";
         }
     }
     $css_class = $this->get_css_class();
     return "    {$copy_values_option}\n                    <div class='ginput_complex{$class_suffix} ginput_container {$css_class}' id='{$field_id}' {$input_style}>\n                        {$inputs}\n                    <div class='gf_clear gf_clear_complex'></div>\n                </div>";
 }
 /**
  * Adds the Math Captcha input area to the site.
  *
  * @since    1.0.0
  */
 public function math_captcha_field_input($input, $field, $value, $lead_id, $form_id)
 {
     if ($field['type'] == 'math_captcha') {
         // Render the math challenge question.
         $display_type = isset($field['field_math_captcha_type']) ? $field['field_math_captcha_type'] : 'mixed';
         $equation = $this->generate_equation($display_type);
         $question = $equation[0] . ' ' . $equation[1] . ' ' . $equation[2];
         // Store the solution in a hex-encoded string.
         $answers = $equation[3] . ',' . $equation[4];
         $answers_no_spam = '';
         for ($i = 0; $i < strlen($answers); $i++) {
             $answers_no_spam .= '%' . zeroise(dechex(ord($answers[$i])), 2);
         }
         // Get the form/field properties to construct the input.
         $input_id = $form_id . '_' . $field['id'];
         $tab_index = GFCommon::get_tabindex();
         $css = !empty($field['cssClass']) ? ' ' . $field['cssClass'] : '';
         return sprintf("<div class='ginput_container'>%s &#61; <input name='input_%d' id='input_%s' type='text' class='%s' %s ><input name='math_captcha_answers_%d' type='hidden' value='%s'></div>", $question, $field['id'], $input_id, $field['type'] . ' small' . esc_attr($css), $tab_index, $field['id'], $answers_no_spam);
     }
     return $input;
 }
 /**
  * Add the Quickbooks Customer Field title
  * Called by Filter gform_field_input
  *
  * @return string
  **/
 public function setFieldInput($input, $field, $value, $lead_id, $form_id)
 {
     $customers = $this->getAll();
     error_log(print_r($customers, true));
     if ($field->type == 'qbcustomer') {
         $tabIndex = \GFCommon::get_tabindex();
         $class = isset($field->cssClass) ? $field->cssClass : '';
         $qbCustomers = json_encode([]);
         ob_start();
         require_once plugin_dir_path(dirname(__FILE__)) . 'public/partials/gf-quickbooks-online-public-customer-autocomplete.php';
         $input = ob_get_clean();
     }
     return $input;
 }
Exemplo n.º 17
0
 public function get_survey_field_content($content, $field, $value, $lead_id, $form_id, $lead = null)
 {
     if ($field['type'] != 'survey') {
         return $content;
     }
     $sub_type = rgar($field, 'inputType');
     switch ($sub_type) {
         case 'likert':
             $multiple_rows = rgar($field, 'gsurveyLikertEnableMultipleRows');
             $field_id = $field['id'];
             $num_rows = $multiple_rows ? count($field['gsurveyLikertRows']) : 1;
             $table_id = "id='input_{$form_id}_{$field_id}'";
             $content = "<div class='ginput_container'>";
             $content .= "<table {$table_id} class='gsurvey-likert'>";
             $content .= '<tr>';
             if ($multiple_rows) {
                 $content .= "<td class='gsurvey-likert-row-label'></td>";
             }
             $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != 'entry' || IS_ADMIN && RG_CURRENT_VIEW == 'entry' && 'edit' != rgpost('screen_mode') ? "disabled='disabled'" : '';
             foreach ($field['choices'] as $choice) {
                 $content .= "<td class='gsurvey-likert-choice-label'>";
                 $content .= $choice['text'];
                 $content .= '</td>';
             }
             $content .= '</tr>';
             $row_id = 1;
             for ($i = 1; $i <= $num_rows; $i++) {
                 //hack to skip numbers ending in 0. so that 5.1 doesn't conflict with 5.10
                 if ($row_id % 10 == 0) {
                     $row_id++;
                 }
                 $row_text = $field['gsurveyLikertRows'][$i - 1]['text'];
                 $row_value = $field['gsurveyLikertRows'][$i - 1]['value'];
                 $content .= '<tr>';
                 if ($multiple_rows) {
                     $content .= "<td class='gsurvey-likert-row-label'>{$row_text}</td>";
                 }
                 $choice_id = 1;
                 foreach ($field['choices'] as $choice) {
                     //hack to skip numbers ending in 0. so that 5.1 doesn't conflict with 5.10
                     if ($choice_id % 10 == 0) {
                         $choice_id++;
                     }
                     $id = $field['id'] . '_' . $row_id . '_' . $choice_id;
                     $field_value = $multiple_rows ? $row_value . ':' . $choice['value'] : $choice['value'];
                     $cell_class = 'gsurvey-likert-choice';
                     $checked = '';
                     $selected = false;
                     if (rgblank($value) && empty($lead)) {
                         $checked = '';
                     } else {
                         if ($multiple_rows) {
                             $input_name = $field['id'] . '.' . $row_id;
                             if (is_array($value) && isset($value[$input_name])) {
                                 $response_value = $value[$input_name];
                                 $selected = $response_value == $field_value ? true : false;
                             } else {
                                 if ($lead == null) {
                                     $lead = GFFormsModel::get_lead($lead_id);
                                 }
                                 if (false === $lead) {
                                     $selected = false;
                                 } else {
                                     $response_col_val = $this->get_likert_col_val_for_row_from_entry($row_value, $field_id, $lead);
                                     $selected = $response_col_val == $choice['value'] ? true : false;
                                 }
                             }
                         } else {
                             $selected = $choice['value'] == $value ? true : false;
                         }
                     }
                     if ($selected) {
                         $checked = "checked='checked'";
                         $cell_class = $cell_class . ' gsurvey-likert-selected';
                     }
                     $logic_event = empty($field['conditionalLogicFields']) || IS_ADMIN ? '' : "onclick='gf_apply_rules(" . $field['formId'] . ',' . GFCommon::json_encode($field['conditionalLogicFields']) . ");'";
                     $tabindex = GFCommon::get_tabindex();
                     $content .= "<td class='{$cell_class}'>";
                     if ($multiple_rows) {
                         //
                         $input_id = sprintf('input_%d.%d', $field_id, $row_id);
                     } else {
                         $input_id = sprintf('input_%d', $field_id);
                     }
                     $content .= sprintf("<input name='{$input_id}' type='radio' {$logic_event} value='%s' %s id='choice_%s' {$tabindex} %s />", esc_attr($field_value), $checked, $id, $disabled_text);
                     $content .= '</td>';
                     $choice_id++;
                 }
                 $row_id++;
                 $content .= '</tr>';
             }
             $content .= '</table>';
             $content .= '</div>';
             break;
         case 'rank':
             $field_id = $field['id'];
             $input_id = "gsurvey-rank-{$form_id}-{$field_id}";
             $content = "<div class='ginput_container'>";
             $content .= "<ul id='{$input_id}' class='gsurvey-rank'>";
             $handle_image_url = $this->get_base_url() . '/images/arrow-handle.png';
             $choice_id = 0;
             $count = 1;
             $choices = array();
             if (false === empty($value)) {
                 $ordered_values = explode(',', $value);
                 foreach ($ordered_values as $ordered_value) {
                     $choices[] = array('value' => $ordered_value, 'text' => RGFormsModel::get_choice_text($field, $ordered_value));
                 }
             } else {
                 $choices = $field['choices'];
             }
             foreach ($choices as $choice) {
                 $id = $field['id'] . '_' . $choice_id++;
                 $field_value = !empty($choice['value']) || rgar($field, 'enableChoiceValue') ? $choice['value'] : $choice['text'];
                 $content .= sprintf("<li data-index='{$choice_id}' class='gsurvey-rank-choice choice_%s' id='{$field_value}' ><img src='{$handle_image_url}'  alt='' />%s</li>", $id, $choice['text']);
                 if (IS_ADMIN && RG_CURRENT_VIEW != 'entry' && $count >= 5) {
                     break;
                 }
                 $count++;
             }
             $content .= '</ul>';
             $content .= sprintf("<input type='hidden' id='{$input_id}-hidden' name='input_%d' />", $field_id);
             $content .= '</div>';
             break;
         case 'rating':
             $field_id = $field['id'];
             $div_id = "input_{$form_id}_{$field_id}";
             $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != 'entry' ? "disabled='disabled'" : '';
             $content = "<div class='gsurvey-rating-wrapper'><div id='{$div_id}' class='gsurvey-rating'>";
             $choice_id = 0;
             $count = 1;
             // choices reversed in the form editor from version 2.1.1
             if (rgar($field, 'reversed')) {
                 $field['choices'] = array_reverse($field['choices']);
             }
             foreach ($field['choices'] as $choice) {
                 $id = $field['id'] . '_' . $choice_id++;
                 $field_value = !empty($choice['value']) || rgar($field, 'enableChoiceValue') ? $choice['value'] : $choice['text'];
                 if (rgblank($value) && RG_CURRENT_VIEW != 'entry') {
                     $checked = rgar($choice, 'isSelected') ? "checked='checked'" : '';
                 } else {
                     $checked = RGFormsModel::choice_value_match($field, $choice, $value) ? "checked='checked'" : '';
                 }
                 $logic_event = empty($field['conditionalLogicFields']) || IS_ADMIN ? '' : "onclick='gf_apply_rules(" . $field['formId'] . ',' . GFCommon::json_encode($field['conditionalLogicFields']) . ");'";
                 $tabindex = GFCommon::get_tabindex();
                 $choice_label = $choice['text'];
                 $content .= sprintf("<input name='input_%d' type='radio' {$logic_event} value='%s' %s id='choice_%s' {$tabindex} %s /><label for='choice_%s' title='%s'>%s</label>", $field_id, esc_attr($field_value), $checked, $id, $disabled_text, $id, $choice_label, $choice_label);
                 if (IS_ADMIN && RG_CURRENT_VIEW != 'entry' && $count >= 5) {
                     break;
                 }
                 $count++;
             }
             $content .= '</div></div>';
     }
     return $content;
 }
Exemplo n.º 18
0
 private function cart_get_list_input($field, $has_columns, $column, $value, $form_id)
 {
     $tabindex = GFCommon::get_tabindex();
     $column_index = 1;
     if ($has_columns && is_array(rgar($field, 'choices'))) {
         foreach ($field['choices'] as $choice) {
             if ($choice['text'] == $column['text']) {
                 break;
             }
             $column_index++;
         }
     }
     $input_info = array('type' => 'text');
     $input_info = apply_filters("gform_column_input_{$form_id}_{$field["id"]}_{$column_index}", apply_filters('gform_column_input', $input_info, $field, rgar($column, 'text'), $value, $form_id), $field, rgar($column, 'text'), $value, $form_id);
     switch ($input_info['type']) {
         case 'select':
             $input = "<select name='input_{$field["id"]}[]' {$tabindex} >";
             if (!is_array($input_info['choices'])) {
                 $input_info['choices'] = explode(',', $input_info['choices']);
             }
             foreach ($input_info['choices'] as $choice) {
                 if (is_array($choice)) {
                     $choice_value = rgar($choice, 'value');
                     $choice_text = rgar($choice, 'text');
                     $choice_selected = rgar($choice, 'isSelected');
                 } else {
                     $choice_value = $choice;
                     $choice_text = $choice;
                     $choice_selected = false;
                 }
                 $is_selected = empty($value) ? $choice_selected : $choice_value == $value;
                 $selected = $is_selected ? "selected='selected'" : '';
                 $input .= "<option value='" . esc_attr($choice_value) . "' {$selected}>" . esc_html($choice_text) . '</option>';
             }
             $input .= '</select>';
             break;
         default:
             $input = "<input type='text' name='input_{$field["id"]}[]' value='" . esc_attr($value) . "' {$tabindex} readonly/>";
             break;
     }
     return apply_filters("gform_column_input_content_{$form_id}_{$field["id"]}_{$column_index}", apply_filters('gform_column_input_content', $input, $input_info, $field, rgar($column, 'text'), $value, $form_id), $input_info, $field, rgar($column, 'text'), $value, $form_id);
 }
 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>";
     }
 }
 private static function get_form_button($form_id, $button_input_id, $button, $default_text, $class, $alt)
 {
     $tabindex = GFCommon::get_tabindex();
     $input_type = 'submit';
     $onclick = "";
     //to prevent multiple form submissions when button is pressed multiple times
     if (GFFormsModel::is_html5_enabled()) {
         $set_submitting = "if( !jQuery(\"#gform_{$form_id}\")[0].checkValidity || jQuery(\"#gform_{$form_id}\")[0].checkValidity()){window[\"gf_submitting_{$form_id}\"]=true;}";
     } else {
         $set_submitting = "window[\"gf_submitting_{$form_id}\"]=true;";
     }
     $onclick = "onclick='if(window[\"gf_submitting_{$form_id}\"]){return false;}  {$set_submitting} '";
     $button_input = "<input type='{$input_type}' id='{$button_input_id}' class='{$class}' value='Update' {$tabindex} {$onclick}/>";
     return $button_input;
 }
function prso_theme_gform_field_choices($choices, $field)
{
    //Init vars
    $type = 'radio';
    $choices = NULL;
    if (!is_admin()) {
        //Change html content for text input and address fields
        if ($field['type'] === 'radio' || $field['type'] === 'checkbox') {
            if ($field['type'] === 'checkbox') {
                $type = 'checkbox';
            }
            if (is_array($field["choices"])) {
                $choice_id = 0;
                // add "other" choice to choices if enabled
                if (rgar($field, 'enableOtherChoice')) {
                    $other_default_value = GFCommon::get_other_choice_value();
                    $field["choices"][] = array('text' => $other_default_value, 'value' => 'gf_other_choice', 'isSelected' => false, 'isOtherChoice' => true);
                }
                //$logic_event = GFCommon::get_logic_event($field, "click");
                $count = 1;
                foreach ($field["choices"] as $choice) {
                    $id = $field["id"] . '_' . $choice_id++;
                    $field_value = !empty($choice["value"]) || rgar($field, "enableChoiceValue") ? $choice["value"] : $choice["text"];
                    if (rgget("enablePrice", $field)) {
                        $field_value .= "|" . GFCommon::to_number(rgar($choice, "price"));
                    }
                    if (RG_CURRENT_VIEW != "entry") {
                        $checked = rgar($choice, "isSelected") ? "checked='checked'" : "";
                    } else {
                        $checked = RGFormsModel::choice_value_match($field, $choice, $value) ? "checked='checked'" : "";
                    }
                    $tabindex = GFCommon::get_tabindex();
                    $label = sprintf("%s</label>", $choice["text"]);
                    $input_focus = '';
                    // handle "other" choice
                    if (rgar($choice, 'isOtherChoice')) {
                        $onfocus = !IS_ADMIN ? 'jQuery(this).prev("input").attr("checked", true); if(jQuery(this).val() == "' . $other_default_value . '") { jQuery(this).val(""); }' : '';
                        $onblur = !IS_ADMIN ? 'if(jQuery(this).val().replace(" ", "") == "") { jQuery(this).val("' . $other_default_value . '"); }' : '';
                        $input_focus = !IS_ADMIN ? "onfocus=\"jQuery(this).next('input').focus();\"" : "";
                        $value_exists = RGFormsModel::choices_value_match($field, $field["choices"], $value);
                        if ($value == 'gf_other_choice' && rgpost("input_{$field["id"]}_other")) {
                            $other_value = rgpost("input_{$field["id"]}_other");
                        } else {
                            if (!$value_exists && !empty($value)) {
                                $other_value = $value;
                                $value = 'gf_other_choice';
                                $checked = "checked='checked'";
                            } else {
                                $other_value = $other_default_value;
                            }
                        }
                        $label = "<input name='input_{$field["id"]}_other' type='text' value='" . esc_attr($other_value) . "' onfocus='{$onfocus}' onblur='{$onblur}' {$tabindex} {$disabled_text} />";
                    }
                    $choices .= sprintf("<li class='gchoice_{$id}'><label for='choice_%s'><input name='input_%d' type='{$type}' value='%s' %s id='choice_%s' {$tabindex} %s />&nbsp;%s</li>", $field["id"], $field["id"], esc_attr($field_value), $checked, $id, $input_focus, $label);
                    if (IS_ADMIN && RG_CURRENT_VIEW != "entry" && $count >= 5) {
                        break;
                    }
                    $count++;
                }
                $total = sizeof($field["choices"]);
                if ($count < $total) {
                    $choices .= "<li class='gchoice_total'>" . sprintf(__("%d of %d items shown. Edit field to view all", "gravityforms"), $count, $total) . "</li>";
                }
            }
        }
    }
    return $choices;
}
Exemplo n.º 22
0
 public static function get_form_button($form_id, $button_input_id, $button, $default_text, $class, $alt, $target_page_number, $onclick = '')
 {
     $tabindex = GFCommon::get_tabindex();
     $input_type = 'submit';
     if (!empty($target_page_number)) {
         $onclick = "onclick='jQuery(\"#gform_target_page_number_{$form_id}\").val(\"{$target_page_number}\"); {$onclick} jQuery(\"#gform_{$form_id}\").trigger(\"submit\",[true]); '";
         $input_type = 'button';
     } else {
         // prevent multiple form submissions when button is pressed multiple times
         if (GFFormsModel::is_html5_enabled()) {
             $set_submitting = "if( !jQuery(\"#gform_{$form_id}\")[0].checkValidity || jQuery(\"#gform_{$form_id}\")[0].checkValidity()){window[\"gf_submitting_{$form_id}\"]=true;}";
         } else {
             $set_submitting = "window[\"gf_submitting_{$form_id}\"]=true;";
         }
         $onclick_submit = $button['type'] == 'link' ? "jQuery(\"#gform_{$form_id}\").trigger(\"submit\",[true]);" : '';
         $onclick = "onclick='if(window[\"gf_submitting_{$form_id}\"]){return false;}  {$set_submitting} {$onclick} {$onclick_submit}'";
     }
     if (rgar($button, 'type') == 'text' || rgar($button, 'type') == 'link' || empty($button['imageUrl'])) {
         $button_text = !empty($button['text']) ? $button['text'] : $default_text;
         if (rgar($button, 'type') == 'link') {
             $button_input = "<a href='javascript:void(0);' id='{$button_input_id}_link' class='{$class}' {$tabindex} {$onclick}>{$button_text}</a>";
         } else {
             $class .= ' button';
             $button_input = "<input type='{$input_type}' id='{$button_input_id}' class='{$class}' value='" . esc_attr($button_text) . "' {$tabindex} {$onclick} />";
         }
     } else {
         $imageUrl = $button['imageUrl'];
         $class .= ' gform_image_button';
         $button_input = "<input type='image' src='{$imageUrl}' id='{$button_input_id}' class='{$class}' alt='{$alt}' {$tabindex} {$onclick} />";
     }
     return $button_input;
 }
Exemplo n.º 23
0
function convert_minors($input, $input_info, $field, $text, $value, $form_id)
{
    //build field name, must match List field syntax to be processed correctly
    $input_field_name = 'input_' . $field["id"] . '[]';
    $tabindex = GFCommon::get_tabindex();
    $new_input = '<select multiple="multiple" size="2" title="Select Minor(s)" name="' . $input_field_name . '" ' . $tabindex . ' class="large gfield_select" tabindex="1">
  <option value="Executive">Executive</option>
  <option value="Administrator/IT">Administrator/IT</option>
  <option value="Applications/Intake">Applications/Intake</option>
  <option value="Accounts Payable">Accounts Payable</option>
  <option value="PH Tenant Accounting">PH Tenant Accounting</option>
  <option value="S8 Tenant Accounting">S8 Tenant Accounting</option>
  <option value="Tenant Accounting">Tenant Accounting</option>
  <option value="Payroll">Payroll</option>
  <option value="Purchase Order">Purchase Order</option>
  <option value="PH Inspector">PH Inspector</option>
  <option value="S8 Inspector">S8 Inspector</option>
  <option value="Work Order Clerk">Work Order Clerk</option>
  <option value="Stock Clerk (CI)">Stock Clerk (CI)</option>
  <option value="Property Security">Property Security</option>
  <option value="Case Management">Case Management</option>
  <option value="FSS Case Management">FSS Case Management</option>
  <option value="Multi-family/TRACS">Multi-family/TRACS</option>
  </select>';
    return $new_input;
}
 /**
  * get HTML for input and label for Interval Type field
  * @param array $field
  * @param string $value
  * @param integer $lead_id
  * @param integer $form_id
  * @return string
  */
 protected function fieldIntervalType($field, $value = "", $lead_id = 0, $form_id = 0)
 {
     $id = $field['id'];
     $sub_id = $field['sub_id'];
     $field_id = IS_ADMIN || $form_id == 0 ? "gfeway_{$id}_{$sub_id}" : "gfeway_{$form_id}_{$id}_{$sub_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;
     $tabindex = GFCommon::get_tabindex();
     $spanClass = '';
     if (!empty($field['hidden'])) {
         $spanClass = 'gf_hidden';
     }
     $class = esc_attr($class);
     $inputName = sprintf('gfeway_%s[%s]', $id, $sub_id);
     $label = esc_html($field['label']);
     $periods = apply_filters('gfeway_recurring_periods', array('weekly', 'fortnightly', 'monthly', 'quarterly', 'yearly'), $form_id, $field);
     if (count($periods) == 1) {
         // build a hidden field and label
         $label = sprintf('%s: %s', $label, $periods[0]);
         ob_start();
         require GFEWAY_PLUGIN_ROOT . 'views/recurring-field-hidden-interval.php';
         $input = ob_get_clean();
     } else {
         // build a drop-down list
         ob_start();
         require GFEWAY_PLUGIN_ROOT . 'views/recurring-field-select-interval.php';
         $input = ob_get_clean();
     }
     return $input;
 }
 function wps_tos_field_input($input, $field, $value, $lead_id, $form_id)
 {
     //Init vars
     $default_tos_value = "Terms of Service -- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
     if ($field["type"] == "tos") {
         if (empty($value)) {
             $value = $default_tos_value;
         }
         $max_chars = "";
         if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
             $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
         }
         $input_name = $form_id . '_' . $field["id"];
         $tabindex = GFCommon::get_tabindex();
         $css = isset($field['cssClass']) ? $field['cssClass'] : '';
         $input = sprintf("<div id='gform-tos-container' class='ginput_container'><textarea readonly name='input_%s' id='%s' class='textarea gform_tos %s' {$tabindex} rows='10' cols='50'>%s</textarea></div>{$max_chars}", $field["id"], 'tos-' . $field['id'], $field["type"] . ' ' . esc_attr($css) . ' ' . $field['size'], esc_html($value));
         //Apply fitlers to allow devs to move the tos conainter to another location in the dom - e.g. modal box
         $input = apply_filters('prso_gform_tos_container', $input, $field, $form_id);
     }
     return $input;
 }