diff options
author | Mario Vavti <mario@mariovavti.com> | 2015-11-26 22:14:20 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2015-11-26 22:14:20 +0100 |
commit | 056db37c662864954181fea9c1af48d69866340f (patch) | |
tree | b85749b9dbd1973e03035727729a26e999b95b48 | |
parent | 5cb71fa5da219e97a4c105c6025ff9b79553a38c (diff) | |
download | volse-hubzilla-056db37c662864954181fea9c1af48d69866340f.tar.gz volse-hubzilla-056db37c662864954181fea9c1af48d69866340f.tar.bz2 volse-hubzilla-056db37c662864954181fea9c1af48d69866340f.zip |
beautify event item code
-rw-r--r-- | include/text.php | 77 | ||||
-rw-r--r-- | view/tpl/event_item_content.tpl | 10 | ||||
-rwxr-xr-x | view/tpl/event_item_header.tpl | 11 |
3 files changed, 53 insertions, 45 deletions
diff --git a/include/text.php b/include/text.php index f40d67f23..4777e7a61 100644 --- a/include/text.php +++ b/include/text.php @@ -1381,7 +1381,37 @@ function generate_named_map($location) { return (($arr['html']) ? $arr['html'] : $location); } +function format_event($jobject) { + $event = array(); + + $object = json_decode($jobject,true); + + //ensure compatibility with older items - this check can be removed at a later point + if(array_key_exists('description', $object)) { + + $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM + + $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( + '$title' => bbcode($object['title']), + '$dtstart_label' => t('Starts:'), + '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['start'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['start'] , $bd_format))), + '$finish' => (($object['nofinish']) ? false : true), + '$dtend_label' => t('Finishes:'), + '$dtend_title' => datetime_convert('UTC','UTC',$object['finish'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['finish'] , $bd_format ))) + )); + $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( + '$description' => bbcode($object['description']), + '$location_label' => t('Location:'), + '$location' => bbcode($object['location']) + )); + + } + + return $event; +} function prepare_body(&$item,$attach = false) { require_once('include/identity.php'); @@ -1414,54 +1444,11 @@ function prepare_body(&$item,$attach = false) { } } - $event = array(); - $is_event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? true : false); - - if($is_event) { - $object = json_decode($item['object'],true); - - //ensure compatibility with older items - if(array_key_exists('description', $object)) { - - $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM - - $event['header'] = '<div class="event-title"><h3><i class="icon-calendar"></i> ' . bbcode($object['title']) . '</h3></div>' . "\r\n"; - - $event['header'] .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span> <span class="dtstart" title="' - . datetime_convert('UTC', 'UTC', $object['start'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) - . '" >' - . (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), - $object['start'] , $bd_format )) - : day_translate(datetime_convert('UTC', 'UTC', - $object['start'] , $bd_format))) - . '</span></div>' . "\r\n"; - - if(! $object['nofinish']) - $event['header'] .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span> <span class="dtend" title="' - . datetime_convert('UTC','UTC',$object['finish'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) - . '" >' - . (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), - $object['finish'] , $bd_format )) - : day_translate(datetime_convert('UTC', 'UTC', - $object['finish'] , $bd_format ))) - . '</span></div>' . "\r\n"; - - - $event['content'] = '<div class="event-description">' . bbcode($object['description']) . '</div>' . "\r\n"; - - if(strlen($object['location'])) - $event['content'] .= '<div class="event-location"><span class="event-label"> ' . t('Location:') . '</span> <span class="location">' - . bbcode($object['location']) - . '</span></div>' . "\r\n"; - } - else { - $is_event = false; - } - } + $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event($item['object']) : false); $prep_arr = array( 'item' => $item, - 'html' => $is_event ? $event['content'] : $s, + 'html' => $event ? $event['content'] : $s, 'event' => $event['header'], 'photo' => $photo ); diff --git a/view/tpl/event_item_content.tpl b/view/tpl/event_item_content.tpl new file mode 100644 index 000000000..868e5ad27 --- /dev/null +++ b/view/tpl/event_item_content.tpl @@ -0,0 +1,10 @@ +{{if $description}} +<div class="event-description"> + {{$description}} +</div> +{{/if}} +{{if $location}} +<div class="event-location"> + <span class="event-label">{{$location_label}}</span> <span class="event_location">{{$location}}</span> +</div> +{{/if}} diff --git a/view/tpl/event_item_header.tpl b/view/tpl/event_item_header.tpl new file mode 100755 index 000000000..de1899457 --- /dev/null +++ b/view/tpl/event_item_header.tpl @@ -0,0 +1,11 @@ +<div class="event-title"> + <h3>{{$title}}</h3> +</div> +<div class="event-start"> + <span class="event-label">{{$dtstart_label}}</span> <span class="dtstart" title="{{$dtstart_title}}">{{$dtstart_dt}}</span> +</div> +{{if $finish}} +<div class="event-start"> + <span class="event-label">{{$dtend_label}}</span> <span class="dtend" title="{{$dtend_title}}">{{$dtend_dt}}</span> +</div> +{{/if}} |