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


PHP GFCommon::parse_date方法代码示例

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


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

示例1: date_display

 /**
  * Get the default date format for a field based on the field ID and the time format setting
  *
  * @since 1.16.4
  * @param string $date_format The Gravity Forms date format for the field. Default: "mdy"
  * @param int $field_id The ID of the field. Used to figure out full date/day/month/year
  *
  * @return string PHP date format for the date
  */
 public static function date_display($value = '', $date_format = 'mdy', $field_id = 0)
 {
     // Let Gravity Forms figure out, based on the date format, what day/month/year values are.
     $parsed_date = GFCommon::parse_date($value, $date_format);
     // Are we displaying an input or the whole field?
     $field_input_id = gravityview_get_input_id_from_id($field_id);
     $date_field_output = '';
     switch ($field_input_id) {
         case 1:
             $date_field_output = rgar($parsed_date, 'day');
             break;
         case 2:
             $date_field_output = rgar($parsed_date, 'month');
             break;
         case 3:
             $date_field_output = rgar($parsed_date, 'year');
             break;
     }
     /**
      * @filter `gravityview_date_format` Whether to override the Gravity Forms date format with a PHP date format
      * @see https://codex.wordpress.org/Formatting_Date_and_Time
      * @param null|string Date Format (default: $field->dateFormat)
      */
     $full_date_format = apply_filters('gravityview_date_format', $date_format);
     $full_date = GFCommon::date_display($value, $full_date_format);
     // If the field output is empty, use the full date.
     // Note: The output might be empty because $parsed_date didn't parse correctly.
     return '' === $date_field_output ? $full_date : $date_field_output;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:38,代码来源:class-gravityview-field-date.php

示例2: prepare_date

 public static function prepare_date($date_format, $value)
 {
     $format = empty($date_format) ? 'mdy' : $date_format;
     $date_info = GFCommon::parse_date($value, $format);
     if (!empty($date_info) && !GFCommon::is_empty_array($date_info)) {
         $value = sprintf('%s-%02d-%02d', $date_info['year'], $date_info['month'], $date_info['day']);
     } else {
         $value = '';
     }
     return $value;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:11,代码来源:forms_model.php

示例3: validate


//.........这里部分代码省略.........
                             }
                             $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"];
                                 }
                             }
                             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"];
                                 }
                             }
                             break;
                         case "date":
                             if (is_array($value) && rgempty(0, $value) && rgempty(1, $value) && rgempty(2, $value)) {
                                 $value = null;
                             }
                             if (!empty($value)) {
                                 $format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
                                 $date = GFCommon::parse_date($value, $format);
                                 if (empty($date) || !self::checkdate($date["month"], $date["day"], $date["year"])) {
                                     $field["failed_validation"] = true;
                                     $format_name = "";
                                     switch ($format) {
                                         case "mdy":
                                             $format_name = "mm/dd/yyyy";
                                             break;
                                         case "dmy":
                                             $format_name = "dd/mm/yyyy";
                                             break;
                                         case "dmy_dash":
                                             $format_name = "dd-mm-yyyy";
                                             break;
                                         case "dmy_dot":
                                             $format_name = "dd.mm.yyyy";
                                             break;
                                         case "ymd_slash":
                                             $format_name = "yyyy/mm/dd";
                                             break;
                                         case "ymd_dash":
                                             $format_name = "yyyy-mm-dd";
                                             break;
                                         case "ymd_dot":
                                             $format_name = "yyyy.mm.dd";
                                             break;
                                     }
                                     $message = $field["dateType"] == "datepicker" ? sprintf(__("Please enter a valid date in the format (%s).", "gravityforms"), $format_name) : __("Please enter a valid date.", "gravityforms");
                                     $field["validation_message"] = empty($field["errorMessage"]) ? $message : $field["errorMessage"];
                                 }
                             }
                             break;
                         case "time":
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:67,代码来源:form_display.php

