/** * 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; }
/** * When showing a single column values, display the label of the column instead of the field * * @since 1.14 * * @param string $label Existing label string * @param array $field GV field settings array, with `id`, `show_label`, `label`, `custom_label`, etc. keys * @param array $form Gravity Forms form array * @param array $entry Gravity Forms entry array * * @return string Existing label if the field isn't */ public function _filter_field_label($label, $field, $form, $entry) { $field_object = RGFormsModel::get_field($form, $field['id']); // Not a list field if (!$field_object || 'list' !== $field_object->type) { return $label; } // Custom label is defined, so use it if (!empty($field['custom_label'])) { return $label; } $column_id = gravityview_get_input_id_from_id($field['id']); // Parent field, not column field if (false === $column_id) { return $label; } return self::get_column_label($field_object, $column_id, $label); }
<?php /** * Display the list field type * * @todo Confirm it works with http://gravitywiz.com/use-list-field-choices-gravity-forms/ * @package GravityView * @subpackage GravityView/templates/fields * @global GF_Field_List $field * @global string $field_id ID of the field * @global string $value Gravity Forms serializes the list field values * @global string $display_value Field output HTML. For list fields with columns, it's a table. Otherwise, an unordered list */ $gravityview_view = GravityView_View::getInstance(); extract($gravityview_view->getCurrentField()); $column_id = gravityview_get_input_id_from_id($field_id); if ($field->enableColumns && false !== $column_id) { /** * @filter `gravityview/fields/list/column-format` Format of single list column output of a List field with Multiple Columns enabled * @since 1.14 * @param string $format `html` (for <ul> list), `text` (for CSV output) */ $format = apply_filters('gravityview/fields/list/column-format', 'html'); echo GravityView_Field_List::column_value($field, $value, $column_id, $format); } else { echo $display_value; }
/** * Get the default date format for a field based on the field ID and the time format setting * * @since 1.14 * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14} * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} * * @return string PHP date format for the time */ public static function date_format($time_format = '12', $field_id = 0) { $field_input_id = gravityview_get_input_id_from_id($field_id); $default = 'h:i A'; // This doesn't take into account 24-hour switch ($field_input_id) { // Hours case 1: return $time_format === '12' ? 'h' : 'H'; break; // Minutes // Minutes case 2: return 'i'; break; // AM/PM // AM/PM case 3: return 'A'; break; // Full time field // Full time field case 0: return $time_format === '12' ? $default : 'H:i'; break; } return $default; }