Skip to content

Commit

Permalink
Merge pull request #1 from contao-thememanager/feature-rework
Browse files Browse the repository at this point in the history
Rework for ThemeManager v1.5.0
  • Loading branch information
zoglo committed Nov 22, 2022
2 parents 8767650 + 6c9f02e commit 6e68f1b
Show file tree
Hide file tree
Showing 75 changed files with 10,257 additions and 22,180 deletions.
95 changes: 50 additions & 45 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
{
"name":"contao-thememanager/ctm-estatemanager",
"type":"contao-bundle",
"description":"Estate manager integration for Contao Theme-Manager",
"keywords":["estate","theme"],
"homepage":"https://www.oveleon.de/",
"license":"MIT",
"authors":[
{
"name":"Oveleon",
"homepage":"https://oveleon.de/",
"role":"Developer"
}
],
"require":{
"php":"^5.6 || ^7.0 || ^8.0",
"contao/core-bundle":"^4.4",
"contao-estatemanager/core":"^1.0",
"contao-thememanager/core":"^1.4"
},
"require-dev": {
"contao/manager-plugin": "^2.0"
},
"conflict": {
"contao/core": "*",
"contao/core-bundle": "4.4.1",
"contao/manager-plugin": "<2.0 || >=3.0"
},
"autoload":{
"psr-4": {
"ContaoThemeManager\\EstateManager\\": "src/"
},
"classmap": [
"src/Resources/contao/"
"name": "contao-thememanager/ctm-estatemanager",
"type": "contao-bundle",
"description": "Estate manager integration for Contao Theme-Manager",
"keywords": ["estate","theme"],
"homepage": "https://www.oveleon.de/",
"license": "MIT",
"authors": [
{
"name": "Oveleon",
"homepage": "https://oveleon.de/",
"role": "Developer"
},
{
"name": "Daniele Sciannimanica",
"homepage": "https://github.com/doishub",
"role": "Developer"
}
],
"exclude-from-classmap": [
"src/Resources/contao/config/",
"src/Resources/contao/dca/",
"src/Resources/contao/languages/",
"src/Resources/contao/templates/"
]
},
"extra":{
"branch-alias": {
"dev-master": "1.0.x-dev"
"require": {
"php": "^7.4 || ^8.0",
"contao/core-bundle": "^4.13",
"contao-estatemanager/core": "^1.0 || ^2.0",
"contao-thememanager/core": "^1.5",
"oveleon/contao-component-style-manager": "^3.0"
},
"require-dev": {
"contao/manager-plugin": "^2.3.1"
},
"contao-manager-plugin": "ContaoThemeManager\\EstateManager\\ContaoManager\\Plugin"
}
"conflict": {
"contao/core": "*",
"contao/manager-plugin": "<2.0 || >=3.0"
},
"autoload": {
"psr-4": {
"ContaoThemeManager\\EstateManager\\": "src/"
},
"classmap": [
"contao/"
],
"exclude-from-classmap": [
"contao/config/",
"contao/dca/",
"contao/languages/",
"contao/templates/"
]
},
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
},
"contao-manager-plugin": "ContaoThemeManager\\EstateManager\\ContaoManager\\Plugin"
}
}
91 changes: 91 additions & 0 deletions contao/classes/EstateManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

declare(strict_types=1);

/*
* This file is part of Contao ThemeManager Contao EstateManager.
*
* @package ctm-estatemanager
* @license MIT
* @author Daniele Sciannimanica <https://github.com/doishub>
* @copyright Oveleon <https://www.oveleon.de/>
*/

namespace ContaoThemeManager\EstateManager;

use Contao\Model\Collection;
use Contao\StringUtil;
use Oveleon\ContaoComponentStyleManager\Model\StyleManagerModel;