示例4: get_field_input

 public function get_field_input($form, $value = '', $entry = null)
 {
     $picker_value = '';
     if (is_array($value)) {
         // GFCommon::parse_date() takes a numeric array.
         $value = array_values($value);
     } else {
         $picker_value = $value;
     }
     $format = empty($this->dateFormat) ? 'mdy' : esc_attr($this->dateFormat);
     $date_info = GFCommon::parse_date($value, $format);
     $day_value = esc_attr(rgget('day', $date_info));
     $month_value = esc_attr(rgget('month', $date_info));
     $year_value = esc_attr(rgget('year', $date_info));
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $form_id = $form['id'];
     $id = intval($this->id);
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $size = $this->size;
     $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
     $class_suffix = $is_entry_detail ? '_admin' : '';
     $class = $size . $class_suffix;
     $form_sub_label_placement = rgar($form, 'subLabelPlacement');
     $field_sub_label_placement = rgar($this, 'subLabelPlacement');
     $is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
     $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : '';
     $month_input = GFFormsModel::get_input($this, $this->id . '.1');
     $day_input = GFFormsModel::get_input($this, $this->id . '.2');
     $year_input = GFFormsModel::get_input($this, $this->id . '.3');
     $month_sub_label = rgar($month_input, 'customLabel') != '' ? $month_input['customLabel'] : esc_html(_x('MM', 'Abbreviation: Month', 'gravityforms'));
     $day_sub_label = rgar($day_input, 'customLabel') != '' ? $day_input['customLabel'] : esc_html__('DD', 'gravityforms');
     $year_sub_label = rgar($year_input, 'customLabel') != '' ? $year_input['customLabel'] : esc_html__('YYYY', 'gravityforms');
     $month_placeholder_attribute = GFCommon::get_input_placeholder_attribute($month_input);
     $day_placeholder_attribute = GFCommon::get_input_placeholder_attribute($day_input);
     $year_placeholder_attribute = GFCommon::get_input_placeholder_attribute($year_input);
     $month_placeholder_value = GFCommon::get_input_placeholder_value($month_input);
     $day_placeholder_value = GFCommon::get_input_placeholder_value($day_input);
     $year_placeholder_value = GFCommon::get_input_placeholder_value($year_input);
     $date_picker_placeholder = $this->get_field_placeholder_attribute();
     $is_html5 = RGFormsModel::is_html5_enabled();
     $date_input_type = $is_html5 ? 'number' : 'text';
     $month_html5_attributes = $is_html5 ? "min='1' max='12' step='1'" : '';
     $day_html5_attributes = $is_html5 ? "min='1' max='31' step='1'" : '';
     $year_min = apply_filters('gform_date_min_year', '1920', $form, $this);
     $year_max = apply_filters('gform_date_max_year', date('Y') + 1, $form, $this);
     $year_min_attribute = $is_html5 && is_numeric($year_min) ? "min='{$year_min}'" : '';
     $year_max_attribute = $is_html5 && is_numeric($year_max) ? "max='{$year_max}'" : '';
     $year_step_attribute = $is_html5 ? "step='1'" : '';
     $field_position = substr($format, 0, 3);
     if ($is_form_editor) {
         $datepicker_display = in_array($this->dateType, array('datefield', 'datedropdown')) ? 'none' : 'inline';
         $datefield_display = $this->dateType == 'datefield' ? 'inline' : 'none';
         $dropdown_display = $this->dateType == 'datedropdown' ? 'inline' : 'none';
         $icon_display = $this->calendarIconType == 'calendar' ? 'inline' : 'none';
         if ($is_sub_label_above) {
             $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$datefield_display}'>\n                                    <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n                                    <input id='{$field_id}_1' name='ginput_month' type='text' {$month_placeholder_attribute} {$disabled_text} value='{$month_value}'/>\n                                </div>";
             $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$datefield_display}'>\n                                    <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n                                    <input id='{$field_id}_2' name='ginput_day' type='text' {$day_placeholder_attribute} {$disabled_text} value='{$day_value}'/>\n                               </div>";
             $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$datefield_display}'>\n                                    <label {$sub_label_class_attribute}>{$year_sub_label}</label>\n                                    <input id='{$field_id}_3' type='text' name='text' {$year_placeholder_attribute} {$disabled_text} value='{$year_value}'/>\n                               </div>";
         } else {
             $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$datefield_display}'>\n                                    <input id='{$field_id}_1' name='ginput_month' type='text' {$month_placeholder_attribute} {$disabled_text} value='{$month_value}'/>\n                                    <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n                                </div>";
             $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$datefield_display}'>\n                                    <input id='{$field_id}_2' name='ginput_day' type='text' {$day_placeholder_attribute} {$disabled_text} value='{$day_value}'/>\n                                    <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n                              </div>";
             $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$datefield_display}'>\n                                    <input type='text' id='{$field_id}_3' name='ginput_year' {$year_placeholder_attribute} {$disabled_text} value='{$year_value}'/>\n                                    <label for='{$field_id}_3' {$sub_label_class_attribute}>{$year_sub_label}</label>\n                               </div>";
         }
         $month_dropdown = "<div class='gfield_date_dropdown_month ginput_date_dropdown' id='gfield_dropdown_date_month' style='display:{$dropdown_display}'>" . $this->get_month_dropdown('', "{$field_id}_1", rgar($date_info, 'month'), '', $disabled_text, $month_placeholder_value) . '</div>';
         $day_dropdown = "<div class='gfield_date_dropdown_day ginput_date_dropdown' id='gfield_dropdown_date_day' style='display:{$dropdown_display}'>" . $this->get_day_dropdown('', "{$field_id}_2", rgar($date_info, 'day'), '', $disabled_text, $day_placeholder_value) . '</div>';
         $year_dropdown = "<div class='gfield_date_dropdown_year ginput_date_dropdown' id='gfield_dropdown_date_year' style='display:{$dropdown_display}'>" . $this->get_year_dropdown('', "{$field_id}_3", rgar($date_info, 'year'), '', $disabled_text, $year_placeholder_value, $form) . '</div>';
         $field_string = "<div class='ginput_container ginput_container_date' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' {$date_picker_placeholder} {$disabled_text} value = '{$picker_value}'/><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
         switch ($field_position) {
             case 'dmy':
                 $date_inputs = $day_field . $month_field . $year_field . $day_dropdown . $month_dropdown . $year_dropdown;
                 break;
             case 'ymd':
                 $date_inputs = $year_field . $month_field . $day_field . $year_dropdown . $month_dropdown . $day_dropdown;
                 break;
             default:
                 $date_inputs = $month_field . $day_field . $year_field . $month_dropdown . $day_dropdown . $year_dropdown;
                 break;
         }
         $field_string .= "<div id='{$field_id}' class='ginput_container ginput_container_date'>{$date_inputs}</div>";
         return $field_string;
     } else {
         $date_type = $this->dateType;
         if (in_array($date_type, array('datefield', 'datedropdown'))) {
             switch ($field_position) {
                 case 'dmy':
                     $tabindex = $this->get_tabindex();
                     if ($date_type == 'datedropdown') {
                         $field_str = "<div class='clear-multi'><div class='gfield_date_dropdown_day ginput_container ginput_container_date' id='{$field_id}_2_container'>" . $this->get_day_dropdown("input_{$id}[]", "{$field_id}_2", rgar($date_info, 'day'), $tabindex, $disabled_text, $day_placeholder_value) . '</div>';
                         $tabindex = $this->get_tabindex();
                         $field_str .= "<div class='gfield_date_dropdown_month ginput_container ginput_container_date' id='{$field_id}_1_container'>" . $this->get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, 'month'), $tabindex, $disabled_text, $month_placeholder_value) . '</div>';
                         $tabindex = $this->get_tabindex();
                         $field_str .= "<div class='gfield_date_dropdown_year ginput_container ginput_container_date' id='{$field_id}_3_container'>" . $this->get_year_dropdown("input_{$id}[]", "{$field_id}_3", rgar($date_info, 'year'), $tabindex, $disabled_text, $year_placeholder_value, $form) . '</div></div>';
                     } else {
                         $field_str = $is_sub_label_above ? "<div class='clear-multi'>\n                                        <div class='gfield_date_day ginput_container ginput_container_date' id='{$field_id}_2_container'>\n                                            <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n                                            <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$day_value}' {$tabindex} {$disabled_text} {$day_placeholder_attribute} {$day_html5_attributes}/>\n                                        </div>" : "<div class='clear-multi'>\n                                        <div class='gfield_date_day ginput_container ginput_container_date' id='{$field_id}_2_container'>\n                                            <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_2' value='{$day_value}' {$tabindex} {$disabled_text} {$day_placeholder_attribute} {$day_html5_attributes}/>\n                                            <label for='{$field_id}_2' {$sub_label_class_attribute}>{$day_sub_label}</label>\n                                        </div>";
                         $tabindex = $this->get_tabindex();
                         $field_str .= $is_sub_label_above ? "<div class='gfield_date_month ginput_container ginput_container_date' id='{$field_id}_1_container'>\n                                        <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n                                        <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$month_value}' {$tabindex} {$disabled_text} {$month_placeholder_attribute} {$month_html5_attributes}/>\n                                   </div>" : "<div class='gfield_date_month ginput_container ginput_container_date' id='{$field_id}_1_container'>\n                                        <input type='{$date_input_type}' maxlength='2' name='input_{$id}[]' id='{$field_id}_1' value='{$month_value}' {$tabindex} {$disabled_text} {$month_placeholder_attribute} {$month_html5_attributes}/>\n                                        <label for='{$field_id}_1' {$sub_label_class_attribute}>{$month_sub_label}</label>\n                                   </div>";
                         $tabindex = $this->get_tabindex();
                         $field_str .= $is_sub_label_above ? "<div class='gfield_date_year ginput_container ginput_container_date' id='{$field_id}_3_container'>\n                                            <label for='{$field_id}_3' {$sub_label_class_attribute}>{$year_sub_label}</label>\n                                            <input type='{$date_input_type}' maxlength='4' name='input_{$id}[]' id='{$field_id}_3' value='{$year_value}' {$tabindex} {$disabled_text} {$year_placeholder_attribute} {$year_min_attribute} {$year_max_attribute} {$year_step_attribute}/>\n                                       </div>\n                                    </div>" : "<div class='gfield_date_year ginput_container ginput_container_date' id='{$field_id}_3_container'>\n                                        <input type='{$date_input_type}' maxlength='4' name='input_{$id}[]' id='{$field_id}_3' value='{$year_value}' {$tabindex} {$disabled_text} {$year_placeholder_attribute} {$year_min_attribute} {$year_max_attribute} {$year_step_attribute}/>\n                                        <label for='{$field_id}_3' {$sub_label_class_attribute}>{$year_sub_label}</label>\n                                   </div>\n                                </div>";
                     }
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:davis,代码行数:101,代码来源:class-gf-field-date.php

示例5: prepare_date

 public static function prepare_date($date_format, $value)
 {
     $format = empty($date_format) ? "mdy" : $date_format;
     $date_info = GFCommon::parse_date($value, $format);
     if (!empty($date_info) && !GFCommon::is_empty_array($date_info)) {
         $value = sprintf("%s-%02d-%02d", $date_info["year"], $date_info["month"], $date_info["day"]);
     } else {
         $value = "";
     }
     return $value;
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:11,代码来源:forms_model.php

示例6: get_field_input


//.........这里部分代码省略.........
             if (IS_ADMIN || !$field["hideState"]) {
                 $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text, $form_id);
                 $state = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_4_container' {$style}>{$state_field}<label for='%s.4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state_{$form_id}", apply_filters("gform_address_state", $state_label, $form_id), $form_id) . "</label></span>", $field_id);
             } else {
                 $state = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.4' id='%s_4' value='%s'/>", $id, $field_id, $state_value);
             }
             //zip field
             $tabindex = self::get_tabindex();
             $zip = sprintf("<span class='ginput_left{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip_{$form_id}", apply_filters("gform_address_zip", $zip_label, $form_id), $form_id) . "</label></span>", $id, $field_id, $zip_value, $disabled_text, $field_id);
             if (IS_ADMIN || !$hide_country) {
                 $style = $hide_country ? "style='display:none;'" : "";
                 $tabindex = self::get_tabindex();
                 $country = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_6_container' {$style}><select name='input_%d.6' id='%s_6' {$tabindex} %s>%s</select><label for='%s_6' id='" . $field_id . "_6_label'>" . apply_filters("gform_address_country_{$form_id}", apply_filters("gform_address_country", __("Country", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $disabled_text, $country_list, $field_id);
             } else {
                 $country = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.6' id='%s_6' value='%s'/>", $id, $field_id, $country_value);
             }
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $street_address . $street_address2 . $city . $state . $zip . $country . "</div>";
         case "date":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $format = empty($field["dateFormat"]) ? "mdy" : esc_attr($field["dateFormat"]);
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $datepicker_display = $field["dateType"] == "datefield" ? "none" : "inline";
                 $dropdown_display = $field["dateType"] == "datefield" ? "inline" : "none";
                 $icon_display = $field["calendarIconType"] == "calendar" ? "inline" : "none";
                 $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$dropdown_display}'><input name='ginput_month' type='text' disabled='disabled'/><label>" . __("MM", "gravityforms") . "</label></div>";
                 $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$dropdown_display}'><input name='ginput_day' type='text' disabled='disabled'/><label>" . __("DD", "gravityforms") . "</label></div>";
                 $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$dropdown_display}'><input type='text' name='ginput_year' disabled='disabled'/><label>" . __("YYYY", "gravityforms") . "</label></div>";
                 $field_string = "<div class='ginput_container' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' /><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
                 $field_string .= $field["dateFormat"] == "dmy" ? $day_field . $month_field . $year_field : $month_field . $day_field . $year_field;
                 return $field_string;
             } else {
                 $date_info = GFCommon::parse_date($value, $format);
                 if ($field["dateType"] == "datefield") {
                     if ($format == "mdy") {
                         $tabindex = self::get_tabindex();
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], $disabled_text, $field_id);
                         $tabindex = self::get_tabindex();
                         $field_str .= sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$tabindex} %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], $disabled_text, $field_id);
                     } else {
                         $tabindex = self::get_tabindex();
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$tabindex} %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], $disabled_text, $field_id);
                         $tabindex = self::get_tabindex();
                         $field_str .= sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], $disabled_text, $field_id);
                     }
                     $tabindex = self::get_tabindex();
                     $field_str .= sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s.3' value='%s' {$tabindex} %s/><label for='%s.3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, $date_info["year"], $disabled_text, $field_id);
                     return $field_str;
                 } else {
                     $value = GFCommon::date_display($value, $format);
                     $icon_class = $field["calendarIconType"] == "none" ? "datepicker_no_icon" : "datepicker_with_icon";
                     $icon_url = empty($field["calendarIconUrl"]) ? GFCommon::get_base_url() . "/images/calendar.png" : $field["calendarIconUrl"];
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='datepicker %s %s %s' {$tabindex} %s/> </div><input type='hidden' id='gforms_calendar_icon_{$field_id}' class='gform_hidden' value='{$icon_url}'/>", $id, $field_id, esc_attr($value), esc_attr($class), $format, $icon_class, $disabled_text);
                 }
             }
         case "time":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) (.*)$/', $value, $matches);
                 $hour = esc_attr($matches[1]);
                 $minute = esc_attr($matches[2]);
                 $am_selected = $matches[3] == "am" ? "selected='selected'" : "";
