* @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 '';
}
return $o;
}
-/*
-function parse_event($h) {
-
- require_once('include/Scrape.php');
- require_once('include/html2bbcode');
-
- $h = '<html><body>' . $h . '</body></html>';
-
- $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 = '';
$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];
}
$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'])
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;
}
*
* @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) {
*/
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;
}
* @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;
}
}
// The permission condition if no condition was transmitted
- if($sql_extra == '') {
+ if ($sql_extra == '') {
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' ";
}
'$export_csv' => t("Export calendar as csv"),
'$user' => $user
));
-
}