GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes
GravityView_Field_Time Class Reference

Add custom options for date fields. More...

Inheritance diagram for GravityView_Field_Time:
GravityView_Field

Public Member Functions

 __construct ()
 GravityView_Field_Time constructor. More...
 
 _filter_date_display_date_format ()
 Modify the default PHP date formats used by the time field based on the field IDs and the field settings. More...
 
 _maybe_filter_gravity_forms_query ($criteria, $form_ids, $view_id)
 If the sorting key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL. More...
 
 _modify_query_sort_by_time_hack ($query)
 Modify Gravity Forms query SQL to convert times to numbers Gravity Forms couldn't sort by time...until NOW. More...
 
 field_options ($field_options, $template_id= '', $field_id= '', $context= '', $input_type= '')
 
 modify_sort_id ($sort_field_id, $form_id)
 Modify the sort key for the time field so it can be parsed by the query filter. More...
 
- Public Member Functions inherited from GravityView_Field
 __construct ()
 GravityView_Field constructor. More...
 
 _filter_gform_custom_merge_tags ($custom_merge_tags=array(), $form_id, $fields=array(), $element_id= '')
 Add custom merge tags to merge tag options. More...
 
 _filter_gform_replace_merge_tags ($text, $form=array(), $entry=array(), $url_encode=false, $esc_html=false)
 Match the merge tag in replacement text for the field. More...
 
 _filter_sortable_fields ($not_sortable)
 Use field settings to modify whether a field is sortable. More...
 
 add_entry_meta ($entry_meta)
 Add the custom entry meta key to make it searchable and sortable. More...
 
 add_field_support ($key= '', &$field_options)
 
 add_sortable_field ($fields)
 Add the field to the Filter & Sort available fields. More...
 
 field_options ($field_options, $template_id, $field_id, $context, $input_type)
 Tap in here to modify field options. More...
 
 replace_merge_tag ($matches=array(), $text= '', $form=array(), $entry=array(), $url_encode=false, $esc_html=false)
 Run GravityView filters when using GFCommon::replace_variables() More...
 
 set_default_search_label ($label= '', $gf_field=null, $field=array())
 Allow setting a default search label for search fields based on the field type. More...
 

Static Public Member Functions

static _get_time_format_for_field ($field_id, $form_id=0)
 Return the field's time format by fetching the form ID and checking the field settings. More...
 
static date_format ($time_format= '12', $field_id=0)
 Get the default date format for a field based on the field ID and the time format setting. More...
 

Data Fields

 $_gf_field_class_name = 'GF_Field_Time'
 
 $group = 'advanced'
 
 $is_numeric
 
 $name = 'time'
 
 $search_operators = array( 'is', 'isnot', 'greater_than', 'less_than' )
 
const GF_SORTING_SQL = 'SELECT 0 as query, lead_id as id, value'
 
- Data Fields inherited from GravityView_Field
 $_gf_field_class_name
 
 $contexts = array( 'single', 'multiple', 'edit', 'export' )
 
 $default_search_label
 
 $description
 
 $entry_meta_is_default_column = false
 
 $entry_meta_key = null
 
 $entry_meta_update_callback = null
 
 $group
 standard, advanced, post, pricing, meta, gravityview More...
 
 $is_numeric
 boolean Is field content number-based? More...
 
 $is_searchable = true
 
 $is_sortable = true
 boolean Can the field be sorted in search? More...
 
 $label
 
 $name
 
 $search_operators
 

Private Member Functions

 _get_time_format ()
 Return the field's time format by fetching the form ID and checking the field settings. More...
 

Private Attributes

 $_date_format = null
 
 $_sort_divider = '|:time:|'
 
 $_time_format = null
 

Additional Inherited Members

- Protected Member Functions inherited from GravityView_Field
 custom_merge_tags ($form=array(), $fields=array())
 Add custom Merge Tags to Merge Tag options, if custom Merge Tags exist. More...
 
 is_choice_value_enabled ()
 Check whether the enableChoiceValue flag is set for a GF field. More...
 
- Protected Attributes inherited from GravityView_Field
 $_custom_merge_tag = false
 
 $_field_id = ''
 
 $_field_options = array()
 

Detailed Description

Add custom options for date fields.

Definition at line 11 of file class-gravityview-field-time.php.

Constructor & Destructor Documentation

__construct ( )

GravityView_Field_Time constructor.

Definition at line 54 of file class-gravityview-field-time.php.

Member Function Documentation

_filter_date_display_date_format ( )

Modify the default PHP date formats used by the time field based on the field IDs and the field settings.

Since
1.14
Returns
string PHP date() format text to to display the correctly formatted time value for the newly created field

