'', 'redirect' => '', 'hidden' => '', 'email_to' => '', ), $atts ) ); // Verify form number self::$global_options = FSCF_Util::get_global_options(); self::$form_id_num = '1'; if ( isset($form) && is_numeric($form) ) { self::$form_id_num = (int)$form; } else { echo __( 'Contact Form Shortcode Error: Invalid form number in shortcode.', 'si-contact-form' ); return; } $frm_id = self::$form_id_num; // Get the form options self::$form_options = FSCF_Util::get_form_options( self::$form_id_num, false ); // Don't use defaults if it doesn't exist if ( ! self::$form_options ) { // Form does not exist in options table // Display error message and return echo sprintf( __( 'Contact Form Shortcode Error: Form %s does not exist', 'si-contact-form' ), self::$form_id_num ); return; } // Update some language // The update_lang function receives the array by reference, so it can be changed FSCF_Util::update_lang(self::$form_options); // Store shortcode atts // http://www.fastsecurecontactform.com/shortcode-options if (self::$global_options['enable_php_sessions'] == 'true') { // this feature only works when PHP sessions are enabled $_SESSION["fsc_shortcode_redirect_$frm_id"] = $redirect; $_SESSION["fsc_shortcode_hidden_$frm_id"] = $hidden; $_SESSION["fsc_shortcode_email_to_$frm_id"] = $email_to; } else { if ( !empty($redirect) || !empty($hidden) || !empty($email_to)) { // trying to use shorcode attributes with the required PHP sessions setting turn off // Display error message and return echo __( 'Contact Form Shortcode Error: Using shorcode attributes requires the PHP sessions setting to be enabled on the Advanced tab in form settings.', 'si-contact-form' ); return; } } self::$form_action_url = self::get_form_action_url(); // initialize vars self::$contact_error = 0; // Save parameters from query string, if any self::get_query_parms(); // initialize external css if (self::$form_options['external_style'] == 'true') self::get_ext_css(); // Has a preview been selected? $preview = ( isset($_POST['ctf_action']) && __('Preview Form', 'si-contact-form') == $_POST['ctf_action'] ) ? true : false; if (is_admin() && $preview && self::$form_options['external_style'] == 'true') self::external_style_head(); self::$req_field_ind = ( self::$form_options['req_field_indicator_enable'] == 'true' ) ? ''.self::$form_options['req_field_indicator'] . '' : ''; // See if a form has been processed, and if so, if there were errors if ( FSCF_Process::$form_processed && FSCF_Process::$form_id_num == self::$form_id_num && empty(FSCF_Process::$form_errors) ) { // Form was processed and has no errors--display thank you message $string = self::display_thank_you(); } else { if (!isset(self::$add_date_js)) { self::$add_date_js_array = array(); self::$add_date_js = ''; } if (!isset(self::$add_recaptcha_js)) { self::$add_recaptcha_js_array = array(); self::$add_recaptcha_js = ''; } if ( ! empty(FSCF_Process::$form_errors) && FSCF_Process::$form_id_num == self::$form_id_num ) { // The form was processed, but had errors if ( ! empty(FSCF_Process::$form_data) ) { // If this is not true, there is an internal error... self::$form_content = array_merge( self::$form_content, FSCF_Process::$form_data ); self::$form_errors = array_merge( self::$form_errors, FSCF_Process::$form_errors ); // XXX later, improve variable usage for error tracking? self::$contact_error = true; } } // ***** Display the Form ***** self::$placeholder = 0; self::$add_recaptcha_script = 0; $string = "\n\n
\n" . self::$form_options['welcome']; $string = self::display_form($string); } return($string); } // end function process_short_code() static function get_this_css($tag){ // returns the correct css, inline or external css return $this_style = ( self::$form_options['external_style'] == 'true' ) ? 'class="'.self::$ext_css[$tag] .'"' : self::convert_css( self::$form_options[$tag]); } static function external_style_head() { // puts style on form preview when external css is enabled wp_enqueue_script('jquery'); ?> 'fscf-div-form', // Form DIV, how wide is the form DIV 'left_box_style' => 'fscf-div-left-box', // left box DIV, container for vcita 'right_box_style' => 'fscf-div-right-box', // right box DIV, container for vcita 'clear_style' => 'fscf-div-clear', // clear both 'field_left_style' => 'fscf-div-field-left', // field left 'field_prefollow_style' => 'fscf-div-field-prefollow', // field prefollow 'field_follow_style' => 'fscf-div-field-follow', // field follow 'title_style' => 'fscf-div-label', // Input labels alignment DIV 'field_div_style' => 'fscf-div-field', // Input fields alignment DIV 'captcha_div_style_sm' => 'fscf-div-captcha-sm', // Small CAPTCHA DIV 'captcha_div_style_m' => 'fscf-div-captcha-m', // Large CAPTCHA DIV 'captcha_image_style' => 'fscf-image-captcha', // CAPTCHA image alignment 'captcha_reload_image_style' => 'fscf-image-captcha-refresh', // CAPTCHA refresh image alignment 'submit_div_style' => 'fscf-div-submit', // Submit DIV 'border_style' => 'fscf-fieldset', // style of the fieldset box (if enabled) // Styles of labels, fields and text 'required_style' => 'fscf-required-indicator', // required field indicator 'required_text_style' => 'fscf-required-text', // required field text 'hint_style' => 'fscf-hint-text', // small text hints like file types 'error_style' => 'fscf-div-error', // Input validation messages 'redirect_style' => 'fscf-div-redirecting', // Redirecting message 'fieldset_style' => 'fscf-fieldset-field', // style of the fieldset box (for a field) 'label_style' => 'fscf-label', // Field labels 'option_label_style' => 'fscf-option-label', // Options labels 'field_style' => 'fscf-input-text', // Input text fields 'captcha_input_style' => 'fscf-input-captcha', // CAPTCHA input field 'textarea_style' => 'fscf-input-textarea', // Input Textarea 'select_style' => 'fscf-input-select', // Input Select 'checkbox_style' => 'fscf-input-checkbox', // Input checkbox 'radio_style' => 'fscf-input-radio', // Input radio 'button_style' => 'fscf-button-submit', // Submit button 'reset_style' => 'fscf-button-reset', // Reset button 'vcita_button_style' => 'fscf-button-vcita', // vCita button 'vcita_div_button_style' => 'fscf-button-div-vcita', // vCita button div box 'powered_by_style' => 'fscf-powered-by', // the "powered by" link ); } static function get_honeypot_slugs($fields) { // filter a list of field names that are not currently used on the form $decoy_fields = array( 'address','suite','company','phone','title','city','state','fax','newsletter','webites','zipcode','address2','firstname','lastname','birthday'); // check for custom post types, // none of the field slugs can be the same as a post type rewrite_slug // or you will get "page not found" when posting the form with that field filled in $pt_args = array('public' => true,'_builtin' => false); $post_types = get_post_types( $pt_args, 'objects' ); $pt_slugs = array(); if ( $post_types ) { foreach ( $post_types as $post_type ) { $pt_slugs[] = ( isset( $post_type->rewrite_slug ) ) ? $post_type->rewrite_slug : $post_type->name; } } if ($fields && is_array($fields)) { foreach ($decoy_fields as $index => $decoy) { if (isset($fields[$decoy])) // decoy field matches a form field, remove the decoy from list unset($decoy_fields[$index]); if (!empty($pt_slugs) && in_array( $decoy, $pt_slugs ) ) unset($decoy_fields[$index]); // decoy field matches a custom post type, remove the decoy from list } } sort($decoy_fields); return $decoy_fields; } static function get_todays_honeypot_slug($fields) { // find a decoy field name that is not currently used on the form // change it each day of the week $decoy_fields = self::get_honeypot_slugs($fields); $max = count($decoy_fields); if ($max > 5) $index = date('w'); else if ($max > 0) $index = 0; else return 'email456'; return $decoy_fields[$index]; } static function display_form($string) { // Build the code to display the form in $string and return it // The form code will be appended to $string and returned global $captcha_path_cf; // used by secureimage.php $captcha_path_cf = FSCF_CAPTCHA_PATH; // Set up the styles for the form self::$style['hint'] = self::convert_css( self::$form_options['hint_style'] ); self::$style['textarea'] = self::convert_css( self::$form_options['textarea_style'] ); self::$style['checkbox'] = self::convert_css( self::$form_options['checkbox_style'] ); self::$style['option_label'] = self::convert_css( self::$form_options['option_label_style'] ); // option label self::$style['label'] = self::convert_css( self::$form_options['label_style'] ); // label self::$style['form'] = self::convert_css( self::$form_options['form_style'] ); self::$style['border'] = self::convert_css( self::$form_options['border_style'] ); self::$style['fieldset'] = self::convert_css( self::$form_options['fieldset_style'] ); self::$style['select'] = self::convert_css( self::$form_options['select_style'] ); self::$style['title'] = self::convert_css( self::$form_options['title_style'] ); self::$style['field'] = self::convert_css( self::$form_options['field_style'] ); // text fields self::$style['field_div'] = self::convert_css( self::$form_options['field_div_style'] ); self::$style['error'] = self::convert_css( self::$form_options['error_style'] ); self::$style['required'] = self::convert_css( self::$form_options['required_style'] ); self::$style['required_text'] = self::convert_css( self::$form_options['required_text_style'] ); self::$style['submit_div'] = self::convert_css(self::$form_options['submit_div_style']); self::$style['submit'] = self::convert_css(self::$form_options['button_style']); self::$style['reset'] = self::convert_css(self::$form_options['reset_style']); self::$aria_required = ' aria-required="true" '; $hidden = "\n"; if ( self::$contact_error ) // this is for some people who hide the form in a div, if there are validation errors, unhide it self::$form_options['form_style'] = str_replace( 'display: none;', '', self::$form_options['form_style'] ); $string .= '
'; $form_attributes = ''; if( !empty(self::$form_options['form_attributes']) ) $form_attributes = self::$form_options['form_attributes'].' '; if (self::$form_options['vcita_scheduling_button'] == 'true' && self::is_vcita_activated() ) $string .= "\n
"; $anchor = ''; if ( self::$form_options['anchor_enable'] == 'true' ) $anchor = '#FSContact' . self::$form_id_num; $string .= '
'; if ( self::$form_options['border_enable'] == 'true' ) { $string .= '
\n"; if ( self::$form_options['title_border'] != '' ) { $string .= ''; $string .= self::$form_options['title_border']; $string .= "\n"; } } // check attachment directory $frm_id = self::$form_id_num; // needed for use w/in "" below.. can't use self:: if ( self::$have_attach ) { self::init_temp_dir( FSCF_ATTACH_DIR ); if ( self::$form_options['php_mailer_enable'] == 'php' ) { self::set_form_error("fscf_attach_dir$frm_id", __( 'Attachments are only supported when the Send Email function is set to WordPress. You can find this setting on the contact form settings page.', 'si-contact-form' ) ); } if ( ! is_dir( FSCF_ATTACH_DIR ) ) { self::set_form_error("fscf_attach_dir$frm_id", __( 'The temporary folder for the attachment field does not exist.', 'si-contact-form' ) ); } else if ( ! is_writable( FSCF_ATTACH_DIR ) ) { self::set_form_error("fscf_attach_dir$frm_id", __( 'The temporary folder for the attachment field is not writable.', 'si-contact-form' ) ); } else { // delete files over 3 minutes old in the attachment directory // full directory sweep cleanup //self::clean_temp_dir( FSCF_ATTACH_DIR, 3 ); } } // check for custom post types, returns the global static self::$post_types_slugs // none of the field slugs can be the same as a post type rewrite_slug // or you will get "page not found" when posting the form with that field filled in $pt_args = array('public' => true,'_builtin' => false); $post_types = get_post_types( $pt_args, 'objects' ); $slug_list = array(); $post_types_slugs = array('post','page','attachment','revision'); if ( $post_types ) { foreach ( $post_types as $post_type ) { $post_types_slugs[] = ( isset( $post_type->rewrite_slug ) ) ? $post_type->rewrite_slug : $post_type->name; } // print_r($post_types_slugs); foreach ( self::$form_options['fields'] as $key => $field ) { $slug_list[] = $field['slug']; } //print_r($slug_list); foreach ($post_types_slugs as $key => $slug) { if ( in_array( strtolower( $slug ), $slug_list ) ) { $string .= '
' .sprintf( __( 'Warning: one of your field tags conflicts with the post type redirect tag "%s". To automatically correct this, click the Save Changes button on the form edit page.', 'si-contact-form' ), $slug ) . "\n
\n"; } } } // print input error message if ( self::$contact_error ) { // There are errors, so print the generic error message $string .= '
\n"; $string .= (self::$form_options['error_correct'] != '') ? self::$form_options['error_correct'] : __( 'Please make corrections below and try again.', 'si-contact-form' ); $string .= "\n
\n"; // Print errors that appear at the top of the form $string .= self::echo_if_error("fscf_attach_dir$frm_id"); $string .= self::echo_if_error('akismet'); } // Get the email-to list self::$contacts = self::get_contact_list(self::$form_id_num, self::$form_options['email_to']); if ( empty( self::$contacts ) ) { // was $ctf_contacts $string .= '
' . __( 'ERROR: Misconfigured email address in options.', 'si-contact-form' ) . "\n
\n"; } if ( self::$global_options['enable_php_sessions'] == 'true' ) { // this feature only works when PHP sessions are enabled if ( ! empty( $_SESSION["fsc_shortcode_hidden_$frm_id"] ) ) { $hidden_fields = self::get_hidden_fields(); if ( ! empty( $hidden_fields ) ) { foreach ( $hidden_fields as $key => $value ) { $hidden .= "\n" . ''. "\n"; } } } else { unset( $_SESSION["fsc_shortcode_hidden_$frm_id"] ); } } // Add a hidden field if this is the admin preview, so that we return to the preview after submit if ( is_admin() ) $hidden .= ''. "\n"; $hidden .= ''. "\n"; $hidden .= ''. "\n"; $hidden .= ''. "\n"; $hidden .= ''. "\n"; if ( self::$form_options['req_field_label_enable'] == 'true' && self::$form_options['req_field_indicator_enable'] == 'true' ) { $string .= "\n".'
' . "\n"; $string .= ' ' . self::$form_options['req_field_indicator'] . ' '; $string .= (self::$form_options['tooltip_required'] != '') ? self::$form_options['tooltip_required'] : __( 'indicates required field', 'si-contact-form' ); $string .= "\n
\n\n"; } // If there are multiple mail-to contacts, display a select form if ( count( self::$contacts ) > 1 ) { $string .= '
' . "\n" . '
' . self::echo_if_error( 'contact' ) . '
'; } else { $hidden .= ''. "\n"; } $open_fieldset = false; // is a fieldset field open? // A div class="fscf-clear" is used to group a field with any that follow it // $open_div tracks whether this div is currently open $open_div = false; $date_fields = array(); // List of date fields self::$printed_tooltip_filetypes = 0; // ********** Go through all the fields and print them ********** // fill in any missing defaults $field_opt_defaults = array( 'hide_label' => 'false', 'placeholder' => 'false', ); // Create a list of follow values for fields $field_follow = array(); foreach ( self::$form_options['fields'] as $key => $field ) { if ( 'true' != $field['disable'] ) $field_follow[] = $field['follow']; } $fld_cnt = 0; $fields_in_use = array(); foreach ( self::$form_options['fields'] as $key => $field ) { // fill in any missing field options defaults foreach ( $field_opt_defaults as $dfkey => $dfval ) { if ( !isset($field[$dfkey]) || empty($field[$dfkey]) ) $field[$dfkey] = $dfval; } if ( 'true' == $field['disable'] ) continue; $fields_in_use[$field['slug']] = 1; if ( 'true' == $field['follow'] && $open_div ) { $string .= '
'; } else { if ( $open_div ) { // close the preceeding div used for grouping $string .= "
\n"; $open_div = false; } if ( 'fieldset' == $field['type'] || 'fieldset-close' == $field['type'] ) { $string .= "\n" . '
\n"; } else { $open_div = true; $string .= "\n" . '
' . "\n" . ' '; $string .= '
'; // narrow else $string .= self::get_this_css('field_left_style').'>'; // wide } } $fld_cnt++; // Display code common to all/most field types if ( ! in_array( $field['type'], array('fieldset', 'fieldset-close', 'hidden') ) ) { if ( $field['notes'] != '' ) { $string .= "\n". self::ctf_notes( $field['notes'] ); } if ( ('checkbox' != $field['type'] && $field['standard'] < 1) && ( 'false' == $field['hide_label'] ) ) { // hiding the label // Standard field labels can be changed in options, so don't print them here // single checkbox labels are printed next to the checkbox $string .= "\n
\n
"; } else if ( ('checkbox' == $field['type'] && $field['standard'] < 1) || ( 'true' == $field['hide_label'] ) ) { // single checkbox keep the div to maintain style left alignment (no label here), or hide label was checked $string .= "\n
\n"; $open_fieldset = true; break; case 'fieldset-close' : if($open_fieldset) $string .= "
\n"; $open_fieldset = false; break; case 'hidden' : $string .= ' ' . "\n"; break; case 'password' : $string .= '
'.self::echo_if_error( $field['slug'] ) . "\n" . ' $field['type'] && 'fieldset-close' <> $field['type'] && 'hidden' <> $field['type'] ) { if ( $field['notes_after'] != '' ) { $string .= self::ctf_notes($field['notes_after'])."\n"; } } if ( $open_div ) { $string .= "
\n"; // close field div } } // end foreach (go through fields) // action hook for form display after fields $string = apply_filters( 'si_contact_display_after_fields', $string, self::$style, self::$form_errors, self::$form_id_num ); // Are there any date fields? if ( count($date_fields) > 0 ) self::setup_calendar($date_fields); // ********** Display stuff at the bottom of form ********** // close final outer container for field and follow groups if ( $open_div ) { $string .= '
' . "\n"; } $captcha_enabled = self::is_captcha_enabled(self::$form_id_num); if ( $captcha_enabled == 'recaptcha' ) { $string .= self::display_recaptcha() . "\n"; } else if ( $captcha_enabled == 'sicaptcha' ) { $string .= self::display_captcha() . "\n"; } // hidden empty honeypot field, if enabled if ( self::$form_options['honeypot_enable'] == 'true' ) { $honeypot_slug = self::get_todays_honeypot_slug($fields_in_use); $string .= ' '.self::echo_if_error( $honeypot_slug ).'
'; } // Display the submit button $string .= "\n
'; } $string .= "\n
\n"; if ( self::$form_options['border_enable'] == 'true' ) { $string .= "\n"; } $string .= $hidden; // Close the form $string .= "\n\n"; if ( self::$form_options['enable_credit_link'] == 'true' ) { $string .= "\n

' . __( 'Powered by', 'si-contact-form' ) . ' ' . __( 'Fast Secure Contact Form', 'si-contact-form' ) . "

\n"; } if ( self::$form_options['vcita_scheduling_button'] == 'true' && self::is_vcita_activated() ) { $string .= "
\n
\n"; $string = self::display_vcita_scheduler_button( $string ); $string .= "\n
\n"; } $string .= ''; // closes fscf-container $string .= "
\n"; if (self::$placeholder && self::$form_options['external_style'] == 'false') { self::$add_placeholder_script = 1; // for adding the javascript $placeholder_style = self::$form_options['placeholder_style']; if ( preg_match( "/^style=\"(.*)\"$/i", $placeholder_style, $matches ) ) $placeholder_style = $matches[1]; if ( preg_match( "/^class=\"(.*)\"$/i", $placeholder_style, $matches ) ) $placeholder_style = $matches[1]; $string .= ' '; } if ( !empty( self::$form_options['after_form_note'] ) ) $string .= self::$form_options['after_form_note']; $string .= "\n".''. "\n"; return($string); } // end function display_form() static function display_name($key, $field) { // Returns the code to display the name field on the form global $current_user, $user_ID; // Get defaults // Find logged in user's WP name (auto form fill feature): // http://codex.wordpress.org/Function_Reference/get_currentuserinfo $auto_fill = 0; if ( isset(self::$form_content[$field['slug']]) && '' == self::$form_content[$field['slug']] && $user_ID != '' && $current_user->user_login != 'admin' && ! current_user_can( 'manage_options' ) && self::$form_options['auto_fill_enable'] == 'true' ) { // user logged in (and not admin rights) (and auto_fill_enable set in options) $auto_fill = 1; self::$form_content[$field['slug']] = $current_user->user_login; } $f_default = $m_default = $mi_default = $l_default = ''; if ( $field['default'] != '') { if ( self::$form_options['name_format'] == 'first_last' ) { if ( !preg_match('/^(.*)(==)(.*)$/', $field['default'], $matches) ) $field['default'] = 'First Name==Last Name'; // default to proper format if ( preg_match('/^(.*)(==)(.*)$/', $field['default'], $matches) ) { $f_default = $matches[1]; $l_default = $matches[3]; } } else if ( self::$form_options['name_format'] == 'first_middle_last' ) { if ( !preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches) ) $field['default'] = 'First Name==Middle Name==Last Name'; // default to proper format if ( preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches) ) { $f_default = $matches[1]; $m_default = $matches[3]; $l_default = $matches[5]; } } else if ( self::$form_options['name_format'] == 'first_middle_i_last' ) { if ( !preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches) ) $field['default'] = 'First Name==Middle Initial==Last Name'; // default to proper format if ( preg_match('/^(.*)(==)(.*)(==)(.*)$/', $field['default'], $matches) ) { $f_default = $matches[1]; $mi_default = $matches[3]; $l_default = $matches[5]; } } } $string = ''; $f_name_string = '
\n"; if ( 'false' == $field['hide_label'] ) { $f_name_string .= ' \n"; } $f_name_string .= '
' . self::echo_if_error( 'f_name' ) . ' \n"; if ( 'false' == $field['hide_label'] ) { $l_name_string .= ' \n"; } $l_name_string .= '
' . self::echo_if_error( 'l_name' ) . ' \n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= '
' . self::echo_if_error( 'full_name' ) . ' '; $string .= $l_name_string; break; case 'first_middle_i_last': $string .= $f_name_string; // See if name parts are to be displayed inline if ( 'true' == $field['inline'] ) $string .= '
'; $string .= '
\n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= '
' . self::echo_if_error( 'mi_name' ) . ' '; $string .= $l_name_string; break; case 'first_middle_last': $string .= $f_name_string; // See if name parts are to be displayed inline if ( 'true' == $field['inline'] ) $string .= '
'; $string .= '
\n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= '
' . self::echo_if_error( 'm_name' ) . ' '; $string .= $l_name_string; break; } return($string); } // end function display_name() static function display_email($key, $field) { global $current_user, $user_ID; $string = ''; //filter hook for email input type, someone might want to change it from type='text' to type='email' $email_input_type = apply_filters( 'si_contact_email_input_type', 'text', self::$form_id_num); // Find logged in user's WP email address (auto form fill feature): // http://codex.wordpress.org/Function_Reference/get_currentuserinfo $auto_fill = 0; if ( '' == self::$form_content[$field['slug']] && $user_ID != '' && $current_user->user_login != 'admin' && !current_user_can( 'manage_options' ) && self::$form_options['auto_fill_enable'] == 'true' ) { // user logged in (and not admin rights) (and auto_fill_enable set in options) $auto_fill = 1; self::$form_content[$field['slug']] = $current_user->user_email; if ( 'true' == self::$form_options['double_email'] ) self::$form_content['email2'] = $current_user->user_email; } $email_default = ''; $email2_default = ''; if ( 'true' == self::$form_options['double_email'] ) { $field['req'] = 'true'; $default = self::$form_options['fields']['1']['default']; // email field // find the true default for email, email2 // is there xx==xx if ( !preg_match('/^(.*)(==)(.*)$/', $default, $matches) ) $default = 'Email==Re-enter Email'; if ( preg_match('/^(.*)(==)(.*)$/', $default, $matches) ) { $email_default = $matches[1]; $email2_default = $matches[3]; } } else { $email_default = $field['default']; } $string .= "\n
\n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= "
\n"; $string .= '
' . self::echo_if_error( 'email' ) . "\n \n"; if ( 'true' == self::$form_options['double_email'] ) { $string .= "
\n
\n\n" . '
' . "\n" . '
'; $string .= "\n
\n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= "
\n
' . self::echo_if_error( 'email2' ) . "\n \n"; } return($string); } // function display_email() static function display_field_text($key, $field) { // display function for a text, email, or url field type $string = ''; if ( FSCF_NAME_FIELD == $field['standard'] ) return(self::display_name($key, $field)); if ( FSCF_EMAIL_FIELD == $field['standard'] ) return(self::display_email($key, $field)); if ( FSCF_SUBJECT_FIELD == $field['standard']) { // Display field title for special fields $string = ''; $string .= "\n
\n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= "
"; } $type = $field['type']; //if ( 'email' == $field['type'] || 'url' == $field['type']) // XXX fix this later? email or url type was breaking the 'already posted' javascript // $type = 'text'; // Since then I have changed the 'already posted' javascript, so try email and url types again. $string .= "\n
' . self::echo_if_error( $field['slug'] ) ."\n" . ' \n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= "
\n
' . self::echo_if_error( 'message' ) . "\n \n
\n"; } return($string); } static function display_field_select($key, $field) { $string = ''; // Get the options list $opts_array = explode("\n",$field['options']); $frm_id = self::$form_id_num; if ( '' == $opts_array[0] ) { // Error: no options were entered self::set_form_error("fscf_select$frm_id", __('Error: No options were entered for a select field in settings.', 'si-contact-form')); $string .= self::echo_if_error("fscf_select$frm_id"); } // Display the field if ( FSCF_SUBJECT_FIELD == $field['standard']) { // Display field title for special fields $string = ''; $string .= "\n
\n"; if ( 'false' == $field['hide_label'] ) { $string .= ' \n"; } $string .= "
"; // Check for subject_id parm for backward compatibility if ( 0 == count(self::$form_content[$field['slug']]) && '' != self::$form_content['subject_id']) self::$form_content[$field['slug']][] = self::$form_content['subject_id']; } $mult = ( 'select-multiple' == $field['type'] ) ? ' multiple="multiple"' : ''; $string .= "\n
'.self::echo_if_error( $field['slug'] ) ."\n \n
\n"; return($string); } // end function display_field_select() static function display_field_checkbox($key, $field) { // Displays checkbox, checkbox-multiple, and radio field types $string = ''; // Get the options list $opts_array = explode("\n",$field['options']); if ( '' == $opts_array[0] ) { if ( 'checkbox' == $field['type']) { // use the field name as the option name $opts_array[0] = $field['label']; } else { // Error: no options were entered self::$contact_error = 1; self::$form_errors['fscf_checkbox'] = __('Error: No options were entered for a checkbox-multiple field in settings.', 'si-contact-form'); $string .= self::echo_if_error('fscf_checkbox'); } } if ( 'checkbox' == $field['type'] ) { // Single checkbox $string .= "\n
'. self::echo_if_error( $field['slug'] ) . "\n" . ' ' . $field['label']; $string .= ( 'true' == $field['req'] ) ? self::$req_field_ind : ''; $string .= "\n
\n"; } else { // checkbox-multiple or radio if ( 'checkbox-multiple' == $field['type'] ) { $ftype = 'checkbox'; } else { $ftype = 'radio'; } $string .= "\n
'. self::echo_if_error( $field['slug'] ) . "\n"; $opt_cnt = 1; foreach ( $opts_array as $opt ) { $opt = trim( $opt ); if ( 'false' == $field['inline'] && $opt_cnt > 1 ) $string .= "
\n"; else if ($opt_cnt > 1) $string .= "\n"; $string .= ' 0 && in_array($opt_cnt, self::$form_content[$field['slug']]) ) { $string .= ' checked="checked"'; } } else if ( $opt_cnt == self::$form_content[$field['slug']] ) { $string .= ' checked="checked"'; } // is this key==value set? Just display the value if ( preg_match('/^(.*)(==)(.*)$/', $opt, $matches) ) { $opt = $matches[3]; } if ( $field['attributes'] != '' ) $string .= ' ' . $field['attributes']; $string .= ' /> "; $opt_cnt++; } // end foreach $string .= "\n
\n"; } // end else return($string); } // end function display_field_checkbox static function display_field_date($key, $field) { $string = ''; $cal_date_array = array( 'mm/dd/yyyy' => esc_html( __( 'mm/dd/yyyy', 'si-contact-form' ) ), 'dd/mm/yyyy' => esc_html( __( 'dd/mm/yyyy', 'si-contact-form' ) ), 'mm-dd-yyyy' => esc_html( __( 'mm-dd-yyyy', 'si-contact-form' ) ), 'dd-mm-yyyy' => esc_html( __( 'dd-mm-yyyy', 'si-contact-form' ) ), 'mm.dd.yyyy' => esc_html( __( 'mm.dd.yyyy', 'si-contact-form' ) ), 'dd.mm.yyyy' => esc_html( __( 'dd.mm.yyyy', 'si-contact-form' ) ), 'yyyy/mm/dd' => esc_html( __( 'yyyy/mm/dd', 'si-contact-form' ) ), 'yyyy-mm-dd' => esc_html( __( 'yyyy-mm-dd', 'si-contact-form' ) ), 'yyyy.mm.dd' => esc_html( __( 'yyyy.mm.dd', 'si-contact-form' ) ), ); $string .= "\n
' . self::echo_if_error( $field['slug'] ) . "\n ' . self::echo_if_error( $field['slug'] ) . "\n '; $file_type_message .= sprintf( (self::$form_options['tooltip_filetypes'] != '') ? self::$form_options['tooltip_filetypes'] : __( 'Acceptable file types: %s.', 'si-contact-form' ), self::$form_options['attach_types'] ); $file_type_message .= '
'; $file_type_message .= sprintf( (self::$form_options['tooltip_filesize'] != '') ? self::$form_options['tooltip_filesize'] : __( 'Maximum file size: %s.', 'si-contact-form' ), self::$form_options['attach_size']) . "\n"; //filter hook for file attachment acceptable types message $file_type_message = apply_filters( 'si_contact_file_type_message', $file_type_message, self::$form_options, self::$form_id_num); $string .= $file_type_message; } self::$printed_tooltip_filetypes++; $string .= "
\n"; } return($string); } static function setup_calendar($date_fields) { // Set up the popup calendar display for date fields foreach ( $date_fields as $v ) { self::$add_date_js_array[] = self::$form_id_num . '_' . $v; } if ( self::$add_date_js == '' ) { // only add for 1st form with date fields self::$add_date_js = '
'; } } $ctf_thank_you .= '
'; if (!empty(self::$form_options['success_page_html'])) { $ctf_thank_you .= self::$form_options['success_page_html'] .' '; } if (self::$form_options['border_enable'] == 'true') { $ctf_thank_you .= ' '; } $ctf_thank_you .= '
'; $ctf_thank_you .= ' '; //filter hook for thank_you_message return apply_filters( 'si_contact_thank_you_message', $ctf_thank_you, self::$form_id_num); } static function set_form_error($fld, $msg) { // Sets a form error for field $fld with message $msg // This is called from FSCF_Process class functions // The key is 'field' plus the field index number, or a special name such as // capctha, f_name, fscf_select, etc. self::$form_errors[$fld] = $msg; self::$contact_error = 1; // Set the error flag } static function check_form_errors() { // Returns 1 if there are form errors, and 0 if not // Called from FSCF_Process::process_form() return(self::$contact_error); } static function ctf_notes($notes) { $html = "\n
\n$notes\n"; // filter hook for html_before_after return apply_filters( 'si_contact_html_before_after', $html, self::$form_id_num); } static function get_form_action_url() { // returns the URL for the WP page the form was on if ( function_exists( 'qtrans_convertURL' ) ) // compatible with qtranslate plugin // In case of multi-lingual pages, the /de/ /en/ language url is used. $form_action_url = qtrans_convertURL( strip_tags( $_SERVER['REQUEST_URI'] ) ); else $form_action_url = 'http://' . strip_tags( $_SERVER['HTTP_HOST'] ) . strip_tags( $_SERVER['REQUEST_URI'] ); // set the type of request (SSL or not) if ( is_ssl() ) $form_action_url = preg_replace( '|http://|', 'https://', $form_action_url ); //filter hook for form action URL return apply_filters( 'si_contact_form_action_url', $form_action_url, self::$form_id_num); } // end function form_action_url static function is_vcita_activated() { if ( self::$form_options['vcita_approved'] == 'true' && !empty( self::$form_options['vcita_uid'] ) ) return true; else return false; } static function display_vcita_scheduler_button( $string ) { // vcita_scheduling_button enabled and is_vcita_activated has already been checked if (self::$form_options['vcita_scheduling_button'] == 'true'){ $string .= '"; } return($string); } // end function display_vcita_scheduler_button } // end class FSCF_Display // end of file