| <?php |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| namespace Eluceo\iCal\Component; |
|
|
| use Eluceo\iCal\Component; |
| use Eluceo\iCal\PropertyBag; |
|
|
| class Calendar extends Component |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| 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'; |
|
|
| |
| |
| |
| |
| |
| |
| |
| const CALSCALE_GREGORIAN = 'GREGORIAN'; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| protected $prodId = null; |
| protected $method = null; |
| protected $name = null; |
| protected $description = null; |
| protected $timezone = null; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| protected $calendarScale = null; |
|
|
| |
| |
| |
| |
| |
| |
| |
| protected $forceInspectOrOpen = false; |
|
|
| |
| |
| |
| |
| |
| |
| |
| protected $calId = null; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| protected $publishedTTL = null; |
|
|
| |
| |
| |
| |
| |
| |
| |
| protected $calendarColor = null; |
|
|
| public function __construct($prodId) |
| { |
| if (empty($prodId)) { |
| throw new \UnexpectedValueException('PRODID cannot be empty'); |
| } |
|
|
| $this->prodId = $prodId; |
| } |
|
|
| |
| |
| |
| public function getType() |
| { |
| return 'VCALENDAR'; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setMethod($method) |
| { |
| $this->method = $method; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setName($name) |
| { |
| $this->name = $name; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setDescription($description) |
| { |
| $this->description = $description; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setTimezone($timezone) |
| { |
| $this->timezone = $timezone; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setCalendarColor($calendarColor) |
| { |
| $this->calendarColor = $calendarColor; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setCalendarScale($calendarScale) |
| { |
| $this->calendarScale = $calendarScale; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setForceInspectOrOpen($forceInspectOrOpen) |
| { |
| $this->forceInspectOrOpen = $forceInspectOrOpen; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setCalId($calId) |
| { |
| $this->calId = $calId; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| |
| |
| public function setPublishedTTL($ttl) |
| { |
| $this->publishedTTL = $ttl; |
|
|
| return $this; |
| } |
|
|
| |
| |
| |
| public function buildPropertyBag() |
| { |
| $propertyBag = new PropertyBag(); |
| $propertyBag->set('VERSION', '2.0'); |
| $propertyBag->set('PRODID', $this->prodId); |
|
|
| if ($this->method) { |
| $propertyBag->set('METHOD', $this->method); |
| } |
|
|
| if ($this->calendarColor) { |
| $propertyBag->set('X-APPLE-CALENDAR-COLOR', $this->calendarColor); |
| $propertyBag->set('X-OUTLOOK-COLOR', $this->calendarColor); |
| $propertyBag->set('X-FUNAMBOL-COLOR', $this->calendarColor); |
| } |
|
|
| if ($this->calendarScale) { |
| $propertyBag->set('CALSCALE', $this->calendarScale); |
| $propertyBag->set('X-MICROSOFT-CALSCALE', $this->calendarScale); |
| } |
|
|
| if ($this->name) { |
| $propertyBag->set('X-WR-CALNAME', $this->name); |
| } |
|
|
| if ($this->description) { |
| $propertyBag->set('X-WR-CALDESC', $this->description); |
| } |
|
|
| if ($this->timezone) { |
| if ($this->timezone instanceof Timezone) { |
| $propertyBag->set('X-WR-TIMEZONE', $this->timezone->getZoneIdentifier()); |
| $this->addComponent($this->timezone); |
| } else { |
| $propertyBag->set('X-WR-TIMEZONE', $this->timezone); |
| $this->addComponent(new Timezone($this->timezone)); |
| } |
| } |
|
|
| if ($this->forceInspectOrOpen) { |
| $propertyBag->set('X-MS-OLK-FORCEINSPECTOROPEN', $this->forceInspectOrOpen); |
| } |
|
|
| if ($this->calId) { |
| $propertyBag->set('X-WR-RELCALID', $this->calId); |
| } |
|
|
| if ($this->publishedTTL) { |
| $propertyBag->set('X-PUBLISHED-TTL', $this->publishedTTL); |
| } |
|
|
| return $propertyBag; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| public function addEvent(Event $event) |
| { |
| $this->addComponent($event); |
| } |
|
|
| |
| |
| |
| public function getProdId() |
| { |
| return $this->prodId; |
| } |
|
|
| public function getMethod() |
| { |
| return $this->method; |
| } |
| } |
|
|