From 231b70b987bb76a27cc8c4a36b128b4fef2178ce Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 19 Dec 2016 16:06:49 -0800 Subject: call zidify_links() when formatting bbcode for internal consumption --- include/event.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index cbee2b759..8fb060a40 100644 --- a/include/event.php +++ b/include/event.php @@ -25,7 +25,7 @@ function format_event_html($ev) { $o = '
' . "\r\n"; - $o .= '

 ' . bbcode($ev['summary']) . '

' . "\r\n"; + $o .= '

 ' . zidify_links(smilies(bbcode($ev['summary']))) . '

' . "\r\n"; $o .= '
' . t('Starts:') . ' ' . "\r\n"; + $o .= '
' . zidify_links(smilies(bbcode($ev['description']))) . '
' . "\r\n"; if(strlen($ev['location'])) $o .= '
' . t('Location:') . ' ' - . bbcode($ev['location']) + . zidify_links(smilies(bbcode($ev['location']))) . '
' . "\r\n"; $o .= '
' . "\r\n"; @@ -69,7 +69,7 @@ function format_event_obj($jobject) { $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']), + '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Starts:'), '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), @@ -80,9 +80,9 @@ function format_event_obj($jobject) { )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( - '$description' => bbcode($object['description']), + '$description' => zidify_links(smilies(bbcode($object['description']))), '$location_label' => t('Location:'), - '$location' => bbcode($object['location']) + '$location' => zidify_links(smilies(bbcode($object['location']))) )); } -- cgit v1.2.3 From dfede520481f94407ef3dd3b9d622cf6c6ab98f1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 5 Jan 2017 13:55:04 -0800 Subject: ical import/export - provide mechanism to preserve original source formatting across zot based systems. --- include/event.php | 65 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 13 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 8fb060a40..f3366fb69 100644 --- a/include/event.php +++ b/include/event.php @@ -127,12 +127,18 @@ function format_event_ical($ev) { $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); if($ev['dtend'] && ! $ev['nofinish']) $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); - if($ev['summary']) + if($ev['summary']) { $o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']); - if($ev['location']) + $o .= "\r\nX-ZOT-SUMMARY:" . format_ical_sourcetext($ev['summary']); + } + if($ev['location']) { $o .= "\r\nLOCATION:" . format_ical_text($ev['location']); - if($ev['description']) + $o .= "\r\nX-ZOT-LOCATION:" . format_ical_sourcetext($ev['location']); + } + if($ev['description']) { $o .= "\r\nDESCRIPTION:" . format_ical_text($ev['description']); + $o .= "\r\nX-ZOT-DESCRIPTION:" . format_ical_sourcetext($ev['description']); + } if($ev['event_priority']) $o .= "\r\nPRIORITY:" . intval($ev['event_priority']); $o .= "\r\nUID:" . $ev['event_hash'] ; @@ -154,8 +160,10 @@ function format_todo_ical($ev) { $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); if($ev['dtend'] && ! $ev['nofinish']) $o .= "\r\nDUE:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : '')); - if($ev['summary']) + if($ev['summary']) { $o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']); + $o .= "\r\nX-ZOT-SUMMARY:" . format_ical_sourcetext($ev['summary']); + } if($ev['event_status']) { $o .= "\r\nSTATUS:" . $ev['event_status']; if($ev['event_status'] === 'COMPLETED') @@ -165,10 +173,14 @@ function format_todo_ical($ev) { $o .= "\r\nPERCENT-COMPLETE:" . $ev['event_percent']; if(intval($ev['event_sequence'])) $o .= "\r\nSEQUENCE:" . $ev['event_sequence']; - if($ev['location']) + if($ev['location']) { $o .= "\r\nLOCATION:" . format_ical_text($ev['location']); - if($ev['description']) + $o .= "\r\nX-ZOT-LOCATION:" . format_ical_sourcetext($ev['location']); + } + if($ev['description']) { $o .= "\r\nDESCRIPTION:" . format_ical_text($ev['description']); + $o .= "\r\nX-ZOT-DESCRIPTION:" . format_ical_sourcetext($ev['description']); + } $o .= "\r\nUID:" . $ev['event_hash'] ; if($ev['event_priority']) $o .= "\r\nPRIORITY:" . intval($ev['event_priority']); @@ -178,7 +190,6 @@ function format_todo_ical($ev) { } - function format_ical_text($s) { require_once('include/bbcode.php'); require_once('include/html2plain.php'); @@ -186,6 +197,12 @@ function format_ical_text($s) { $s = html2plain(bbcode($s)); $s = str_replace(["\r\n","\n"],["",""],$s); return(wordwrap(str_replace(['\\',',',';'],['\\\\','\\,','\\;'],$s),72,"\r\n ",true)); + +} + +function format_ical_sourcetext($s) { + $s = base64_encode($s); + return(wordwrap(str_replace(['\\',',',';'],['\\\\','\\,','\\;'],$s),72,"\r\n ",true)); } @@ -623,12 +640,21 @@ function event_import_ical($ical, $uid) { $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C)); } - if(isset($ical->LOCATION)) + if(isset($ical->{'X-ZOT-LOCATION'})) + $ev['location'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-LOCATION'}); + elseif(isset($ical->LOCATION)) $ev['location'] = (string) $ical->LOCATION; - if(isset($ical->DESCRIPTION)) + + if(isset($ical->{'X-ZOT-DESCRIPTION'})) + $ev['description'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-DESCRIPTION'}); + elseif(isset($ical->DESCRIPTION)) $ev['description'] = (string) $ical->DESCRIPTION; - if(isset($ical->SUMMARY)) + + if(isset($ical->{'X-ZOT-SUMMARY'})) + $ev['summary'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-SUMMARY'}); + elseif(isset($ical->SUMMARY)) $ev['summary'] = (string) $ical->SUMMARY; + if(isset($ical->PRIORITY)) $ev['event_priority'] = intval((string) $ical->PRIORITY); @@ -663,6 +689,10 @@ function event_import_ical($ical, $uid) { } +function event_ical_get_sourcetext($s) { + return base64_decode($s); +} + function event_import_ical_task($ical, $uid) { $c = q("select * from channel where channel_id = %d limit 1", @@ -718,12 +748,21 @@ function event_import_ical_task($ical, $uid) { $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C)); } - if(isset($ical->LOCATION)) + if(isset($ical->{'X-ZOT-LOCATION'})) + $ev['location'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-LOCATION'}); + elseif(isset($ical->LOCATION)) $ev['location'] = (string) $ical->LOCATION; - if(isset($ical->DESCRIPTION)) + + if(isset($ical->{'X-ZOT-DESCRIPTION'})) + $ev['description'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-DESCRIPTION'}); + elseif(isset($ical->DESCRIPTION)) $ev['description'] = (string) $ical->DESCRIPTION; - if(isset($ical->SUMMARY)) + + if(isset($ical->{'X-ZOT-SUMMARY'})) + $ev['summary'] = event_ical_get_sourcetext( (string) $ical->{'X-ZOT-SUMMARY'}); + elseif(isset($ical->SUMMARY)) $ev['summary'] = (string) $ical->SUMMARY; + if(isset($ical->PRIORITY)) $ev['event_priority'] = intval((string) $ical->PRIORITY); -- cgit v1.2.3 From 7dfadfea4a637ce5566eb45f2d1adedf04bd04f3 Mon Sep 17 00:00:00 2001 From: Hubzilla Date: Wed, 18 Jan 2017 18:45:17 -0800 Subject: urlencode the message-id component of generated /display/ links; in most cases this will be a no-op, unless the message-id is a url of some kind from a different provider. --- include/event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index f3366fb69..85f14c5f9 100644 --- a/include/event.php +++ b/include/event.php @@ -1016,9 +1016,9 @@ function event_store_item($arr, $event) { // otherwise we'll fallback to /display/$message_id if($wall) - $item_arr['plink'] = z_root() . '/channel/' . $z[0]['channel_address'] . '/?f=&mid=' . $item_arr['mid']; + $item_arr['plink'] = z_root() . '/channel/' . $z[0]['channel_address'] . '/?f=&mid=' . urlencode($item_arr['mid']); else - $item_arr['plink'] = z_root() . '/display/' . $item_arr['mid']; + $item_arr['plink'] = z_root() . '/display/' . urlencode($item_arr['mid']); $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) -- cgit v1.2.3 From 96f196febda488e1db2d9a677fd5eb736aa76ae6 Mon Sep 17 00:00:00 2001 From: Hubzilla Date: Thu, 19 Jan 2017 15:37:30 -0800 Subject: add gen_link_id() function to selectively encode/decode the message-id component of /display/ links for message-ids that contain troublesome characters --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 85f14c5f9..cf1cc331d 100644 --- a/include/event.php +++ b/include/event.php @@ -1018,7 +1018,7 @@ function event_store_item($arr, $event) { if($wall) $item_arr['plink'] = z_root() . '/channel/' . $z[0]['channel_address'] . '/?f=&mid=' . urlencode($item_arr['mid']); else - $item_arr['plink'] = z_root() . '/display/' . urlencode($item_arr['mid']); + $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) -- cgit v1.2.3