diff --git a/library/templates/Intonation/Library/FormCustomizer.php b/library/templates/Intonation/Library/FormCustomizer.php new file mode 100644 index 0000000000000000000000000000000000000000..70f95ea6c7c1414a29ef2e70252b5ae36e98a8d5 --- /dev/null +++ b/library/templates/Intonation/Library/FormCustomizer.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_FormCustomizer { + protected $_template; + + + public function __construct($template) { + $this->_template = $template; + } + + + public function getWidgetForm($form) { + if (!$strategy = $this->_getStrategyFor($form)) + return (new Intonation_Library_FormCustomizer_Widget_Default($this->_template, + $form)) + ->getForm(); + + $class = 'Intonation_Library_FormCustomizer_Widget_' . $strategy; + return (new $class($this->_template, $form))->getForm(); + } + + + public function getSectionForm($form) { + return (new Intonation_Library_FormCustomizer_Section($this->_template, $form))->getForm(); + } + + + public function getTemplateForm($form) { + return (new Intonation_Library_FormCustomizer_Template($this->_template, $form))->getForm(); + } + + + protected function _getStrategyFor($form) { + $strategies = ['ZendAfi_Form_Configuration_Widget_Login' => 'FormStyle', + 'ZendAfi_Form_Configuration_Widget_Search' => 'FormStyle']; + + if (!in_array(get_class($form), array_keys($strategies))) + return false; + + return $strategies[get_class($form)]; + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Form/Helper.php b/library/templates/Intonation/Library/FormCustomizer/Abstract.php similarity index 63% rename from library/templates/Intonation/Form/Helper.php rename to library/templates/Intonation/Library/FormCustomizer/Abstract.php index 6fef26b3fda3f5c916686bf948d6a4220244a2ba..58e52d65efccb69da564b891b2ba9d362bdb89c9 100644 --- a/library/templates/Intonation/Form/Helper.php +++ b/library/templates/Intonation/Library/FormCustomizer/Abstract.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. * * BOKEH is free software; you can redistribute it and/or modify * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by @@ -20,55 +20,17 @@ */ -class Intonation_Form_Helper { - protected - $_form, - $_template; - - - public function __construct($template, $form) { - $this->_template = $template; - $this->_form = $form; - } - - - public function getWidgetForm() { - if (! $strategy = $this->_getStrategyFor($this->_form)) - return (new Intonation_Form_Helper_Widget_DefaultStrategy($this->_template, - $this->_form)) - ->getForm(); - - $class = 'Intonation_Form_Helper_Widget_' . $strategy; - return (new $class($this->_template, $this->_form))->getForm(); - } - - - public function getSectionForm() { - return (new Intonation_Form_Helper_Section($this->_template, $this->_form))->getForm(); - } - - - public function getTemplateForm() { - return (new Intonation_Form_Helper_Template($this->_template, $this->_form))->getForm(); - } - - - protected function _getStrategyFor($form) { - $strategies = ['ZendAfi_Form_Configuration_Widget_Login' => 'FormStyle', - 'ZendAfi_Form_Configuration_Widget_Search' => 'FormStyle']; - - if (!in_array(get_class($form), array_keys($strategies))) - return false; - - return $strategies[get_class($form)]; - } -} - +class Intonation_Library_FormCustomizer_Abstract { + use Trait_Translator; + CONST + FIRST = 99, + SECOND = 102, + THIRD = 103, + FOURTH = 104, + FIFTH = 105; -class Intonation_Form_Helper_Abstract { - use Trait_Translator; protected $_form, $_template; @@ -184,7 +146,7 @@ class Intonation_Form_Helper_Abstract { 'order_xlarge']), $this->_template->withNameSpace('responsive_group'), ['legend' => $this->_('Thème %s : responsive', $this->_template->getId()), - 'order' => 98]); + 'order' => static::FOURTH]); return $this; } @@ -232,7 +194,7 @@ class Intonation_Form_Helper_Abstract { 'auth']), $this->_template->withNameSpace('visibility_group'), ['legend' => $this->_('Thème %s : visibilité', $this->_template->getId()), - 'order' => 99]); + 'order' => static::FIFTH]); return $this; } @@ -262,7 +224,7 @@ class Intonation_Form_Helper_Abstract { },$elements), $this->_template->withNameSpace('group'), ['legend' => $this->_('Thème %s', $this->_template->getId()), - 'order' => 97]); + 'order' => static::FIRST]); return $this; } @@ -298,7 +260,8 @@ class Intonation_Form_Helper_Abstract { return $this->_template->withNameSpace($element); }, ['hydrating_mapping']), $this->_template->withNameSpace('hydrating_mapping_group'), - ['legend' => $this->_('Thème %s : bootstrap', $this->_template->getId())]); + ['legend' => $this->_('Thème %s : bootstrap', $this->_template->getId()), + 'order' => static::SECOND]); return $this; } @@ -316,7 +279,8 @@ class Intonation_Form_Helper_Abstract { return $this->_template->withNameSpace($element); }, array_keys($maps)), $this->_template->withNameSpace('icons_map_group'), - ['legend' => $this->_('Thème %s : icons', $this->_template->getId())]); + ['legend' => $this->_('Thème %s : icons', $this->_template->getId()), + 'order' => static::THIRD]); return $this; } @@ -339,171 +303,3 @@ class Intonation_Form_Helper_Abstract { return $this; } } - - - - -class Intonation_Form_Helper_Widget_DefaultStrategy extends Intonation_Form_Helper_Abstract { - public function getForm() { - $this->_form - ->addElement('checkbox', - $this->_template->withNameSpace('show_header'), - ['label' => $this->_('Afficher le titre'), - 'value' => 1]) - - ->addElement('checkbox', - $this->_template->withNameSpace('show_content'), - ['label' => $this->_('Décorer le contenu'), - 'value' => 1]) - - ->addElement('checkbox', - $this->_template->withNameSpace('show_footer'), - ['label' => $this->_('Afficher le pied'), - 'value' => 1]); - $this->_addCustomElement(); - - $this->_addToTemplateGroup($this->_getDefaultElementsNames()); - - $this->_form - ->replaceWith('picto', ['userfile', - 'picto', - ['label' => $this->_('Logo'), - 'folder' => 'image']]); - - $this->_replaceBoiteByCss(); - $this->_addResponsiveGroupTo(); - $this->_addControllerVisibilityGroupTo(); - return $this->_form; - } - - - protected function _getDefaultElementsNames() { - return ['show_header', - 'show_content', - 'show_footer']; - } -} - - - - -class Intonation_Form_Helper_Widget_FormStyle extends Intonation_Form_Helper_Widget_DefaultStrategy { - - protected function _addCustomElement() { - $this->_form->addElement('radio', - $this->_template->withNameSpace('form_style'), - ['label' => $this->_('Style d\'affichage'), - 'multiOptions' => ['default' => $this->_('Formulaire standart'), - 'inline' => $this->_('Formulaire en ligne'), - 'toggle' => $this->_('Formulaire à bascule')]]); - - } - - - protected function _getDefaultElementsNames() { - return array_merge(parent::_getDefaultElementsNames(), ['form_style']); - } -} - - - - -class Intonation_Form_Helper_Section extends Intonation_Form_Helper_Abstract { - public function getForm() { - return $this - ->_replaceBoiteByCss() - ->_addDisplayModeElementTo() - ->_addToTemplateGroup(['display_mode']) - ->_addResponsiveGroupTo() - ->_addControllerVisibilityGroupTo(); - } -} - - - - -class Intonation_Form_Helper_Template extends Intonation_Form_Helper_Abstract { - public function getForm() { - $this->_form - ->addElement('checkbox', - $this->_template->withNameSpace('core_css'), - ['label' => $this->_('Bokeh core.css')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('core_js'), - ['label' => $this->_('Bokeh core.js')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('intonation_css'), - ['label' => $this->_('Intonation.css')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('font_awesome_css'), - ['label' => $this->_('FontAwesome 5.5.0 Free')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('jquery'), - ['label' => $this->_('JQuery 3.2.1.min')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('jquery_ui'), - ['label' => $this->_('JQuery-UI 1.12.1')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('bootstrap_css'), - ['label' => $this->_('Boostrap 4.0.0 min.css')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('bootstrap_js'), - ['label' => $this->_('Boostrap 4.0.0-beta min.js')]) - - ->addElement('checkbox', - $this->_template->withNameSpace('bootstrap_dependency_popper'), - ['label' => $this->_('Boostrap 4 dépendance popper.min.js 1.11.0')]) - - ->addElement('multiInput', - $this->_template->withNameSpace('custom_css'), - ['label' => $this->_('Fichiers CSS'), - 'fields' => [['name' => $this->_template->withNameSpace('custom_css_url'), - 'label' => $this->_('url')]], - 'values' => [$this->_template->withNameSpace('custom_css_url') => $this->_template->getCustomCssUrl()], - 'deleteMessage' => $this->_('Ce fichier')]) - - ->addElement('multiInput', - $this->_template->withNameSpace('custom_js'), - ['label' => $this->_('Fichiers JS'), - 'fields' => [['name' => $this->_template->withNameSpace('custom_js_url'), - 'label' => $this->_('url')]], - 'values' => [$this->_template->withNameSpace('custom_js_url') => $this->_template->getCustomJsUrl()], - 'deleteMessage' => $this->_('ce fichier')]) - - ->addElement('multiInput', - $this->_template->withNameSpace('custom_css_classes'), - ['label' => $this->_('Classes CSS sélectionnables'), - 'fields' => [['name' => $this->_template->withNameSpace('custom_css_class'), - 'label' => $this->_('classe')]], - 'values' => [$this->_template->withNameSpace('custom_css_class') => $this->_template->getCustomCssClass()], - 'deleteMessage' => $this->_('cette classe')]) - ; - - $this - ->_addToTemplateGroup(['core_css', - 'core_js', - 'intonation_css', - 'font_awesome_css', - 'jquery', - 'jquery_ui', - 'bootstrap_css', - 'bootstrap_js', - 'bootstrap_dependency_popper', - 'custom_css', - 'custom_js', - 'nb_cols', - 'custom_css_classes']) - ->_addHydratingMappingGroupTo() - ->_addResponsiveGroupTo() - ->_addIconsMappingGroupTo(); - - return $this; - } -} \ No newline at end of file diff --git a/library/templates/Intonation/Library/FormCustomizer/Section.php b/library/templates/Intonation/Library/FormCustomizer/Section.php new file mode 100644 index 0000000000000000000000000000000000000000..be9900ece343b1d7dfa05937e3fbe60099d6113d --- /dev/null +++ b/library/templates/Intonation/Library/FormCustomizer/Section.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_FormCustomizer_Section extends Intonation_Library_FormCustomizer_Abstract { + public function getForm() { + return $this + ->_replaceBoiteByCss() + ->_addDisplayModeElementTo() + ->_addToTemplateGroup(['display_mode']) + ->_addResponsiveGroupTo() + ->_addControllerVisibilityGroupTo(); + } +} diff --git a/library/templates/Intonation/Library/FormCustomizer/Template.php b/library/templates/Intonation/Library/FormCustomizer/Template.php new file mode 100644 index 0000000000000000000000000000000000000000..8f13e81e5d74fc40cd0a743fddcc15cfd0df4c06 --- /dev/null +++ b/library/templates/Intonation/Library/FormCustomizer/Template.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_FormCustomizer_Template extends Intonation_Library_FormCustomizer_Abstract { + + public function getForm() { + $this->_form + ->addElement('checkbox', + $this->_template->withNameSpace('core_css'), + ['label' => $this->_('Bokeh core.css')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('core_js'), + ['label' => $this->_('Bokeh core.js')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('intonation_css'), + ['label' => $this->_('Intonation.css')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('font_awesome_css'), + ['label' => $this->_('FontAwesome 5.5.0 Free')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('jquery'), + ['label' => $this->_('JQuery 3.2.1.min')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('jquery_ui'), + ['label' => $this->_('JQuery-UI 1.12.1')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('bootstrap_css'), + ['label' => $this->_('Boostrap 4.0.0 min.css')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('bootstrap_js'), + ['label' => $this->_('Boostrap 4.0.0-beta min.js')]) + + ->addElement('checkbox', + $this->_template->withNameSpace('bootstrap_dependency_popper'), + ['label' => $this->_('Boostrap 4 dépendance popper.min.js 1.11.0')]) + + ->addElement('multiInput', + $this->_template->withNameSpace('custom_css'), + ['label' => $this->_('Fichiers CSS'), + 'fields' => [['name' => $this->_template->withNameSpace('custom_css_url'), + 'label' => $this->_('url')]], + 'values' => [$this->_template->withNameSpace('custom_css_url') => $this->_template->getCustomCssUrl()], + 'deleteMessage' => $this->_('Ce fichier')]) + + ->addElement('multiInput', + $this->_template->withNameSpace('custom_js'), + ['label' => $this->_('Fichiers JS'), + 'fields' => [['name' => $this->_template->withNameSpace('custom_js_url'), + 'label' => $this->_('url')]], + 'values' => [$this->_template->withNameSpace('custom_js_url') => $this->_template->getCustomJsUrl()], + 'deleteMessage' => $this->_('ce fichier')]) + + ->addElement('multiInput', + $this->_template->withNameSpace('custom_css_classes'), + ['label' => $this->_('Classes CSS sélectionnables'), + 'fields' => [['name' => $this->_template->withNameSpace('custom_css_class'), + 'label' => $this->_('classe')]], + 'values' => [$this->_template->withNameSpace('custom_css_class') => $this->_template->getCustomCssClass()], + 'deleteMessage' => $this->_('cette classe')]); + + $this + ->_addToTemplateGroup(['core_css', + 'core_js', + 'intonation_css', + 'font_awesome_css', + 'jquery', + 'jquery_ui', + 'bootstrap_css', + 'bootstrap_js', + 'bootstrap_dependency_popper', + 'custom_css', + 'custom_js', + 'nb_cols', + 'custom_css_classes']) + ->_addHydratingMappingGroupTo() + ->_addResponsiveGroupTo() + ->_addIconsMappingGroupTo(); + + return $this; + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/FormCustomizer/Widget/Default.php b/library/templates/Intonation/Library/FormCustomizer/Widget/Default.php new file mode 100644 index 0000000000000000000000000000000000000000..f466052ab314e98cba8d81d4069900b17b6496fd --- /dev/null +++ b/library/templates/Intonation/Library/FormCustomizer/Widget/Default.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_FormCustomizer_Widget_Default extends Intonation_Library_FormCustomizer_Abstract { + + public function getForm() { + $this->_form + ->addElement('checkbox', + $this->_template->withNameSpace('show_header'), + ['label' => $this->_('Afficher le titre'), + 'value' => 1]) + + ->addElement('checkbox', + $this->_template->withNameSpace('show_content'), + ['label' => $this->_('Décorer le contenu'), + 'value' => 1]) + + ->addElement('checkbox', + $this->_template->withNameSpace('show_footer'), + ['label' => $this->_('Afficher le pied'), + 'value' => 1]); + $this->_addCustomElement(); + + $this->_addToTemplateGroup($this->_getDefaultElementsNames()); + + $this->_form + ->replaceWith('picto', ['userfile', + 'picto', + ['label' => $this->_('Logo'), + 'folder' => 'image']]); + + $this->_replaceBoiteByCss(); + $this->_addResponsiveGroupTo(); + $this->_addControllerVisibilityGroupTo(); + return $this->_form; + } + + + protected function _getDefaultElementsNames() { + return ['show_header', + 'show_content', + 'show_footer']; + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/FormCustomizer/Widget/FormStyle.php b/library/templates/Intonation/Library/FormCustomizer/Widget/FormStyle.php new file mode 100644 index 0000000000000000000000000000000000000000..e730902dd8b464d79a54ef6dc7f36f5cda27aa4d --- /dev/null +++ b/library/templates/Intonation/Library/FormCustomizer/Widget/FormStyle.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_FormCustomizer_Widget_FormStyle extends Intonation_Library_FormCustomizer_Widget_Default { + + protected function _addCustomElement() { + $this->_form->addElement('radio', + $this->_template->withNameSpace('form_style'), + ['label' => $this->_('Style d\'affichage'), + 'multiOptions' => ['default' => $this->_('Formulaire standart'), + 'inline' => $this->_('Formulaire en ligne'), + 'toggle' => $this->_('Formulaire à bascule')]]); + + } + + + protected function _getDefaultElementsNames() { + return array_merge(parent::_getDefaultElementsNames(), ['form_style']); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index f5d6ba360a42b6a63781e0eaaee853aa062031d6..b93f3dc5337ec3025e92dd09e62ec170092deb9b 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -121,20 +121,20 @@ class Intonation_Template extends Class_Template { public function customWidgetForm($form) { - $helper = new Intonation_Form_Helper($this, $form); - return $helper->getWidgetForm(); + $helper = new Intonation_Library_FormCustomizer($this); + return $helper->getWidgetForm($form); } public function customSectionForm($form) { - $helper = new Intonation_Form_Helper($this, $form); - return $helper->getSectionForm(); + $helper = new Intonation_Library_FormCustomizer($this); + return $helper->getSectionForm($form); } public function customTemplateForm($form) { - $helper = new Intonation_Form_Helper($this, $form); - return $helper->getTemplateForm(); + $helper = new Intonation_Library_FormCustomizer($this); + return $helper->getTemplateForm($form); }