Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Commit

Permalink
Adds support for Solspace Calendar 1.7.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Jun 26, 2017
1 parent 86f7aeb commit e905397
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
37 changes: 13 additions & 24 deletions reasons/ReasonsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,6 @@ protected function getConditionals()
$sources['globalSet:' . $globalSet->id] = $globalSet->fieldLayoutId;
}

// Matrix blocks – TODO
// $matrixBlockTypeRecords = MatrixBlockTypeRecord::model()->findAll();
// if ($matrixBlockTypeRecords) {
// foreach ($matrixBlockTypeRecords as $matrixBlockTypeRecord) {
// $matrixBlockType = MatrixBlockTypeModel::populateModel($matrixBlockTypeRecord);
// $sources['matrixBlockType:' . $matrixBlockType->id] = $matrixBlockType->fieldLayoutId;
// }
// }

// Users
$usersFieldLayout = craft()->fields->getLayoutByType(ElementType::User);
if ($usersFieldLayout) {
Expand All @@ -346,24 +337,22 @@ protected function getConditionals()
// Solspace Calendar
$solspaceCalendarPlugin = craft()->plugins->getPlugin('calendar');
if ($solspaceCalendarPlugin && $solspaceCalendarPlugin->getDeveloper() === 'Solspace') {
$solspaceCalendarFieldLayout = craft()->fields->getLayoutByType('Calendar_Event');
if ($solspaceCalendarFieldLayout) {
$sources['solspaceCalendar'] = $solspaceCalendarFieldLayout->id;
// Before 1.7.0, Solspace Calendar used a single Field Layout for all calendars. Let's try and support both the old and the new
if (version_compare($solspaceCalendarPlugin->getVersion(), '1.7.0', '>=')) {
$solspaceCalendars = craft()->calendar_calendars->getAllCalendars();
if ($solspaceCalendars && is_array($solspaceCalendars) && !empty($solspaceCalendars)) {
foreach ($solspaceCalendars as $solspaceCalendar) {
$sources['solspaceCalendar:'.$solspaceCalendar->id] = $solspaceCalendar->fieldLayoutId;
}
}
} else {
$solspaceCalendarFieldLayout = craft()->fields->getLayoutByType('Calendar_Event');
if ($solspaceCalendarFieldLayout) {
$sources['solspaceCalendar'] = $solspaceCalendarFieldLayout->id;
}
}
}

// Commerce – TODO
// $commercePlugin = craft()->plugins->getPlugin('commerce');
// if ($commercePlugin && $commercePlugin->getDeveloper() === 'Pixel & Tonic') {
// // Product types
// $productTypes = craft()->commerce_productTypes->getAllProductTypes();
// if ($productTypes) {
// foreach ($productTypes as $productType) {
// $sources['commerceProductType:'.$productType->id] =
// }
// }
// }

// Get all conditionals
$conditionals = array();
$conditionalsRecords = Reasons_ConditionalsRecord::model()->findAll();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion reasons/resources/rev-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"javascripts/reasons.js": "javascripts/reasons-a08bbfa4180502815a4e.js",
"javascripts/reasons.js": "javascripts/reasons-557580bb0fb4a8808525.js",
"stylesheets/reasons.css": "stylesheets/reasons-8f9624f667.css"
}
18 changes: 13 additions & 5 deletions source/javascripts/reasons.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
USERS_HANDLE : 'users',
FIELDS_HANDLE : 'field',
SOLSPACE_CALENDAR_HANDLE : 'solspaceCalendar',
//COMMERCE_PRODUCT_TYPE_HANDLE : 'commerceProductType',

ASSET_SOURCE_ACTION : 'assetSources/saveSource',
CATEGORY_ACTION : 'categories/saveCategory',
Expand All @@ -33,9 +32,8 @@
USERS_FIELDS_ACTION : 'users/saveFieldLayout',
FIELDS_ACTION : 'fields/saveField',
SOLSPACE_CALENDAR_EVENTS_ACTION : 'calendar/events/saveEvent',
SOLSPACE_CALENDAR_SETTINGS_ACTION : 'calendar/settings/saveSettings',
// COMMERCE_PRODUCT_TYPE_ACTION : 'commerce/productTypes/saveProductType',
// COMMERCE_PRODUCT_ACTION : 'commerce/products/saveProduct',
SOLSPACE_CALENDAR_SETTINGS_ACTION: 'calendar/calendars/saveCalendar',
SOLSPACE_CALENDAR_LEGACY_SETTINGS_ACTION : 'calendar/settings/saveSettings', // Solspace Calendar < 1.7.0

RENDER_CONTEXT : 'render',
LAYOUT_DESIGNER_CONTEXT : 'fld',
Expand Down Expand Up @@ -259,9 +257,18 @@
idInputSelector = 'input[type="hidden"][name="fieldId"]';
break;

case this.SOLSPACE_CALENDAR_SETTINGS_ACTION :
case this.SOLSPACE_CALENDAR_LEGACY_SETTINGS_ACTION :
type = this.SOLSPACE_CALENDAR_HANDLE;
break;

case this.SOLSPACE_CALENDAR_EVENTS_ACTION :
type = this.SOLSPACE_CALENDAR_HANDLE;
idInputSelector = 'input[type="hidden"][name="calendarEvent[calendarId]"]';
break;

case this.SOLSPACE_CALENDAR_SETTINGS_ACTION :
type = this.SOLSPACE_CALENDAR_HANDLE;
idInputSelector = 'input[type="hidden"][name="calendarId"]';
break;

case this.COMMERCE_PRODUCT_TYPE_ACTION :
Expand Down Expand Up @@ -309,6 +316,7 @@
case this.ENTRY_TYPE_ACTION :
case this.TAG_GROUP_ACTION :
case this.USERS_FIELDS_ACTION :
case this.SOLSPACE_CALENDAR_LEGACY_SETTINGS_ACTION :
case this.SOLSPACE_CALENDAR_SETTINGS_ACTION :
case this.COMMERCE_PRODUCT_TYPE_ACTION :
return this.LAYOUT_DESIGNER_CONTEXT;
Expand Down

0 comments on commit e905397

Please sign in to comment.