Skip to content

Commit

Permalink
v2.0.0-beta.10
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmartens committed May 3, 2018
1 parent 70b6d44 commit 76f407b
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 130 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Solspace Calendar Changelog

## 2.0.0-beta.10 - 2018-05-03
### Added
- Added `startDateLocalized` and `endDateLocalized` workaround properties to Event object for use with `|date` filter, which is compatible with translations.

### Fixed
- Fixed a bug where deleting calendars would not work.
- Fixed a bug where adding an Author column in Events list in CP would error.
- Fixed a bug where references to `dateRangeStart` and `dateRangeEnd` parameters would not work because they were renamed to `rangeStart` and `rangeEnd` for Calendar 2. They are now aliased so both ways work for legacy.
- Fixed a bug where the Calendar fieldtype (for relating events to Craft Entries) wouldn't let you reorder the events in the list (if you have more than 1).
- Fixed a bug where the Start Date and End Date columns in the Events list in CP incorrectly showed localized dates/times.
- Fixed a bug where Calendar's `get userID` could potentially conflict with other plugins.
- Fixed a bug where editing Sites could trigger a Calendar error.

## 2.0.0-beta.9 - 2018-04-04
### Fixed
- Fixed a bug where Calendar would error about `Client` constant in Craft 3.0.0 GA release, as the Client edition was removed without warning.

## 2.0.0-beta.8 - 2018-04-03
### Fixed
- Fixed a bug where sorting events in control panel by Post Date would error.
- Fixed several visual bugs in control panel.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Calendar is the most powerful event management and calendaring plugin on the market for Craft CMS. The intuitive interface allows you to create events with complex recurring event rules and exclusions, while the flexible templating offers a variety of options to satisfy your calendaring needs.

🚨 **NOTE: Calendar has proven to be fairly stable now, but please take caution if using in production environments. 🐛 Any issues during the beta should only be reported on [GitHub Issues](https://github.com/solspace/craft3-calendar/issues) please.** 🚨
🚨 **NOTE: Calendar has proven to be fairly stable now, but please take caution if using in production environments.** 🚨

![Screenshot](src/icon.svg)

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solspace/craft3-calendar",
"description": "The most powerful event management plugin for Craft.",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"type": "craft-plugin",
"minimum-stability": "dev",
"authors": [
Expand Down
228 changes: 128 additions & 100 deletions src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,113 @@ public function init()
{
parent::init();

$this->initControllers();
$this->initServices();
$this->initRoutes();
$this->initTemplateVariables();
$this->initWidgets();
$this->initFieldTypes();
$this->initEventListeners();
$this->initPermissions();

if (\Craft::$app->request->getIsCpRequest()) {
\Craft::$app->view->registerTranslations(self::TRANSLATION_CATEGORY, self::$javascriptTranslationKeys);
}

if (\Craft::$app->request->getIsSiteRequest()) {
$extension = new CalendarTwigExtension();
\Craft::$app->view->registerTwigExtension($extension);
}

if (\Craft::$app->request->isCpRequest) {
\Craft::$app->view->registerAssetBundle(MainAssetBundle::class);
}
}

/**
* @param string $message
* @param array $params
* @param string $language
*
* @return string
*/
public static function t(string $message, array $params = [], string $language = null): string
{
return \Craft::t(self::TRANSLATION_CATEGORY, $message, $params, $language);
}

/**
* On install - insert a default calendar
*
* @return void
*/
public function afterInstall()
{
$calendarsService = self::getInstance()->calendars;
$siteIds = \Craft::$app->sites->getAllSiteIds();

$siteSettings = [];
foreach ($siteIds as $siteId) {
$siteSetting = new CalendarSiteSettingsModel();
$siteSetting->siteId = $siteId;
$siteSetting->enabledByDefault = true;

$siteSettings[] = $siteSetting;
}

$defaultCalendar = CalendarModel::create();
$defaultCalendar->name = 'Default';
$defaultCalendar->handle = 'default';
$defaultCalendar->description = 'The default calendar';
$defaultCalendar->hasTitleField = true;
$defaultCalendar->titleLabel = 'Title';
$defaultCalendar->setSiteSettings($siteSettings);

$calendarsService->saveCalendar($defaultCalendar, false);
}

/**
* @return Plugin|Calendar
*/
public static function getInstance(): Calendar
{
return parent::getInstance();
}

/**
* @return array|null
*/
public function getCpNavItem()
{
$navItem = parent::getCpNavItem();
$navItem['subnav'] = include __DIR__ . '/subnav.php';

return $navItem;
}

/**
* @return SettingsModel
*/
protected function createSettingsModel(): SettingsModel
{
return new SettingsModel();
}

/**
* @return string
*/
protected function settingsHtml(): string
{
return \Craft::$app->getView()->renderTemplate(
'calendar/settings',
[
'settings' => $this->getSettings(),
]
);
}

private function initControllers()
{
if (!\Craft::$app->request->isConsoleRequest) {
$this->controllerMap = [
'api' => ApiController::class,
Expand All @@ -112,7 +219,10 @@ public function init()
'view' => ViewController::class,
];
}
}

private function initServices()
{
$this->setComponents(
[
'calendars' => CalendarsService::class,
Expand All @@ -123,7 +233,10 @@ public function init()
'viewData' => ViewDataService::class,
]
);
}

private function initRoutes()
{
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
Expand All @@ -132,15 +245,21 @@ function (RegisterUrlRulesEvent $event) {
$event->rules = array_merge($event->rules, $routes);
}
);
}

private function initTemplateVariables()
{
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
function (Event $event) {
$event->sender->set('calendar', CalendarVariable::class);
}
);
}

