/** * Erstellt aus den übergebenen Datenobjekt ein DOMElement. * @param xCalDataEvent $xCalDataEvent * @return DOMElement */ public static function getXCalEventByXCalDataEvent(xCalDataEvent $xCalDataEvent) { $xmlDocument = new DOMDocument("1.0", "UTF-8"); $root = $xmlDocument->appendChild($xmlDocument->createElement("vevent")); $root->appendChild($xmlDocument->createElement("uid", $xCalDataEvent->getUid())); $dtStart = $root->appendChild($xmlDocument->createElement("dtstart", $xCalDataEvent->getDtStart())); $dtStart->appendChild($xmlDocument->createAttribute("value"))->appendChild($xmlDocument->createTextNode($xCalDataEvent->getDtStartValue())); if ($xCalDataEvent->getDtEnd() == "") { $root->appendChild($xmlDocument->createElement("duration", $xCalDataEvent->getDuration())); } else { $dtEnd = $root->appendChild($xmlDocument->createElement("dtend", $xCalDataEvent->getDtEnd())); $dtEnd->appendChild($xmlDocument->createAttribute("value"))->appendChild($xmlDocument->createTextNode($xCalDataEvent->getDtEndValue())); } $root->appendChild($xmlDocument->createElement("description", $xCalDataEvent->getDescription())); $root->appendChild($xmlDocument->createElement("url", $xCalDataEvent->getUrl())); $root->appendChild($xmlDocument->createElement("summary", $xCalDataEvent->getSummary())); return $root; }
/** * Gibt die xCal-Repräsentation dieses Objektes zurück. * @return DOMElement */ public function toXCal() { $xCalData = new xCalDataEvent(); #$dateTime = new DateTime(); $xCalData->setUid($this->UID); $xCalData->setSummary($this->title); // TODO: Wiederholende Termine über when holen --> Wiederholungen über xCal angeben // Parameter vermutlich Timestamp /*if (is_null($this->time)) { $dtStart = $this->day; // TODO: Testen ob Timestamp oder nicht $xCalData->setDtStartValue(xCalDataEvent::DTVALUE_DATE); $xCalData->setDtStart(gmdate("Ymd", $dtStart)); } else {*/ $dtStart = Kalender::parseDay($this->day) + Kalender::parseTime($this->time) - 60; #echo date("dmY His", $dtStart).": ".$this->title."<br />"; // TODO: Test des Formats // parseTime parseDay Kalender-Klasse $xCalData->setDtStartValue(xCalDataEvent::DTVALUE_DATETIME); $xCalData->setDtStart(gmdate("Ymd", $dtStart) . "T" . gmdate("His", $dtStart) . "Z"); #} /*if (is_null($this->endTime)) { $dtEnd = $this->endDay; $xCalData->setDtEnd(gmdate("Ymd", $dtEnd)); $xCalData->setDtEndValue(xCalDataEvent::DTVALUE_DATE);*/ #} else { $dtEnd = Kalender::parseDay($this->endDay) + Kalender::parseTime($this->endTime) - 60; $xCalData->setDtEnd(gmdate("Ymd", $dtEnd) . "T" . gmdate("His", $dtEnd) . "Z"); $xCalData->setDtEndValue(xCalDataEvent::DTVALUE_DATETIME); #} #$dateTime->setTimestamp($dtStart); return xCalUtil::getXCalEventByXCalDataEvent($xCalData); }