当前位置: 首页>>代码示例>>PHP>>正文


PHP GFCommon::is_valid_email方法代码示例

本文整理汇总了PHP中GFCommon::is_valid_email方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::is_valid_email方法的具体用法?PHP GFCommon::is_valid_email怎么用?PHP GFCommon::is_valid_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GFCommon的用法示例。


在下文中一共展示了GFCommon::is_valid_email方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_value_entry_detail

 public function get_value_entry_detail($value, $currency = '', $use_text = false, $format = 'html', $media = 'screen')
 {
     return GFCommon::is_valid_email($value) && $format == 'html' ? "<a href='mailto:{$value}'>{$value}</a>" : $value;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:4,代码来源:class-gf-field-email.php

示例2: handle_save_email_confirmation

 public static function handle_save_email_confirmation($form, $ajax)
 {
     $resume_email = $_POST['gform_resume_email'];
     if (!GFCommon::is_valid_email($resume_email)) {
         GFCommon::log_debug('GFFormDisplay::handle_save_email_confirmation(): Invalid email address: ' . $resume_email);
         return new WP_Error('invalid_email');
     }
     $resume_token = $_POST['gform_resume_token'];
     $submission_details = GFFormsModel::get_incomplete_submission_values($resume_token);
     $submission_json = $submission_details['submission'];
     $submission = json_decode($submission_json, true);
     $entry = $submission['partial_entry'];
     $form = self::update_confirmation($form, $entry, 'form_save_email_sent');
     $confirmation = '<div class="form_saved_message_sent"><span>' . rgar($form['confirmation'], 'message') . '</span></div>';
     $nl2br = rgar($form['confirmation'], 'disableAutoformat') ? false : true;
     $save_email_confirmation = self::replace_save_variables($confirmation, $form, $resume_token, $resume_email);
     $save_email_confirmation = GFCommon::replace_variables($save_email_confirmation, $form, $entry, false, true, $nl2br);
     $save_email_confirmation = GFCommon::gform_do_shortcode($save_email_confirmation);
     $form_id = absint($form['id']);
     $has_pages = self::has_pages($form);
     $default_anchor = $has_pages || $ajax ? true : false;
     $use_anchor = gf_apply_filters(array('gform_confirmation_anchor', $form_id), $default_anchor);
     if ($use_anchor !== false) {
         $save_email_confirmation = "<a id='gf_{$form_id}' class='gform_anchor' ></a>" . $save_email_confirmation;
     }
     if ($ajax) {
         $save_email_confirmation = "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $save_email_confirmation . '</body></html>';
     }
     GFCommon::log_debug('GFFormDisplay::handle_save_email_confirmation(): Confirmation => ' . print_r($save_email_confirmation, true));
     return $save_email_confirmation;
 }
开发者ID:timk85,项目名称:DIT,代码行数:31,代码来源:form_display.php

示例3: validate


//.........这里部分代码省略.........
                                     $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
                                 }
                             }
                             break;
                         case "creditcard":
                             $card_number = rgpost("input_" . $field["id"] . "_1");
                             $expiration_date = rgpost("input_" . $field["id"] . "_2");
                             $security_code = rgpost("input_" . $field["id"] . "_3");
                             if (rgar($field, "isRequired") && (empty($card_number) || empty($security_code) || empty($expiration_date[0]) || empty($expiration_date[1]))) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter your credit card information.", "gravityforms") : $field["errorMessage"];
                             } else {
                                 if (!empty($card_number)) {
                                     $card_type = GFCommon::get_card_type($card_number);
                                     $security_code = rgpost("input_" . $field["id"] . "_3");
                                     if (empty($security_code)) {
                                         $field["failed_validation"] = true;
                                         $field["validation_message"] = __("Please enter your card's security code.", "gravityforms");
                                     } else {
                                         if (!$card_type) {
                                             $field["failed_validation"] = true;
                                             $field["validation_message"] = __("Invalid credit card number.", "gravityforms");
                                         } else {
                                             if (!GFCommon::is_card_supported($field, $card_type["slug"])) {
                                                 $field["failed_validation"] = true;
                                                 $field["validation_message"] = $card_type["name"] . " " . __("is not supported. Please enter one of the supported credit cards.", "gravityforms");
                                             }
                                         }
                                     }
                                 }
                             }
                             break;
                         case "email":
                             if (!rgblank($value) && !GFCommon::is_valid_email($value)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid email address.", "gravityforms") : $field["errorMessage"];
                             } else {
                                 if (rgget("emailConfirmEnabled", $field) && !empty($value)) {
                                     $confirm = rgpost("input_" . $field["id"] . "_2");
                                     if ($confirm != $value) {
                                         $field["failed_validation"] = true;
                                         $field["validation_message"] = __("Your emails do not match.", "gravityforms");
                                     }
                                 }
                             }
                             break;
                         case "donation":
                         case "price":
                             if (!class_exists("RGCurrency")) {
                                 require_once "currency.php";
                             }
                             $donation = GFCommon::to_number($value);
                             if (!rgblank($value) && ($donation === false || $donation < 0)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid amount.", "gravityforms") : $field["errorMessage"];
                             }
                             break;
                         case "number":
                             if (!rgblank($value) && !self::validate_range($field, $value) && !GFCommon::has_field_calculation($field)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? GFCommon::get_range_message($field) : $field["errorMessage"];
                             } else {
                                 if ($field["type"] == "quantity" && intval($value) != $value) {
                                     $field["failed_validation"] = true;
                                     $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid quantity. Quantity cannot contain decimals.", "gravityforms") : $field["errorMessage"];
                                 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:67,代码来源:form_display.php

示例4: get_lead_field_display

 public static function get_lead_field_display($field, $value, $currency = "", $use_text = false, $format = "html", $media = "screen")
 {
     if ($field['type'] == 'post_category') {
         $value = self::prepare_post_category_value($value, $field);
     }
     switch (RGFormsModel::get_input_type($field)) {
         case "name":
             if (is_array($value)) {
                 $prefix = trim(rgget($field["id"] . ".2", $value));
                 $first = trim(rgget($field["id"] . ".3", $value));
                 $last = trim(rgget($field["id"] . ".6", $value));
                 $suffix = trim(rgget($field["id"] . ".8", $value));
                 $name = $prefix;
                 $name .= !empty($name) && !empty($first) ? " {$first}" : $first;
                 $name .= !empty($name) && !empty($last) ? " {$last}" : $last;
                 $name .= !empty($name) && !empty($suffix) ? " {$suffix}" : $suffix;
                 return $name;
             } else {
                 return $value;
             }
             break;
         case "creditcard":
             if (is_array($value)) {
                 $card_number = trim(rgget($field["id"] . ".1", $value));
                 $card_type = trim(rgget($field["id"] . ".4", $value));
                 $separator = $format == "html" ? "<br/>" : "\n";
                 return empty($card_number) ? "" : $card_type . $separator . $card_number;
             } else {
                 return "";
             }
             break;
         case "address":
             if (is_array($value)) {
                 $street_value = trim(rgget($field["id"] . ".1", $value));
                 $street2_value = trim(rgget($field["id"] . ".2", $value));
                 $city_value = trim(rgget($field["id"] . ".3", $value));
                 $state_value = trim(rgget($field["id"] . ".4", $value));
                 $zip_value = trim(rgget($field["id"] . ".5", $value));
                 $country_value = trim(rgget($field["id"] . ".6", $value));
                 $line_break = $format == "html" ? "<br />" : "\n";
                 $address_display_format = apply_filters("gform_address_display_format", "default");
                 if ($address_display_format == "zip_before_city") {
                     /*
                     Sample:
                     3333 Some Street
                     suite 16
                     2344 City, State
                     Country
                     */
                     $addr_ary = array();
                     $addr_ary[] = $street_value;
                     if (!empty($street2_value)) {
                         $addr_ary[] = $street2_value;
                     }
                     $zip_line = trim($zip_value . " " . $city_value);
                     $zip_line .= !empty($zip_line) && !empty($state_value) ? ", {$state_value}" : $state_value;
                     $zip_line = trim($zip_line);
                     if (!empty($zip_line)) {
                         $addr_ary[] = $zip_line;
                     }
                     if (!empty($country_value)) {
                         $addr_ary[] = $country_value;
                     }
                     $address = implode("<br />", $addr_ary);
                 } else {
                     $address = $street_value;
                     $address .= !empty($address) && !empty($street2_value) ? $line_break . $street2_value : $street2_value;
                     $address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? $line_break . $city_value : $city_value;
                     $address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", {$state_value}" : $state_value;
                     $address .= !empty($address) && !empty($zip_value) ? " {$zip_value}" : $zip_value;
                     $address .= !empty($address) && !empty($country_value) ? $line_break . $country_value : $country_value;
                 }
                 //adding map link
                 if (!empty($address) && $format == "html") {
                     $address_qs = str_replace($line_break, " ", $address);
                     //replacing <br/> and \n with spaces
                     $address_qs = urlencode($address_qs);
                     $address .= "<br/><a href='http://maps.google.com/maps?q={$address_qs}' target='_blank' class='map-it-link'>Map It</a>";
                 }
                 return $address;
             } else {
                 return "";
             }
             break;
         case "email":
             return GFCommon::is_valid_email($value) && $format == "html" ? "<a href='mailto:{$value}'>{$value}</a>" : $value;
             break;
         case "website":
             return GFCommon::is_valid_url($value) && $format == "html" ? "<a href='{$value}' target='_blank'>{$value}</a>" : $value;
             break;
         case "checkbox":
             if (is_array($value)) {
                 $items = '';
                 foreach ($value as $key => $item) {
                     if (!empty($item)) {
                         switch ($format) {
                             case "text":
                                 $items .= GFCommon::selection_display($item, $field, $currency, $use_text) . ", ";
                                 break;
                             default:
//.........这里部分代码省略.........
开发者ID:ipman3,项目名称:Mediassociates-wp,代码行数:101,代码来源:common.php

示例5: edit_page


//.........这里部分代码省略.........
                //legacy notification settings (for backwards compatibility)
                $config["meta"]["delay_autoresponder"] = rgpost('gf_paypal_delay_autoresponder');
                $config["meta"]["delay_notification"] = rgpost('gf_paypal_delay_notification');
                if (isset($config["meta"]["delay_notifications"])) {
                    unset($config["meta"]["delay_notifications"]);
                }
                if (isset($config["meta"]["selected_notifications"])) {
                    unset($config["meta"]["selected_notifications"]);
                }
            }
            // paypal conditional
            $config["meta"]["paypal_conditional_enabled"] = rgpost('gf_paypal_conditional_enabled');
            $config["meta"]["paypal_conditional_field_id"] = rgpost('gf_paypal_conditional_field_id');
            $config["meta"]["paypal_conditional_operator"] = rgpost('gf_paypal_conditional_operator');
            $config["meta"]["paypal_conditional_value"] = rgpost('gf_paypal_conditional_value');
            //recurring fields
            $config["meta"]["recurring_amount_field"] = rgpost("gf_paypal_recurring_amount");
            $config["meta"]["billing_cycle_number"] = rgpost("gf_paypal_billing_cycle_number");
            $config["meta"]["billing_cycle_type"] = rgpost("gf_paypal_billing_cycle_type");
            $config["meta"]["recurring_times"] = rgpost("gf_paypal_recurring_times");
            $config["meta"]["trial_period_enabled"] = rgpost('gf_paypal_trial_period');
            $config["meta"]["trial_amount"] = rgpost('gf_paypal_trial_amount');
            $config["meta"]["trial_period_number"] = rgpost('gf_paypal_trial_period_number');
            $config["meta"]["trial_period_type"] = rgpost('gf_paypal_trial_period_type');
            $config["meta"]["recurring_retry"] = rgpost('gf_paypal_recurring_retry');
            //-----------------
            $customer_fields = self::get_customer_fields();
            $config["meta"]["customer_fields"] = array();
            foreach ($customer_fields as $field) {
                $config["meta"]["customer_fields"][$field["name"]] = $_POST["paypal_customer_field_{$field["name"]}"];
            }
            $config = apply_filters('gform_paypal_save_config', $config);
            $is_validation_error = apply_filters("gform_paypal_config_validation", false, $config);
            if (GFCommon::is_valid_email($config["meta"]["email"]) && !$is_validation_error) {
                $id = GFPayPalData::update_feed($id, $config["form_id"], $config["is_active"], $config["meta"]);
                ?>
                <div class="updated fade" style="padding:6px"><?php 
                echo sprintf(__("Feed Updated. %sback to list%s", "gravityformspaypal"), "<a href='?page=gf_paypal'>", "</a>");
                ?>
</div>
                <?php 
            } else {
                $is_validation_error = true;
            }
        }
        ?>
        <form method="post" action="">
            <input type="hidden" name="paypal_setting_id" value="<?php 
        echo $id;
        ?>
" />

            <div class="margin_vertical_10 <?php 
        echo $is_validation_error ? "paypal_validation_error" : "";
        ?>
">
                <?php 
        if ($is_validation_error) {
            ?>
                    <span><?php 
            _e('There was an issue saving your feed. Please address the errors below and try again.');
            ?>
</span>
                    <?php 
        }
        ?>
开发者ID:bryanmonzon,项目名称:jenjonesdirect,代码行数:67,代码来源:paypal.php

示例6: send_email

 private static function send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '')
 {
     global $phpmailer;
     $to = str_replace(' ', '', $to);
     $bcc = str_replace(' ', '', $bcc);
     $error = false;
     if (!GFCommon::is_valid_email($from)) {
         $from = get_bloginfo('admin_email');
     }
     if (!GFCommon::is_valid_email_list($to)) {
         $error = new WP_Error('invalid_to', 'Cannot send email because the TO address is invalid.');
     } else {
         if (empty($subject) && empty($message)) {
             $error = new WP_Error('missing_subject_and_message', 'Cannot send email because there is no SUBJECT and no MESSAGE.');
         } else {
             if (!GFCommon::is_valid_email($from)) {
                 $error = new WP_Error('invalid_from', 'Cannot send email because the FROM address is invalid.');
             }
         }
     }
     if (is_wp_error($error)) {
         GFCommon::log_error('GFCommon::send_email(): ' . $error->get_error_message());
         GFCommon::log_error(print_r(compact('to', 'subject', 'message'), true));
         /**
          * Fires when an email from Gravity Forms has failed to send
          *
          * @param string $error The Error message returned after the email fails to send
          */
         do_action('gform_send_email_failed', $error, compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'attachments'));
         return;
     }
     $content_type = $message_format == 'html' ? 'text/html' : 'text/plain';
     $name = empty($from_name) ? $from : $from_name;
     $headers = array();
     $headers['From'] = "From: \"" . wp_strip_all_tags($name, true) . "\" <{$from}>";
     if (GFCommon::is_valid_email_list($reply_to)) {
         $headers['Reply-To'] = "Reply-To: {$reply_to}";
     }
     if (GFCommon::is_valid_email_list($bcc)) {
         $headers['Bcc'] = "Bcc: {$bcc}";
     }
     $headers['Content-type'] = "Content-type: {$content_type}; charset=" . get_option('blog_charset');
     $abort_email = false;
     extract(apply_filters('gform_pre_send_email', compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), $message_format));
     $is_success = false;
     if (!$abort_email) {
         GFCommon::log_debug('GFCommon::send_email(): Sending email via wp_mail().');
         GFCommon::log_debug(print_r(compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), true));
         $is_success = wp_mail($to, $subject, $message, $headers, $attachments);
         $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
         GFCommon::log_debug("GFCommon::send_email(): Result from wp_mail(): {$result}");
         if (!is_wp_error($is_success) && $is_success) {
             GFCommon::log_debug('GFCommon::send_email(): Mail was passed from WordPress to the mail server.');
         } else {
             GFCommon::log_error('GFCommon::send_email(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
         }
         if (has_filter('phpmailer_init')) {
             GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
         }
         if (!empty($phpmailer->ErrorInfo)) {
             GFCommon::log_debug(__METHOD__ . '(): PHPMailer class returned an error message: ' . $phpmailer->ErrorInfo);
         }
     } else {
         GFCommon::log_debug('GFCommon::send_email(): Aborting. The gform_pre_send_email hook was used to set the abort_email parameter to true.');
     }
     self::add_emails_sent();
     /**
      * Fires after Gravity Forms has sent an email
      *
      * @param bool $is_success Check if the email was successfully sent
      * @param string $to The user Email to send to
      * @param string $subject The Subject of the email sent out
      * @param string $message The Message sent with a notification, alert, etc.
      * @param string $headers The email headers (the content-type and charset)
      * @param string $attachments The email attachments sent along
      * @param string $message_fomrat The Message format (HTML/Plain Text)
      * @param string $from Who the email is coming from
      * @param string $form_name The Name of the user who is associated with the from email
      * @param string $bcc The blind carbon copy which is an extra email that won't appear in the email header
      * @param string $reply_to A header that allows you to reply to another email
      */
     do_action('gform_after_email', $is_success, $to, $subject, $message, $headers, $attachments, $message_format, $from, $from_name, $bcc, $reply_to);
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:83,代码来源:common.php

示例7: get_lead_field_display

 public static function get_lead_field_display($field, $value, $currency = "", $use_text = false)
 {
     switch (RGFormsModel::get_input_type($field)) {
         case "name":
             if (is_array($value)) {
                 $prefix = trim($value[$field["id"] . ".2"]);
                 $first = trim($value[$field["id"] . ".3"]);
                 $last = trim($value[$field["id"] . ".6"]);
                 $suffix = trim($value[$field["id"] . ".8"]);
                 $name = $prefix;
                 $name .= !empty($name) && !empty($first) ? " {$first}" : $first;
                 $name .= !empty($name) && !empty($last) ? " {$last}" : $last;
                 $name .= !empty($name) && !empty($suffix) ? " {$suffix}" : $suffix;
                 return $name;
             } else {
                 return $value;
             }
             break;
         case "address":
             if (is_array($value)) {
                 $street_value = trim($value[$field["id"] . ".1"]);
                 $street2_value = trim($value[$field["id"] . ".2"]);
                 $city_value = trim($value[$field["id"] . ".3"]);
                 $state_value = trim($value[$field["id"] . ".4"]);
                 $zip_value = trim($value[$field["id"] . ".5"]);
                 $country_value = trim($value[$field["id"] . ".6"]);
                 $address_display_format = apply_filters("gform_address_display_format", "street,city,state,zip,country");
                 if ($address_display_format == "zip_before_city") {
                     /*
                     Sample:
                     3333 Some Street
                     suite 16
                     2344 City, State
                     Country
                     */
                     $addr_ary = array();
                     $addr_ary[] = $street_value;
                     if (!empty($street2_value)) {
                         $addr_ary[] = $street2_value;
                     }
                     $zip_line = trim($zip_value . " " . $city_value);
                     $zip_line .= !empty($zip_line) && !empty($state_value) ? ", {$state_value}" : $state_value;
                     $zip_line = trim($zip_line);
                     if (!empty($zip_line)) {
                         $addr_ary[] = $zip_line;
                     }
                     if (!empty($country_value)) {
                         $addr_ary[] = $country_value;
                     }
                     $address = implode("<br />", $addr_ary);
                 } else {
                     $address = $street_value;
                     $address .= !empty($address) && !empty($street2_value) ? "<br />{$street2_value}" : $street2_value;
                     $address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? "<br />{$city_value}" : $city_value;
                     $address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", {$state_value}" : $state_value;
                     $address .= !empty($address) && !empty($zip_value) ? " {$zip_value}" : $zip_value;
                     $address .= !empty($address) && !empty($country_value) ? "<br />{$country_value}" : $country_value;
                 }
                 //adding map link
                 if (!empty($address)) {
                     $address_qs = str_replace("<br />", " ", $address);
                     //replacing <br/> with spaces
                     $address_qs = urlencode($address_qs);
                     $address .= "<br/><a href='http://maps.google.com/maps?q={$address_qs}' target='_blank' class='map-it-link'>Map It</a>";
                 }
                 return $address;
             } else {
                 return "";
             }
             break;
         case "email":
             return GFCommon::is_valid_email($value) ? "<a href='mailto:{$value}'>{$value}</a>" : $value;
             break;
         case "website":
             return GFCommon::is_valid_url($value) ? "<a href='{$value}' target='_blank'>{$value}</a>" : $value;
             break;
         case "checkbox":
             if (is_array($value)) {
                 foreach ($value as $key => $item) {
                     if (!empty($item)) {
                         $items .= "<li>" . GFCommon::selection_display($item, $field, $currency, $use_text) . "</li>";
                     }
                 }
                 return empty($items) ? "" : "<ul class='bulleted'>{$items}</ul>";
             } else {
                 return $value;
             }
             break;
         case "post_image":
             list($url, $title, $caption, $description) = explode("|:|", $value);
             if (!empty($url)) {
                 $url = str_replace(" ", "%20", $url);
                 $value = "<a href='{$url}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$url}' width='100' /></a>";
                 $value .= !empty($title) ? "<div>Title: {$title}</div>" : "";
                 $value .= !empty($caption) ? "<div>Caption: {$caption}</div>" : "";
                 $value .= !empty($description) ? "<div>Description: {$description}</div>" : "";
             }
             return $value;
         case "fileupload":
             $file_path = $value;
//.........这里部分代码省略.........
开发者ID:novuscory,项目名称:ACH,代码行数:101,代码来源:common.php

示例8: send_email

 private static function send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '')
 {
     global $phpmailer;
     $to = str_replace(' ', '', $to);
     $bcc = str_replace(' ', '', $bcc);
     $error = false;
     if (!GFCommon::is_valid_email($from)) {
         $from = get_bloginfo('admin_email');
     }
     if (!GFCommon::is_valid_email_list($to)) {
         $error = new WP_Error('invalid_to', 'Cannot send email because the TO address is invalid.');
     } else {
         if (empty($subject) && empty($message)) {
             $error = new WP_Error('missing_subject_and_message', 'Cannot send email because there is no SUBJECT and no MESSAGE.');
         } else {
             if (!GFCommon::is_valid_email($from)) {
                 $error = new WP_Error('invalid_from', 'Cannot send email because the FROM address is invalid.');
             }
         }
     }
     if (is_wp_error($error)) {
         GFCommon::log_error('GFCommon::send_email(): ' . $error->get_error_message());
         GFCommon::log_error(print_r(compact('to', 'subject', 'message'), true));
         do_action('gform_send_email_failed', $error, compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'attachments'));
         return;
     }
     $content_type = $message_format == 'html' ? 'text/html' : 'text/plain';
     $name = empty($from_name) ? $from : $from_name;
     $headers = array();
     $headers['From'] = "From: \"" . wp_strip_all_tags($name, true) . "\" <{$from}>";
     if (GFCommon::is_valid_email_list($reply_to)) {
         $headers['Reply-To'] = "Reply-To: {$reply_to}";
     }
     if (GFCommon::is_valid_email_list($bcc)) {
         $headers['Bcc'] = "Bcc: {$bcc}";
     }
     $headers['Content-type'] = "Content-type: {$content_type}; charset=" . get_option('blog_charset');
     $abort_email = false;
     extract(apply_filters('gform_pre_send_email', compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), $message_format));
     $is_success = false;
     if (!$abort_email) {
         GFCommon::log_debug('GFCommon::send_email(): Sending email via wp_mail().');
         GFCommon::log_debug(print_r(compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), true));
         $is_success = wp_mail($to, $subject, $message, $headers, $attachments);
         $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
         GFCommon::log_debug("GFCommon::send_email(): Result from wp_mail(): {$result}");
         if (!is_wp_error($is_success) && $is_success) {
             GFCommon::log_debug('GFCommon::send_email(): Mail was passed from WordPress to the mail server.');
         } else {
             GFCommon::log_error('GFCommon::send_email(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
         }
         if (has_filter('phpmailer_init')) {
             GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
         }
         if (!empty($phpmailer->ErrorInfo)) {
             GFCommon::log_debug(__METHOD__ . '(): PHPMailer class returned an error message: ' . $phpmailer->ErrorInfo);
         }
     } else {
         GFCommon::log_debug('GFCommon::send_email(): Aborting. The gform_pre_send_email hook was used to set the abort_email parameter to true.');
     }
     self::add_emails_sent();
     do_action('gform_after_email', $is_success, $to, $subject, $message, $headers, $attachments, $message_format, $from, $from_name, $bcc, $reply_to);
 }
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:63,代码来源:common.php

示例9: send_email

 private static function send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false)
 {
     global $phpmailer;
     $to = str_replace(' ', '', $to);
     $bcc = str_replace(' ', '', $bcc);
     $error = false;
     if (!GFCommon::is_valid_email($from)) {
         $from = get_bloginfo('admin_email');
     }
     if (!GFCommon::is_valid_email_list($to)) {
         $error = new WP_Error('invalid_to', 'Cannot send email because the TO address is invalid.');
     } else {
         if (empty($subject) && empty($message)) {
             $error = new WP_Error('missing_subject_and_message', 'Cannot send email because there is no SUBJECT and no MESSAGE.');
         } else {
             if (!GFCommon::is_valid_email($from)) {
                 $error = new WP_Error('invalid_from', 'Cannot send email because the FROM address is invalid.');
             }
         }
     }
     if (is_wp_error($error)) {
         GFCommon::log_error('GFCommon::send_email(): ' . $error->get_error_message());
         GFCommon::log_error(print_r(compact('to', 'subject', 'message'), true));
         /**
          * Fires when an email from Gravity Forms has failed to send
          *
          * @since 1.8.10
          *
          * @param string $error   The Error message returned after the email fails to send
          * @param array  $details The details of the message that failed
          * @param array  $entry   The Entry object
          *
          */
         do_action('gform_send_email_failed', $error, compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'attachments'), $entry);
         return;
     }
     $content_type = $message_format == 'html' ? 'text/html' : 'text/plain';
     $name = empty($from_name) ? $from : $from_name;
     $headers = array();
     $headers['From'] = "From: \"" . wp_strip_all_tags($name, true) . "\" <{$from}>";
     if (GFCommon::is_valid_email_list($reply_to)) {
         $headers['Reply-To'] = "Reply-To: {$reply_to}";
     }
     if (GFCommon::is_valid_email_list($bcc)) {
         $headers['Bcc'] = "Bcc: {$bcc}";
     }
     $headers['Content-type'] = "Content-type: {$content_type}; charset=" . get_option('blog_charset');
     $abort_email = false;
     extract(apply_filters('gform_pre_send_email', compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), $message_format, $notification));
     $is_success = false;
     if (!$abort_email) {
         GFCommon::log_debug('GFCommon::send_email(): Sending email via wp_mail().');
         GFCommon::log_debug(print_r(compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), true));
         $is_success = wp_mail($to, $subject, $message, $headers, $attachments);
         $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
         GFCommon::log_debug("GFCommon::send_email(): Result from wp_mail(): {$result}");
         if (!is_wp_error($is_success) && $is_success) {
             GFCommon::log_debug('GFCommon::send_email(): Mail was passed from WordPress to the mail server.');
         } else {
             GFCommon::log_error('GFCommon::send_email(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
         }
         if (has_filter('phpmailer_init')) {
             GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
         }
         if (!empty($phpmailer->ErrorInfo)) {
             GFCommon::log_debug(__METHOD__ . '(): PHPMailer class returned an error message: ' . $phpmailer->ErrorInfo);
         }
     } else {
         GFCommon::log_debug('GFCommon::send_email(): Aborting. The gform_pre_send_email hook was used to set the abort_email parameter to true.');
     }
     self::add_emails_sent();
     /**
      * Fires after an email is sent
      *
      * @param bool   $is_success     True is successfully sent.  False if failed
      * @param string $to             Recipient address
      * @param string $subject        Subject line
      * @param string $message        Message body
      * @param string $headers        Email headers
      * @param string $attachments    Email attachments
      * @param string $message_format Format of the email.  Ex: text, html
      * @param string $from           Address of the sender
      * @param string $from_name      Displayed name of the sender
      * @param string $bcc            BCC recipients
      * @param string $reply_to       Reply-to address
      * @param array  $entry          Entry object associated with the sent email
      *
      */
     do_action('gform_after_email', $is_success, $to, $subject, $message, $headers, $attachments, $message_format, $from, $from_name, $bcc, $reply_to, $entry);
 }
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:90,代码来源:common.php

