From 5abcce03128b5a38ec15d98394aad8c62e46125b Mon Sep 17 00:00:00 2001 From: pbarroca <pbarroca@afi-sa.fr> Date: Thu, 27 Apr 2017 17:54:39 +0200 Subject: [PATCH] dev #59717 : handling search configuration --- .../Systeme/ModulesAccueil/RechercheSimple.php | 11 +++++++++++ .../Form/Configuration/Widget/Search.php | 11 +++++++---- .../VersionCompare/ActivitiesSelector.php | 2 -- .../VersionCompare/AlbumsCategoriesSelector.php | 2 -- .../Decorator/VersionCompare/TreeSelect.php | 10 ++-------- .../VersionCompare/TreeSelectSingle.php | 17 +++++------------ 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php index 47d45db3a67..a7e3f571a0c 100644 --- a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php +++ b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php @@ -51,4 +51,15 @@ class Class_Systeme_ModulesAccueil_RechercheSimple extends Class_Systeme_Modules 'domain_ids' => '', 'domain_select_style' => self::DOMAIN_SELECT_SELECT]; } + + + public function getSelectionModeOptions() { + return [static::DOMAIN_SELECT_SELECT => $this->_('liste déroulante'), + static::DOMAIN_SELECT_CHECKBOX => $this->_('cases à cocher')]; + } + + + public function getSelectionModeDefault() { + return static::DOMAIN_SELECT_SELECT; + } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Configuration/Widget/Search.php b/library/ZendAfi/Form/Configuration/Widget/Search.php index 6b7468572bc..830874234ef 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Search.php +++ b/library/ZendAfi/Form/Configuration/Widget/Search.php @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class ZendAfi_Form_Configuration_Widget_Search extends ZendAfi_Form_Configuration_Widget_Base { +class ZendAfi_Form_Configuration_Widget_Search + extends ZendAfi_Form_Configuration_Widget_Base { + public function init() { parent::init(); $this @@ -42,6 +44,8 @@ class ZendAfi_Form_Configuration_Widget_Search extends ZendAfi_Form_Configuratio 'multiOptions' => [1,0]]); } + $simple_search = new Class_Systeme_ModulesAccueil_RechercheSimple(); + $this ->addElement('checkbox', 'select_doc', @@ -98,9 +102,8 @@ class ZendAfi_Form_Configuration_Widget_Search extends ZendAfi_Form_Configuratio ->addElement('radio', 'domain_select_style', ['label' => $this->_('Mode de sélection des domaines'), - 'multiOptions' => [Class_Systeme_ModulesAccueil_RechercheSimple::DOMAIN_SELECT_SELECT => $this->_('liste déroulante'), - Class_Systeme_ModulesAccueil_RechercheSimple::DOMAIN_SELECT_CHECKBOX => $this->_('cases à cocher')], - 'value' => Class_Systeme_ModulesAccueil_RechercheSimple::DOMAIN_SELECT_SELECT]); + 'multiOptions' => $simple_search->getSelectionModeOptions(), + 'value' => $simple_search->getSelectionModeDefault()]); } diff --git a/library/ZendAfi/Form/Decorator/VersionCompare/ActivitiesSelector.php b/library/ZendAfi/Form/Decorator/VersionCompare/ActivitiesSelector.php index edcf70c9a9f..d33d99f258a 100644 --- a/library/ZendAfi/Form/Decorator/VersionCompare/ActivitiesSelector.php +++ b/library/ZendAfi/Form/Decorator/VersionCompare/ActivitiesSelector.php @@ -23,8 +23,6 @@ class ZendAfi_Form_Decorator_VersionCompare_ActivitiesSelector extends ZendAfi_Form_Decorator_VersionCompare_TreeSelectSingle { - protected $_current_separator = '-'; - protected function _find($id) { return Class_Activity::find($id); } diff --git a/library/ZendAfi/Form/Decorator/VersionCompare/AlbumsCategoriesSelector.php b/library/ZendAfi/Form/Decorator/VersionCompare/AlbumsCategoriesSelector.php index 388bcfdd31c..be9b96018f0 100644 --- a/library/ZendAfi/Form/Decorator/VersionCompare/AlbumsCategoriesSelector.php +++ b/library/ZendAfi/Form/Decorator/VersionCompare/AlbumsCategoriesSelector.php @@ -23,8 +23,6 @@ class ZendAfi_Form_Decorator_VersionCompare_AlbumsCategoriesSelector extends ZendAfi_Form_Decorator_VersionCompare_TreeSelectSingle { - protected $_current_separator = '-'; - protected function _find($id) { return Class_AlbumCategorie::find($id); } diff --git a/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelect.php b/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelect.php index 636859ea28a..fbd46118c47 100644 --- a/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelect.php +++ b/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelect.php @@ -23,11 +23,6 @@ class ZendAfi_Form_Decorator_VersionCompare_TreeSelect extends ZendAfi_Form_Decorator_VersionCompare_TreeSelectSingle { - protected - $_version_separator = '-', - $_current_separator = '-'; - - protected function _getCurrentIds() { return [$this->_idsFromAttrib('IdItems'), $this->_idsFromAttrib('IdCategories')]; @@ -35,8 +30,7 @@ class ZendAfi_Form_Decorator_VersionCompare_TreeSelect protected function _idsFromAttrib($name) { - return $this->_getIds($this->_element->getAttrib($name), - $this->_current_separator); + return $this->_getIds($this->_element->getAttrib($name)); } @@ -63,7 +57,7 @@ class ZendAfi_Form_Decorator_VersionCompare_TreeSelect return []; return (array_key_exists($name, $datas) - ? $this->_getIds($datas[$name], $this->_version_separator) + ? $this->_getIds($datas[$name]) : []); } diff --git a/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelectSingle.php b/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelectSingle.php index 5ebeba523e7..3f7d6af6d20 100644 --- a/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelectSingle.php +++ b/library/ZendAfi/Form/Decorator/VersionCompare/TreeSelectSingle.php @@ -23,19 +23,13 @@ class ZendAfi_Form_Decorator_VersionCompare_TreeSelectSingle extends ZendAfi_Form_Decorator_VersionCompare { - protected - $_version_separator = '-', - $_current_separator = ';'; - - protected function _renderCurrentValue() { return $this->_renderValue($this->_getCurrentIds()); } protected function _getCurrentIds() { - return $this->_getIds($this->_element->getValue(), - $this->_current_separator); + return $this->_getIds($this->_element->getValue()); } @@ -49,7 +43,7 @@ class ZendAfi_Form_Decorator_VersionCompare_TreeSelectSingle return []; return (array_key_exists($name = $this->_element->getName(), $datas) - ? $this->_getIds($datas[$name], $this->_version_separator) + ? $this->_getIds($datas[$name]) : []); } @@ -69,16 +63,15 @@ class ZendAfi_Form_Decorator_VersionCompare_TreeSelectSingle } - protected function _getIds($value, $separator) { - return $value ? explode($separator, $value) : []; + protected function _getIds($value) { + $value = str_replace(';', '-', $value); + return $value ? array_unique(explode('-', $value)) : []; } protected function _isModified() { $current = $this->_getCurrentIds(); $version = $this->_getVersionIds(); - sort($current); - sort($version); return $current != $version; } -- GitLab