/** * Returns a new component for a passed File_iCal_{Event, Alarm, FreeBusy, TimeZone, ToDo} * * @access public * @static * @param object $e The event for which you wish to return a component object * @return File_iCal_Component_Event The new component object */ public static function getComponent($e) { //ideally we call the component constructor with an array of contentlines $props = array(); $component_name = ""; //print_r($e); switch (get_class($e)) { case "File_iCal_Alarm": $component_name = "VALARM"; break; case "File_iCal_Event": $component_name = "VEVENT"; break; case "File_iCal_FreeBusy": $component_name = "VFREEBUSY"; break; case "File_iCal_TimeZone": $component_name = "VTIMEZONE"; break; case "File_iCal_ToDo": $component_name = "VTODO"; break; case "File_iCal_Journal": $component_name = "VJOURNAL"; break; default: trigger_error("Passed object not valid type (is a " . get_class($e) . ")", E_USER_WARNING); } require_once 'File/iCal/Property.php'; $props[] = File_iCal_Property::getProperty("BEGIN", array(), $component_name); //attachment is defined in the basecomponent class, so method_exists is always true if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_Alarm")) { } //needs to be finished if (is_subclass_of($e, "File_iCal_BaseComponent_EFJT") || is_a($e, "File_iCal_TimeZone")) { foreach ($e->getComments() as $c) { } } //this method is defined in the BaseComponent class, so it always exists //method should only be public for AEJT if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_Alarm")) { if ($description = $e->getDescription()) { $props[] = File_iCal_Property::getProperty("DESCRIPTION", array(), $description); } } if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_Alarm")) { if ($summary = $e->getSummary()) { $props[] = File_iCal_Property::getProperty("SUMMARY", array(), $summary); } } if (is_a($e, "File_iCal_Event") || is_a($e, "File_iCal_FreeBusy")) { if (($de = $e->getDateEnd()) > 0) { $props[] = File_iCal_Property::getProperty("DTEND", array(), $de); } } if (is_subclass_of($e, "File_iCal_BaseComponent_EFJT")) { if (($ds = $e->getDateStart()) > 0) { $props[] = File_iCal_Property::getProperty("DTSTART", array(), $ds); } } if (is_subclass_of($e, "File_iCal_BaseComponent_ET") || is_a($e, "File_iCal_Alarm") || is_a($e, "File_iCal_FreeBusy")) { if (($dur = $e->getDuration()) > 0) { $props[] = File_iCal_Property::getProperty("DURATION", array(), $dur); } } //should be changed if (method_exists($e, "getAttendees")) { } if (is_subclass_of($e, "File_iCal_BaseComponent_EJT") || is_a($e, "File_iCal_TimeZone")) { } if (method_exists($e, "getContacts")) { } if (method_exists($e, "getOrganizer")) { if ($o = $e->getOrganizer()) { $props[] = File_iCal_Property::getProperty("ORGANIZER", array(), $o); } } if (method_exists($e, "getURL")) { if ($url = $e->getURL()) { $props[] = File_iCal_Property::getProperty("URL", array(), $url); } } if (method_exists($e, "getUID")) { if ($uid = $e->getUID()) { $props[] = File_iCal_Property::getProperty("UID", array(), $uid); } } if (method_exists($e, "getDateStamp")) { if ($ds = $e->getDateStamp()) { $props[] = File_iCal_Property::getProperty("DTSTAMP", array(), $uid); } } if (method_exists($e, "getRequestStatus")) { } if (method_exists($e, "getCategories")) { } if (method_exists($e, "getClassification")) { } if (method_exists($e, "getStatus")) { } if (method_exists($e, "getRecurrenceId")) { } if (method_exists($e, "getRelatedTo")) { } if (method_exists($e, "getCreated")) { } if (method_exists($e, "getSequence")) { if ($sequence = $e->getSequence()) { $props[] = File_iCal_Property::getProperty("SEQUENCE", array(), $sequence); } } if (method_exists($e, "getLatitude")) { } if (method_exists($e, "getLongitude")) { } if (method_exists($e, "getLocation")) { if ($location = $e->getLocation()) { $props[] = File_iCal_Property::getLocation("LOCATION", array(), $location); } } if (method_exists($e, "getPriority")) { } if (method_exists($e, "getResources")) { } if (method_exists($e, "getTransparency")) { } $props[] = File_iCal_Property::getProperty("END", array(), $component_name); //convert these properties to contentlines require_once 'File/iCal/ContentLine.php'; foreach ($props as $k => $p) { $props[$k] = new File_iCal_ContentLine($p); } //echo '<PRE>';print_R(array($e, $component_name,$props)); switch ($component_name) { case "VEVENT": return new File_iCal_Component_Event($props); break; case "VTODO": return new File_iCal_Component_Todo($props); break; case "VTIMEZONE": return new File_iCal_Component_Timezone($props); break; case "VALARM": return new File_iCal_Component_Alarm($props); break; case "VFREEBUSY": return new File_iCal_Component_FreeBusy($props); break; case "VJOURNAL": return new File_iCal_Component_Journal($props); break; default: trigger_error("Cannot yet retrieve component"); } }
public function __construct($value, $params) { parent::__construct($value, $params); $this->_name = "REQUEST-STATUS"; $this->_values[] = new File_iCal_ValueDataType_Text($value); }
/** * Create a new ContentLine * * @access public * @param mixed $line The parameter can be of a few types: * 1) a File_iCal_Property object * 2) a line of text in an iCal file */ public function __construct($line) { //if we ar econstructing a contentline out of an existing property if (is_a($line, "File_iCal_Property")) { $this->_property = $line; } else { //remove all special characters from beginning and end $line = trim($line); //now it is time again to rewrite the tokenizer (for the 4th time) $tokens = array(); //array of strings which represent tokens $i = 0; //string position $l = strlen($line); //every entry will start looking for a new token do { $t = ""; //our new token $begin = $i; //behave differently depending on what type of character we encounter switch ($line[$i]) { case '\\"': //encounter the beginning of a double quoted string $valid = true; while ($valid) { $i = strpos($line, '\\"', $i); if ($line[$i - 1] == '\\') { $valid = false; } } $t = substr($line, $begin, $i - $begin); $i++; break; case ':': case ';': $t = $line[$i]; $i++; break; default: //if we don't have a semicolon or colon in the tokens array yet, we are reading the name string $present_colon = in_array(':', $tokens); $present_semi = in_array(';', $tokens); if (!$present_colon && !$present_semi) { $m; preg_match("/^([\\w\\d-]+)[;:]?/", $line, $m); //$m[1] contains the name $t = $m[1]; $i += strlen($t); } else { if ($present_colon && $tokens[count($tokens) - 1] == ':') { //if the last token is a colon, read out the value $t = substr($line, $i); $i += strlen($t); } else { if ($present_semi && $tokens[count($tokens) - 1] == ';') { //if the last token is a semicolon $t = substr($line, $i, strpos($line, ':', $i) - $i); $i += strlen($t); } else { $t = $line[$i]; $i++; } } } } $tokens[] = $t; } while ($i < $l); //print_r($tokens); $colon_key = array_search(':', $tokens); $name_string = $tokens[0]; $value_string = $tokens[$colon_key + 1]; $params = array(); if ($tokens[1] == ';') { $arr = explode(';', $tokens[2]); foreach ($arr as $v) { $val = explode('=', $v); $name = $val[0]; $values = array($val[1]); $params[] = File_iCal_Parameter::getParameter($name, $values); } } $this->_property = File_iCal_Property::getProperty($name_string, $params, $value_string); } }