From c7cbd41c16e36a6244ada6d4317dcd390e8dde0d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 26 Nov 2015 12:26:27 +0100 Subject: first iteration on the event item --- include/text.php | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index eb9171b40..f40d67f23 100644 --- a/include/text.php +++ b/include/text.php @@ -5,6 +5,7 @@ require_once("include/template_processor.php"); require_once("include/smarty.php"); +require_once("include/bbcode.php"); // random string, there are 86 characters max in text mode, 128 for hex // output is urlsafe @@ -1413,9 +1414,55 @@ 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'] = '

 ' . bbcode($object['title']) . '

' . "\r\n"; + + $event['header'] .= '
' . t('Starts:') . ' ' + . (($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))) + . '
' . "\r\n"; + + if(! $object['nofinish']) + $event['header'] .= '
' . t('Finishes:') . ' ' + . (($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 ))) + . '
' . "\r\n"; + + + $event['content'] = '
' . bbcode($object['description']) . '
' . "\r\n"; + + if(strlen($object['location'])) + $event['content'] .= '
' . t('Location:') . ' ' + . bbcode($object['location']) + . '
' . "\r\n"; + } + else { + $is_event = false; + } + } + $prep_arr = array( 'item' => $item, - 'html' => $s, + 'html' => $is_event ? $event['content'] : $s, + 'event' => $event['header'], 'photo' => $photo ); @@ -1423,6 +1470,7 @@ function prepare_body(&$item,$attach = false) { $s = $prep_arr['html']; $photo = $prep_arr['photo']; + $event = $prep_arr['event']; // q("update item set html = '%s' where id = %d", // dbesc($s), @@ -1489,6 +1537,7 @@ function prepare_body(&$item,$attach = false) { 'item' => $item, 'photo' => $photo, 'html' => $s, + 'event' => $event, 'categories' => $categories, 'folders' => $filer, 'tags' => $tags, -- cgit v1.2.3