function _agenda_parse_event in Agenda 6
Same name and namespace in other branches
- 6.2 agenda.module \_agenda_parse_event()
- 7.2 agenda.module \_agenda_parse_event()
- 7 agenda.module \_agenda_parse_event()
Read useful event information from XML chunk
@access private
Parameters
SimpleXMLElement $xml An event node from a gData feed:
object $block The settings object:
Return value
array Associative array of information about the event
2 calls to _agenda_parse_event()
- agenda_debug in ./
agenda.admin.php - Provide a page to debug a calendar ID that is not working
- agenda_get_events in ./
agenda.module - Given a list of calendar IDs, parse out and return any event data
File
- ./
agenda.module, line 335
Code
function _agenda_parse_event($xml, $block) {
$gd = $xml
->children('http://schemas.google.com/g/2005');
// Build up information about the event
$event = array();
$event['title'] = htmlspecialchars((string) $xml->title);
$event['where'] = htmlspecialchars((string) $gd->where
->attributes()->valueString);
$event['description'] = _filter_autop(filter_xss((string) $xml->content));
$event['start original'] = (string) $gd->when
->attributes()->startTime;
$event['start timestamp'] = strtotime($gd->when
->attributes()->startTime);
$event['start date'] = format_date($event['start timestamp'], $block->dateformat, $block->customdate);
$event['start time'] = format_date($event['start timestamp'], $block->dateformat, $block->timeformat);
$event['end original'] = (string) $gd->when
->attributes()->endTime;
$event['end timestamp'] = strtotime($gd->when
->attributes()->endTime);
$event['end date'] = format_date($event['end timestamp'], $block->dateformat, $block->customdate);
$event['end time'] = format_date($event['end timestamp'], $block->dateformat, $block->timeformat);
$event['published'] = format_date(strtotime($xml->published), $block->dateformat, $block->customdate);
$event['updated'] = format_date(strtotime($xml->updated), $block->dateformat, $block->customdate);
$link = (array) $xml->link[0];
$event['url'] = (string) $link['@attributes']['href'];
$event['link'] = l($block->linktext, $event['url']);
// The day the event occurs on (without time) for grouping
$event['when'] = format_date($event['start timestamp'], 'custom', 'Y-m-d');
// If the Date API is installed, we can do better at DST times
if (module_exists('date_api')) {
$start = date_make_date($event['start timestamp'], NULL, DATE_UNIX);
$event['start time'] = date_format_date($start, 'custom', $block->timeformat);
$end = date_make_date($event['end timestamp'], NULL, DATE_UNIX);
$event['end time'] = date_format_date($end, 'custom', $block->timeformat);
}
// Hide the start and end times for full day events
if (strlen($gd->when
->attributes()->startTime) === 10) {
$event['start time'] = '';
$event['end time'] = '';
}
// Hide end date if it's the same as the start date
if ($event['start timestamp'] === $event['end timestamp'] - 86400) {
$event['end date'] = '';
}
return $event;
}