Definition at line 265 of file class-gravityview-field-time.php.

References GravityView_Field\$_field_id, $field_id, and _get_time_format().

_get_time_format ( )
private

Return the field's time format by fetching the form ID and checking the field settings.

Since
1.14
Returns
string Either "12" or "24". "12" is default.

Definition at line 221 of file class-gravityview-field-time.php.

References $current_form, $post, and gravityview_get_form_id().

Referenced by _filter_date_display_date_format().

static _get_time_format_for_field (   $field_id,
  $form_id = 0 
)
static

Return the field's time format by fetching the form ID and checking the field settings.

Since
1.14
Parameters
string$field_idID for Gravity Forms time field
int$form_idID for Gravity Forms form
Returns
string Either "12" or "24". "12" is default.

Definition at line 238 of file class-gravityview-field-time.php.

References $field, $field_id, $form, and $form_id.

_maybe_filter_gravity_forms_query (   $criteria,
  $form_ids,
  $view_id 
)

If the sorting key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL.

Since
1.14
See also
modify_sort_id()
Parameters
array$criteriaSearch criteria used by GravityView
array$form_idsForms to search
int$view_idID of the view being used to search
Returns
$criteria If a match, the sorting will be updated to set is_numeric to true and make sure the field ID is an int

And the sort key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL

See also
modify_sort_id()

Make sure sorting is numeric (# of seconds). IMPORTANT.

See also
GVCommon::is_field_numeric() is_numeric should also be set here

Definition at line 100 of file class-gravityview-field-time.php.

References $criteria.

_modify_query_sort_by_time_hack (   $query)

Modify Gravity Forms query SQL to convert times to numbers Gravity Forms couldn't sort by time...until NOW.

Since
1.14
Parameters
string$queryMySQL query
Returns
string Modified query, if the query matches the expected Gravity Forms SQL string used for sorting time fields. Otherwise, original query.

If this is a Gravity Forms entry selection sorting query, generated by sort_by_field_query(), then we want to modify the query.

See also
GFFormsModel::sort_by_field_query()

Convert the time (12:30 pm) to the MySQL TIME_TO_SEC() value for that time (45000) This way, Gravity Forms is able to sort numerically.

Replace it in the main query

REMOVE the Gravity Forms WP Query modifications!

Definition at line 143 of file class-gravityview-field-time.php.

static date_format (   $time_format = '12',
  $field_id = 0 
)
static

Get the default date format for a field based on the field ID and the time format setting.

Since
1.14
Parameters
string$time_formatThe time format ("12" or "24"). Default: "12" {
Since
1.14}
Parameters
int$field_idThe ID of the field. Used to figure out full time/hours/minutes/am/pm {
Since
1.14}
Returns
string PHP date format for the time

Definition at line 283 of file class-gravityview-field-time.php.

References $field_id, and gravityview_get_input_id_from_id().

field_options (   $field_options,
  $template_id = '',
  $field_id = '',
  $context = '',
  $input_type = '' 
)

Set default date format based on field ID and Form ID

Definition at line 193 of file class-gravityview-field-time.php.

References $field_id, and GravityView_Field\add_field_support().

modify_sort_id (   $sort_field_id,
  $form_id 
)

Modify the sort key for the time field so it can be parsed by the query filter.

See also
_modify_query_sort_by_time_hack
Since
1.14
Parameters
string$sort_field_idExisting sort field ID (like "5")
int$form_idGravity Forms Form ID being sorted
Returns
string Modified sort key imploded with $_sort_divider, like 5|:time:|12|:time:|h:i A

Definition at line 76 of file class-gravityview-field-time.php.

References $form_id.

Field Documentation

$_date_format = null
private

Definition at line 49 of file class-gravityview-field-time.php.

$_gf_field_class_name = 'GF_Field_Time'

Definition at line 17 of file class-gravityview-field-time.php.

$_sort_divider = '|:time:|'
private

Definition at line 37 of file class-gravityview-field-time.php.

$_time_format = null
private

Definition at line 43 of file class-gravityview-field-time.php.

$group = 'advanced'

Definition at line 19 of file class-gravityview-field-time.php.

$is_numeric

Definition at line 25 of file class-gravityview-field-time.php.

$name = 'time'

Definition at line 13 of file class-gravityview-field-time.php.

$search_operators = array( 'is', 'isnot', 'greater_than', 'less_than' )

Definition at line 15 of file class-gravityview-field-time.php.

const GF_SORTING_SQL = 'SELECT 0 as query, lead_id as id, value'

Definition at line 31 of file class-gravityview-field-time.php.


The documentation for this class was generated from the following file: