X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fevent.php;h=089fe705dbbe1b10a6ee68f7e22e01d00787e82c;hb=34815de99c548b61c94b6e6939edd485eca728d6;hp=82d5a1ec58b6fdf0d640920005144dee8e306331;hpb=8f7d191bfca553f9d928666e7ef3b52a26911a8e;p=friendica.git diff --git a/include/event.php b/include/event.php index 82d5a1ec58..089fe705db 100644 --- a/include/event.php +++ b/include/event.php @@ -4,13 +4,15 @@ * @brief functions specific to event handling */ +use Friendica\App; + require_once 'include/bbcode.php'; require_once 'include/map.php'; require_once 'include/datetime.php'; function format_event_html($ev, $simple = false) { - if(! ((is_array($ev)) && count($ev))) { + if (! ((is_array($ev)) && count($ev))) { return ''; } @@ -81,73 +83,6 @@ function format_event_html($ev, $simple = false) { return $o; } -/* -function parse_event($h) { - - require_once('include/Scrape.php'); - require_once('include/html2bbcode'); - - $h = '' . $h . ''; - - $ret = array(); - - - try { - $dom = HTML5_Parser::parse($h); - } catch (DOMException $e) { - logger('parse_event: parse error: ' . $e); - } - - if(! $dom) - return $ret; - - $items = $dom->getElementsByTagName('*'); - - foreach($items as $item) { - if(attribute_contains($item->getAttribute('class'), 'vevent')) { - $level2 = $item->getElementsByTagName('*'); - foreach($level2 as $x) { - if(attribute_contains($x->getAttribute('class'),'dtstart') && $x->getAttribute('title')) { - $ret['start'] = $x->getAttribute('title'); - if(! strpos($ret['start'],'Z')) - $ret['adjust'] = true; - } - if(attribute_contains($x->getAttribute('class'),'dtend') && $x->getAttribute('title')) - $ret['finish'] = $x->getAttribute('title'); - - if(attribute_contains($x->getAttribute('class'),'description')) - $ret['desc'] = $x->textContent; - if(attribute_contains($x->getAttribute('class'),'location')) - $ret['location'] = $x->textContent; - } - } - } - - // sanitise - - if((x($ret,'desc')) && ((strpos($ret['desc'],'<') !== false) || (strpos($ret['desc'],'>') !== false))) { - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.DefinitionImpl', null); - $purifier = new HTMLPurifier($config); - $ret['desc'] = html2bbcode($purifier->purify($ret['desc'])); - } - - if((x($ret,'location')) && ((strpos($ret['location'],'<') !== false) || (strpos($ret['location'],'>') !== false))) { - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.DefinitionImpl', null); - $purifier = new HTMLPurifier($config); - $ret['location'] = html2bbcode($purifier->purify($ret['location'])); - } - - if(x($ret,'start')) - $ret['start'] = datetime_convert('UTC','UTC',$ret['start']); - if(x($ret,'finish')) - $ret['finish'] = datetime_convert('UTC','UTC',$ret['finish']); - - return $ret; -} -*/ - function format_event_bbcode($ev) { $o = ''; @@ -195,32 +130,32 @@ function bbtoevent($s) { $ev = array(); $match = ''; - if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is",$s,$match)) { + if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $s, $match)) { $ev['summary'] = $match[1]; } $match = ''; - if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is",$s,$match)) { + if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is", $s, $match)) { $ev['desc'] = $match[1]; } $match = ''; - if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is",$s,$match)) { + if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is", $s, $match)) { $ev['start'] = $match[1]; } $match = ''; - if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is",$s,$match)) { + if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is", $s, $match)) { $ev['finish'] = $match[1]; } $match = ''; - if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match)) { + if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is", $s, $match)) { $ev['location'] = $match[1]; } $match = ''; - if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) { + if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is", $s, $match)) { $ev['adjust'] = $match[1]; } @@ -269,11 +204,11 @@ function event_store($arr) { $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); - $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid'])); - $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0); + $arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid'])); + $arr['private'] = ((x($arr, 'private')) ? intval($arr['private']) : 0); $arr['guid'] = get_guid(32); - if($arr['cid']) { + if ($arr['cid']) { $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($arr['cid']), intval($arr['uid']) @@ -463,7 +398,7 @@ function event_store($arr) { function get_event_strings() { // First day of the week (0 = Sunday) - $firstDay = get_pconfig(local_user(),'system', 'first_day_of_week'); + $firstDay = get_pconfig(local_user(), 'system', 'first_day_of_week'); if ($firstDay === false) { $firstDay = 0; } @@ -534,7 +469,7 @@ function get_event_strings() { * * @param array $dates Array of possibly duplicated events * @return array Cleaned events - * + * * @todo We should replace this with a separate update function if there is some time left */ function event_remove_duplicates($dates) { @@ -595,7 +530,7 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') { */ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') { // Only allow events if there is a valid owner_id - if($owner_uid == 0) { + if ($owner_uid == 0) { return; } @@ -699,7 +634,7 @@ function process_events($arr) { * @return string Content according to selected export format */ function event_format_export ($events, $format = 'ical', $timezone) { - if(! ((is_array($events)) && count($events))) { + if (! ((is_array($events)) && count($events))) { return; } @@ -812,7 +747,7 @@ function events_by_uid($uid = 0, $sql_extra = '') { } // The permission condition if no condition was transmitted - if($sql_extra == '') { + if ($sql_extra == '') { $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' "; } @@ -940,5 +875,4 @@ function widget_events() { '$export_csv' => t("Export calendar as csv"), '$user' => $user )); - }