public static function decode(Vpdi_Property $FREEBUSY) { $fbs = array(); $periods = Vpdi::decodeTextList($FREEBUSY->value()); foreach ($periods as $p) { list($start, $end) = Vpdi::decodePeriod($p); $fbs[] = new Vpdi_Icalendar_Freebusy($start, $end); } if (count($fbs) == 1) return $fbs[0]; return $fbs; }
public static function decode(Vpdi_Property $N, Vpdi_Property $FN = null) { $N = Vpdi::decodeTextList($N->rawValue(), ';'); $name = new Vpdi_Vcard_Name; $name->family = (isset($N[0])) ? $N[0] : ''; $name->given = (isset($N[1])) ? $N[1] : ''; $name->additional = (isset($N[2])) ? $N[2] : ''; $name->prefixes = (isset($N[3])) ? $N[3] : ''; $name->suffixes = (isset($N[4])) ? $N[4] : ''; if ($FN !== null) { $name->fullname = $FN->rawValue(); } return $name; }
public static function decode(Vpdi_Property $ADR) { $parts = Vpdi::decodeTextList($ADR->value(), ';'); $add = new Vpdi_Vcard_Address; foreach (self::$addr_parts as $i => $part) { $add->{$part} = (isset($parts[$i])) ? $parts[$i] : ''; } $add->addTypes($ADR->getParam('TYPE')); return $add; }
public function getRrule() { if (($rrule = $this->getProperty('RRULE')) === null) { return null; } $data = Vpdi::decodeTextList($rrule->value(), ';'); foreach($data as $d) { list($name, $value) = explode('=', $d); $name = strtolower($name); $property[$name]=$value; } $freq = strtolower($property['freq']); if (!in_array($freq, $this->frequency)) return null; $return = array(); switch ($freq) { case 'weekly': $days = '0000000'; if(!is_null($property['byday'])) { $byday = Vpdi::decodeTextList($property['byday']); foreach($byday as $day) { $index = date('w', strtotime($this->weekDays[strtolower($day)])); $days[$index] = '1'; } } $return['repeat_days'] = $days; break; case 'monthly' : if(!is_null($property['byday'])) { $freq = 'monthlybyday'; } else { $freq = 'monthlybydate'; } break; } $return['freq'] = $freq; if(is_numeric($property['interval'])) { $return['interval'] = $property['interval']; } else { $return['interval'] = 1; } if(!is_null($property['count'])) { $return['count'] = $property['count']; } elseif(!is_null($property['until'])) { $return['until'] = Vpdi::decodeDate($property['until']); } // Exceptions $return['exdates'] = null; if (($exdates = $this->getPropertiesByName('EXDATE')) != null) { foreach($exdates as $exdate) { $return['exdates'][] = new Of_Date($exdate->value()); } } return $return; }