class EstateManager
{
/**
* StyleManager Support
* Find published css groups using their table
*
* @return Collection|StyleManagerModel[]|StyleManagerModel|null A collection of models or null if there are no css groups
*/
public function onFindByTable($strTable, array $arrOptions)
{
switch ($strTable)
{
case 'tl_filter':
return StyleManagerModel::findBy(['extendRealEstateFilter=1'], null, $arrOptions);

case 'tl_filter_item':
return StyleManagerModel::findBy(['extendRealEstateFilterItem=1'], null, $arrOptions);

case 'tl_expose_module':
return StyleManagerModel::findBy(['extendRealEstateExposeModule=1'], null, $arrOptions);
}

return null;
}

/**
* StyleManager Support
* If the field has not been selected, it is skipped
*/
public function onSkipField($objStyleGroups, $objWidget): bool
{
if (!!$objStyleGroups->extendRealEstateFilterItem && 'tl_filter_item' === $objWidget->strTable)
{
$arrFilterItems = StringUtil::deserialize($objStyleGroups->realEstateFilterItems);

if (null !== $arrFilterItems && !in_array($objWidget->activeRecord->type, $arrFilterItems))
{
return true;
}
}

if (!!$objStyleGroups->extendRealEstateExposeModule && 'tl_expose_module' === $objWidget->strTable)
{
$arrModules = StringUtil::deserialize($objStyleGroups->realEstateExposeModules);

if (null !== $arrModules && !in_array($objWidget->activeRecord->type, $arrModules))
{
return true;
}
}

return false;
}

/**
* StyleManager Support
* Check whether an element is visible in style manager widget
*/
public function isVisibleGroup($objGroup, $strTable): bool
{
if (
'tl_filter_item' === $strTable && !!$objGroup->extendRealEstateFilterItem ||
'tl_filter' === $strTable && !!$objGroup->extendRealEstateFilter ||
'tl_expose_module' === $strTable && !!$objGroup->extendRealEstateExposeModule
)
{
return true;
}

return false;
}
}
21 changes: 21 additions & 0 deletions contao/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

/*
* This file is part of Contao ThemeManager Contao EstateManager.
*
* @package ctm-estatemanager
* @license MIT
* @author Daniele Sciannimanica <https://github.com/doishub>
* @copyright Oveleon <https://www.oveleon.de/>
*/

// Add SCSS sources
$GLOBALS['TC_SOURCES']['configFiles'][] = 'bundles/contaothememanagerestatemanager/framework/scss/_config.scss';
$GLOBALS['TC_SOURCES']['files'][] = 'bundles/contaothememanagerestatemanager/framework/scss/_realestate.scss';

// Add HOOK
$GLOBALS['TL_HOOKS']['styleManagerFindByTable'][] = ['ContaoThemeManager\EstateManager\EstateManager', 'onFindByTable'];
$GLOBALS['TL_HOOKS']['styleManagerSkipField'][] = ['ContaoThemeManager\EstateManager\EstateManager', 'onSkipField'];
$GLOBALS['TL_HOOKS']['styleManagerIsVisibleGroup'][] = ['ContaoThemeManager\EstateManager\EstateManager', 'isVisibleGroup'];
78 changes: 78 additions & 0 deletions contao/dca/tl_expose_module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

declare(strict_types=1);

/*
* This file is part of Contao ThemeManager Contao EstateManager.
*
* @package ctm-estatemanager
* @license MIT
* @author Daniele Sciannimanica <https://github.com/doishub>
* @copyright Oveleon <https://www.oveleon.de/>
*/

// Extend the regular palette
use Contao\CoreBundle\DataContainer\PaletteManipulator;

$palette = PaletteManipulator::create()
->addLegend('style_manager_legend', 'expert_legend', PaletteManipulator::POSITION_BEFORE)
->addField(['styleManager'], 'style_manager_legend', PaletteManipulator::POSITION_APPEND);

foreach ($GLOBALS['TL_DCA']['tl_expose_module']['palettes'] as $key => $value)
{

if ($key === '__selector__' || $key === 'default' || $key === 'html')
{
continue;
}

$palette->applyToPalette($key, 'tl_expose_module');
}

// Adding more headline options
$GLOBALS['TL_DCA']['tl_expose_module']['fields']['headline']['options'] = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div'];

// Extend fields
$GLOBALS['TL_DCA']['tl_expose_module']['fields']['styleManager'] = [
'label' => &$GLOBALS['TL_LANG']['tl_form_field']['styleManager'],
'exclude' => true,
'inputType' => 'stylemanager',
'eval' => ['tl_class'=>'clr stylemanager'],
'sql' => "blob NULL"
];

$GLOBALS['TL_DCA']['tl_expose_module']['fields']['headlineStyle'] = [
'label' => &$GLOBALS['TL_LANG']['tl_expose_module']['headlineStyle'],
'exclude' => true,
'inputType' => 'select',
'options' => ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
'eval' => ['includeBlankOption'=>true, 'tl_class'=>'w50'],
'sql' => "varchar(2) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_expose_module']['fields']['headline2'] = [
'label' => &$GLOBALS['TL_LANG']['tl_expose_module']['headline2'],
'exclude' => true,
'search' => true,
'inputType' => 'inputUnit',
'options' => ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div'],
'eval' => ['tl_class'=>'w50 clr'],
'sql' => "mediumtext NULL"
];