开发者ID:novuscory,项目名称:ACH,代码行数:67,代码来源:common.php

示例7: parse_field_date

 static function parse_field_date($field)
 {
     $date_value = rgpost("input_{$field['id']}");
     $date_format = empty($field['dateFormat']) ? 'mdy' : esc_attr($field['dateFormat']);
     $date_info = GFCommon::parse_date($date_value, $date_format);
     if (empty($date_info)) {
         return false;
     }
     return strtotime("{$date_info['year']}-{$date_info['month']}-{$date_info['day']}");
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:10,代码来源:yearsBetweenDates.php

示例8: validate


//.........这里部分代码省略.........
                             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;
                             }
                             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).", "gravityforms"), $format == "mdy" ? "mm/dd/yyyy" : "dd/mm/yyyy") : $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;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid time.", "gravityforms") : $field["errorMessage"];
                                 $is_valid = false;
                             }
                             break;
                         case "website":
                             if (empty($value) || $value == "http://") {
                                 $value = "";
                                 if ($field["isRequired"]) {
                                     $field["failed_validation"] = true;
开发者ID:hypenotic,项目名称:slowfood,代码行数:67,代码来源:form_display.php

示例9: pronamic_events_gform_parse_date

function pronamic_events_gform_parse_date($value, $format)
{
    $date_info = GFCommon::parse_date($value, $format);
    return $date_info;
}
开发者ID:joffcrabtree,项目名称:wp-pronamic-events,代码行数:5,代码来源:gravityforms.php

示例10: validate


//.........这里部分代码省略.........
                             $is_valid_number = self::validate_range($field, $value) && GFCommon::is_numeric($raw_value, $field["numberFormat"]);
                             if ($requires_valid_number && !$is_valid_number) {
                                 $field["failed_validation"] = true;
                                 $field["validation_message"] = empty($field["errorMessage"]) ? GFCommon::get_range_message($field) : $field["errorMessage"];
                             } else {
                                 if ($field['type'] == 'quantity') {
                                     if (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'];
                                     } else {
                                         if (!empty($value) && (!is_numeric($value) || intval($value) != floatval($value) || intval($value) < 0)) {
                                             $field['failed_validation'] = true;
                                             $field['validation_message'] = empty($field['errorMessage']) ? __('Please enter a valid quantity', 'gravityforms') : $field['errorMessage'];
                                         }
                                     }
                                 }
                             }
                             break;
                         case "phone":
                             $regex = '/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/';
                             if ($field["phoneFormat"] == "standard" && $value !== "" && $value !== 0 && !preg_match($regex, $value)) {
                                 $field["failed_validation"] = true;
                                 if (!empty($field["errorMessage"])) {
                                     $field["validation_message"] = $field["errorMessage"];
                                 }
                             }
                             break;
                         case "date":
                             if (is_array($value) && rgempty(0, $value) && rgempty(1, $value) && rgempty(2, $value)) {
                                 $value = null;
                             }
                             if (!empty($value)) {
                                 $format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
                                 $date = GFCommon::parse_date($value, $format);
                                 if (empty($date) || !GFFormDisplay::checkdate($date["month"], $date["day"], $date["year"])) {
                                     $field["failed_validation"] = true;
                                     $format_name = "";
                                     switch ($format) {
                                         case "mdy":
                                             $format_name = "mm/dd/yyyy";
                                             break;
                                         case "dmy":
                                             $format_name = "dd/mm/yyyy";
                                             break;
                                         case "dmy_dash":
                                             $format_name = "dd-mm-yyyy";
                                             break;
                                         case "dmy_dot":
                                             $format_name = "dd.mm.yyyy";
                                             break;
                                         case "ymd_slash":
                                             $format_name = "yyyy/mm/dd";
                                             break;
                                         case "ymd_dash":
                                             $format_name = "yyyy-mm-dd";
                                             break;
                                         case "ymd_dot":
                                             $format_name = "yyyy.mm.dd";
                                             break;
                                     }
                                     $message = $field["dateType"] == "datepicker" ? sprintf(__("Please enter a valid date in the format (%s).", "gravityforms"), $format_name) : __("Please enter a valid date.", "gravityforms");
                                     $field["validation_message"] = empty($field["errorMessage"]) ? $message : $field["errorMessage"];
                                 }
                             }
                             break;
                         case "time":
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:67,代码来源:entry-edit-logic.php

示例11: prepare_value

 private static function prepare_value($form_id, $field, $value, $input_name)
 {
     $input_type = self::get_input_type($field);
     switch ($input_type) {
         case "post_category":
             $cat = get_category($value);
             $value = $cat->name;
             break;
         case "phone":
             if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
                 $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
             }
             break;
         case "time":
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
                 $value = array();
                 $value[0] = $matches[1];
                 $value[1] = $matches[2];
                 $value[2] = $matches[3];
             }
             $hour = empty($value[0]) ? "0" : strip_tags($value[0]);
             $minute = empty($value[1]) ? "0" : strip_tags($value[1]);
             $ampm = strip_tags($value[2]);
             if (!(empty($hour) && empty($minute))) {
                 $value = sprintf("%02d:%02d %s", $hour, $minute, $ampm);
             } else {
                 $value = "";
             }
             break;
         case "date":
             $format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
             $date_info = GFCommon::parse_date($value, $format);
             if (!empty($date_info)) {
                 $value = sprintf("%d-%02d-%02d", $date_info["year"], $date_info["month"], $date_info["day"]);
             } else {
                 $value = "";
             }
             break;
         case "post_image":
             $url = self::get_fileupload_value($form_id, $input_name);
             $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : "";
             $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : "";
             $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : "";
             $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
             break;
         case "fileupload":
             $value = self::get_fileupload_value($form_id, $input_name);
             break;
         case "number":
             $value = GFCommon::clean_number($value);
             break;
         default:
             $value = stripslashes($value);
             //allow HTML for certain field types
             if (!in_array($field["type"], array("post_custom_field", "post_title", "post_content", "post_excerpt", "post_tags")) && !in_array($input_type, array("checkbox", "radio"))) {
                 $value = strip_tags($value);
             }
             //do not save price fields with blank price
             if ($field["enablePrice"]) {
                 list($label, $price) = explode("|", $value);
                 $is_empty = strlen(trim($price)) <= 0;
                 if ($is_empty) {
                     $value = "";
                 }
             }
             break;
     }
     return $value;
 }
