public function __toString() { $line = ''; $upper_case = Vpdi::getConfig('always_encode_in_upper_case'); if ($this->group !== null) { $line.= $this->group.'.'; } $line.= ($upper_case) ? strtoupper($this->name) : $this->name; foreach ($this->params as $name => $values) { if (!is_array($values)) { $values = array($values); } if (count($values) === 0) { continue; } if (strtoupper($name) == 'TYPE' && Vpdi::getConfig('type_values_as_a_parameter_list') == true) { $list = array(); foreach ($values as $v) { $list[] = 'TYPE='.$v; } $line.= ';'.implode(';', $list); } else { $line.= ';'.$name.'='.implode(',', $values); } } $line.= ':'.$this->value; return $line; }
protected function getDateTime($propName) { $prop = $this->getProperty($propName); if (is_null($prop)) { return null; } $dt = Vpdi::decodeDateTime($prop->value()); if (($tzid = $prop->getParam('TZID')) !== false) { $dt->setTimezone(Vpdi::decodeTimezone($tzid)); } return $dt; }
public function encode() { return new Vpdi_Property('n', Vpdi::encodeTextList(array($this->family, $this->given, $this->additional, $this->prefixes, $this->suffixes), ';')); }
/** * Returns the value for a property * * @param Vpdi_Property $property * @access private * @return mixed */ protected function decodeProperty($property) { return Vpdi::decodeText($property->value()); }
public function encode() { $parts = array(); foreach (self::$addr_parts as $part) { $parts[] = $this->{$part}; } $value = Vpdi::encodeTextList($parts, ';'); $params = array(); $params = array_merge($params, $this->location, $this->delivery); if ($this->preferred) { $params[] = 'pref'; } return new Vpdi_Property('ADR', $value, array('TYPE' => $params)); }
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; }
/** * Returns a DateTime object set to the value of the BDAY property * * @access public * @return DateTime */ public function getBday() { if (($bday = $this->getValue('BDAY')) === null) { return null; } return Vpdi::decodeDate($bday); }
public function encode() { return new Vpdi_Property('FREEBUSY', Vpdi::encodePeriod($this->start, $this->end), array('FBTYPE' => $this->type)); }
private function get_freebusy_from_obmsync($obmsyncserver, $email){ $obmSyncRootPath = "http://".$obmsyncserver.":8080"; $freebusyUrl = $obmSyncRootPath."/obm-sync/freebusy/".rawurlencode($email)."?dataSource=remote"; $ret = @file_get_contents($freebusyUrl); if (!$ret) { return false; } $calendar = reset(Vpdi::decode($ret)); $periods = $calendar->getBusyPeriods(); return $periods; }