'data-format' => $date_format, 'data-parent' => $id, ); if ( $required ) { $label = self::get_property( 'day_label', $field ); if ( ! empty( $label ) ) { $html .= sprintf( '', $day_data['id'], $this->sanitize_value( $label ), '*' ); } $html .= self::create_input( $day_data, false, '', $required, $design ); } else { $html .= self::create_input( $day_data, $this->sanitize_value( self::get_property( 'day_label', $field ) ), '', $required, $design ); } $html .= ''; $html .= ''; break; case 'mm': $month = $id . '-month'; $html .= '
'; $html .= '
'; $month_data = array( 'type' => 'number', 'min' => 1, 'max' => 12, 'name' => $id . '-month', 'value' => $month_value, 'placeholder' => $this->sanitize_value( self::get_property( 'month_placeholder', $field ) ), 'id' => 'forminator-field-' . $id . '-month', 'class' => 'forminator-input', 'data-field' => 'month', 'data-format' => $date_format, 'data-parent' => $id, ); if ( $required ) { $label = self::get_property( 'month_label', $field ); if ( ! empty( $label ) ) { $html .= sprintf( '', $month_data['id'], $this->sanitize_value( $label ), '*' ); } $html .= self::create_input( $month_data, false, '', $required, $design ); } else { $html .= self::create_input( $month_data, $this->sanitize_value( self::get_property( 'month_label', $field ) ), '', $required, $design ); } $html .= '
'; $html .= '
'; break; case 'yy': $year = $id . '-year'; $html .= '
'; $html .= '
'; $year_data = array( 'type' => 'number', 'min' => 1, 'name' => $id . '-year', 'placeholder' => $this->sanitize_value( self::get_property( 'year_placeholder', $field ) ), 'id' => 'forminator-field-' . $id . '-year', 'class' => 'forminator-input', 'data-field' => 'year', 'value' => $year_value, 'data-format' => $date_format, 'data-parent' => $id, ); if ( $required ) { $label = self::get_property( 'year_label', $field ); if ( ! empty( $label ) ) { $html .= sprintf( '', $year_data['id'], $this->sanitize_value( $label ), '*' ); } $html .= self::create_input( $year_data, false, '', $required, $design ); } else { $html .= self::create_input( $year_data, $this->sanitize_value( self::get_property( 'year_label', $field ) ), '', $required, $design ); } $html .= '
'; $html .= '
'; break; default: break; } } $html .= ''; // END: Row $html .= ''; $html .= self::get_description( $description, 'forminator-field-' . $id ); } if ( 'picker' === $type ) { $html .= ''; } return apply_filters( 'forminator_field_date_markup', $html, $field, $this ); } /** * Return modified date format * * @since 1.7.0.1 * * @param string $date_format * * @return string */ public function normalize_date_format( $date_format ) { $date_format = str_replace( 'dd', 'd', $date_format ); $date_format = str_replace( 'mm', 'm', $date_format ); $date_format = str_replace( 'yy', 'Y', $date_format ); return $date_format; } /** * Return all years between two dates * * @since 1.0 * * @param string $min_year * @param string $max_year * * @return array */ public function get_years( $min_year = '', $max_year = '' ) { $array = array(); $year = intval( date( 'Y' ) );// phpcs:ignore $end = empty( $min_year ) ? $year - 100 : intval( $min_year ) - 1; $start = empty( $max_year ) ? $year + 100 : intval( $max_year ); for ( $i = $start; $i > $end; $i -- ) { $array[] = array( 'label' => $i, 'value' => $i, ); } array_unshift( $array, [ 'label' => esc_html__( 'Select Year', 'forminator' ), 'value' => '', ]); return apply_filters( 'forminator_field_date_get_years', $array, $min_year, $max_year, $year, $start, $end, $this ); } /** * Return monts * * @since 1.0 * @return array */ public function get_months() { $array = array(); for ( $i = 1; $i < 13; $i ++ ) { $array[] = array( 'label' => $i, 'value' => $i, ); } array_unshift( $array, [ 'label' => esc_html__( 'Select month', 'forminator' ), 'value' => '', ]); return apply_filters( 'forminator_field_date_get_months', $array, $this ); } /** * Return days * * @since 1.0 * @return array */ public function get_day() { $array = array(); for ( $i = 1; $i < 32; $i ++ ) { $array[] = array( 'label' => $i, 'value' => $i, ); } array_unshift( $array, [ 'label' => esc_html__( 'Select day', 'forminator' ), 'value' => '', ]); return apply_filters( 'forminator_field_date_get_day', $array, $this ); } /** * Parse date * * @since 1.0 * * @param string|array $date - the date to be parsed * @param string $format - the data format * * @return array */ public static function parse_date( $date, $format = 'yy-mm-dd' ) { $date_info = array( 'year' => 0, 'month' => 0, 'day' => 0, ); $position = substr( $format, 0, 8 ); if ( is_array( $date ) ) { switch ( $position ) { case 'mm/dd/yy': case 'mm-dd-yy': case 'mm.dd.yy': $date_info['month'] = isset( $date['month'] ) ? $date['month'] : 0; $date_info['day'] = isset( $date['day'] ) ? $date['day'] : 0; $date_info['year'] = isset( $date['year'] ) ? $date['year'] : 0; break; case 'dd/mm/yy': case 'dd-mm-yy': case 'dd.mm.yy': $date_info['day'] = isset( $date['day'] ) ? $date['day'] : 0; $date_info['month'] = isset( $date['month'] ) ? $date['month'] : 0; $date_info['year'] = isset( $date['year'] ) ? $date['year'] : 0; break; case 'yy-mm-dd': case 'yy/mm/dd': case 'yy.mm.dd': $date_info['year'] = isset( $date['year'] ) ? $date['year'] : 0; $date_info['month'] = isset( $date['month'] ) ? $date['month'] : 0; $date_info['day'] = isset( $date['day'] ) ? $date['day'] : 0; break; default: break; } return apply_filters( 'forminator_field_date_parse_dates', $date_info, $date, $format ); } $date = preg_replace( '|[/\.]|', '-', $date ); if ( 'mm/dd/yy' === $position || 'mm-dd-yy' === $position || 'mm.dd.yy' === $position ) { if ( preg_match( '/^(\d{1,2})-(\d{1,2})-(\d{1,4})$/', $date, $matches ) ) { $date_info['month'] = $matches[1]; $date_info['day'] = $matches[2]; $date_info['year'] = $matches[3]; } } elseif ( 'dd/mm/yy' === $position || 'dd-mm-yy' === $position || 'dd.mm.yy' === $position ) { if ( preg_match( '/^(\d{1,2})-(\d{1,2})-(\d{1,4})$/', $date, $matches ) ) { $date_info['day'] = $matches[1]; $date_info['month'] = $matches[2]; $date_info['year'] = $matches[3]; } } elseif ( 'yy-mm-dd' === $position || 'yy/mm/dd' === $position || 'yy.mm.dd' === $position ) { if ( preg_match( '/^(\d{1,4})-(\d{1,2})-(\d{1,2})$/', $date, $matches ) ) { $date_info['year'] = $matches[1]; $date_info['month'] = $matches[2]; $date_info['day'] = $matches[3]; } } return apply_filters( 'forminator_field_date_parse_dates', $date_info, $date, $format ); } /** * Check data * * @since 1.0 * * @param int $month - the month * @param int $day - the day * @param int $year - the year * * @return bool */ public function check_date( $month, $day, $year ) { if ( empty( $month ) || ! is_numeric( $month ) || empty( $day ) || ! is_numeric( $day ) || empty( $year ) || ! is_numeric( $year ) || 4 !== strlen( $year ) ) { return false; } return checkdate( $month, $day, $year ); } /** * Return field inline validation rules * * @since 1.0 * @return string */ public function get_validation_rules() { $field = $this->field; $id = self::get_property( 'element_id', $field ); $type = trim( self::get_property( 'field_type', $field ) ); $date_format = self::get_property( 'date_format', $field ); $rules = ''; if ( 'picker' === $type ) { $rules .= '"' . $this->get_id( $field ) . '": {' . "\n"; if ( $this->is_required( $field ) ) { $rules .= '"required": true,'; } $rules .= '"dateformat": "' . $date_format . '",'; $rules .= '},' . "\n"; } else { if ( $this->is_required( $field ) ) { $rules .= '"' . $this->get_id( $field ) . '-day": "required",'; $rules .= '"' . $this->get_id( $field ) . '-month": "required",'; $rules .= '"' . $this->get_id( $field ) . '-year": "required",'; } } return apply_filters( 'forminator_field_date_validation_rules', $rules, $id, $field ); } /** * Return field inline validation errors * * @since 1.0 * @return string */ public function get_validation_messages() { $field = $this->field; $type = trim( self::get_property( 'field_type', $field ) ); $date_format = self::get_property( 'date_format', $field ); $required_validation_message = self::get_property( 'required_message', $field, '' ); $month_label = self::get_property( 'month_label', $field, '' ); $day_label = self::get_property( 'day_label', $field, '' ); $year_label = self::get_property( 'year_label', $field, '' ); if ( empty( $required_validation_message ) ) { $required_validation_message = __( 'This field is required.', 'forminator' ); } $messages = ''; if ( 'picker' === $type ) { $messages = '"' . $this->get_id( $field ) . '": {' . "\n"; if ( $this->is_required( $field ) ) { $required_validation_message = apply_filters( 'forminator_field_date_required_validation_message', $required_validation_message, $field, $type, $date_format, $this ); $messages .= '"required": "' . forminator_addcslashes( $required_validation_message ) . '",' . "\n"; } $format_validation_message = apply_filters( 'forminator_field_date_format_validation_message', __( 'Not valid date', 'forminator' ), $field, $type, $date_format, $this ); $messages .= '"dateformat": "' . forminator_addcslashes( $format_validation_message ) . '",' . "\n"; $messages .= '},' . "\n"; } else { if ( $this->is_required( $field ) ) { $day_validation_message = apply_filters( 'forminator_field_date_day_validation_message', $required_validation_message, $field, $type, $date_format, $this ); $messages = '"' . $this->get_id( $field ) . '-day": "' . $day_label . ': ' . forminator_addcslashes( $day_validation_message ) . '",' . "\n"; $month_validation_message = apply_filters( 'forminator_field_date_month_validation_message', $required_validation_message, $field, $type, $date_format, $this ); $messages .= '"' . $this->get_id( $field ) . '-month": "' . $month_label . ': ' . forminator_addcslashes( $month_validation_message ) . '",' . "\n"; $year_validation_message = apply_filters( 'forminator_field_date_year_validation_message', $required_validation_message, $field, $type, $date_format, $this ); $messages .= '"' . $this->get_id( $field ) . '-year": "' . $year_label . ': ' . forminator_addcslashes( $year_validation_message ) . '",' . "\n"; } } return apply_filters( 'forminator_field_date_validation_message', $messages, $field, $type, $date_format, $this ); } /** * Field back-end validation * * @since 1.0 * * @param array $field * @param array|string $data * @param array $post_data */ public function validate( $field, $data, $post_data = array() ) { $id = self::get_property( 'element_id', $field ); $start_date_type = self::get_property( 'start-date', $field, '' ); $end_date_type = self::get_property( 'end-date', $field, '' ); $date_type = self::get_property( 'field_type', $field, 'picker' ); $disabled_dates = self::get_property( 'disabled-dates', $field, array() ); $disabled_range = self::get_property( 'disable-date-range', $field, array() ); $restrict_type = self::get_property( 'howto-restrict', $field ); if ( $this->is_required( $field ) ) { $required_validation_message = self::get_property( 'required_message', $field, __( 'This field is required. Please enter a valid date.', 'forminator' ) ); if ( empty( $data ) ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_required_field_validation_message', $required_validation_message, $id, $data, $this ); return; } } if ( empty( $data ) ) { return; } // subfields `{"year":"","day":"","month":""}` if ( is_array( $data ) ) { $is_all_empty = true; foreach ( $data as $value ) { if ( ! empty( $value ) ) { $is_all_empty = false; break; } } if ( $is_all_empty ) { return; } } // Always! (we dont have validate flag on builder) validate date_format $date_format = self::get_property( 'date_format', $field ); $date = self::parse_date( $data, $date_format ); // strtotime does not recognize all of our date formats so we need to convert all dates to 1 accepted format before processing. if ( 'Y-m-d' !== datepicker_default_format( $date_format ) && ! is_array( $data ) ) { $format_date = date_create_from_format( datepicker_default_format( $date_format ), $data ); $data = date_format( $format_date, 'Y-m-d' ); } if ( empty( $date ) || ! $this->check_date( $date['month'], $date['day'], $date['year'] ) ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_date_validation_message', __( 'Please enter a valid date.', 'forminator' ), $id, $data, $date_format, $this ); } else { if ( 'select' === $date_type ) { $min_year = self::get_property( 'min_year', $field, date( 'Y' ) - 100 ); $max_year = self::get_property( 'max_year', $field, date( 'Y' ) + 100 ); $year = intval( $date['year'] ); if ( ! empty( $min_year ) && ! empty( $max_year ) ) { if ( $year < $min_year || $year > $max_year ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_maxmin_year_validation_message', __( 'Please select a valid year.', 'forminator' ) ); } } else { if ( ! empty( $min_year ) ) { if ( $year < $min_year ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_maxmin_year_validation_message', __( 'Please select a valid year.', 'forminator' ) ); } } if ( ! empty( $max_year ) ) { if ( $year > $max_year ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_maxmin_year_validation_message', __( 'Please select a valid year.', 'forminator' ) ); } } } } if ( 'picker' === $date_type ) { $selected_date = preg_replace( "/(\d+)\D+(\d+)\D+(\d+)/","$1/$2/$3", $data ); if ( 'week' === $restrict_type ) { $restrict = array(); $days = forminator_week_days(); foreach ( $days as $k => $day ) { if ( ! self::get_property( $k, $field ) ) { $restrict[] = $k; } } if ( ! empty( $restrict ) ) { $current_day = date( 'l', strtotime( $selected_date ) ); if ( in_array( strtolower( $current_day ), $restrict, true ) ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_between_date_validation_message', self::get_property( 'restrict_message', $field, __( 'Please select one of the available dates.', 'forminator' ) ) ); } } } if ( ! empty( $start_date_type ) ) { if ( 'specific' === $start_date_type ) { $start_date = self::get_property( 'start-specific-date', $field, '' ); } else { $start_offset_operator = self::get_property( 'start-offset-operator', $field, '+' ); $start_offset_value = self::get_property( 'start-offset-value', $field, '0' ); $start_offset_duration = self::get_property( 'start-offset-duration', $field, 'days' ); if ( 'today' === $start_date_type ) { $start_date = date_i18n( 'm/d/Y', strtotime( $start_offset_operator . $start_offset_value . ' ' . $start_offset_duration ) ); } else { $start_date_field = isset( $post_data[ $start_date_type ] ) ? $post_data[ $start_date_type ] : ''; $start_date = ! empty( $start_date_field ) ? date_i18n( 'm/d/Y', strtotime( $start_date_field . ' ' . $start_offset_operator . $start_offset_value . ' ' . $start_offset_duration ) ) : ''; } } if ( ! empty( $start_date ) && strtotime( $selected_date ) < strtotime( $start_date ) ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_between_date_validation_message', self::get_property( 'restrict_message', $field, __( 'Please select one of the available dates.', 'forminator' ) ) ); } } if ( ! empty( $end_date_type ) ) { if ( 'specific' === $end_date_type ) { $end_date = self::get_property( 'end-specific-date', $field, '' ); } else { $end_offset_operator = self::get_property( 'end-offset-operator', $field, '+' ); $end_offset_value = self::get_property( 'end-offset-value', $field, '0' ); $end_offset_duration = self::get_property( 'end-offset-duration', $field, 'days' ); if ( 'today' === $end_date_type ) { $end_date = date_i18n( 'm/d/Y', strtotime( $end_offset_operator . $end_offset_value . ' ' . $end_offset_duration ) ); } else { $end_date_field = isset( $post_data[ $end_date_type ] ) ? $post_data[ $end_date_type ] : ''; $end_date = date_i18n( 'm/d/Y', strtotime( $end_date_field . ' ' . $end_offset_operator . $end_offset_value . ' ' . $end_offset_duration ) ); } } if ( ! empty( $end_date ) && strtotime( $selected_date ) > strtotime( $end_date ) ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_between_date_validation_message', self::get_property( 'restrict_message', $field, __( 'Please select one of the available dates.', 'forminator' ) ) ); } } if ( ! empty( $disabled_dates ) && in_array( $selected_date, $disabled_dates, true ) ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_disabled_validation_message', self::get_property( 'restrict_message', $field, __( 'Please select one of the available dates.', 'forminator' ) ) ); } if ( ! empty( $disabled_range ) ) { $has_range = true; foreach ( $disabled_range as $range ) { $range_arr = array_map( 'trim', explode( '-', $range ) ); if ( ! empty( $range_arr ) ) { $start_date = isset( $range_arr[0] ) ? $range_arr[0] : ''; $end_date = isset( $range_arr[1] ) ? $range_arr[1] : ''; if ( strtotime( $selected_date ) >= strtotime( $start_date ) && strtotime( $selected_date ) <= strtotime( $end_date ) ) { $has_range = false; continue; } } } if ( ! $has_range ) { $this->validation_message[ $id ] = apply_filters( 'forminator_field_date_valid_disabled_validation_message', self::get_property( 'restrict_message', $field, __( 'Please select one of the available dates.', 'forminator' ) ) ); } } } } } /** * Sanitize data * * @since 1.0.2 * * @param array $field * @param array|string $data - the data to be sanitized * * @return array|string $data - the data after sanitization */ public function sanitize( $field, $data ) { $original_data = $data; // Sanitize $data = forminator_sanitize_field( $data ); return apply_filters( 'forminator_field_date_sanitize', $data, $field, $original_data ); } } Wairarapa Lizard Survey - Wairarapa Pūkaha to Kawakawa Alliance

Events Calendar

Loading Events

« All Events

  • This event has passed.

Wairarapa Lizard Survey

October 17, 2020 @ 10:00 am - 3:00 pm

Sustainable Wairarapa is looking for volunteers to help with lizard surveying at the Ponatahi Lizard Sanctuary on 17, 18, and 24 October.

Volunteers will help install tracking tunnels, traps, and onduline covers and will need a reasonable level of fitness.

For more information and to register, contact Ray Stewart of Sustainable Wairarapa Inc at ray@bagend.nz or phone 0272499245.

______________________________

Photo: “File:Oligosoma lineoocellatum (New Zealand spotted skink) at Zealandia Ecosanctuary in Wellington.jpg” by Kimberley Collins is licensed with CC BY-SA 4.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/4.0

Details

Date:
October 17, 2020
Time:
10:00 am - 3:00 pm

Organizer

Sustainable Wairarapa
Phone:
0272499245
Email:
ray@bagend.nz

Venue

Ponatahi, Wairarapa