开发者ID:novuscory,项目名称:ACH,代码行数:70,代码来源:forms_model.php

示例12: 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

示例13: get_field_input


//.........这里部分代码省略.........
             //address field
             $street_address = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_1_container'><input type='text' name='input_%d.1' id='%s_1' value='%s' tabindex='%d' %s/><label for='%s_1' id='" . $field_id . "_1_label'>" . apply_filters("gform_address_street", __("Street Address", "gravityforms"), $form_id) . "</label></span>", $id, $field_id, $street_value, self::$tab_index++, $disabled_text, $field_id);
             //address line 2 field
             $style = IS_ADMIN && $field["hideAddress2"] ? "style='display:none;'" : "";
             $street_address2 = IS_ADMIN || !$field["hideAddress2"] ? sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_2_container' {$style}><input type='text' name='input_%d.2' id='%s_2' value='%s' tabindex='%d' %s/><label for='%s_2' id='" . $field_id . "_2_label'>" . apply_filters("gform_address_street2", __("Address Line 2", "gravityforms"), $form_id) . "</label></span>", $id, $field_id, $street2_value, self::$tab_index++, $disabled_text, $field_id) : "";
             //city field
             $city = sprintf("<span class='ginput_left{$class_suffix}' id='" . $field_id . "_3_container'><input type='text' name='input_%d.3' id='%s_3' value='%s' tabindex='%d' %s/><label for='%s_3' id='{$field_id}.3_label'>" . apply_filters("gform_address_city", __("City", "gravityforms"), $form_id) . "</label></span>", $id, $field_id, $city_value, self::$tab_index++, $disabled_text, $field_id);
             //state field
             $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text);
             $state = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_4_container'>{$state_field}<label for='%s.4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state", $state_label, $form_id) . "</label></span>", $field_id);
             $zip = sprintf("<span class='ginput_left{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' tabindex='%d' %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip", $zip_label, $form_id) . "</label></span>", $id, $field_id, $zip_value, self::$tab_index++, $disabled_text, $field_id);
             if (IS_ADMIN || !$hide_country) {
                 $style = $hide_country ? "style='display:none;'" : "";
                 $country = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_6_container' {$style}><select name='input_%d.6' id='%s_6' tabindex='%d' %s>%s</select><label for='%s_6' id='" . $field_id . "_6_label'>" . apply_filters("gform_address_country", __("Country", "gravityforms"), $form_id) . "</label></span>", $id, $field_id, self::$tab_index++, $disabled_text, $country_list, $field_id);
             } else {
                 $country = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.6' id='%s_6' value='%s'/>", $id, $field_id, $country_value);
             }
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $street_address . $street_address2 . $city . $state . $zip . $country . "</div>";
         case "date":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $format = empty($field["dateFormat"]) ? "mdy" : esc_attr($field["dateFormat"]);
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $datepicker_display = $field["dateType"] == "datefield" ? "none" : "inline";
                 $dropdown_display = $field["dateType"] == "datefield" ? "inline" : "none";
                 $icon_display = $field["calendarIconType"] == "calendar" ? "inline" : "none";
                 $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$dropdown_display}'><input name='ginput_month' type='text' disabled='disabled'/><label>" . __("MM", "gravityforms") . "</label></div>";
                 $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$dropdown_display}'><input name='ginput_day' type='text' disabled='disabled'/><label>" . __("DD", "gravityforms") . "</label></div>";
                 $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$dropdown_display}'><input type='text' name='ginput_year' disabled='disabled'/><label>" . __("YYYY", "gravityforms") . "</label></div>";
                 $field_string = "<div class='ginput_container' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' /><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
                 $field_string .= $field["dateFormat"] == "dmy" ? $day_field . $month_field . $year_field : $month_field . $day_field . $year_field;
                 return $field_string;
             } else {
                 $date_info = GFCommon::parse_date($value, $format);
                 if ($field["dateType"] == "datefield") {
                     if ($format == "mdy") {
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' tabindex='%d' %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], self::$tab_index++, $disabled_text, $field_id);
                         $field_str .= sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' tabindex='%d' %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], self::$tab_index++, $disabled_text, $field_id);
                     } else {
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' tabindex='%d' %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], self::$tab_index++, $disabled_text, $field_id);
                         $field_str .= sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' tabindex='%d' %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], self::$tab_index++, $disabled_text, $field_id);
                     }
                     $field_str .= sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s.3' value='%s' tabindex='%d' %s/><label for='%s.3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, $date_info["year"], self::$tab_index++, $disabled_text, $field_id);
                     return $field_str;
                 } else {
                     $value = GFCommon::date_display($value, $format);
                     $icon_class = $field["calendarIconType"] == "none" ? "datepicker_no_icon" : "datepicker_with_icon";
                     $icon_url = empty($field["calendarIconUrl"]) ? GFCommon::get_base_url() . "/images/calendar.png" : $field["calendarIconUrl"];
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='datepicker %s %s %s' tabindex='%d' %s/>%s</div><input type='hidden' id='gforms_calendar_icon_{$field_id}' class='gform_hidden' value='{$icon_url}'/>", $id, $field_id, esc_attr($value), esc_attr($class), $format, $icon_class, self::$tab_index++, $disabled_text, $datepicker);
                 }
             }
         case "time":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) (.*)$/', $value, $matches);
                 $hour = esc_attr($matches[1]);
                 $minute = esc_attr($matches[2]);
                 $am_selected = $matches[3] == "am" ? "selected='selected'" : "";
                 $pm_selected = $matches[3] == "pm" ? "selected='selected'" : "";
             } else {
                 $hour = esc_attr($value[0]);
                 $minute = esc_attr($value[1]);
                 $am_selected = $value[2] == "am" ? "selected='selected'" : "";
                 $pm_selected = $value[2] == "pm" ? "selected='selected'" : "";
             }
             return sprintf("<div class='clear-multi'><div class='gfield_time_hour ginput_container' id='%s'><input type='text' name='input_%d[]' id='%s.1' value='%s' tabindex='%d' %s/> : <label for='%s.1'>" . __("HH", "gravityforms") . "</label></div><div class='gfield_time_minute'><input type='text' name='input_%d[]' id='%s.2' value='%s' tabindex='%d' %s/><label for='%s.2'>" . __("MM", "gravityforms") . "</label></div><div class='gfield_time_ampm'><select name='input_%d[]' id='%s.3' tabindex='%d' %s><option value='am' %s>" . __("AM", "gravityforms") . "</option><option value='pm' %s>" . __("PM", "gravityforms") . "</option></select></div></div>", $field_id, $id, $field_id, $hour, self::$tab_index++, $disabled_text, $field_id, $id, $field_id, $minute, self::$tab_index++, $disabled_text, $field_id, $id, $field_id, self::$tab_index++, $disabled_text, $am_selected, $pm_selected);
         case "fileupload":
             $upload = sprintf("<input name='input_%d' id='%s' type='file' value='%s' size='20' class='%s' tabindex='%d' %s/>", $id, $field_id, esc_attr($value), esc_attr($class), self::$tab_index++, $disabled_text);
             if (IS_ADMIN && !empty($value)) {
                 $value = esc_attr($value);
                 $preview = sprintf("<div id='preview_%d'><a href='%s' target='_blank' alt='%s' title='%s'>%s</a><a href='%s' target='_blank' alt='" . __("Download file", "gravityforms") . "' title='" . __("Download file", "gravityforms") . "'><img src='%s' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='" . __("Delete file", "gravityforms") . "' title='" . __("Delete file", "gravityforms") . "' onclick='DeleteFile(%d,%d);' ><img src='%s' style='margin-left:10px;'/></a></div>", $id, $value, $value, $value, GFCommon::truncate_url($value), $value, GFCommon::get_base_url() . "/images/download.png", $lead_id, $id, GFCommon::get_base_url() . "/images/delete.png");
                 return $preview . "<div id='upload_{$id}' style='display:none;'>{$upload}</div>";
             } else {
                 return "<div class='ginput_container'>{$upload}</div>";
             }
         case "captcha":
             if (!function_exists("recaptcha_get_html")) {
                 require_once GFCommon::get_base_path() . '/recaptchalib.php';
             }
             $theme = empty($field["captchaTheme"]) ? "red" : esc_attr($field["captchaTheme"]);
             $publickey = get_option("rg_gforms_captcha_public_key");
             $privatekey = get_option("rg_gforms_captcha_private_key");
             if (IS_ADMIN) {
                 if (empty($publickey) || empty($privatekey)) {
                     return "<div class='captcha_message'>" . __("To use the reCaptcha field you must first do the following:", "gravityforms") . "</div><div class='captcha_message'>1 - <a href='https://admin.recaptcha.net/recaptcha/createsite/?app=php' target='_blank'>" . __(sprintf("Sign up%s for a free reCAPTCHA account", "</a>"), "gravityforms") . "</div><div class='captcha_message'>2 - " . __(sprintf("Enter your reCAPTCHA keys in the %ssettings page%s", "<a href='?page=gf_settings'>", "</a>"), "gravityforms") . "</div>";
                 } else {
                     return "<div><img class='gfield_captcha' src='" . GFCommon::get_base_url() . "/images/captcha_{$theme}.jpg' alt='reCAPTCHA' title='reCAPTCHA'/></div>";
                 }
             } else {
                 $language = empty($field["captchaLanguage"]) ? "en" : esc_attr($field["captchaLanguage"]);
                 $options = "<script type='text/javascript'>var RecaptchaOptions = {theme : '{$theme}',tabindex : " . self::$tab_index++ . ", lang : '{$language}'};</script>";
                 $is_ssl = !empty($_SERVER['HTTPS']);
                 return $options . "<div class='ginput_container' id='{$field_id}'>" . recaptcha_get_html($publickey, null, $is_ssl) . "</div>";
             }
             break;
     }
 }
