';
foreach ($fields as $field) {
$field_tree = explode(':', $field);
$value = self::getValue($event, $field_tree);
$field_tree = array_reverse($field_tree);
$output[] = apply_filters('squat_radar_field_html', $value, $value, $field_tree, $context);
}
$output[] = '';
return $output;
}
/**
* Date field formatting implementation of 'squat_radar_field_html' filter.
*/
static public function field_date_html($value, $original, $field, $context) {
switch ($field[0]) {
case 'created':
case 'updated':
$output = '';
if ($value) {
$output = date_i18n( get_option( 'date_format' ), $value );
$placeholder = ($field[0] == 'created') ? __('Created: %s', 'squat-radar') : __('Updated: %s', 'squat-radar');
$output = '';
$output .= self::field_date_format($value['time_start'], 'start');
if ($value['time_start'] != $value['time_end']) {
$output .= self::field_date_format($value['time_end'], 'end');
}
$output .= '';
return $output;
case 'time_start':
$output = '';
$output .= self::field_date_format($value, 'start');
$output .= '';
return $output;
case 'time_end':
$output = '';
$output .= self::field_date_format($value, 'start');
$output .= '';
return $output;
}
return $value;
}
private static function field_date_format($time, $start_end) {
$date_format = get_option('squat_radar_date_format', 'j M Y');
$time_format = get_option('squat_radar_time_format', 'H:i');
$output = '';
$output .= '';
$output .= date_i18n($date_format, strtotime($time));
$output .= ' ';
$output .= date_i18n($time_format, strtotime($time));
$output .= '';
return $output;
}
/**
* Location field implementation of 'squat_radar_field_html' filter.
*
* "offline": [
* {
* "uri": "https://radar.squat.net/api/1.2/location/b5786379-da49-4026-8c4e-bcc1a1563284",
* "id": "b5786379-da49-4026-8c4e-bcc1a1563284",
* "resource": "location",
* "title": "Yorck-Kino Yorckstr. 86 Berlin Deutschland",
* "map": {
* "geom": "POINT (13.3853499 52.4930248)",
* "geo_type": "point",
* "lat": "52.493024800000",
* "lon": "13.385349900000",
* "left": "13.385349900000",
* "top": "52.493024800000",
* "right": "13.385349900000",
* "bottom": "52.493024800000",
* "srid": null,
* "latlon": "52.493024800000,13.385349900000",
* "schemaorg_shape": ""
* }
* }
* ]
*/
function field_location_html($value, $original, $field, $context) {
switch ($field[0]) {
case 'map':
$output = [];
foreach ($value as $map) {
if ( is_array($value) && $value['lat'] !== NULL && $value['lon'] !== NULL ) {
$this_output = '';
$lat = $value['lat'];
$lon = $value['lon'];
$this_output .= "";
$this_output .= __('[Map]', 'squat-radar');
$this_output .= '';
$output[] = $this_output;
}
}
return implode(', ', $output);
case 'address':
$output = [];
foreach ($value as $address) {
if ( is_array($value) ) {
$this_address = [];
foreach (['name_line', 'thoroughfare', 'locality', 'postal_code', 'country'] as $field_name) {
if (! empty($value[$field_name])) {
$this_line = '';
$this_line .= sanitize_text_field($value[$field_name]);
$this_line .= '';
$this_address[] = $this_line;
}
}
$this_output = '';
$this_output .= implode(' ,', $this_address);
$this_output .= '';
$output[] = $this_output;
}
}
return implode('; ', $output);
}
return $value;
}
/**
* Item Radar links implementation of 'squat_radar_field_html' filter.
*/
function field_link_html($value, $original, $field, $context) {
if ($field[0] == 'title' && ! empty($context['event']['url'])) {
return '' . sanitize_text_field( $value ) . '';
}
if ($field[0] == 'url' && count($field) == 1) {
return '' . __('moreā¦', 'squat-radar') . '';
}
if ($field[0] == 'url') {
array_shift($field);
$field_tree = array_reverse($field);
$sibling_fields = self::getValue($event, $field_tree);
$title = esc_url($value);
$class = 'squat-radar-url-link';
if (! empty($sibling_fields['title']) ) {
$title = sanitize_text_field( $sibling_fields['title']);
$class = 'squat-radar-url-title';
}
elseif ( ! empty($sibling_fields['name']) ) {
$title = sanitize_text_field( $sibling_fields['name']);
$class = 'squat-radar-url-name';
}
return '' . $title . '';
}
if ($field[0] == 'link') {
return '' . esc_url($value['url']) . '';
}
return $value;
}
/**
* Format image implementation of 'squat_radar_field_html' filter.
*
* Deliberatly run after field_link_html. Showing how to override an existing filter.
* image:file:url
*/
function field_image_html($value, $original, $field, $context) {
if ($field[0] == 'url' && $field[1] == 'file' && $field[2] == 'image') {
return '';
}
return $value;
}
/**
* Basic implementation of 'squat_radar_field_html' filter.
*
* Put the output into HTML.
*
* @param array|string $value
* The field value being manipulated to become HTML to be displayed.
* @param array|string $original
* The original value of the field before any changes by filters.
* @param array $field
* The field tree. $field[0] being the name of the present field. $field[1]
* being any parent etc.
* @param array $context
*
* @return string
* Flattend array with additional default classes.
*/
function field_html($value, $original, $field, $context) {
if ($value != $original) {
return $value;
}
if (is_array($value)) {
if ( ! empty($value['value']) ) {
$value = $value['value'];
}
elseif ( ! empty($value['title']) ) {
$value = $value['title'];
}
elseif ( ! empty($value['name']) ) {
$value = $value['name'];
}
elseif ( ! empty($value[0]['value']) ) {
foreach ($value as $row) {
$values[] = $row['value'];
}
$value = $values;
}
elseif ( ! empty($value[0]['title']) ) {
foreach ($value as $row) {
$titles[] = $row['title'];
}
$value = $titles;
}
elseif ( ! empty($value[0]['name']) ) {
foreach ($value as $row) {
$names[] = $row['name'];
}
$value = $names;
}
}
if (is_array($value)) {
$output = '