aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/event.php50
-rw-r--r--include/widgets.php16
2 files changed, 60 insertions, 6 deletions
diff --git a/include/event.php b/include/event.php
index d95e8b401..a79770d23 100644
--- a/include/event.php
+++ b/include/event.php
@@ -45,6 +45,56 @@ function format_event_html($ev) {
return $o;
}
+
+
+function ical_wrapper($ev) {
+
+ if(! ((is_array($ev)) && count($ev)))
+ return '';
+
+ $o .= "BEGIN:VCALENDAR";
+ $o .= "\nVERSION:2.0";
+ $o .= "\nMETHOD:PUBLISH";
+ $o .= "\nPRODID:-//" . get_config('system','sitename') . "//" . RED_PLATFORM . "//" . strtoupper(get_app()->language). "\n";
+ if(array_key_exists('start',$ev))
+ $o .= format_event_ical($ev);
+ else {
+ foreach($ev as $e) {
+ $o .= format_event_ical($e);
+ }
+ }
+ $o .= "\nEND:VCALENDAR\n";
+
+ return $o;
+}
+
+function format_event_ical($ev) {
+
+ $o = '';
+
+ $o .= "\nBEGIN:VEVENT";
+ if($ev['start'])
+ $o .= "\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\This' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['finish'] && ! $ev['nofinish'])
+ $o .= "\nDTEND:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\This' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['summary'])
+ $o .= "\nSUMMARY:" . format_ical_text($ev['summary']);
+ if($ev['location'])
+ $o .= "\nLOCATION:" . format_ical_text($ev['location']);
+ if($ev['description'])
+ $o .= "\nDESCRIPTION:" . format_ical_text($ev['description']);
+ $o .= "\nEND:VEVENT\n";
+ return $o;
+}
+
+function format_ical_text($s) {
+
+ require_once('include/bbcode.php');
+ require_once('include/html2plain.php');
+ return(wordwrap(html2plain(bbcode($s)),72,"\n ",true));
+}
+
+
function format_event_bbcode($ev) {
$o = '';
diff --git a/include/widgets.php b/include/widgets.php
index a25139558..f7b8a20bd 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -659,9 +659,11 @@ function widget_bookmarkedchats($arr) {
$r = q("select * from xchat where xchat_xchan = '%s' group by xchat_url order by xchat_desc",
dbesc($h)
);
-
- for($x = 0; $x < count($r); $x ++)
- $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ }
+ }
return replace_macros(get_markup_template('bookmarkedchats.tpl'),array(
'$header' => t('Bookmarked Chatrooms'),
'$rooms' => $r
@@ -677,9 +679,11 @@ function widget_suggestedchats($arr) {
if(! $h)
return;
$r = q("select *, count(xchat_url) as total from xchat group by xchat_url order by total desc, xchat_desc limit 24");
-
- for($x = 0; $x < count($r); $x ++)
- $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ }
+ }
return replace_macros(get_markup_template('bookmarkedchats.tpl'),array(
'$header' => t('Suggested Chatrooms'),
'$rooms' => $r