开发者ID:812studio,项目名称:812studio,代码行数:101,代码来源:common.php

示例14: prepare_value

 private static function prepare_value($form, $field, $value, $input_name, $lead_id)
 {
     $form_id = $form["id"];
     $input_type = self::get_input_type($field);
     switch ($input_type) {
         case "total":
             $lead = RGFormsModel::get_lead($lead_id);
             $value = GFCommon::get_order_total($form, $lead);
             break;
         case "post_category":
             $cat = get_category($value);
             $value = !empty($cat) ? $cat->name . ":" . $value : "";
             break;
         case "phone":
             if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
                 $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
             }
             break;
         case "time":
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
                 $value = array();
                 $value[0] = $matches[1];
                 $value[1] = $matches[2];
                 $value[2] = rgar($matches, 3);
             }
             $hour = empty($value[0]) ? "0" : strip_tags($value[0]);
             $minute = empty($value[1]) ? "0" : strip_tags($value[1]);
             $ampm = strip_tags(rgar($value, 2));
             if (!empty($ampm)) {
                 $ampm = " {$ampm}";
             }
             if (!(empty($hour) && empty($minute))) {
                 $value = sprintf("%02d:%02d%s", $hour, $minute, $ampm);
             } else {
                 $value = "";
             }
             break;
         case "date":
             $format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
             $date_info = GFCommon::parse_date($value, $format);
             if (!empty($date_info)) {
                 $value = sprintf("%d-%02d-%02d", $date_info["year"], $date_info["month"], $date_info["day"]);
             } else {
                 $value = "";
             }
             break;
         case "post_image":
             $url = self::get_fileupload_value($form_id, $input_name);
             $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : "";
             $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : "";
             $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : "";
             $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
             break;
         case "fileupload":
             $value = self::get_fileupload_value($form_id, $input_name);
             break;
         case "number":
             $value = GFCommon::clean_number($value, rgar($field, "numberFormat"));
             break;
         case "website":
             if ($value == "http://") {
                 $value = "";
             }
             break;
         case "list":
             if (GFCommon::is_empty_array($value)) {
                 $value = "";
             } else {
                 $value = self::create_list_array($field, $value);
                 $value = serialize($value);
             }
             break;
         case "radio":
             if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') {
                 $value = rgpost("input_{$field['id']}_other");
             }
             break;
         case "multiselect":
             $value = empty($value) ? "" : implode(",", $value);
             break;
         case "creditcard":
             //saving last 4 digits of credit card
             list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3);
             if ($input_id == "1") {
                 $value = str_replace(" ", "", $value);
                 $card_number_length = strlen($value);
                 $value = substr($value, -4, 4);
                 $value = str_pad($value, $card_number_length, "X", STR_PAD_LEFT);
             } else {
                 if ($input_id == "4") {
                     $card_number = rgpost("input_{$field_id_token}_1");
                     $card_type = GFCommon::get_card_type($card_number);
                     $value = $card_type ? $card_type["name"] : "";
                 } else {
                     $value = "";
                 }
             }
             break;
         default:
