Calendar Sync V1
This commit is contained in:
86
src/CalendarEvent.php
Normal file
86
src/CalendarEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace dokuwiki\plugin\luxtools;
|
||||
|
||||
/**
|
||||
* Normalized calendar event/task for internal use.
|
||||
*
|
||||
* All calendar data (from any slot, any source) is converted into this
|
||||
* structure before rendering or querying.
|
||||
*/
|
||||
class CalendarEvent
|
||||
{
|
||||
/** @var string Calendar slot key (e.g. 'general', 'maintenance') */
|
||||
public $slotKey;
|
||||
|
||||
/** @var string Unique source event UID */
|
||||
public $uid;
|
||||
|
||||
/** @var string Recurrence ID (empty for non-recurring or master) */
|
||||
public $recurrenceId;
|
||||
|
||||
/** @var string Event summary/title */
|
||||
public $summary;
|
||||
|
||||
/** @var string ISO 8601 start date/time */
|
||||
public $startIso;
|
||||
|
||||
/** @var string ISO 8601 end date/time (may be empty) */
|
||||
public $endIso;
|
||||
|
||||
/** @var bool Whether this is an all-day event */
|
||||
public $allDay;
|
||||
|
||||
/** @var string Formatted time string (HH:MM) or empty for all-day */
|
||||
public $time;
|
||||
|
||||
/** @var string Location (may be empty) */
|
||||
public $location;
|
||||
|
||||
/** @var string Description (may be empty) */
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* Status: empty, CONFIRMED, TENTATIVE, CANCELLED, TODO, COMPLETED,
|
||||
* IN-PROCESS, NEEDS-ACTION.
|
||||
* @var string
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/** @var string Component type from source: VEVENT or VTODO */
|
||||
public $componentType;
|
||||
|
||||
/** @var string The date (YYYY-MM-DD) this event applies to */
|
||||
public $dateIso;
|
||||
|
||||
/**
|
||||
* Build a stable completion key for maintenance task tracking.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function completionKey(): string
|
||||
{
|
||||
return implode('|', [$this->slotKey, $this->uid, $this->dateIso]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this event/task is marked as completed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCompleted(): bool
|
||||
{
|
||||
$s = strtoupper($this->status);
|
||||
return $s === 'COMPLETED';
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this event/task is open (for maintenance filtering).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOpen(): bool
|
||||
{
|
||||
return !$this->isCompleted();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user