aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2025-10-27 13:12:18 +0100
committerMoritz Strohm <strohm@data-quest.de>2025-10-27 13:12:18 +0100
commit1548261c211386da0a2398ffcfd2365b1fc28488 (patch)
tree08db686e35419b3cdc87aaa8526af0e6038991bb
parent4c1538a75264205789ff0415462bbb4d03588a29 (diff)
EventData: added tooltip and extra field support, InstititueCalendarHelper: use EventData to create Fullcalendar eventsstep-04887-biest-05991
-rw-r--r--lib/classes/InstituteCalendarHelper.php106
-rw-r--r--lib/classes/calendar/EventData.php61
2 files changed, 104 insertions, 63 deletions
diff --git a/lib/classes/InstituteCalendarHelper.php b/lib/classes/InstituteCalendarHelper.php
index bd19c4f..498b2d3 100644
--- a/lib/classes/InstituteCalendarHelper.php
+++ b/lib/classes/InstituteCalendarHelper.php
@@ -448,29 +448,38 @@ class InstituteCalendarHelper
'room' => UserConfig::get($GLOBALS['user']->id)->TIMETABLE_ROOMS_VISIBLE ? $room_name : null
];
- $events[] = [
- 'resourceId' => $resource_column,
- 'id' => $cycle_date->id,
- 'title' => empty($fields) ? $name : '',
- 'start' => $start,
- 'end' => $end,
- 'textColor' => $textcolor,
- 'backgroundColor' => $backgroundcolor,
- 'borderColor' => '#000',
- 'editable' => $is_editable,
- 'startEditable' => $is_start_editable,
- 'durationEditable' => $is_duration_editable,
- 'resourceEditable' => true,
- 'studip_api_urls' => ['move' => $move_url],
- 'studip_view_urls' => ['edit' => URLHelper::getURL('dispatch.php/course/details/index/' . $cycle_date->seminar_id)],
- 'metadate_id' => $cycle_date->metadate_id,
- 'course_id' => $cycle_date->seminar_id,
- 'tooltip' => self::getCycleInfos($course, $cycle_date),
- 'icon' => $is_start_editable ? '' : 'lock-locked',
- 'conform' => $conform,
- // custom props (event.extendedProps)
- 'content_fields' => $fields,
- ];
+ $event_data = new \Studip\Calendar\EventData(
+ new DateTime($start),
+ new DateTime($end),
+ empty($fields) ? $name : '',
+ [],
+ $textcolor,
+ $backgroundcolor,
+ $is_editable,
+ 'SeminarCycleDate',
+ $cycle_date->id,
+ 'Course',
+ $cycle_date->seminar_id,
+ 'special',
+ $resource_column,
+ [
+ 'edit' => URLHelper::getURL('dispatch.php/course/details/index/' . $cycle_date->seminar_id)
+ ],
+ ['move' => $move_url],
+ $is_start_editable ? '' : 'lock-locked',
+ '#000000',
+ false,
+ '',
+ self::getCycleInfos($course, $cycle_date),
+ [
+ 'start_editable' => $is_start_editable,
+ 'duration_editable' => $is_duration_editable,
+ 'resource_editable' => true,
+ 'conform' => $conform,
+ 'content_fields' => $fields,
+ ]
+ );
+ $events[] = $event_data->toFullcalendarEvent();
}
}, array_keys($courses));
@@ -574,26 +583,37 @@ class InstituteCalendarHelper
}
}
- return [
- 'resourceId' => $resource_column,
- 'id' => $cycle_date->id,
- 'title' => $name,
- 'start' => $start,
- 'end' => $end,
- 'textColor' => $textcolor,
- 'backgroundColor' => $backgroundcolor,
- 'borderColor' => '#000',
- 'editable' => $is_editable,
- 'startEditable' => $is_start_editable,
- 'durationEditable' => $is_duration_editable,
- 'resourceEditable' => true,
- 'studip_api_urls' => ['move' => $move_url],
- 'studip_view_urls' => ['edit' => URLHelper::getURL('dispatch.php/course/details/index/' . $cycle_date->seminar_id)],
- 'metadate_id' => $cycle_date->metadate_id,
- 'course_id' => $cycle_date->seminar_id,
- 'tooltip' => self::getCycleInfos($course, $cycle_date),
- 'icon' => $is_start_editable ? '' : 'lock-locked'
- ];
+ $event_data = new \Studip\Calendar\EventData(
+ new DateTime($start),
+ new DateTime($end),
+ $name,
+ [],
+ $textcolor,
+ $backgroundcolor,
+ $is_editable,
+ 'SeminarCycleDate',
+ $cycle_date->id,
+ 'Course',
+ $cycle_date->seminar_id,
+ 'special',
+ $resource_column,
+ [
+ 'edit' => URLHelper::getURL('dispatch.php/course/details/index/' . $cycle_date->seminar_id)
+ ],
+ ['move' => $move_url],
+ $is_start_editable ? '' : 'lock-locked',
+ '#000000',
+ false,
+ '',
+ self::getCycleInfos($course, $cycle_date),
+ [
+ 'start_editable' => $is_start_editable,
+ 'duration_editable' => $is_duration_editable,
+ 'resource_editable' => true
+ ]
+ );
+
+ return $event_data->toFullcalendarEvent();
}
/**
diff --git a/lib/classes/calendar/EventData.php b/lib/classes/calendar/EventData.php
index 233f131..8a76b74 100644
--- a/lib/classes/calendar/EventData.php
+++ b/lib/classes/calendar/EventData.php
@@ -26,6 +26,17 @@ class EventData
public $all_day;
/**
+ * @var string An optional tooltip for the event.
+ */
+ public $tooltip;
+
+ /**
+ * @var array An array with extra fields that are special to the
+ * calendar view that is displayed.
+ */
+ public $extra_fields;
+
+ /**
* @var string The ID in this field is used to group events when displayed
* in Fullcalendar so that they can be moved together.
*/
@@ -50,7 +61,9 @@ class EventData
string $icon = '',
string $border_colour = '',
bool $all_day = false,
- string $group_id = ''
+ string $group_id = '',
+ string $tooltip = '',
+ array $extra_fields = []
)
{
$this->begin = $begin;
@@ -72,6 +85,8 @@ class EventData
$this->border_colour = $border_colour ?: $background_colour;
$this->all_day = $all_day;
$this->group_id = $group_id;
+ $this->tooltip = $tooltip;
+ $this->extra_fields = $extra_fields;
}
@@ -98,25 +113,31 @@ class EventData
];
}
- return $fc_date + [
- 'resourceId' => $this->range_id,
- 'title' => $this->title,
- 'classNames' => $this->event_classes,
- 'textColor' => $this->text_colour,
- 'color' => $this->background_colour,
- 'borderColor' => $this->border_colour,
- 'editable' => $this->editable,
- 'studip_weekday_begin' => $this->begin->format('N'),
- 'studip_weekday_end' => $this->end->format('N'),
- 'studip_object_class' => $this->object_class,
- 'studip_object_id' => $this->object_id,
- 'studip_parent_object_class' => $this->parent_object_class,
- 'studip_parent_object_id' => $this->parent_object_id,
- 'studip_range_type' => $this->range_type,
- 'studip_range_id' => $this->range_id,
- 'studip_view_urls' => $this->view_urls,
- 'studip_api_urls' => $this->api_urls,
- 'icons' => $this->icon ? explode(',', $this->icon) : [] //Backwards compatibility in case only one icon is set.
+ return $fc_date +[
+ 'resourceId' => $this->range_id,
+ 'title' => $this->title,
+ 'classNames' => $this->event_classes,
+ 'textColor' => $this->text_colour,
+ 'color' => $this->background_colour,
+ 'borderColor' => $this->border_colour,
+ 'editable' => $this->editable,
+ 'studip_weekday_begin' => $this->begin->format('N'),
+ 'studip_weekday_end' => $this->end->format('N'),
+ 'studip_object_class' => $this->object_class,
+ 'studip_object_id' => $this->object_id,
+ 'studip_parent_object_class' => $this->parent_object_class,
+ 'studip_parent_object_id' => $this->parent_object_id,
+ 'studip_range_type' => $this->range_type,
+ 'studip_range_id' => $this->range_id,
+ 'studip_view_urls' => $this->view_urls,
+ 'studip_api_urls' => $this->api_urls,
+ 'icons' => (
+ $this->icon
+ ? explode(',', $this->icon) //Backwards compatibility in case only one icon is set.
+ : []
+ ),
+ 'tooltip' => $this->tooltip,
+ 'extra' => $this->extra_fields
] + ($this->group_id ? ['groupId' => $this->group_id] : []);
}
}