public function ParserVcalendar::parseTextProperty in Date iCal 7.3
Handler that parses text fields.
Return value
string The parsed text property.
File
- libraries/
ParserVcalendar.inc, line 216 - Defines a class that parses iCalcreator vcalendar objects into Feeds-compatible data arrays.
Class
- ParserVcalendar
- @file Defines a class that parses iCalcreator vcalendar objects into Feeds-compatible data arrays.
Code
public function parseTextProperty($property_key, $vcalendar_component) {
$text = $vcalendar_component
->getProperty($property_key);
// In case someone writes a hook that adds a source for a multi-entry
// property and a parameter of that same property, we need to force
// iCalcreator to assume it has not accessed that property, yet.
// TODO: This is really just a hack. If/when multi-entry properties
// become supported, this will need to be redesigned.
if (in_array($property_key, $this->multi_entry_properties)) {
unset($vcalendar_component->propix[$property_key]);
}
if (is_array($text) && isset($vcalendar_component->xprop[$property_key])) {
# This is an X-PROPERTY, which iCalcreator returns as an array like array('X-PROP-NAME', value).
# We only care about the value, though.
$text = $text[1];
}
if ($text === FALSE) {
if ($property_key != 'SUMMARY') {
return NULL;
}
else {
$uid = $vcalendar_component
->getProperty('UID');
if ($vcalendar_component->objName == 'vfreebusy') {
// FREEBUSY elements can't have SUMMARY, but they can have COMMENT.
// So if the feed has been configured to ask for SUMMARY, use COMMENT
// instead. If COMMENT is also missing, we can't import.
$text = $vcalendar_component
->getProperty('COMMENT');
if ($text === FALSE) {
throw new DateIcalParseException(t('The VFREEBUSY component with UID %uid is invalid because it has no COMMENT.
Nodes require a title, and since VFREEBUSY components can\'t have SUMMARY, Date iCal pulls that title from the COMMENT.', array(
'%uid' => $uid,
)));
}
}
else {
// Non-VFREEBUSY components must have a SUMMARY.
throw new DateIcalParseException(t('The component with UID %uid is invalid because it has no SUMMARY (nodes require a title).', array(
'%uid' => $uid,
)));
}
}
}
// Convert literal \n and \N into newline characters.
$text = str_replace(array(
'\\n',
'\\N',
), "\n", $text);
return $text;
}