config = $config; $this->userId = $userId; $this->appData = $appData; $this->calendarInitialStateService = $calendarInitialStateService; } /** * Load the main calendar page * * @NoAdminRequired * @NoCSRFRequired * * @return TemplateResponse */ public function index():TemplateResponse { $this->calendarInitialStateService->run(); return new TemplateResponse($this->appName, 'main'); } /** * @NoAdminRequired * @NoCSRFRequired * * This function makes the colour dots work for mobile widgets * * Returns an SVG with size32x32 if the hex colour is valid * or a F7cloud blue svg if the colour is not * * @param string $color - url encoded HEX colour * @return FileDisplayResponse * @throws NotPermittedException */ public function getCalendarDotSvg(string $color = '#0082c9'): FileDisplayResponse { $validColor = '#0082c9'; $color = trim(urldecode($color), '#'); if (preg_match('/^([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) { $validColor = '#' . $color; } $svg = ''; $folderName = implode('_', [ 'calendar', $this->userId ]); try { $folder = $this->appData->getFolder($folderName); } catch (NotFoundException $e) { $folder = $this->appData->newFolder($folderName); } $file = $folder->newFile($color . '.svg', $svg); $response = new FileDisplayResponse($file); // Some browsers won't render SVGs without content types (for security reasons) $response->addHeader('Content-Type', 'image/svg+xml'); $response->cacheFor(24 * 3600); // 1 day return $response; } }