Skip to content

Commit

Permalink
fixup! implement IButtonWidget and IIconWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Oct 14, 2022
1 parent edbf058 commit 93a8230
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
namespace OCA\Calendar\Controller;

use InvalidArgumentException;
use OCA\Calendar\Service\Appointments\AppointmentConfigService;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
Expand Down Expand Up @@ -151,13 +152,20 @@ private function getView(string $view): string {
}

/**
* @NoAdminRequired
* @NoCSRFRequired
*
* This function makes the colour dots work for mobile widgets
*
* Returns an SVG with size32x32
* Returns an SVG with size32x32 if the hex colour is valid
*
* @param string $color - url encoded HEX colour
* @return DataDownloadResponse
*/
public function getCalendarDotSvg(string $color) {
public function getCalendarDotSvg(string $color): DataDownloadResponse {
if (!preg_match('/^#[a-f0-9]{6}$/i', urldecode($color))) {
throw new InvalidArgumentException('Not a HEX colour');
}
$svg = '<svg height="32" width="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" fill="' . urldecode($color) . '"/></svg>';
$response = new DataDownloadResponse($svg, "$color.svg", 'svg+xml');
$response->cacheFor(31536000);
Expand Down

0 comments on commit 93a8230

Please sign in to comment.