//.........这里部分代码省略.........
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:101,代码来源:forms_model.php

示例15: prepare_value

 private static function prepare_value($form_id, $field, $value, $input_name)
 {
     switch (self::get_input_type($field)) {
         case "post_category":
             $cat = get_category($value);
             $value = $cat->name;
             break;
         case "post_title":
         case "post_content":
         case "post_excerpt":
         case "post_tags":
         case "post_custom_fields":
         case "post_image":
             $value = stripslashes($value);
             break;
         case "phone":
             if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
                 $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
             }
             break;
         case "time":
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
                 $value = array();
                 $value[0] = $matches[1];
                 $value[1] = $matches[2];
                 $value[2] = $matches[3];
             }
             $hour = empty($value[0]) ? "0" : strip_tags($value[0]);
             $minute = empty($value[1]) ? "0" : strip_tags($value[1]);
             $ampm = strip_tags($value[2]);
             if (!(empty($hour) && empty($minute))) {
                 $value = sprintf("%02d:%02d %s", $hour, $minute, $ampm);
             } else {
                 $value = "";
             }
             break;
         case "date":
             $format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
             $date_info = GFCommon::parse_date($value, $format);
             if (!empty($date_info)) {
                 $value = sprintf("%d-%02d-%02d", $date_info["year"], $date_info["month"], $date_info["day"]);
             } else {
                 $value = "";
             }
             break;
         case "fileupload":
             $value = self::upload_file($form_id, $_FILES[$input_name]);
             break;
         case "number":
             $value = GFCommon::clean_number($value);
             break;
         default:
             $value = strip_tags(stripslashes($value));
             break;
     }
     return $value;
 }
开发者ID:812studio,项目名称:812studio,代码行数:58,代码来源:forms_model.php


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