Skip to content
Snippets Groups Projects
Commit 99ac40c4 authored by Markus Poerschke's avatar Markus Poerschke
Browse files

Merge pull request #20 from elceka/master

Some ideas... :)
parents db02a891 b9149a3c
Branches
Tags 0.1.3
No related merge requests found
......@@ -20,7 +20,7 @@ $vEvent->setSummary('Christmas');
$vEvent->setUseTimezone(true);
// 3. Add event to calendar
$vCalendar->addEvent($vEvent);
$vCalendar->addComponent($vEvent);
// 4. Set headers
header('Content-Type: text/calendar; charset=utf-8');
......
......@@ -20,7 +20,7 @@ $vEvent->setSummary('Summary with some german "umlauten" and a backslash \\: Kin
$vEvent->setUseTimezone(true);
// 3. Add event to calendar
$vCalendar->addEvent($vEvent);
$vCalendar->addComponent($vEvent);
// 4. Set headers
header('Content-Type: text/calendar; charset=utf-8');
......
......@@ -26,7 +26,7 @@ $vEvent->setRecurrenceRule($recurrenceRule);
$vEvent->setUseTimezone(true);
// 3. Add event to calendar
$vCalendar->addEvent($vEvent);
$vCalendar->addComponent($vEvent);
// 4. Set headers
header('Content-Type: text/calendar; charset=utf-8');
......
......@@ -25,7 +25,7 @@ $vEvent->setRecurrenceRule($recurrenceRule);
$vEvent->setUseTimezone(true);
// 3. Add event to calendar
$vCalendar->addEvent($vEvent);
$vCalendar->addComponent($vEvent);
// 4. Set headers
header('Content-Type: text/calendar; charset=utf-8');
......
......@@ -46,7 +46,7 @@ abstract class Component
* @param Component $component The Component that will be added
* @param null $key The key of the Component
*/
protected function addComponent(Component $component, $key = null)
public function addComponent(Component $component, $key = null)
{
if (null == $key) {
$this->components[] = $component;
......
<?php
/*
* This file is part of the eluceo/iCal package.
*
* (c) Radoslav Lukac <dev@elceka.sk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eluceo\iCal\Component;
use Eluceo\iCal\Component;
use Eluceo\iCal\PropertyBag;
use Eluceo\iCal\Property;
use \InvalidArgumentException;
/**
* Implementation of the VALARM component
*/
class Alarm extends Component
{
/**
* Alarm ACTION property
*
* According to RFC 5545: 3.8.6.1. Action
*
* @link http://tools.ietf.org/html/rfc5545#section-3.8.6.1
*/
const ACTION_AUDIO = 'AUDIO';
const ACTION_DISPLAY = 'DISPLAY';
const ACTION_EMAIL = 'EMAIL';
protected $action;
protected $repeat;
protected $duration;
protected $description;
protected $attendee;
protected $trigger;
public function getType()
{
return "VALARM";
}
public function getAction()
{
return $this->action;
}
public function getRepeat()
{
return $this->repeat;
}
public function getDuration()
{
return $this->duration;
}
public function getDescription()
{
return $this->description;
}
public function getAttendee()
{
return $this->attendee;
}
public function getTrigger()
{
return $this->trigger;
}
public function setAction($action)
{
$this->action = $action;
return $this;
}
public function setRepeat($repeat)
{
$this->repeat = $repeat;
return $this;
}
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
public function setDescription($description)
{
$this->description = $description;
return $this;
}
public function setAttendee($attendee)
{
$this->attendee = $attendee;
return $this;
}
public function setTrigger($trigger)
{
$this->trigger = $trigger;
return $this;
}
/**
* {@inheritdoc}
*/
public function buildPropertyBag()
{
$this->properties = new PropertyBag;
if (null != $this->trigger) {
$this->properties->set('TRIGGER', $this->trigger);
}
if (null != $this->action) {
$this->properties->set('ACTION', $this->action);
}
if (null != $this->repeat) {
$this->properties->set('REPEAT', $this->repeat);
}
if (null != $this->duration) {
$this->properties->set('DURATION', $this->duration);
}
if (null != $this->description) {
$this->properties->set('DESCRIPTION', $this->description);
}
if (null != $this->attendee) {
$this->properties->set('ATTENDEE', $this->attendee);
}
}
}
......@@ -16,6 +16,35 @@ use Eluceo\iCal\PropertyBag;
class Calendar extends Component
{
/**
* Methods for calendar components
*
* According to RFP 5545: 3.7.2. Method
*
* @link http://tools.ietf.org/html/rfc5545#section-3.7.2
*
* And then according to RFC 2446: 3 APPLICATION PROTOCOL ELEMENTS
*
* @link https://www.ietf.org/rfc/rfc2446.txt
*/
const METHOD_PUBLISH = 'PUBLISH';
const METHOD_REQUEST = 'REQUEST';
const METHOD_REPLY = 'REPLY';
const METHOD_ADD = 'ADD';
const METHOD_CANCEL = 'CANCEL';
const METHOD_REFRESH = 'REFRESH';
const METHOD_COUNTER = 'COUNTER';
const METHOD_DECLINECOUNTER = 'DECLINECOUNTER';
/**
* This property defines the calendar scale used for the calendar information specified in the iCalendar object.
*
* According to RFC 5545: 3.7.1. Calendar Scale
*
* @link http://tools.ietf.org/html/rfc5545#section-3.7
*/
const CALSCALE_GREGORIAN = 'GREGORIAN';
/**
* The Product Identifier
*
......@@ -31,6 +60,7 @@ class Calendar extends Component
protected $method = null;
protected $name = null;
protected $timezone = null;
protected $calendarScale = null;
public function __construct($prodId)
{
......@@ -80,6 +110,16 @@ class Calendar extends Component
return $this;
}
/**
* @param $calendarScale
* @return $this
*/
public function setCalendarScale($calendarScale)
{
$this->calendarScale = $calendarScale;
return $this;
}
/**
* {@inheritdoc}
*/
......@@ -93,6 +133,10 @@ class Calendar extends Component
$this->properties->set('METHOD', $this->method);
}
if ($this->calendarScale) {
$this->properties->set('CALSCALE', $this->calendarScale);
}
if ($this->name) {
$this->properties->set('X-WR-CALNAME', $this->name);
}
......@@ -109,6 +153,7 @@ class Calendar extends Component
* Wrapper for addComponent()
*
* @see Eluceo\iCal::addComponent
* @deprecated Please, use public method addComponent() from abstract Component class
*
* @param Event $event
*/
......
......@@ -10,10 +10,17 @@ class ComponentTest extends \PHPUnit_Framework_TestCase
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
$vEvent = new \Eluceo\iCal\Component\Event();
$vEvent->setDtStart(new \DateTime('2012-12-24'));
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
$vEvent->setDtStart(new \DateTime('2014-12-24'));
$vEvent->setDtEnd(new \DateTime('2014-12-24'));
$vEvent->setDescription($input);
$vCalendar->addEvent($vEvent);
$vAlarm = new \Eluceo\iCal\Component\Alarm;
$vAlarm->setAction(\Eluceo\iCal\Component\Alarm::ACTION_DISPLAY);
$vAlarm->setDescription($input);
$vAlarm->setTrigger('PT0S', true);
$vEvent->addComponent($vAlarm);
$vCalendar->addComponent($vEvent);
$output = $vCalendar->render();
$output = preg_replace('/\r\n /u', '', $output);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment