From cf23a6e545de25c8d3d85a2b29d84b1110e0da34 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Wed, 11 Jan 2017 10:04:33 +0100 Subject: [PATCH] hotline #52819 add adminVar --- library/Class/AdminVar.php | 6 ++++++ library/Class/AdminVar/Meta.php | 1 + .../ZendAfi/View/Helper/ListeNotices/Abstract.php | 13 ++++++++++++- .../ZendAfi/View/Helper/ListeNotices/MurTest.php | 1 + .../View/Helper/ListeNotices/VERSIONS_HOTLINE/52819 | 1 + .../View/Helper/ListeNotices/VignettesTest.php | 1 + 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/library/ZendAfi/View/Helper/ListeNotices/VERSIONS_HOTLINE/52819 diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index d47339a0660..522b1a179c4 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -155,6 +155,7 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'FACETTE_TAG_LIBELLE' => Class_AdminVar_Meta::newDefault('Libellé de la facette tag'), 'UNLEASHED_FACETS' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des codes des facettes qui ne sont pas limitées à l\'affichage dans le résultat de recherche<br/>Exemple : T => Type de doc, Y => Annexe, B => Bibliothèque, ... (Voir <a href="' . BOKEH_REMOTE_FILES . 'blob/' . BOKEH_VERSION . '/library/Class/Codification.php#L24">la liste complète</a>)')), 'AFFICHER_DISPONIBILITE_SUR_RECHERCHE' => Class_AdminVar_Meta::newOnOff($this->_('Activation de la disponibilite dans le resultat de recherche.')), + 'AFFICHER_DISPONIBILITE_SUR_RECHERCHE_MODE_FACETTE' => Class_AdminVar_Meta::newOnOff($this->_('Activation de la disponibilite dans le resultat de recherche. Calculé grâce à la facette "En rayon".')), 'SEARCH_ALSO_IN' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des sites de recherche élargie (la chaine \'%s\' dans l\'url sera remplacée par le terme de recherche)'), [ 'options' => ['fields' => [['name' => 'site_label', 'label' => $this->_('Nom du site')], ['name' => 'site_url', 'label' => $this->_('Url de recherche')] ]]]), @@ -774,6 +775,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader { } + public function isShowAvailabilityFromFacetEnabled() { + return Class_AdminVar::isModuleEnabled('AFFICHER_DISPONIBILITE_SUR_RECHERCHE_MODE_FACETTE'); + } + + public function isAlbumMediaNoAutoindexTitleEnabled() { return Class_AdminVar::isModuleEnabled('ALBUM_MEDIA_NO_AUTOINDEX_TITLE'); } diff --git a/library/Class/AdminVar/Meta.php b/library/Class/AdminVar/Meta.php index 48e17d3ea73..f1ddeb7e630 100644 --- a/library/Class/AdminVar/Meta.php +++ b/library/Class/AdminVar/Meta.php @@ -144,6 +144,7 @@ class Class_AdminVar_Meta { return $this->getAttribute('value', ''); } + public function bePrivate() { $this->_attributes['role_level'] = ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN; return $this; diff --git a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php index e9121cf77ed..fd360f5fbe0 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Abstract.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Abstract.php @@ -40,13 +40,24 @@ abstract class ZendAfi_View_Helper_ListeNotices_Abstract extends ZendAfi_View_He protected function _recordAvailability($record) { - if(!$this->_isAllowedToDisplayAvailabilty($record)) + if(!$this->_isAllowedToDisplayAvailabiltyFromFacet($record)) return ''; return $this->view->Notice_Availability($record); } + protected function _isAllowedToDisplayAvailabiltyFromFacet($record) { + if(!Class_AdminVar::isShowAvailabilityFromFacetEnabled()) + return false; + + if($record->isRessourceNumerique()) + return false; + + return true; + } + + protected function _isAllowedToDisplayAvailabilty($record) { if(!Class_AdminVar::isAfficherDispoSurRechercheEnabled()) return false; diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php index c5de8c4ed16..37d747b3dec 100644 --- a/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/MurTest.php @@ -41,6 +41,7 @@ abstract class ZendAfi_View_Helper_ListeNotices_MurTestCase extends ViewHelperTe class ZendAfi_View_Helper_ListeNotices_MurForNoticeTest extends ZendAfi_View_Helper_ListeNotices_MurTestCase { public function setUp() { parent::setUp(); + $this->fixture('Class_AdminVar', ['id'=>'AFFICHER_DISPONIBILITE_SUR_RECHERCHE_MODE_FACETTE', 'valeur'=>1] ); $time_source = new TimeSourceForTest('2013-12-14 09:00:00'); Class_Notice::setTimeSource($time_source); diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/VERSIONS_HOTLINE/52819 b/tests/library/ZendAfi/View/Helper/ListeNotices/VERSIONS_HOTLINE/52819 new file mode 100644 index 00000000000..c15823e7030 --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/VERSIONS_HOTLINE/52819 @@ -0,0 +1 @@ + - ticket #52819 : Administration : ajout d'une variable pour gérer l'affichage de la disponibilité dans le résultat de recherche calculé avec la facette "En rayon". \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php index bf63fa1058d..f3c7d475bf5 100644 --- a/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php +++ b/tests/library/ZendAfi/View/Helper/ListeNotices/VignettesTest.php @@ -25,6 +25,7 @@ class VignettesRGAATest extends ViewHelperTestCase { public function setUp() { parent::setUp(); + $this->fixture('Class_AdminVar', ['id'=>'AFFICHER_DISPONIBILITE_SUR_RECHERCHE_MODE_FACETTE', 'valeur'=>1] ); $this->fixture('Class_AdminVar', ['id'=>'AFFICHER_DISPONIBILITE_SUR_RECHERCHE', 'valeur'=>1] ); defineConstant('PATH_SKIN', './public/opac/skins/original/'); -- GitLab