From 4ecc2e56c8a4850a1437d3fad146535095dec5f5 Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Wed, 3 Oct 2018 15:22:33 +0200 Subject: [PATCH] dev #59497 : fix failures --- .../views/scripts/recherche/viewnotice.phtml | 10 +++++++--- library/Class/ModeleFusion.php | 5 +++++ .../Controller/Plugin/Printer/SearchResult.php | 18 ++++++++++++++++++ library/ZendAfi/View/Helper/ListeNotices.php | 2 +- .../RechercheControllerPrintActionTest.php | 4 ++-- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/application/modules/opac/views/scripts/recherche/viewnotice.phtml b/application/modules/opac/views/scripts/recherche/viewnotice.phtml index 5582487bd67..ffc8e86f9e4 100644 --- a/application/modules/opac/views/scripts/recherche/viewnotice.phtml +++ b/application/modules/opac/views/scripts/recherche/viewnotice.phtml @@ -18,9 +18,13 @@ $script_loader = Class_ScriptLoader::getInstance() ['title' => $this->_('Retourner au résultat de recherche'), 'class' => 'retour']); - echo $this->tagPrintLink((new Class_Entity()) - ->setModels([$this->notice]) - ->setStrategy('Notice_View')); + echo Class_ModeleFusion::canPrintRecord() + ? $this->tagAnchor(['controller' => 'recherche', + 'action' => 'print'], + $this->_('Imprimer'), + ['title' => $this->_('Imprimer "%s"', $this->notice->getTitrePrincipal()), + 'target' => '_blank']) + : ''; echo $this->tagAnchor($this->url_panier, $this->_('Ajouter au panier'), diff --git a/library/Class/ModeleFusion.php b/library/Class/ModeleFusion.php index df9105b597b..a3c5f20a869 100644 --- a/library/Class/ModeleFusion.php +++ b/library/Class/ModeleFusion.php @@ -53,6 +53,11 @@ class Class_ModeleFusionLoader extends Storm_Model_Loader { } + public function canPrintRecord() { + return 0 < Class_ModeleFusion::countBy(['type' => Class_ModeleFusion::RECORD_TEMPLATE]); + } + + public function getTrainingTemplateFor($training_page) { $names = ['EMARGEMENT' => Class_ModeleFusion::TRAINING_TEMPLATE.'EMARGEMENT', 'STAGIAIRES' => Class_ModeleFusion::TRAINING_TEMPLATE.'LISTE_STAGIAIRES', diff --git a/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php b/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php index 04fca871912..0037e60454d 100644 --- a/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php +++ b/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php @@ -24,6 +24,24 @@ class ZendAfi_Controller_Plugin_Printer_SearchResult extends ZendAfi_Controller_Plugin_Printer_ModelFusion { protected function _getPrinterConfig() { + return $this->_getParam('id') + ? $this->_getOnePrinterConfig() + : $this->_getManyPrinterConfig(); + } + + + protected function _getOnePrinterConfig() { + $model_fusion = Class_ModeleFusion::getFusionForStrategyAndProfilOrDefault(Class_ModeleFusion::RECORD_TEMPLATE, + Class_Profil::getCurrentProfil()); + + return parent::_getPrinterConfig() + ->setStrategy($model_fusion->getType()) + ->setModelFusion($model_fusion->getId()) + ->setId($this->_getParam('id')); + } + + + protected function _getManyPrinterConfig() { $model_fusion = Class_ModeleFusion::getFusionForStrategyAndProfilOrDefault(Class_ModeleFusion::RECORDS_TEMPLATE, Class_Profil::getCurrentProfil()); diff --git a/library/ZendAfi/View/Helper/ListeNotices.php b/library/ZendAfi/View/Helper/ListeNotices.php index a48e848c12f..e87940c182c 100644 --- a/library/ZendAfi/View/Helper/ListeNotices.php +++ b/library/ZendAfi/View/Helper/ListeNotices.php @@ -23,7 +23,7 @@ class ZendAfi_View_Helper_ListeNotices extends ZendAfi_View_Helper_BaseHelper { public function listeNotices($search_result) { $criteres_recherche = $search_result->getCriteresRecherche(); - $notices = $search_result->getRecords(); + $notices = $search_result->fetchRecords(); $nombre_resultats = $search_result->getRecordsCount(); $page = $criteres_recherche->getPage(); $preferences = $search_result->getSettings(); diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index 34cb0c47c3e..2a493eeae16 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -140,7 +140,7 @@ class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTe -class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractControllerTestCase { +class RechercheControllerPrintActionViewNoticeWithRecordsTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; public function setUp() { @@ -153,7 +153,7 @@ class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractCo <div>{notice.resume} </div> {notice.avis[<p>{avis}</p>]} </p>', - 'type' => 'Notice_View']); + 'type' => Class_ModeleFusion::RECORD_TEMPLATE]); Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12, -- GitLab