/** * get component property value/params * * if property has multiply values, consequtive function calls are needed * * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**> * @since 2.12.4 - 2012-04-22 * @param string $propName, optional * @param int @propix, optional, if specific property is wanted in case of multiply occurences * @param bool $inclParam=FALSE * @param bool $specform=FALSE * @return mixed */ function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE, $specform = FALSE) { if ('GEOLOCATION' == strtoupper($propName)) { $content = $this->getProperty('LOCATION'); $content = !empty($content) ? $content . ' ' : ''; if (FALSE === ($geo = $this->getProperty('GEO')) || empty($geo)) { return FALSE; } if (0.0 < $geo['latitude']) { $sign = '+'; } else { $sign = 0.0 > $geo['latitude'] ? '-' : ''; } $content .= $sign . sprintf("%09.6f", abs($geo['latitude'])); // sprintf && lpad && float && sign !"#¤%&/( $content = rtrim(rtrim($content, '0'), '.'); if (0.0 < $geo['longitude']) { $sign = '+'; } else { $sign = 0.0 > $geo['longitude'] ? '-' : ''; } return $content . $sign . sprintf('%8.6f', abs($geo['longitude'])) . '/'; // sprintf && lpad && float && sign !"#¤%&/( } if ($this->_notExistProp($propName)) { return FALSE; } $propName = $propName ? strtoupper($propName) : 'X-PROP'; if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { if (!$propix) { $propix = isset($this->propix[$propName]) ? $this->propix[$propName] + 2 : 1; } $this->propix[$propName] = --$propix; } switch ($propName) { case 'ACTION': if (!empty($this->action['value'])) { return $inclParam ? $this->action : $this->action['value']; } break; case 'ATTACH': $ak = is_array($this->attach) ? array_keys($this->attach) : array(); while (is_array($this->attach) && !isset($this->attach[$propix]) && 0 < count($this->attach) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->attach[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->attach[$propix] : $this->attach[$propix]['value']; break; case 'ATTENDEE': $ak = is_array($this->attendee) ? array_keys($this->attendee) : array(); while (is_array($this->attendee) && !isset($this->attendee[$propix]) && 0 < count($this->attendee) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->attendee[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->attendee[$propix] : $this->attendee[$propix]['value']; break; case 'CATEGORIES': $ak = is_array($this->categories) ? array_keys($this->categories) : array(); while (is_array($this->categories) && !isset($this->categories[$propix]) && 0 < count($this->categories) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->categories[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->categories[$propix] : $this->categories[$propix]['value']; break; case 'CLASS': if (!empty($this->class['value'])) { return $inclParam ? $this->class : $this->class['value']; } break; case 'COMMENT': $ak = is_array($this->comment) ? array_keys($this->comment) : array(); while (is_array($this->comment) && !isset($this->comment[$propix]) && 0 < count($this->comment) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->comment[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->comment[$propix] : $this->comment[$propix]['value']; break; case 'COMPLETED': if (!empty($this->completed['value'])) { return $inclParam ? $this->completed : $this->completed['value']; } break; case 'CONTACT': $ak = is_array($this->contact) ? array_keys($this->contact) : array(); while (is_array($this->contact) && !isset($this->contact[$propix]) && 0 < count($this->contact) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->contact[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->contact[$propix] : $this->contact[$propix]['value']; break; case 'CREATED': if (!empty($this->created['value'])) { return $inclParam ? $this->created : $this->created['value']; } break; case 'DESCRIPTION': $ak = is_array($this->description) ? array_keys($this->description) : array(); while (is_array($this->description) && !isset($this->description[$propix]) && 0 < count($this->description) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->description[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->description[$propix] : $this->description[$propix]['value']; break; case 'DTEND': if (!empty($this->dtend['value'])) { return $inclParam ? $this->dtend : $this->dtend['value']; } break; case 'DTSTAMP': if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { return; } if (!isset($this->dtstamp['value'])) { $this->_makeDtstamp(); } return $inclParam ? $this->dtstamp : $this->dtstamp['value']; break; case 'DTSTART': if (!empty($this->dtstart['value'])) { return $inclParam ? $this->dtstart : $this->dtstart['value']; } break; case 'DUE': if (!empty($this->due['value'])) { return $inclParam ? $this->due : $this->due['value']; } break; case 'DURATION': if (!isset($this->duration['value'])) { return FALSE; } $value = $specform && isset($this->dtstart['value']) && isset($this->duration['value']) ? iCalUtilityFunctions::_duration2date($this->dtstart['value'], $this->duration['value']) : $this->duration['value']; return $inclParam ? array('value' => $value, 'params' => $this->duration['params']) : $value; break; case 'EXDATE': $ak = is_array($this->exdate) ? array_keys($this->exdate) : array(); while (is_array($this->exdate) && !isset($this->exdate[$propix]) && 0 < count($this->exdate) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->exdate[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->exdate[$propix] : $this->exdate[$propix]['value']; break; case 'EXRULE': $ak = is_array($this->exrule) ? array_keys($this->exrule) : array(); while (is_array($this->exrule) && !isset($this->exrule[$propix]) && 0 < count($this->exrule) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->exrule[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->exrule[$propix] : $this->exrule[$propix]['value']; break; case 'FREEBUSY': $ak = is_array($this->freebusy) ? array_keys($this->freebusy) : array(); while (is_array($this->freebusy) && !isset($this->freebusy[$propix]) && 0 < count($this->freebusy) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->freebusy[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; break; case 'GEO': if (!empty($this->geo['value'])) { return $inclParam ? $this->geo : $this->geo['value']; } break; case 'LAST-MODIFIED': if (!empty($this->lastmodified['value'])) { return $inclParam ? $this->lastmodified : $this->lastmodified['value']; } break; case 'LOCATION': if (!empty($this->location['value'])) { return $inclParam ? $this->location : $this->location['value']; } break; case 'ORGANIZER': if (!empty($this->organizer['value'])) { return $inclParam ? $this->organizer : $this->organizer['value']; } break; case 'PERCENT-COMPLETE': if (!empty($this->percentcomplete['value']) || isset($this->percentcomplete['value']) && '0' == $this->percentcomplete['value']) { return $inclParam ? $this->percentcomplete : $this->percentcomplete['value']; } break; case 'PRIORITY': if (!empty($this->priority['value']) || isset($this->priority['value']) && '0' == $this->priority['value']) { return $inclParam ? $this->priority : $this->priority['value']; } break; case 'RDATE': $ak = is_array($this->rdate) ? array_keys($this->rdate) : array(); while (is_array($this->rdate) && !isset($this->rdate[$propix]) && 0 < count($this->rdate) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->rdate[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->rdate[$propix] : $this->rdate[$propix]['value']; break; case 'RECURRENCE-ID': if (!empty($this->recurrenceid['value'])) { return $inclParam ? $this->recurrenceid : $this->recurrenceid['value']; } break; case 'RELATED-TO': $ak = is_array($this->relatedto) ? array_keys($this->relatedto) : array(); while (is_array($this->relatedto) && !isset($this->relatedto[$propix]) && 0 < count($this->relatedto) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->relatedto[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; break; case 'REPEAT': if (!empty($this->repeat['value']) || isset($this->repeat['value']) && '0' == $this->repeat['value']) { return $inclParam ? $this->repeat : $this->repeat['value']; } break; case 'REQUEST-STATUS': $ak = is_array($this->requeststatus) ? array_keys($this->requeststatus) : array(); while (is_array($this->requeststatus) && !isset($this->requeststatus[$propix]) && 0 < count($this->requeststatus) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->requeststatus[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; break; case 'RESOURCES': $ak = is_array($this->resources) ? array_keys($this->resources) : array(); while (is_array($this->resources) && !isset($this->resources[$propix]) && 0 < count($this->resources) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->resources[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->resources[$propix] : $this->resources[$propix]['value']; break; case 'RRULE': $ak = is_array($this->rrule) ? array_keys($this->rrule) : array(); while (is_array($this->rrule) && !isset($this->rrule[$propix]) && 0 < count($this->rrule) && $propix < end($ak)) { ++$propix; } $this->propix[$propName] = $propix; if (!isset($this->rrule[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->rrule[$propix] : $this->rrule[$propix]['value']; break; case 'SEQUENCE': if (isset($this->sequence['value']) && (isset($this->sequence['value']) && '0' <= $this->sequence['value'])) { return $inclParam ? $this->sequence : $this->sequence['value']; } break; case 'STATUS': if (!empty($this->status['value'])) { return $inclParam ? $this->status : $this->status['value']; } break; case 'SUMMARY': if (!empty($this->summary['value'])) { return $inclParam ? $this->summary : $this->summary['value']; } break; case 'TRANSP': if (!empty($this->transp['value'])) { return $inclParam ? $this->transp : $this->transp['value']; } break; case 'TRIGGER': if (!empty($this->trigger['value'])) { return $inclParam ? $this->trigger : $this->trigger['value']; } break; case 'TZID': if (!empty($this->tzid['value'])) { return $inclParam ? $this->tzid : $this->tzid['value']; } break; case 'TZNAME': $ak = is_array($this->tzname) ? array_keys($this->tzname) : array(); while (is_array($this->tzname) && !isset($this->tzname[$propix]) && 0 < count($this->tzname) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->tzname[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->tzname[$propix] : $this->tzname[$propix]['value']; break; case 'TZOFFSETFROM': if (!empty($this->tzoffsetfrom['value'])) { return $inclParam ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; } break; case 'TZOFFSETTO': if (!empty($this->tzoffsetto['value'])) { return $inclParam ? $this->tzoffsetto : $this->tzoffsetto['value']; } break; case 'TZURL': if (!empty($this->tzurl['value'])) { return $inclParam ? $this->tzurl : $this->tzurl['value']; } break; case 'UID': if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { return FALSE; } if (empty($this->uid['value'])) { $this->_makeuid(); } return $inclParam ? $this->uid : $this->uid['value']; break; case 'URL': if (!empty($this->url['value'])) { return $inclParam ? $this->url : $this->url['value']; } break; default: if ($propName != 'X-PROP') { if (!isset($this->xprop[$propName])) { return FALSE; } return $inclParam ? array($propName, $this->xprop[$propName]) : array($propName, $this->xprop[$propName]['value']); } else { if (empty($this->xprop)) { return FALSE; } $xpropno = 0; foreach ($this->xprop as $xpropkey => $xpropvalue) { if ($propix == $xpropno) { return $inclParam ? array($xpropkey, $this->xprop[$xpropkey]) : array($xpropkey, $this->xprop[$xpropkey]['value']); } else { $xpropno++; } } return FALSE; // not found ?? } } return FALSE; }
/** * get component property value/params * * if property has multiply values, consequtive function calls are needed * * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**> * @since 2.21.13 - 2015-03-29 * @param string $propName * @param int $propix specific property in case of multiply occurences * @param bool $inclParam * @param bool $specform * @uses calendarComponent::getProperty() * @uses iCalUtilityFunctions::_geo2str2() * @uses iCalUtilityFunctions::$geoLatFmt * @uses iCalUtilityFunctions::$geoLongFmt * @uses calendarComponent::_notExistProp() * @uses iCalUtilityFunctions::$mProps2 * @uses calendarComponent::$propix * @uses calendarComponent::$action * @uses calendarComponent::$attendee * @uses calendarComponent::$categories * @uses calendarComponent::$class * @uses calendarComponent::$comment * @uses calendarComponent::$completed * @uses calendarComponent::$contact * @uses calendarComponent::$created * @uses calendarComponent::$description * @uses calendarComponent::$dtend * @uses iCalUtilityFunctions::$miscComps * @uses calendarComponent::$dtstamp * @uses calendarComponent::_makeDtstamp() * @uses calendarComponent::$dtstart * @uses calendarComponent::$due * @uses calendarComponent::$duration * @uses iCalUtilityFunctions::_duration2date() * @uses calendarComponent::$exdate * @uses calendarComponent::$exrule * @uses calendarComponent::$freebusy * @uses calendarComponent::$geo * @uses calendarComponent::$lastmodified * @uses calendarComponent::$location * @uses calendarComponent::$organizer * @uses calendarComponent::$percentcomplete * @uses calendarComponent::$priority * @uses calendarComponent::$rdate * @uses calendarComponent::$recurrenceid * @uses calendarComponent::$relatedto * @uses calendarComponent::$repeat * @uses calendarComponent::$requeststatus * @uses calendarComponent::$resources * @uses calendarComponent::$rrule * @uses calendarComponent::$sequence * @uses calendarComponent::$status * @uses calendarComponent::$summary * @uses calendarComponent::$transp * @uses calendarComponent::$trigger * @uses calendarComponent::$tzid * @uses calendarComponent::$tzname * @uses calendarComponent::$tzoffsetfrom * @uses calendarComponent::$tzoffsetto * @uses calendarComponent::$tzurl * @uses calendarComponent::$uid * @uses calendarComponent::$objName * @uses calendarComponent::_makeuid() * @uses calendarComponent::$url * @uses calendarComponent::$xprop * @return mixed */ function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE, $specform = FALSE) { if ('GEOLOCATION' == strtoupper($propName)) { $content = FALSE === ($loc = $this->getProperty('LOCATION')) ? '' : $loc . ' '; if (FALSE === ($geo = $this->getProperty('GEO'))) { return FALSE; } return $content . iCalUtilityFunctions::_geo2str2($geo['latitude'], iCalUtilityFunctions::$geoLatFmt) . iCalUtilityFunctions::_geo2str2($geo['longitude'], iCalUtilityFunctions::$geoLongFmt) . '/'; } if ($this->_notExistProp($propName)) { return FALSE; } $propName = $propName ? strtoupper($propName) : 'X-PROP'; if (in_array($propName, iCalUtilityFunctions::$mProps2)) { if (empty($propix)) { $propix = isset($this->propix[$propName]) ? $this->propix[$propName] + 2 : 1; } $this->propix[$propName] = --$propix; } switch ($propName) { case 'ACTION': if (isset($this->action['value'])) { return $inclParam ? $this->action : $this->action['value']; } break; case 'ATTACH': $ak = is_array($this->attach) ? array_keys($this->attach) : array(); while (is_array($this->attach) && !isset($this->attach[$propix]) && 0 < count($this->attach) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->attach[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->attach[$propix] : $this->attach[$propix]['value']; break; case 'ATTENDEE': $ak = is_array($this->attendee) ? array_keys($this->attendee) : array(); while (is_array($this->attendee) && !isset($this->attendee[$propix]) && 0 < count($this->attendee) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->attendee[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->attendee[$propix] : $this->attendee[$propix]['value']; break; case 'CATEGORIES': $ak = is_array($this->categories) ? array_keys($this->categories) : array(); while (is_array($this->categories) && !isset($this->categories[$propix]) && 0 < count($this->categories) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->categories[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->categories[$propix] : $this->categories[$propix]['value']; break; case 'CLASS': if (isset($this->class['value'])) { return $inclParam ? $this->class : $this->class['value']; } break; case 'COMMENT': $ak = is_array($this->comment) ? array_keys($this->comment) : array(); while (is_array($this->comment) && !isset($this->comment[$propix]) && 0 < count($this->comment) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->comment[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->comment[$propix] : $this->comment[$propix]['value']; break; case 'COMPLETED': if (isset($this->completed['value'])) { return $inclParam ? $this->completed : $this->completed['value']; } break; case 'CONTACT': $ak = is_array($this->contact) ? array_keys($this->contact) : array(); while (is_array($this->contact) && !isset($this->contact[$propix]) && 0 < count($this->contact) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->contact[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->contact[$propix] : $this->contact[$propix]['value']; break; case 'CREATED': if (isset($this->created['value'])) { return $inclParam ? $this->created : $this->created['value']; } break; case 'DESCRIPTION': $ak = is_array($this->description) ? array_keys($this->description) : array(); while (is_array($this->description) && !isset($this->description[$propix]) && 0 < count($this->description) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->description[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->description[$propix] : $this->description[$propix]['value']; break; case 'DTEND': if (isset($this->dtend['value'])) { return $inclParam ? $this->dtend : $this->dtend['value']; } break; case 'DTSTAMP': if (in_array($this->objName, iCalUtilityFunctions::$miscComps)) { return; } if (!isset($this->dtstamp['value'])) { $this->_makeDtstamp(); } return $inclParam ? $this->dtstamp : $this->dtstamp['value']; break; case 'DTSTART': if (isset($this->dtstart['value'])) { return $inclParam ? $this->dtstart : $this->dtstart['value']; } break; case 'DUE': if (isset($this->due['value'])) { return $inclParam ? $this->due : $this->due['value']; } break; case 'DURATION': if (!isset($this->duration['value'])) { return FALSE; } $value = $specform && isset($this->dtstart['value']) && isset($this->duration['value']) ? iCalUtilityFunctions::_duration2date($this->dtstart['value'], $this->duration['value']) : $this->duration['value']; $params = $specform && $inclParam && isset($this->dtstart['params']['TZID']) ? array_merge((array) $this->duration['params'], $this->dtstart['params']) : $this->duration['params']; return $inclParam ? array('value' => $value, 'params' => $params) : $value; break; case 'EXDATE': $ak = is_array($this->exdate) ? array_keys($this->exdate) : array(); while (is_array($this->exdate) && !isset($this->exdate[$propix]) && 0 < count($this->exdate) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->exdate[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->exdate[$propix] : $this->exdate[$propix]['value']; break; case 'EXRULE': $ak = is_array($this->exrule) ? array_keys($this->exrule) : array(); while (is_array($this->exrule) && !isset($this->exrule[$propix]) && 0 < count($this->exrule) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->exrule[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->exrule[$propix] : $this->exrule[$propix]['value']; break; case 'FREEBUSY': $ak = is_array($this->freebusy) ? array_keys($this->freebusy) : array(); while (is_array($this->freebusy) && !isset($this->freebusy[$propix]) && 0 < count($this->freebusy) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->freebusy[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; break; case 'GEO': if (isset($this->geo['value'])) { return $inclParam ? $this->geo : $this->geo['value']; } break; case 'LAST-MODIFIED': if (isset($this->lastmodified['value'])) { return $inclParam ? $this->lastmodified : $this->lastmodified['value']; } break; case 'LOCATION': if (isset($this->location['value'])) { return $inclParam ? $this->location : $this->location['value']; } break; case 'ORGANIZER': if (isset($this->organizer['value'])) { return $inclParam ? $this->organizer : $this->organizer['value']; } break; case 'PERCENT-COMPLETE': if (isset($this->percentcomplete['value'])) { return $inclParam ? $this->percentcomplete : $this->percentcomplete['value']; } break; case 'PRIORITY': if (isset($this->priority['value'])) { return $inclParam ? $this->priority : $this->priority['value']; } break; case 'RDATE': $ak = is_array($this->rdate) ? array_keys($this->rdate) : array(); while (is_array($this->rdate) && !isset($this->rdate[$propix]) && 0 < count($this->rdate) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->rdate[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->rdate[$propix] : $this->rdate[$propix]['value']; break; case 'RECURRENCE-ID': if (isset($this->recurrenceid['value'])) { return $inclParam ? $this->recurrenceid : $this->recurrenceid['value']; } break; case 'RELATED-TO': $ak = is_array($this->relatedto) ? array_keys($this->relatedto) : array(); while (is_array($this->relatedto) && !isset($this->relatedto[$propix]) && 0 < count($this->relatedto) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->relatedto[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; break; case 'REPEAT': if (isset($this->repeat['value'])) { return $inclParam ? $this->repeat : $this->repeat['value']; } break; case 'REQUEST-STATUS': $ak = is_array($this->requeststatus) ? array_keys($this->requeststatus) : array(); while (is_array($this->requeststatus) && !isset($this->requeststatus[$propix]) && 0 < count($this->requeststatus) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->requeststatus[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; break; case 'RESOURCES': $ak = is_array($this->resources) ? array_keys($this->resources) : array(); while (is_array($this->resources) && !isset($this->resources[$propix]) && 0 < count($this->resources) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->resources[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->resources[$propix] : $this->resources[$propix]['value']; break; case 'RRULE': $ak = is_array($this->rrule) ? array_keys($this->rrule) : array(); while (is_array($this->rrule) && !isset($this->rrule[$propix]) && 0 < count($this->rrule) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->rrule[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->rrule[$propix] : $this->rrule[$propix]['value']; break; case 'SEQUENCE': if (isset($this->sequence['value'])) { return $inclParam ? $this->sequence : $this->sequence['value']; } break; case 'STATUS': if (isset($this->status['value'])) { return $inclParam ? $this->status : $this->status['value']; } break; case 'SUMMARY': if (isset($this->summary['value'])) { return $inclParam ? $this->summary : $this->summary['value']; } break; case 'TRANSP': if (isset($this->transp['value'])) { return $inclParam ? $this->transp : $this->transp['value']; } break; case 'TRIGGER': if (isset($this->trigger['value'])) { return $inclParam ? $this->trigger : $this->trigger['value']; } break; case 'TZID': if (isset($this->tzid['value'])) { return $inclParam ? $this->tzid : $this->tzid['value']; } break; case 'TZNAME': $ak = is_array($this->tzname) ? array_keys($this->tzname) : array(); while (is_array($this->tzname) && !isset($this->tzname[$propix]) && 0 < count($this->tzname) && $propix < end($ak)) { $propix++; } $this->propix[$propName] = $propix; if (!isset($this->tzname[$propix])) { unset($this->propix[$propName]); return FALSE; } return $inclParam ? $this->tzname[$propix] : $this->tzname[$propix]['value']; break; case 'TZOFFSETFROM': if (isset($this->tzoffsetfrom['value'])) { return $inclParam ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; } break; case 'TZOFFSETTO': if (isset($this->tzoffsetto['value'])) { return $inclParam ? $this->tzoffsetto : $this->tzoffsetto['value']; } break; case 'TZURL': if (isset($this->tzurl['value'])) { return $inclParam ? $this->tzurl : $this->tzurl['value']; } break; case 'UID': if (in_array($this->objName, iCalUtilityFunctions::$miscComps)) { return FALSE; } if (empty($this->uid)) { $this->_makeuid(); } return $inclParam ? $this->uid : $this->uid['value']; break; case 'URL': if (isset($this->url['value'])) { return $inclParam ? $this->url : $this->url['value']; } break; default: if ($propName != 'X-PROP') { if (!isset($this->xprop[$propName])) { return FALSE; } return $inclParam ? array($propName, $this->xprop[$propName]) : array($propName, $this->xprop[$propName]['value']); } else { if (empty($this->xprop)) { return FALSE; } $xpropno = 0; foreach ($this->xprop as $xpropkey => $xpropvalue) { if ($propix == $xpropno) { return $inclParam ? array($xpropkey, $this->xprop[$xpropkey]) : array($xpropkey, $this->xprop[$xpropkey]['value']); } else { $xpropno++; } } return FALSE; // not found ?? } } return FALSE; }
/** * get component property value/params * * if property has multiply values, consequtive function calls are needed * * @author Kjell-Inge Gustafsson <*****@*****.**> * @since 2.6.22 - 2010-10-21 * @param string $propName, optional * @param int @propix, optional, if specific property is wanted in case of multiply occurences * @param bool $inclParam=FALSE * @param bool $specform=FALSE * @return mixed */ function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE, $specform = FALSE) { if ($this->_notExistProp($propName)) { return FALSE; } $propName = $propName ? strtoupper($propName) : 'X-PROP'; if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { if (!$propix) { $propix = isset($this->propix[$propName]) ? $this->propix[$propName] + 2 : 1; } $this->propix[$propName] = --$propix; } switch ($propName) { case 'ACTION': if (!empty($this->action['value'])) { return $inclParam ? $this->action : $this->action['value']; } break; case 'ATTACH': if (!isset($this->attach[$propix])) { return FALSE; } return $inclParam ? $this->attach[$propix] : $this->attach[$propix]['value']; break; case 'ATTENDEE': if (!isset($this->attendee[$propix])) { return FALSE; } return $inclParam ? $this->attendee[$propix] : $this->attendee[$propix]['value']; break; case 'CATEGORIES': if (!isset($this->categories[$propix])) { return FALSE; } return $inclParam ? $this->categories[$propix] : $this->categories[$propix]['value']; break; case 'CLASS': if (!empty($this->class['value'])) { return $inclParam ? $this->class : $this->class['value']; } break; case 'COMMENT': if (!isset($this->comment[$propix])) { return FALSE; } return $inclParam ? $this->comment[$propix] : $this->comment[$propix]['value']; break; case 'COMPLETED': if (!empty($this->completed['value'])) { return $inclParam ? $this->completed : $this->completed['value']; } break; case 'CONTACT': if (!isset($this->contact[$propix])) { return FALSE; } return $inclParam ? $this->contact[$propix] : $this->contact[$propix]['value']; break; case 'CREATED': if (!empty($this->created['value'])) { return $inclParam ? $this->created : $this->created['value']; } break; case 'DESCRIPTION': if (!isset($this->description[$propix])) { return FALSE; } return $inclParam ? $this->description[$propix] : $this->description[$propix]['value']; break; case 'DTEND': if (!empty($this->dtend['value'])) { return $inclParam ? $this->dtend : $this->dtend['value']; } break; case 'DTSTAMP': if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { return; } if (!isset($this->dtstamp['value'])) { $this->_makeDtstamp(); } return $inclParam ? $this->dtstamp : $this->dtstamp['value']; break; case 'DTSTART': if (!empty($this->dtstart['value'])) { return $inclParam ? $this->dtstart : $this->dtstart['value']; } break; case 'DUE': if (!empty($this->due['value'])) { return $inclParam ? $this->due : $this->due['value']; } break; case 'DURATION': if (!isset($this->duration['value'])) { return FALSE; } $value = $specform && isset($this->dtstart['value']) && isset($this->duration['value']) ? iCalUtilityFunctions::_duration2date($this->dtstart['value'], $this->duration['value']) : $this->duration['value']; return $inclParam ? array('value' => $value, 'params' => $this->duration['params']) : $value; break; case 'EXDATE': if (!isset($this->exdate[$propix])) { return FALSE; } return $inclParam ? $this->exdate[$propix] : $this->exdate[$propix]['value']; break; case 'EXRULE': if (!isset($this->exrule[$propix])) { return FALSE; } return $inclParam ? $this->exrule[$propix] : $this->exrule[$propix]['value']; break; case 'FREEBUSY': if (!isset($this->freebusy[$propix])) { return FALSE; } return $inclParam ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; break; case 'GEO': if (!empty($this->geo['value'])) { return $inclParam ? $this->geo : $this->geo['value']; } break; case 'LAST-MODIFIED': if (!empty($this->lastmodified['value'])) { return $inclParam ? $this->lastmodified : $this->lastmodified['value']; } break; case 'LOCATION': if (!empty($this->location['value'])) { return $inclParam ? $this->location : $this->location['value']; } break; case 'ORGANIZER': if (!empty($this->organizer['value'])) { return $inclParam ? $this->organizer : $this->organizer['value']; } break; case 'PERCENT-COMPLETE': if (!empty($this->percentcomplete['value'])) { return $inclParam ? $this->percentcomplete : $this->percentcomplete['value']; } break; case 'PRIORITY': if (!empty($this->priority['value'])) { return $inclParam ? $this->priority : $this->priority['value']; } break; case 'RDATE': if (!isset($this->rdate[$propix])) { return FALSE; } return $inclParam ? $this->rdate[$propix] : $this->rdate[$propix]['value']; break; case 'RECURRENCE-ID': if (!empty($this->recurrenceid['value'])) { return $inclParam ? $this->recurrenceid : $this->recurrenceid['value']; } break; case 'RELATED-TO': if (!isset($this->relatedto[$propix])) { return FALSE; } return $inclParam ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; break; case 'REPEAT': if (!empty($this->repeat['value'])) { return $inclParam ? $this->repeat : $this->repeat['value']; } break; case 'REQUEST-STATUS': if (!isset($this->requeststatus[$propix])) { return FALSE; } return $inclParam ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; break; case 'RESOURCES': if (!isset($this->resources[$propix])) { return FALSE; } return $inclParam ? $this->resources[$propix] : $this->resources[$propix]['value']; break; case 'RRULE': if (!isset($this->rrule[$propix])) { return FALSE; } return $inclParam ? $this->rrule[$propix] : $this->rrule[$propix]['value']; break; case 'SEQUENCE': if (isset($this->sequence['value']) && '0' <= $this->sequence['value']) { return $inclParam ? $this->sequence : $this->sequence['value']; } break; case 'STATUS': if (!empty($this->status['value'])) { return $inclParam ? $this->status : $this->status['value']; } break; case 'SUMMARY': if (!empty($this->summary['value'])) { return $inclParam ? $this->summary : $this->summary['value']; } break; case 'TRANSP': if (!empty($this->transp['value'])) { return $inclParam ? $this->transp : $this->transp['value']; } break; case 'TRIGGER': if (!empty($this->trigger['value'])) { return $inclParam ? $this->trigger : $this->trigger['value']; } break; case 'TZID': if (!empty($this->tzid['value'])) { return $inclParam ? $this->tzid : $this->tzid['value']; } break; case 'TZNAME': if (!isset($this->tzname[$propix])) { return FALSE; } return $inclParam ? $this->tzname[$propix] : $this->tzname[$propix]['value']; break; case 'TZOFFSETFROM': if (!empty($this->tzoffsetfrom['value'])) { return $inclParam ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; } break; case 'TZOFFSETTO': if (!empty($this->tzoffsetto['value'])) { return $inclParam ? $this->tzoffsetto : $this->tzoffsetto['value']; } break; case 'TZURL': if (!empty($this->tzurl['value'])) { return $inclParam ? $this->tzurl : $this->tzurl['value']; } break; case 'UID': if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { return FALSE; } if (empty($this->uid['value'])) { $this->_makeuid(); } return $inclParam ? $this->uid : $this->uid['value']; break; case 'URL': if (!empty($this->url['value'])) { return $inclParam ? $this->url : $this->url['value']; } break; default: if ($propName != 'X-PROP') { if (!isset($this->xprop[$propName])) { return FALSE; } return $inclParam ? array($propName, $this->xprop[$propName]) : array($propName, $this->xprop[$propName]['value']); } else { if (empty($this->xprop)) { return FALSE; } $xpropno = 0; foreach ($this->xprop as $xpropkey => $xpropvalue) { if ($propix == $xpropno) { return $inclParam ? array($xpropkey, $this->xprop[$xpropkey]) : array($xpropkey, $this->xprop[$xpropkey]['value']); } else { $xpropno++; } } return FALSE; // not found ?? } } return FALSE; }