-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,099 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Contao Component Style Manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name":"oveleon/contao-component-style-manager", | ||
"type":"contao-bundle", | ||
"description":"Style and CSS-Class Manager for Contao Open Source CMS", | ||
"keywords":["contao","styles","css","manager"], | ||
"homepage":"https://www.oveleon.de/", | ||
"license":"MIT", | ||
"authors":[ | ||
{ | ||
"name":"Oveleon", | ||
"homepage":"https://oveleon.de/", | ||
"role":"Developer" | ||
} | ||
], | ||
"require":{ | ||
"php":"^5.6 || ^7.0", | ||
"contao/core-bundle":"^4.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": { | ||
"Oveleon\\ContaoComponentStyleManager\\": "src/" | ||
}, | ||
"classmap": [ | ||
"src/Resources/contao/" | ||
], | ||
"exclude-from-classmap": [ | ||
"src/Resources/contao/config/", | ||
"src/Resources/contao/dca/", | ||
"src/Resources/contao/languages/", | ||
"src/Resources/contao/templates/" | ||
] | ||
}, | ||
"extra":{ | ||
"contao-manager-plugin": "Oveleon\\ContaoComponentStyleManager\\ContaoManager\\Plugin" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of ContaoComponentStyleManager. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoComponentStyleManager; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class ContaoComponentStyleManager extends Bundle | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of ContaoComponentStyleManager. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoComponentStyleManager\ContaoManager; | ||
|
||
use Contao\CoreBundle\ContaoCoreBundle; | ||
use Contao\ManagerPlugin\Bundle\BundlePluginInterface; | ||
use Contao\ManagerPlugin\Bundle\Config\BundleConfig; | ||
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; | ||
use Oveleon\ContaoComponentStyleManager\ContaoComponentStyleManager; | ||
|
||
class Plugin implements BundlePluginInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBundles(ParserInterface $parser): array | ||
{ | ||
return [ | ||
BundleConfig::create(ContaoComponentStyleManager::class) | ||
->setLoadAfter([ContaoCoreBundle::class]) | ||
->setReplace(['componentStyleManager']), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/* | ||
* This file is part of ContaoComponentStyleManager. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoComponentStyleManager; | ||
|
||
class StyleManager | ||
{ | ||
/** | ||
* Add CSS-Class (fe_page) | ||
* | ||
* @param $objPage | ||
* @param $objLayout | ||
* @param $objPageRegular | ||
*/ | ||
public function generatePage($objPage, $objLayout, $objPageRegular) | ||
{ | ||
$objPage->cssClass = $objPage->cssClass ? $objPage->cssClass . ' ' . $objPage->styleManagerCompiled : $objPage->styleManagerCompiled; | ||
} | ||
|
||
/** | ||
* Add CSS-Class (mod_article) | ||
* | ||
* @param $objRow | ||
*/ | ||
public function getArticle($objRow) | ||
{ | ||
$arrCSS = \StringUtil::deserialize($objRow->cssID, true); | ||
$arrCSS[1] = trim($arrCSS[1] . ' ' . $objRow->styleManagerCompiled); | ||
$objRow->cssID = serialize($arrCSS); | ||
} | ||
|
||
/** | ||
* Add CSS-Class (ce_) | ||
* | ||
* @param $objTemplate | ||
*/ | ||
public function parseTemplate($objTemplate) | ||
{ | ||
if(isset($objTemplate->typePrefix) && $objTemplate->typePrefix === 'ce_' && $objTemplate->styleManagerCompiled) | ||
{ | ||
$objTemplate->class .= ' ' . $objTemplate->styleManagerCompiled; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/* | ||
* This file is part of ContaoComponentStyleManager. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
// Back end modules | ||
array_insert($GLOBALS['BE_MOD'], count($GLOBALS['BE_MOD']['design']), array | ||
( | ||
'design' => array | ||
( | ||
'style_manager' => array | ||
( | ||
'tables' => array('tl_style_manager') | ||
), | ||
) | ||
)); | ||
|
||
// Back end form fields | ||
array_insert($GLOBALS['BE_FFL'], 1, array | ||
( | ||
'stylemanager' => '\\Oveleon\\ContaoComponentStyleManager\\ComponentStyleSelect' | ||
)); | ||
|
||
// Models | ||
$GLOBALS['TL_MODELS']['tl_style_manager'] = '\\Oveleon\\ContaoComponentStyleManager\\StyleManagerModel'; | ||
|
||
// Hooks | ||
$GLOBALS['TL_HOOKS']['generatePage'][] = array('\\Oveleon\\ContaoComponentStyleManager\\StyleManager', 'generatePage'); | ||
$GLOBALS['TL_HOOKS']['getArticle'][] = array('\\Oveleon\\ContaoComponentStyleManager\\StyleManager', 'getArticle'); | ||
$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('\\Oveleon\\ContaoComponentStyleManager\\StyleManager', 'parseTemplate'); | ||
|
||
// Style sheet | ||
if (TL_MODE == 'BE') | ||
{ | ||
$GLOBALS['TL_CSS'][] = 'bundles/contaocomponentstylemanager/stylemanager.css|static'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/* | ||
* This file is part of ContaoComponentStyleManager. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
// Extend the regular palette | ||
$palette = Contao\CoreBundle\DataContainer\PaletteManipulator::create() | ||
->addLegend('style_manager_legend', 'expert_legend', Contao\CoreBundle\DataContainer\PaletteManipulator::POSITION_BEFORE) | ||
->addField(array('styleManager'), 'style_manager_legend', Contao\CoreBundle\DataContainer\PaletteManipulator::POSITION_APPEND) | ||
->applyToPalette('default', 'tl_article'); | ||
|
||
// Extend fields | ||
array_insert($GLOBALS['TL_DCA']['tl_article']['fields'], 0, array | ||
( | ||
'styleManager' => array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_article']['styleManager'], | ||
'exclude' => true, | ||
'inputType' => 'stylemanager', | ||
'onload_callback' => array | ||
( | ||
array('tl_style_manager_article', 'checkPermission') | ||
), | ||
'save_callback' => array | ||
( | ||
array('tl_style_manager_article', 'updateStyleManager') | ||
), | ||
'eval' => array('tl_class'=>'clr stylemanager'), | ||
'sql' => "blob NULL" | ||
), | ||
'styleManagerCompiled' => array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_article']['styleManagerCompiled'], | ||
'exclude' => true, | ||
'inputType' => 'text', | ||
'sql' => "varchar(255) NOT NULL default ''" | ||
) | ||
)); | ||
|
||
/** | ||
* Provide miscellaneous methods that are used by the data configuration array. | ||
* | ||
* @author Daniele Sciannimanica <[email protected]> | ||
*/ | ||
class tl_style_manager_article extends \Backend | ||
{ | ||
/** | ||
* Import the back end user object | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->import('BackendUser', 'User'); | ||
} | ||
|
||
/** | ||
* Check permissions to edit table tl_real_estate_group | ||
* | ||
* @throws Contao\CoreBundle\Exception\AccessDeniedException | ||
*/ | ||
public function checkPermission() | ||
{ | ||
return; | ||
} | ||
|
||
/** | ||
* Update StyleManager compiled-Field | ||
* | ||
* @param mixed $varValue | ||
* @param DataContainer $dc | ||
* | ||
* @return mixed | ||
*/ | ||
public function updateStyleManager($varValue, DataContainer $dc) | ||
{ | ||
$varValues = \StringUtil::deserialize($varValue, true); | ||
$varValues = array_filter($varValues); | ||
|
||
// Store the new classes | ||
$this->Database->prepare("UPDATE tl_article SET styleManagerCompiled=? WHERE id=?") | ||
->execute(implode(' ', $varValues), $dc->id); | ||
|
||
return $varValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/* | ||
* This file is part of ContaoComponentStyleManager. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
// Extend the regular palette | ||
$palette = Contao\CoreBundle\DataContainer\PaletteManipulator::create() | ||
->addLegend('style_manager_legend', 'expert_legend', Contao\CoreBundle\DataContainer\PaletteManipulator::POSITION_BEFORE) | ||
->addField(array('styleManager'), 'style_manager_legend', Contao\CoreBundle\DataContainer\PaletteManipulator::POSITION_APPEND); | ||
|
||
foreach ($GLOBALS['TL_DCA']['tl_content']['palettes'] as $key=>$value){ | ||
if($key === '__selector__') | ||
{ | ||
continue; | ||
} | ||
|
||
$palette->applyToPalette($key, 'tl_content'); | ||
} | ||
|
||
// Extend fields | ||
array_insert($GLOBALS['TL_DCA']['tl_content']['fields'], 0, array | ||
( | ||
'styleManager' => array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_article']['styleManager'], | ||
'exclude' => true, | ||
'inputType' => 'stylemanager', | ||
'onload_callback' => array | ||
( | ||
array('tl_style_manager_content', 'checkPermission') | ||
), | ||
'save_callback' => array | ||
( | ||
array('tl_style_manager_content', 'updateStyleManager') | ||
), | ||
'eval' => array('tl_class'=>'clr stylemanager'), | ||
'sql' => "blob NULL" | ||
), | ||
'styleManagerCompiled' => array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_article']['styleManagerCompiled'], | ||
'exclude' => true, | ||
'inputType' => 'text', | ||
'sql' => "varchar(255) NOT NULL default ''" | ||
) | ||
)); | ||
|
||
/** | ||
* Provide miscellaneous methods that are used by the data configuration array. | ||
* | ||
* @author Daniele Sciannimanica <[email protected]> | ||
*/ | ||
class tl_style_manager_content extends \Backend | ||
{ | ||
/** | ||
* Import the back end user object | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->import('BackendUser', 'User'); | ||
} | ||
|
||
/** | ||
* Check permissions to edit table tl_real_estate_group | ||
* | ||
* @throws Contao\CoreBundle\Exception\AccessDeniedException | ||
*/ | ||
public function checkPermission() | ||
{ | ||
return; | ||
} | ||
|
||
/** | ||
* Update StyleManager compiled-Field | ||
* | ||
* @param mixed $varValue | ||
* @param DataContainer $dc | ||
* | ||
* @return mixed | ||
*/ | ||
public function updateStyleManager($varValue, DataContainer $dc) | ||
{ | ||
$varValues = \StringUtil::deserialize($varValue, true); | ||
$varValues = array_filter($varValues); | ||
|
||
// Store the new classes | ||
$this->Database->prepare("UPDATE tl_content SET styleManagerCompiled=? WHERE id=?") | ||
->execute(implode(' ', $varValues), $dc->id); | ||
|
||
return $varValue; | ||
} | ||
} |
Oops, something went wrong.