diff --git a/VERSIONS_HOTLINE/115804 b/VERSIONS_HOTLINE/115804 new file mode 100644 index 0000000000000000000000000000000000000000..fbdcef6b462778e96c82341737ec9e35eb9eaeec --- /dev/null +++ b/VERSIONS_HOTLINE/115804 @@ -0,0 +1 @@ + - ticket #115804 : Magasin de thème : Correction d'une erreur possible lors de l'impression d'un panier de notices \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php b/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php index 5e7d0032e4c499f84e081d005c7cad20df570a30..6bc6bd3ac2b52c071e501e6c51ec9f3d34dd64ce 100644 --- a/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php +++ b/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php @@ -31,8 +31,9 @@ class ZendAfi_Controller_Plugin_Printer_SearchResult protected function _getOnePrinterConfig() { - $model_fusion = Class_ModeleFusion::getFusionForStrategyAndProfilOrDefault(Class_ModeleFusion::RECORD_TEMPLATE, - Class_Profil::getCurrentProfil()); + if (!$model_fusion = Class_ModeleFusion::getFusionForStrategyAndProfilOrDefault(Class_ModeleFusion::RECORD_TEMPLATE, + Class_Profil::getCurrentProfil())) + return parent::_getPrinterConfig(); return parent::_getPrinterConfig() ->setStrategy($model_fusion->getType()) diff --git a/library/ZendAfi/View/Helper/TagModelFusion.php b/library/ZendAfi/View/Helper/TagModelFusion.php index e4f3306f0686c4b81d04714bfa9a004ca4aa4717..60d8dcfd37e334d05d16e3e31023516ca6145bda 100644 --- a/library/ZendAfi/View/Helper/TagModelFusion.php +++ b/library/ZendAfi/View/Helper/TagModelFusion.php @@ -21,49 +21,44 @@ class ZendAfi_View_Helper_TagModelFusion extends ZendAfi_View_Helper_BaseHelper { + const LIST_TYPE = 'List'; + protected $_fusion; public function tagModelFusion($params) { - if(!$params) + if (!$params) return ''; - if(!$fusion = $this->_fusion = Class_ModeleFusion::find($params->getModelFusion())) + if (!$this->_fusion = Class_ModeleFusion::find($params->getModelFusion())) return ''; - if($models = $params->getModels()) - return $this->_render($params); + if ($models = $params->getModels()) + return $this->_render($params->getKey(), new Class_CollectionFusion($models)); - $models = []; $strategy = $params->getStrategy(); - list($class_name, $type) = explode('_', $strategy); $model = 'Class_' . $class_name; - $id_name = 'id_' . $class_name; - $source_key = strtolower($class_name); - $data = $model::find($params->getId()); - if ($type == 'List') { - $models = array_map([$model, 'find'], explode(';', $params->getIds())); - $data = new Class_CollectionFusion($models); - $source_key = Storm_Inflector::pluralize($source_key); - } + return $type == static::LIST_TYPE + ? $this->_render(Storm_Inflector::pluralize($source_key), + new Class_CollectionFusion(array_map([$model, 'find'], + explode(';', $params->getIds())))) - $fusion->setDataSource([$source_key => $data]); - return $this->_tag('div', - $fusion->getContenuFusionne(), - ['class' => 'models_fusion']); + : $this->_render($source_key, + $model::find($params->getId())); } - protected function _render($config) { - return $this->_tag('div', - $this->_fusion - ->setDataSource([ - $config->getKey() => new Class_CollectionFusion($config->getModels())]) - ->getContenuFusionne(), + protected function _render($key, $data) { + $content = $data + ? $this->_fusion->setDataSource([$key => $data]) + ->getContenuFusionne() + : $this->_('Aucune donnée à imprimer'); + + return $this->_tag('div', $content, ['class' => 'models_fusion']); } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Selection.php b/library/templates/Intonation/Library/View/Wrapper/Selection.php index 3c0e20eb32810da5b9e34956b5c3dd451e34c5d4..a02ee344e1e12d94eeeb0a3c159aa5e6d44cd55b 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/Selection.php @@ -81,14 +81,15 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ public function getMainLink() { - return new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'recherche', - 'action' => 'simple', - 'id_panier' => $this->_model->getId()]), - 'Text' => $this->_('Voir'), - 'Title' => $this->_('Voir la sélection dans la recherche'), - 'Image' => Class_Template::current()->getIco($this->_view, - 'search_more', - 'library')]); + $datas = ['Url' => $this->_view->url(['controller' => 'recherche', + 'action' => 'simple', + 'id_panier' => $this->getModelId()], + null, true), + 'Text' => $this->_('Voir'), + 'Title' => $this->_('Voir la sélection dans la recherche'), + 'Image' => $this->getIco('search_more', 'library')]; + + return new Intonation_Library_Link($datas); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index 2f62bd98716a46e0a01ef792eac2f58398fbc4b8..bb0a914c9bb71e3f618126119b534b38b9dd4eff 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -213,3 +213,31 @@ class RechercheControllerPrintActionViewNoticeWithRecordsTest extends AbstractCo $this->assertNotXPathContentContains("//div", '{notice.resume}'); } } + + + + +/** @see #115804 */ +class RechercheControllerPrintActionWithUnknownIdTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_ModeleFusion', + ['id' => 1, + 'nom' => 'recherche', + 'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> <h1>{titre_principal}</h1> <div>{article.contenu}</div> <div>{resume}</div> +]}</p>', + 'type' => 'Notice_View']); + + $this->dispatch('/recherche/print/id/6666888/id_panier/1'); + } + + + /** @test */ + public function shouldDisplayNoDataToPrint() { + $this->assertXPathContentContains('//div', 'Aucune donnée à imprimer'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index e79a616e9d32ff3e92a1a02f2293346a3c85a18a..2ea127673d7107372a5fff07697ab2ace62d2223 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -633,15 +633,32 @@ class TemplatesDispatchAbonneLargeNumberOfHoldsTest extends TemplatesIntonationA class TemplatesDispatchAbonneSelectionsTest extends TemplatesIntonationAccountTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/selections/id_profil/72/id/' . Class_Users::getIdentity()->getId()); + } + + /** @test */ - public function selectionMesBDShouldBeDisplay() { - $this->dispatch('/opac/abonne/selections/id_profil/72'); + public function mesBdShouldBeDisplay() { $this->assertXPathContentContains('//div', 'Mes BD'); } + + + /** + * @test + * @see #115804 + */ + public function mesBdLinkShouldNotContainsIdParam() { + $this->assertXPath('//a[contains(@href, "/recherche/simple")]' + . '[contains(@href, "/id_panier/2")]' + . '[not(contains(@href, "/id/"))]'); + } } + class TemplatesDispatchAbonneReviewsTest extends TemplatesIntonationAccountTestCase { /** @test */ public function selectionMesBDShouldBeDisplay() {