<?php
namespace Website\Widgets\GoogleCalendar; use Moto; class Widget extends Moto\System\Widgets\AbstractWidget { protected $_name = 'google_calendar'; protected static $_defaultProperties = [ 'spacing' => [ 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto' ], 'styles' => [ 'desktop' => [ 'base' => [ 'height' => '600px', ], ], ], 'visible_on' => 'mobile-v', 'animation' => '', 'calendarId' => '', 'params' => [ 'title' => '', 'showTitle' => 1, 'showNav' => 1, 'showDate' => 1, 'showPrint' => 1, 'showTabs' => 1, 'showCalendars' => 1, 'showTz' => 1, 'mode' => 'month', 'wkst' => '1', 'hl' => '', 'bgcolor' => '#FFFFFF' ], ]; protected $_templateType = 'templates'; protected $_widgetId = true; public function getUrl() { if (!strlen($this->getPropertyValue('calendarId'))) { return ''; } $url = 'https://calendar.google.com/calendar/embed?'; $params = 'src=' . $this->getPropertyValue('calendarId'); foreach ($this->getPropertyValue('params') as $param => $value) { if (!strlen($value)) { continue; } $params .= '&' . $param . '=' . urlencode($value); } return $url . $params; } } 