private function initWidgets()
{
Event::on(
Dashboard::class,
Dashboard::EVENT_REGISTER_WIDGET_TYPES,
Expand All @@ -151,26 +270,27 @@ function (RegisterComponentTypesEvent $event) {
$event->types[] = UpcomingEventsWidget::class;
}
);
}

private function initFieldTypes()
{
Event::on(
Fields::class,
Fields::EVENT_REGISTER_FIELD_TYPES,
function (RegisterComponentTypesEvent $event) {
$event->types[] = EventFieldType::class;
}
);
}

// craft()->on('i18n.onAddLocale', [craft()->calendar_events, 'addLocaleHandler']);
// craft()->on('i18n.onAddLocale', [craft()->calendar_calendars, 'addLocaleHandler']);

private function initEventListeners()
{
Event::on(Sites::class, Sites::EVENT_AFTER_SAVE_SITE, [$this->events, 'addSiteHandler']);
Event::on(Sites::class, Sites::EVENT_AFTER_SAVE_SITE, [$this->calendars, 'addSiteHandler']);
}

if (\Craft::$app->request->getIsCpRequest() && \Craft::$app->getUser()->getId()) {
\Craft::$app->view->registerTranslations(self::TRANSLATION_CATEGORY, self::$javascriptTranslationKeys);
}


private function initPermissions()
{
if (\Craft::$app->getEdition() >= \Craft::Pro) {
Event::on(
UserPermissions::class,
Expand Down Expand Up @@ -221,97 +341,5 @@ function (RegisterUserPermissionsEvent $event) {
}
);
}


if (\Craft::$app->request->getIsSiteRequest()) {
$extension = new CalendarTwigExtension();
\Craft::$app->view->registerTwigExtension($extension);
}

if (\Craft::$app->request->isCpRequest) {
\Craft::$app->view->registerAssetBundle(MainAssetBundle::class);
}
}

/**
* @param string $message
* @param array $params
* @param string $language
*
* @return string
*/
public static function t(string $message, array $params = [], string $language = null): string
{
return \Craft::t(self::TRANSLATION_CATEGORY, $message, $params, $language);
}

/**
* On install - insert a default calendar
*
* @return void
*/
public function afterInstall()
{
$calendarsService = self::getInstance()->calendars;
$siteIds = \Craft::$app->sites->getAllSiteIds();

$siteSettings = [];
foreach ($siteIds as $siteId) {
$siteSetting = new CalendarSiteSettingsModel();
$siteSetting->siteId = $siteId;
$siteSetting->enabledByDefault = true;

$siteSettings[] = $siteSetting;
}

$defaultCalendar = CalendarModel::create();
$defaultCalendar->name = 'Default';
$defaultCalendar->handle = 'default';
$defaultCalendar->description = 'The default calendar';
$defaultCalendar->hasTitleField = true;
$defaultCalendar->titleLabel = 'Title';
$defaultCalendar->setSiteSettings($siteSettings);

$calendarsService->saveCalendar($defaultCalendar, false);
}

/**
* @return Plugin|Calendar
*/
public static function getInstance(): Calendar
{
return parent::getInstance();
}

/**
* @return array|null
*/
public function getCpNavItem()
{
$navItem = parent::getCpNavItem();
$navItem['subnav'] = include __DIR__ . '/subnav.php';

return $navItem;
}

/**
* @return SettingsModel
*/
protected function createSettingsModel(): SettingsModel
{
return new SettingsModel();
}

/**
* @return string
*/
protected function settingsHtml(): string
{
return \Craft::$app->getView()->renderTemplate(
'calendar/settings',
[
'settings' => $this->getSettings(),
]
);
}
}
Loading

0 comments on commit 76f407b

Please sign in to comment.