diff --git a/README.md b/README.md new file mode 100644 index 0000000..1cb83e3 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Contao Component Style Manager diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..90cd96f --- /dev/null +++ b/composer.json @@ -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" + } +} \ No newline at end of file diff --git a/src/ContaoComponentStyleManager.php b/src/ContaoComponentStyleManager.php new file mode 100644 index 0000000..715b16d --- /dev/null +++ b/src/ContaoComponentStyleManager.php @@ -0,0 +1,17 @@ +setLoadAfter([ContaoCoreBundle::class]) + ->setReplace(['componentStyleManager']), + ]; + } +} diff --git a/src/Resources/contao/classes/StyleManager.php b/src/Resources/contao/classes/StyleManager.php new file mode 100644 index 0000000..9d227db --- /dev/null +++ b/src/Resources/contao/classes/StyleManager.php @@ -0,0 +1,48 @@ +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; + } + } +} \ No newline at end of file diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php new file mode 100644 index 0000000..3b6eb08 --- /dev/null +++ b/src/Resources/contao/config/config.php @@ -0,0 +1,38 @@ + 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'; +} \ No newline at end of file diff --git a/src/Resources/contao/dca/tl_article.php b/src/Resources/contao/dca/tl_article.php new file mode 100644 index 0000000..8eeb415 --- /dev/null +++ b/src/Resources/contao/dca/tl_article.php @@ -0,0 +1,87 @@ +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 + */ +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; + } +} \ No newline at end of file diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php new file mode 100644 index 0000000..f635d8a --- /dev/null +++ b/src/Resources/contao/dca/tl_content.php @@ -0,0 +1,95 @@ +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 + */ +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; + } +} \ No newline at end of file diff --git a/src/Resources/contao/dca/tl_page.php b/src/Resources/contao/dca/tl_page.php new file mode 100644 index 0000000..2d6d687 --- /dev/null +++ b/src/Resources/contao/dca/tl_page.php @@ -0,0 +1,87 @@ +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('regular', 'tl_page'); + +// Extend fields +array_insert($GLOBALS['TL_DCA']['tl_page']['fields'], 0, array +( + 'styleManager' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_page']['styleManager'], + 'exclude' => true, + 'inputType' => 'stylemanager', + 'onload_callback' => array + ( + array('tl_style_manager_page', 'checkPermission') + ), + 'save_callback' => array + ( + array('tl_style_manager_page', 'updateStyleManager') + ), + 'eval' => array('tl_class'=>'clr stylemanager'), + 'sql' => "blob NULL" + ), + 'styleManagerCompiled' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_page']['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 + */ +class tl_style_manager_page 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_page SET styleManagerCompiled=? WHERE id=?") + ->execute(implode(' ', $varValues), $dc->id); + + return $varValue; + } +} \ No newline at end of file diff --git a/src/Resources/contao/dca/tl_style_manager.php b/src/Resources/contao/dca/tl_style_manager.php new file mode 100644 index 0000000..50f092f --- /dev/null +++ b/src/Resources/contao/dca/tl_style_manager.php @@ -0,0 +1,286 @@ + array + ( + 'dataContainer' => 'Table', + 'switchToEdit' => true, + 'enableVersioning' => true, + 'markAsCopy' => 'title', + 'onload_callback' => array + ( + array('tl_style_manager', 'checkPermission') + ), + 'sql' => array + ( + 'keys' => array + ( + 'id' => 'primary' + ) + ) + ), + + // List + 'list' => array + ( + 'sorting' => array + ( + 'mode' => 1, + 'fields' => array('title'), + 'flag' => 1, + 'panelLayout' => 'filter;search,limit' + ), + 'label' => array + ( + 'fields' => array('title'), + 'format' => '%s' + ), + 'global_operations' => array + ( + 'all' => array + ( + 'label' => &$GLOBALS['TL_LANG']['MSC']['all'], + 'href' => 'act=select', + 'class' => 'header_edit_all', + 'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="e"' + ) + ), + 'operations' => array + ( + 'editheader' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['editheader'], + 'href' => 'act=edit', + 'icon' => 'edit.svg', + 'button_callback' => array('tl_style_manager', 'editHeader') + ), + 'copy' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['copy'], + 'href' => 'act=copy', + 'icon' => 'copy.svg', + 'button_callback' => array('tl_style_manager', 'copy') + ), + 'delete' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['delete'], + 'href' => 'act=delete', + 'icon' => 'delete.svg', + 'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"', + 'button_callback' => array('tl_style_manager', 'delete') + ), + 'show' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['show'], + 'href' => 'act=show', + 'icon' => 'show.svg' + ) + ) + ), + + // Palettes + 'palettes' => array + ( + 'default' => '{title_legend},title,description,alias;{config_legend},cssClasses;{publish_legend},extendPage,extendArticle,extendContentElement;' + ), + + // Fields + 'fields' => array + ( + 'id' => array + ( + 'sql' => "int(10) unsigned NOT NULL auto_increment" + ), + 'tstamp' => array + ( + 'sql' => "int(10) unsigned NOT NULL default '0'" + ), + 'alias' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['alias'], + 'exclude' => true, + 'search' => true, + 'inputType' => 'text', + 'eval' => array('rgxp'=>'folderalias', 'doNotCopy'=>true, 'maxlength'=>128, 'tl_class'=>'w50'), + 'save_callback' => array + ( + array('tl_style_manager', 'generateAlias') + ), + 'sql' => "varchar(255) COLLATE utf8_bin NOT NULL default ''" + ), + 'title' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['title'], + 'exclude' => true, + 'search' => true, + 'inputType' => 'text', + 'eval' => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'w50'), + 'sql' => "varchar(255) NOT NULL default ''" + ), + 'description' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['description'], + 'inputType' => 'text', + 'eval' => array('maxlength'=>255, 'tl_class'=>'w50'), + 'sql' => "varchar(255) NOT NULL default ''" + ), + 'cssClasses' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['cssClasses'], + 'exclude' => true, + 'inputType' => 'listWizard', + 'eval' => array('allowHtml'=>true, 'tl_class'=>'clr'), + 'sql' => "blob NULL" + ), + 'extendPage' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['extendPage'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class'=>'w50 m12 clr'), + 'sql' => "char(1) NOT NULL default ''" + ), + 'extendArticle' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['extendArticle'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class'=>'w50 m12 clr'), + 'sql' => "char(1) NOT NULL default ''" + ), + 'extendContentElement' => array + ( + 'label' => &$GLOBALS['TL_LANG']['tl_style_manager']['extendContentElement'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class'=>'w50 m12 clr'), + 'sql' => "char(1) NOT NULL default ''" + ), + ) +); + + +/** + * Provide miscellaneous methods that are used by the data configuration array. + * + * @author Daniele Sciannimanica + */ +class tl_style_manager 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; + } + + /** + * Return the edit header button + * + * @param array $row + * @param string $href + * @param string $label + * @param string $title + * @param string $icon + * @param string $attributes + * + * @return string + */ + public function editHeader($row, $href, $label, $title, $icon, $attributes) + { + return $this->User->canEditFieldsOf('tl_style_manager') ? ''.Image::getHtml($icon, $label).' ' : Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' '; + } + + /** + * Return the copy group button + * + * @param array $row + * @param string $href + * @param string $label + * @param string $title + * @param string $icon + * @param string $attributes + * + * @return string + */ + public function copy($row, $href, $label, $title, $icon, $attributes) + { + return $this->User->hasAccess('create', 'tl_style_manager') ? ''.Image::getHtml($icon, $label).' ' : Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' '; + } + + /** + * Return the delete group button + * + * @param array $row + * @param string $href + * @param string $label + * @param string $title + * @param string $icon + * @param string $attributes + * + * @return string + */ + public function delete($row, $href, $label, $title, $icon, $attributes) + { + return $this->User->hasAccess('delete', 'tl_style_manager') ? ''.Image::getHtml($icon, $label).' ' : Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' '; + } + + /** + * Auto-generate the news alias if it has not been set yet + * + * @param mixed $varValue + * @param \DataContainer $dc + * + * @return string + * + * @throws Exception + */ + public function generateAlias($varValue, \DataContainer $dc) + { + $autoAlias = false; + + // Generate alias if there is none + if ($varValue == '') + { + $autoAlias = true; + $varValue = \StringUtil::generateAlias($dc->activeRecord->title); + } + + $objAlias = $this->Database->prepare("SELECT id FROM tl_style_manager WHERE alias=? AND id!=?") + ->execute($varValue, $dc->id); + + // Check whether the styles alias exists + if ($objAlias->numRows) + { + if (!$autoAlias) + { + throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue)); + } + + $varValue .= '-' . $dc->id; + } + + return $varValue; + } +} diff --git a/src/Resources/contao/languages/de/modules.xlf b/src/Resources/contao/languages/de/modules.xlf new file mode 100644 index 0000000..032f39c --- /dev/null +++ b/src/Resources/contao/languages/de/modules.xlf @@ -0,0 +1,15 @@ + + + + + + Style Manager + Style Manager + + + Manage styles and CSS-Classes + Styles und CSS-Klasse verwalten + + + + \ No newline at end of file diff --git a/src/Resources/contao/languages/de/tl_article.xlf b/src/Resources/contao/languages/de/tl_article.xlf new file mode 100644 index 0000000..099d919 --- /dev/null +++ b/src/Resources/contao/languages/de/tl_article.xlf @@ -0,0 +1,11 @@ + + + + + + Style Manager + Style Manager + + + + \ No newline at end of file diff --git a/src/Resources/contao/languages/de/tl_content.xlf b/src/Resources/contao/languages/de/tl_content.xlf new file mode 100644 index 0000000..6248a17 --- /dev/null +++ b/src/Resources/contao/languages/de/tl_content.xlf @@ -0,0 +1,11 @@ + + + + + + Style Manager + Style Manager + + + + \ No newline at end of file diff --git a/src/Resources/contao/languages/de/tl_page.xlf b/src/Resources/contao/languages/de/tl_page.xlf new file mode 100644 index 0000000..cdd330d --- /dev/null +++ b/src/Resources/contao/languages/de/tl_page.xlf @@ -0,0 +1,11 @@ + + + + + + Style Manager + Style Manager + + + + \ No newline at end of file diff --git a/src/Resources/contao/languages/de/tl_style_manager.xlf b/src/Resources/contao/languages/de/tl_style_manager.xlf new file mode 100644 index 0000000..dd73a90 --- /dev/null +++ b/src/Resources/contao/languages/de/tl_style_manager.xlf @@ -0,0 +1,97 @@ + + + + + + Title + Titel + + + Configuration + Konfiguration + + + Publishing + Veröffentlichung + + + + Add group + Neue Gruppe + + + Edit Group + Gruppe bearbeiten + + + Copy Group + Gruppe kopieren + + + Delete Group + Gruppe löschen + + + Show Group info + Gruppeinformationen anzeigen + + + + Title + Titel + + + Title or group name of the statements + Titel oder Gruppenname der Anweisungen + + + Description + Beschreibung + + + Enter a field description here + Geben Sie hier eine Feldbeschreibung an + + + Alias + Alias + + + + + + + CSS-Classes + CSS-Klassen + + + Define the available CSS classes in this group. + Definieren Sie hier die in dieser Gruppe vorhandenen CSS-Klassen. + + + Publish for Pages + Für Seiten veröffentlichen + + + Provides the CSS classes in pages + Stellt die CSS-Klassen in Seiten zur Verfügung + + + Publish for Articles + Für Artikel veröffentlichen + + + Provides the CSS classes in articles + Stellt die CSS-Klassen in Artikel zur Verfügung + + + Publish for Content-Elements + Für Content-Elemente veröffentlichen + + + Provides the CSS classes in content elements + Stellt die CSS-Klassen in Content-Elementen zur Verfügung + + + + \ No newline at end of file diff --git a/src/Resources/contao/models/StyleManagerModel.php b/src/Resources/contao/models/StyleManagerModel.php new file mode 100644 index 0000000..5e6d70c --- /dev/null +++ b/src/Resources/contao/models/StyleManagerModel.php @@ -0,0 +1,83 @@ + + */ + +class StyleManagerModel extends \Model +{ + + /** + * Table name + * @var string + */ + protected static $strTable = 'tl_style_manager'; + + /** + * Find published news items by their parent ID + * + * @param integer $intId The news archive ID + * @param integer $intLimit An optional limit + * @param array $arrOptions An optional options array + * + * @return \Model\Collection|StyleManagerModel[]|StyleManagerModel|null A collection of models or null if there are no news + */ + public static function findByTable($strTable, array $arrOptions=array()) + { + $t = static::$strTable; + + switch ($strTable) + { + case 'tl_page': + return static::findByExtendPage(1, $arrOptions); + case 'tl_article': + return static::findByExtendArticle(1, $arrOptions); + case 'tl_content': + return static::findByExtendContentElement(1, $arrOptions); + default: + return null; + } + } +} diff --git a/src/Resources/contao/widgets/ComponentStyleSelect.php b/src/Resources/contao/widgets/ComponentStyleSelect.php new file mode 100644 index 0000000..42cae7f --- /dev/null +++ b/src/Resources/contao/widgets/ComponentStyleSelect.php @@ -0,0 +1,111 @@ + + */ +class ComponentStyleSelect extends \Widget +{ + + /** + * Submit user input + * @var boolean + */ + protected $blnSubmitInput = true; + + /** + * Template + * @var string + */ + protected $strTemplate = 'be_widget'; + + /** + * Generate the widget and return it as string + * + * @return string + */ + public function generate() + { + $arrFields = array(); + $strClass = 'tl_select'; + $objStyleGroups = StyleManagerModel::findByTable($this->strTable); + + if($objStyleGroups === null) + { + return ''; + } + + while($objStyleGroups->next()) + { + $arrFieldOptions = array(array('value'=>'', 'label'=>'-')); + $arrOptions = array(); + $opts = \StringUtil::deserialize($objStyleGroups->cssClasses); + + foreach ($opts as $opt) { + $arrFieldOptions[] = array( + 'label' => $opt, + 'value' => $opt + ); + } + + $strFieldId = $this->strId . '_' . $objStyleGroups->alias; + $strFieldName = $this->strName . '[' . $objStyleGroups->alias . ']'; + + foreach ($arrFieldOptions as $strKey=>$arrOption) + { + if (isset($arrOption['value'])) + { + $arrOptions[] = sprintf('', + \StringUtil::specialchars($arrOption['value']), + $this->isSelected($arrOption), + $arrOption['label']); + } + else + { + $arrOptgroups = array(); + + foreach ($arrOption as $arrOptgroup) + { + $arrOptgroups[] = sprintf('', + \StringUtil::specialchars($arrOptgroup['value']), + $this->isSelected($arrOptgroup), + $arrOptgroup['label']); + } + + $arrOptions[] = sprintf('%s', \StringUtil::specialchars($strKey), implode('', $arrOptgroups)); + } + } + + // Add Chosen + $strClass .= ' tl_chosen'; + + $arrFields[] = sprintf('%s%s%s', + '

', + $strFieldName, + $strFieldId, + $strClass, + (($this->strClass != '') ? ' ' . $this->strClass : ''), + $this->getAttributes(), + implode('', $arrOptions), + $this->wizard, + '

'.$objStyleGroups->description.'

' + ); + } + + return implode("",$arrFields); + } +} diff --git a/src/Resources/public/stylemanager.scss b/src/Resources/public/stylemanager.scss new file mode 100644 index 0000000..d4528d5 --- /dev/null +++ b/src/Resources/public/stylemanager.scss @@ -0,0 +1,25 @@ +.widget{ + + &.stylemanager{ + width: 100%; + margin-left: 0; + margin-right: 0; + clear: both; + + > h3{ + display: none; + } + + > div{ + width: calc(50% - 30px); + float: left; + margin-left: 15px; + margin-right: 15px; + min-height: 80px; + } + + .tl_help{ + font-size: .75rem; + } + } +} \ No newline at end of file