From 82dca423e152507b1860bea6f19a13f215494cb8 Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Mon, 7 Oct 2024 17:42:31 +0200 Subject: [PATCH] added basic my-calendar transformer --- .../transformer/class-my-calendar.php | 88 +++++++++++++++++++ includes/class-setup.php | 9 +- includes/plugins/class-my-calendar.php | 63 +++++++++++++ 3 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 includes/activitypub/transformer/class-my-calendar.php create mode 100644 includes/plugins/class-my-calendar.php diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php new file mode 100644 index 0000000..71475df --- /dev/null +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -0,0 +1,88 @@ +mc_event = get_post_meta( $wp_object->ID, '_mc_event_data', true); + } + + + /** + * Formats time from the plugin to the activitypub standard + */ + private function convert_time( $date_string, $time_string ): string { + // Create a DateTime object with the given date, time, and timezone. + $datetime = new DateTime( $date_string . ' ' . $time_string ); + + // Set the timezone for proper formatting. + $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); + + // Format the DateTime object as 'Y-m-d\TH:i:s\Z'. + $formatted_date = $datetime->format( 'Y-m-d\TH:i:s\Z' ); + return $formatted_date; + } + /** + * Get the start time from the events metadata. + */ + public function get_start_time(): string { + return $this->convert_time( $this->mc_event['event_begin'], $this->mc_event['event_time']); + } + + /** + * Get the end time from the events metadata. + */ + public function get_end_time(): ?string { + return $this->convert_time( $this->mc_event['event_end'], $this->mc_event['event_endtime']); + } + + public function to_object(): Event { + $activitypub_object = parent::to_object(); + + return $activitypub_object; + } + + +} diff --git a/includes/class-setup.php b/includes/class-setup.php index 39a4766..09d9f23 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -124,10 +124,11 @@ class Setup { * @var array */ private const EVENT_PLUGIN_CLASSES = array( - '\ActivityPub_Event_Bridge\Plugins\Events_Manager', - '\ActivityPub_Event_Bridge\Plugins\GatherPress', - '\ActivityPub_Event_Bridge\Plugins\The_Events_Calendar', - '\ActivityPub_Event_Bridge\Plugins\VS_Event_List', + '\Activitypub_Event_Extensions\Plugins\Events_Manager', + '\Activitypub_Event_Extensions\Plugins\GatherPress', + '\Activitypub_Event_Extensions\Plugins\The_Events_Calendar', + '\Activitypub_Event_Extensions\Plugins\VS_Event_List', + '\Activitypub_Event_Extensions\Plugins\My_Calendar', ); /** diff --git a/includes/plugins/class-my-calendar.php b/includes/plugins/class-my-calendar.php new file mode 100644 index 0000000..35604ed --- /dev/null +++ b/includes/plugins/class-my-calendar.php @@ -0,0 +1,63 @@ +