render(); } public function __construct( $title = '', $config = [], $attributes = [], $data_name = 'fullcalendar' ) { $this->title = $title; $this->config = $config; $this->attributes = $attributes; $this->data_name = $data_name; } public function render() { $factory = new \Flexi\Factory($GLOBALS['STUDIP_BASE_PATH'] . '/templates'); $template = $factory->open('studip-fullcalendar.php'); $real_data_name = sprintf('data-%s', $this->data_name); return $template->render( [ 'title' => $this->title, 'config' => $this->config, 'attributes' => array_merge( $this->attributes, [$real_data_name => '1'] ) ] ); } /** * Creates an array with data for a Fullcalendar instance * from Stud.IP objects that implement the EventSource interface. */ public static function createData($objects = [], $begin = null, $end = null) { if (!count($objects)) { //No data means there is nothing to do. return []; } $data = []; foreach ($objects as $object) { if ($object instanceof \Studip\Calendar\EventSource) { $events = $object->getFilteredEventData( $GLOBALS['user']->id, null, null, $begin, $end ); foreach ($events as $event) { $data[] = $event->toFullcalendarEvent(); } } } return $data; } }