示例10: pdf_get_lead_field_display

 public static function pdf_get_lead_field_display($field, $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen')
 {
     if ($field['type'] == 'post_category') {
         $value = GFCommon::prepare_post_category_value($value, $field);
     }
     switch (RGFormsModel::get_input_type($field)) {
         case 'name':
             if (is_array($value)) {
                 $prefix = trim(rgget($field['id'] . '.2', $value));
                 $first = trim(rgget($field['id'] . '.3', $value));
                 $middle = trim(rgget($field['id'] . '.4', $value));
                 $last = trim(rgget($field['id'] . '.6', $value));
                 $suffix = trim(rgget($field['id'] . '.8', $value));
                 $name = $prefix;
                 $name .= !empty($name) && !empty($first) ? " {$first}" : $first;
                 $name .= !empty($name) && !empty($middle) ? " {$middle}" : $middle;
                 $name .= !empty($name) && !empty($last) ? " {$last}" : $last;
                 $name .= !empty($name) && !empty($suffix) ? " {$suffix}" : $suffix;
                 return $name;
             } else {
                 return $value;
             }
             break;
         case 'creditcard':
             if (is_array($value)) {
                 $card_number = trim(rgget($field['id'] . '.1', $value));
                 $card_type = trim(rgget($field['id'] . '.4', $value));
                 $separator = $format == 'html' ? '<br/>' : '\\n';
                 return empty($card_number) ? '' : $card_type . $separator . $card_number;
             } else {
                 return '';
             }
             break;
         case 'address':
             if (is_array($value)) {
                 $street_value = trim(rgget($field['id'] . '.1', $value));
                 $street2_value = trim(rgget($field['id'] . '.2', $value));
                 $city_value = trim(rgget($field['id'] . '.3', $value));
                 $state_value = trim(rgget($field['id'] . '.4', $value));
                 $zip_value = trim(rgget($field['id'] . '.5', $value));
                 $country_value = trim(rgget($field['id'] . '.6', $value));
                 $line_break = $format == 'html' ? '<br />' : '\\n';
                 $address_display_format = apply_filters('gform_address_display_format', 'default');
                 if ($address_display_format == 'zip_before_city') {
                     /*
                     Sample:
                     3333 Some Street
                     suite 16
                     2344 City, State
                     Country
                     */
                     $addr_ary = array();
                     $addr_ary[] = $street_value;
                     if (!empty($street2_value)) {
                         $addr_ary[] = $street2_value;
                     }
                     $zip_line = trim($zip_value . ' ' . $city_value);
                     $zip_line .= !empty($zip_line) && !empty($state_value) ? ", {$state_value}" : $state_value;
                     $zip_line = trim($zip_line);
                     if (!empty($zip_line)) {
                         $addr_ary[] = $zip_line;
                     }
                     if (!empty($country_value)) {
                         $addr_ary[] = $country_value;
                     }
                     $address = implode('<br />', $addr_ary);
                 } else {
                     $address = $street_value;
                     $address .= !empty($address) && !empty($street2_value) ? $line_break . $street2_value : $street2_value;
                     $address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? $line_break . $city_value : $city_value;
                     $address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", {$state_value}" : $state_value;
                     $address .= !empty($address) && !empty($zip_value) ? " {$zip_value}" : $zip_value;
                     $address .= !empty($address) && !empty($country_value) ? $line_break . $country_value : $country_value;
                 }
                 return $address;
             } else {
                 return '';
             }
             break;
         case 'email':
             return GFCommon::is_valid_email($value) && $format == 'html' ? '<a href="mailto:' . $value . '">' . $value . '</a>' : $value;
             break;
         case 'website':
             return GFCommon::is_valid_url($value) && $format == 'html' ? '<a href="' . $value . '" target="_blank">' . $value . '</a>' : $value;
             break;
         case 'checkbox':
             if (is_array($value)) {
                 $items = '';
                 foreach ($value as $key => $item) {
                     if (!empty($item)) {
                         switch ($format) {
                             case 'text':
                                 $items .= GFCommon::selection_display($item, $field, $currency, true) . ', ';
                                 break;
                             default:
                                 $items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
                                 break;
                         }
                     }
                 }
//.........这里部分代码省略.........
开发者ID:quinntron,项目名称:tmad,代码行数:101,代码来源:pdf-entry-detail.php

示例11: validate

 public static function validate(&$form, $field_values, $page_number = 0)
 {
     $is_valid = true;
     foreach ($form["fields"] as &$field) {
         //If a page number is specified, only validates fields that are on current page
         if ($page_number > 0 && $field["pageNumber"] != $page_number) {
             continue;
         }
         //ignore validation if field is hidden or admin only
         if (RGFormsModel::is_field_hidden($form, $field, $field_values) || $field["adminOnly"]) {
             continue;
         }
         $value = RGFormsModel::get_field_value($field);
         //display error message if field is marked as required and the submitted value is empty
         if ($field["isRequired"] && self::is_empty($field, $form["id"])) {
             $field["failed_validation"] = true;
             $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required.", "gravityforms") : $field["errorMessage"];
             $is_valid = false;
         } else {
             if ($field["noDuplicates"] && RGFormsModel::is_duplicate($form["id"], $field, $value)) {
                 $field["failed_validation"] = true;
                 $field["validation_message"] = is_array($value) ? apply_filters("gform_duplicate_message_{$form["id"]}", apply_filters("gform_duplicate_message", __("This field requires an unique entry and the values you entered have been already been used", "gravityforms"), $form), $form) : apply_filters("gform_duplicate_message_{$form["id"]}", apply_filters("gform_duplicate_message", sprintf(__("This field requires an unique entry and '%s' has already been used", "gravityforms"), $value), $form), $form);
                 $is_valid = false;
             } else {
                 if (self::failed_state_validation($form["id"], $field, $value)) {
                     $field["failed_validation"] = true;
                     $field["validation_message"] = in_array($field["inputType"], array("singleproduct", "singleshipping")) ? __("Please enter a valid value.", "gravityforms") : __("Invalid selection. Please select one of the available choices.", "gravityforms");
                     $is_valid = false;
                 } else {
                     switch (RGFormsModel::get_input_type($field)) {
                         case "password":
                             $password = $_POST["input_" . $field["id"]];
                             $confirm = $_POST["input_" . $field["id"] . "_2"];
                             if ($password != $confirm) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = __("Your passwords do not match.", "gravityforms");
                                 $is_valid = false;
                             } else {
                                 if ($field["passwordStrengthEnabled"] && !empty($field["minPasswordStrength"]) && !empty($password)) {
                                     $strength = $_POST["input_" . $field["id"] . "_strength"];
                                     $levels = array("short" => 1, "bad" => 2, "good" => 3, "strong" => 4);
                                     if ($levels[$strength] < $levels[$field["minPasswordStrength"]]) {
                                         $field["failed_validation"] = true;
                                         $field["validation_message"] = empty($field["errorMessage"]) ? __("Your password does not meet the required strength. <br/>Hint: To make it stronger, use upper and lower case letters, numbers and symbols like ! \" ? \$ % ^ & ).", "gravityforms") : $field["errorMessage"];
                                         $is_valid = false;
                                     }
                                 }
                             }
                             break;
                         case "name":
                             if ($field["isRequired"] && $field["nameFormat"] != "simple") {
                                 $first = $_POST["input_" . $field["id"] . "_3"];
                                 $last = $_POST["input_" . $field["id"] . "_6"];
                                 if (empty($first) || empty($last)) {
                                     $field["failed_validation"] = true;
                                     $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter the first and last name.", "gravityforms") : $field["errorMessage"];
                                     $is_valid = false;
                                 }
                             }
                             break;
                         case "address":
                             if ($field["isRequired"]) {
                                 $street = $_POST["input_" . $field["id"] . "_1"];
                                 $city = $_POST["input_" . $field["id"] . "_3"];
                                 $state = $_POST["input_" . $field["id"] . "_4"];
                                 $zip = $_POST["input_" . $field["id"] . "_5"];
                                 $country = $_POST["input_" . $field["id"] . "_6"];
                                 if (empty($street) || empty($city) || empty($zip) || empty($state) && !$field["hideState"] || empty($country) && !$field["hideCountry"]) {
                                     $field["failed_validation"] = true;
                                     $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
                                     $is_valid = false;
                                 }
                             }
                             break;
                         case "email":
                             if (!empty($value) && !GFCommon::is_valid_email($value)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid email address.", "gravityforms") : $field["errorMessage"];
                                 $is_valid = false;
                             } else {
                                 if (rgget("emailConfirmEnabled", $field) && !empty($value)) {
                                     $confirm = rgpost("input_" . $field["id"] . "_2");
                                     if ($confirm != $value) {
                                         $field["failed_validation"] = true;
                                         $field["validation_message"] = __("Your emails do not match.", "gravityforms");
                                         $is_valid = false;
                                     }
                                 }
                             }
                             break;
                         case "donation":
                         case "price":
                             if (!class_exists("RGCurrency")) {
                                 require_once "currency.php";
                             }
                             $donation = GFCommon::to_number($value);
                             if (!empty($value) && ($donation === false || $donation <= 0)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid donation", "gravityforms") : $field["errorMessage"];
                                 $is_valid = false;
//.........这里部分代码省略.........
开发者ID:hypenotic,项目名称:slowfood,代码行数:101,代码来源:form_display.php

示例12: validate

 private function validate(&$form, $field_values)
 {
     $form = apply_filters('gform_pre_validation', $form);
     foreach ($form["fields"] as &$field) {
         /*
          * Skip over the following fields as we aren't processing any of them
          */
         $skip_field = false;
         switch (RGFormsModel::get_input_type($field)) {
             case "captcha":
             case "html":
             case "password":
             case "product":
             case "coupon":
             case "quantity":
             case "shipping":
             case "donation":
             case "total":
             case "singleproduct":
             case "hiddenproduct":
             case "singleshipping":
             case "creditcard":
             case "page":
             case "post_image":
             case "fileupload":
                 //ignore certain fields
                 $skip_field = true;
                 break;
         }
         if (isset($field['productField']) && (int) $field['productField'] > 0 || $field['type'] == 'shipping') {
             $skip_field = true;
         }
         /* ignore validation if field is hidden or admin only */
         if (RGFormsModel::is_field_hidden($form, $field, $field_values) || isset($field['adminOnly']) && $field['adminOnly']) {
             $skip_field = true;
         }
         /* ignore user-defined restricted fields or hidden fields */
         if (in_array($field['id'], $this->atts['restricted_fields']) || in_array($field['id'], $this->atts['hidden_fields'])) {
             $skip_field = true;
         }
         if ($skip_field) {
             continue;
         }
         $value = RGFormsModel::get_field_value($field);
         //display error message if field is marked as required and the submitted value is empty
         if ($field["isRequired"] && GFFormDisplay::is_empty($field, $form["id"])) {
             $field["failed_validation"] = true;
             $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required.", "gravityforms") : $field["errorMessage"];
         } else {
             if ($field["noDuplicates"] && RGFormsModel::is_duplicate($form["id"], $field, $value)) {
                 $field["failed_validation"] = true;
                 $input_type = RGFormsModel::get_input_type($field);
                 switch ($input_type) {
                     case "date":
                         $default_message = __("This date has already been taken. Please select a new date.", "gravityforms");
                         break;
                     default:
                         $default_message = is_array($value) ? __("This field requires a unique entry and the values you entered have been already been used.", "gravityforms") : sprintf(__("This field requires a unique entry and '%s' has already been used", "gravityforms"), $value);
                         break;
                 }
                 $field["validation_message"] = apply_filters("gform_duplicate_message_{$form["id"]}", apply_filters("gform_duplicate_message", $default_message, $form, $field, $value), $form, $field, $value);
             } else {
                 if (GFFormDisplay::failed_state_validation($form["id"], $field, $value)) {
                     $field["failed_validation"] = true;
                     $field["validation_message"] = in_array($field["inputType"], array("singleproduct", "singleshipping", "hiddenproduct")) ? __("Please enter a valid value.", "gravityforms") : __("Invalid selection. Please select one of the available choices.", "gravityforms");
                 } else {
                     switch (RGFormsModel::get_input_type($field)) {
                         case "name":
                             if ($field["isRequired"] && $field["nameFormat"] != "simple") {
                                 $first = $_POST["input_" . $field["id"] . "_3"];
                                 $last = $_POST["input_" . $field["id"] . "_6"];
                                 if (empty($first) || empty($last)) {
                                     $field["failed_validation"] = true;
                                     $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter the first and last name.", "gravityforms") : $field["errorMessage"];
                                 }
                             }
                             break;
                         case "address":
                             if ($field["isRequired"]) {
                                 $street = $_POST["input_" . $field["id"] . "_1"];
                                 $city = $_POST["input_" . $field["id"] . "_3"];
                                 $state = $_POST["input_" . $field["id"] . "_4"];
                                 $zip = $_POST["input_" . $field["id"] . "_5"];
                                 $country = $_POST["input_" . $field["id"] . "_6"];
                                 if (empty($street) || empty($city) || empty($zip) || empty($state) && !$field["hideState"] || empty($country) && !$field["hideCountry"]) {
                                     $field["failed_validation"] = true;
                                     $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
                                 }
                             }
                             break;
                         case "email":
                             if (!rgblank($value) && !GFCommon::is_valid_email($value)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid email address.", "gravityforms") : $field["errorMessage"];
                             } else {
                                 if (rgget("emailConfirmEnabled", $field) && !empty($value)) {
                                     $confirm = rgpost("input_" . $field["id"] . "_2");
                                     if ($confirm != $value) {
                                         $field["failed_validation"] = true;
                                         $field["validation_message"] = __("Your emails do not match.", "gravityforms");
//.........这里部分代码省略.........
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:101,代码来源:entry-edit-logic.php

示例13: validate

 public static function validate(&$form, $field_values)
 {
     $is_valid = true;
     foreach ($form["fields"] as &$field) {
         //ignore validation if field is hidden
         if (RGFormsModel::is_field_hidden($form, $field, $field_values)) {
             continue;
         }
         $value = RGFormsModel::get_field_value($field);
         //display error message if field is marked as required and the submitted value is empty
         if ($field["isRequired"] && self::is_empty($field)) {
             $field["failed_validation"] = true;
             $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a value.", "gravityforms") : $field["errorMessage"];
             $is_valid = false;
         } else {
             if ($field["noDuplicates"] && RGFormsModel::is_duplicate($form["id"], $field, $value)) {
                 $field["failed_validation"] = true;
                 $field["validation_message"] = is_array($value) ? __("This field requires an unique entry and the values you entered have been already been used", "gravityforms") : __(sprintf("This field requires an unique entry and '%s' has already been used", $value), "gravityforms");
                 $is_valid = false;
             } else {
                 switch (RGFormsModel::get_input_type($field)) {
                     case "name":
                         if ($field["isRequired"] && $field["nameFormat"] != "simple") {
                             $first = $_POST["input_" . $field["id"] . "_3"];
                             $last = $_POST["input_" . $field["id"] . "_6"];
                             if (empty($first) || empty($last)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter the first and last name.", "gravityforms") : $field["errorMessage"];
                                 $is_valid = false;
                             }
                         }
                         break;
                     case "address":
                         if ($field["isRequired"]) {
                             $street = $_POST["input_" . $field["id"] . "_1"];
                             $city = $_POST["input_" . $field["id"] . "_3"];
                             $state = $_POST["input_" . $field["id"] . "_4"];
                             $zip = $_POST["input_" . $field["id"] . "_5"];
                             $country = $_POST["input_" . $field["id"] . "_6"];
                             if (empty($street) || empty($city) || empty($state) || empty($zip) || empty($country)) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
                                 $is_valid = false;
                             }
                         }
                         break;
                     case "email":
                         if (!empty($value) && !GFCommon::is_valid_email($value)) {
                             $field["failed_validation"] = true;
                             $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid email address.", "gravityforms") : $field["errorMessage"];
                             $is_valid = false;
                         }
                         break;
                     case "number":
                         if (trim($value) != '' && !self::validate_range($field, $value)) {
                             $field["failed_validation"] = true;
                             $field["validation_message"] = empty($field["errorMessage"]) ? GFCommon::get_range_message($field) : $field["errorMessage"];
                             $is_valid = false;
                         }
                         break;
                     case "phone":
                         $regex = '/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/';
                         if ($field["phoneFormat"] == "standard" && !empty($value) && !preg_match($regex, $value)) {
                             $field["failed_validation"] = true;
                             if (!empty($field["errorMessage"])) {
                                 $field["validation_message"] = $field["errorMessage"];
                             }
                             $is_valid = false;
                         }
                         break;
                     case "date":
                         if (is_array($value) && empty($value[0])) {
                             $value = null;
                         }
                         if (!empty($value)) {
                             $format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
                             $date = GFCommon::parse_date($value, $format);
                             if (empty($date) || !checkdate($date["month"], $date["day"], $date["year"])) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __(sprintf("Please enter a valid date in the format (%s).", $format == "mdy" ? "mm/dd/yyyy" : "dd/mm/yyyy"), "gravityforms") : $field["errorMessage"];
                                 $is_valid = false;
                             }
                         }
                         break;
                     case "time":
                         //create variable values if time came in one field
                         if (!is_array($value) && !empty($value)) {
                             preg_match('/^(\\d*):(\\d*) (.*)$/', $value, $matches);
                             $value = array();
                             $value[0] = $matches[1];
                             $value[1] = $matches[2];
                         }
                         $hour = $value[0];
                         $minute = $value[1];
                         if (empty($hour) && empty($minute)) {
                             break;
                         }
                         $is_valid_format = is_numeric($hour) && is_numeric($minute);
                         if (!$is_valid_format || $hour <= 0 || $hour > 12 || $minute < 0 || $minute >= 60) {
                             $field["failed_validation"] = true;
//.........这里部分代码省略.........
开发者ID:812studio,项目名称:812studio,代码行数:101,代码来源:form_display.php

示例14: get_lead_field_display

 public static function get_lead_field_display($field, $value)
 {
     switch (RGFormsModel::get_input_type($field)) {
         case "name":
             if (is_array($value)) {
                 $prefix = trim($value[$field["id"] . ".2"]);
                 $first = trim($value[$field["id"] . ".3"]);
                 $last = trim($value[$field["id"] . ".6"]);
                 $suffix = trim($value[$field["id"] . ".8"]);
                 $name = $prefix;
                 $name .= !empty($name) && !empty($first) ? " {$first}" : $first;
                 $name .= !empty($name) && !empty($last) ? " {$last}" : $last;
                 $name .= !empty($name) && !empty($suffix) ? " {$suffix}" : $suffix;
                 return $name;
             } else {
                 return $value;
             }
             break;
         case "address":
             if (is_array($value)) {
                 $street_value = trim($value[$field["id"] . ".1"]);
                 $street2_value = trim($value[$field["id"] . ".2"]);
                 $city_value = trim($value[$field["id"] . ".3"]);
                 $state_value = trim($value[$field["id"] . ".4"]);
                 $zip_value = trim($value[$field["id"] . ".5"]);
                 $country_value = trim($value[$field["id"] . ".6"]);
                 $address = $street_value;
                 $address .= !empty($address) && !empty($street2_value) ? " {$street2_value}" : $street2_value;
                 $address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? "<br />{$city_value}" : $city_value;
                 $address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", {$state_value}" : $state_value;
                 $address .= !empty($address) && !empty($zip_value) ? " {$zip_value}" : $zip_value;
                 $address .= !empty($address) && !empty($country_value) ? "<br />{$country_value}" : $country_value;
                 //adding map link
                 if (!empty($address)) {
                     $address_qs = str_replace("<br />", " ", $address);
                     //replacing <br/> with spaces
                     $address_qs = urlencode($address_qs);
                     $address .= "<br/><a href='http://maps.google.com/maps?q={$address_qs}' target='_blank' class='map-it-link'>Map It</a>";
                 }
                 return $address;
             } else {
                 return "";
             }
             break;
         case "email":
             return GFCommon::is_valid_email($value) ? "<a href='mailto:{$value}'>{$value}</a>" : $value;
             break;
         case "website":
             return GFCommon::is_valid_url($value) ? "<a href='{$value}' target='_blank'>{$value}</a>" : $value;
             break;
         case "checkbox":
             if (is_array($value)) {
                 foreach ($value as $key => $item) {
                     if (!empty($item)) {
                         $items .= "<li>{$item}</li>";
                     }
                 }
                 return empty($items) ? "" : "<ul class='bulleted'>{$items}</ul>";
             } else {
                 return $value;
             }
             break;
         case "post_image":
             list($url, $title, $caption, $description) = explode("|:|", $value);
             if (!empty($url)) {
                 $url = str_replace(" ", "%20", $url);
                 $value = "<a href='{$url}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$url}' width='100' /></a>";
                 $value .= !empty($title) ? "<div>Title: {$title}</div>" : "";
                 $value .= !empty($caption) ? "<div>Caption: {$caption}</div>" : "";
                 $value .= !empty($description) ? "<div>Description: {$description}</div>" : "";
             }
             return $value;
         case "fileupload":
             $file_path = $value;
             if (!empty($file_path)) {
                 $info = pathinfo($file_path);
                 $file_path = esc_attr(str_replace(" ", "%20", $file_path));
                 $value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $info["basename"] . "</a>";
             }
             return $value;
             break;
         case "date":
             return GFCommon::date_display($value, $field["dateFormat"]);
             break;
         default:
             return nl2br($value);
             break;
     }
 }
开发者ID:812studio,项目名称:812studio,代码行数:89,代码来源:common.php


注:本文中的GFCommon::is_valid_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。