$GLOBALS['TL_DCA']['tl_expose_module']['fields']['headline2Style'] = [
'label' => &$GLOBALS['TL_LANG']['tl_expose_module']['headline2Style'],
'exclude' => true,
'inputType' => 'select',
'options' => ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
'eval' => ['includeBlankOption'=>true, 'tl_class'=>'w50'],
'sql' => "varchar(2) NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_expose_module']['fields']['cssID']['sql'] = "text NULL";
$GLOBALS['TL_DCA']['tl_expose_module']['fields']['cssID']['eval']['alwaysSave'] = true;

$GLOBALS['TL_DCA']['tl_expose_module']['config']['onload_callback'][] = ['ContaoThemeManager\Core\ThemeManager', 'extendHeadlineField'];

$GLOBALS['TL_DCA']['tl_expose_module']['fields']['cssID']['load_callback'][] = ['Oveleon\ContaoComponentStyleManager\StyleManager\StyleManager', 'onLoad'];
$GLOBALS['TL_DCA']['tl_expose_module']['fields']['cssID']['save_callback'][] = ['Oveleon\ContaoComponentStyleManager\StyleManager\StyleManager', 'onSave'];
35 changes: 35 additions & 0 deletions contao/dca/tl_filter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/*
* This file is part of Contao ThemeManager Contao EstateManager.
*
* @package ctm-estatemanager
* @license MIT
* @author Daniele Sciannimanica <https://github.com/doishub>
* @copyright Oveleon <https://www.oveleon.de/>
*/

// Extend the regular palette
use Contao\CoreBundle\DataContainer\PaletteManipulator;

$palette = PaletteManipulator::create()
->addLegend('style_manager_legend', 'expert_legend', PaletteManipulator::POSITION_BEFORE)
->addField(['styleManager'], 'style_manager_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_filter');

// Extend fields
$GLOBALS['TL_DCA']['tl_filter']['fields']['styleManager'] = [
'label' => &$GLOBALS['TL_LANG']['tl_filter']['styleManager'],
'exclude' => true,
'inputType' => 'stylemanager',
'eval' => ['tl_class'=>'clr stylemanager'],
'sql' => "blob NULL"
];

$GLOBALS['TL_DCA']['tl_filter']['fields']['cssID']['sql'] = "text NULL";
$GLOBALS['TL_DCA']['tl_filter']['fields']['cssID']['eval']['alwaysSave'] = true;

$GLOBALS['TL_DCA']['tl_filter']['fields']['attributes']['load_callback'][] = ['Oveleon\ContaoComponentStyleManager\StyleManager\StyleManager', 'onLoad'];
$GLOBALS['TL_DCA']['tl_filter']['fields']['attributes']['save_callback'][] = ['Oveleon\ContaoComponentStyleManager\StyleManager\StyleManager', 'onSave'];
44 changes: 44 additions & 0 deletions contao/dca/tl_filter_item.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/*
* This file is part of Contao ThemeManager Contao EstateManager.
*
* @package ctm-estatemanager
* @license MIT
* @author Daniele Sciannimanica <https://github.com/doishub>
* @copyright Oveleon <https://www.oveleon.de/>
*/

// Extend the regular palette
use Contao\CoreBundle\DataContainer\PaletteManipulator;

$palette = PaletteManipulator::create()
->addLegend('style_manager_legend', 'expert_legend', PaletteManipulator::POSITION_BEFORE)
->addField(['styleManager'], 'style_manager_legend', PaletteManipulator::POSITION_APPEND);

foreach ($GLOBALS['TL_DCA']['tl_filter_item']['palettes'] as $key=>$value)
{
if ($key === '__selector__')
{
continue;
}

$palette->applyToPalette($key, 'tl_filter_item');
}

// Extend fields
$GLOBALS['TL_DCA']['tl_filter_item']['fields']['styleManager'] = [
'label' => &$GLOBALS['TL_LANG']['tl_form_field']['styleManager'],
'exclude' => true,
'inputType' => 'stylemanager',
'eval' => ['tl_class'=>'clr stylemanager'],
'sql' => "blob NULL"
];

$GLOBALS['TL_DCA']['tl_filter_item']['fields']['cssID']['sql'] = "text NULL";
$GLOBALS['TL_DCA']['tl_filter_item']['fields']['cssID']['eval']['alwaysSave'] = true;

$GLOBALS['TL_DCA']['tl_filter_item']['fields']['class']['load_callback'][] = ['Oveleon\ContaoComponentStyleManager\StyleManager\StyleManager', 'onLoad'];
$GLOBALS['TL_DCA']['tl_filter_item']['fields']['class']['save_callback'][] = ['Oveleon\ContaoComponentStyleManager\StyleManager\StyleManager', 'onSave'];
Loading

0 comments on commit 6e68f1b

Please sign in to comment.