diff --git a/VERSIONS_WIP/24894 b/VERSIONS_WIP/24894 new file mode 100644 index 0000000000000000000000000000000000000000..15e57c06258bc93a3e4c63bfeef2b530414f9184 --- /dev/null +++ b/VERSIONS_WIP/24894 @@ -0,0 +1 @@ + - ticket #24894 : Miop : affichage des sitothèques dans la liste de résultats de recherche \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php index 287af74c6e4504f2009390aff15b56c8048a2ab3..dd848615b903817e1dbeb73674a85998a3142192 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php +++ b/library/ZendAfi/View/Helper/ListeNotices/Vignettes.php @@ -23,6 +23,7 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_ListeNotices_Abstract { protected $_read_speaker; + public function listeNotices_Vignettes($data, $preferences=[]) { $this->loadScript(); $champs = isset($preferences['liste_codes']) ? $preferences['liste_codes'] : 'TANE'; @@ -44,7 +45,8 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_Lis . $this->_cart($notice) . $this->_title($notice, $url_notice) . $this->_author($notice, $url_notice) - . $this->_docType($notice) + . $this->_docType($notice, $type_doc) + . $this->_link($notice, $type_doc) . $this->_image($notice, $preferences) . $this->_info($notice, $champs) . $this->_pcTag($notice); @@ -84,8 +86,7 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_Lis } - protected function _docType($record) { - $type_doc = $record->getTypeDoc(); + protected function _docType($record, $type_doc) { $icon = $this->view->iconeSupport($type_doc); $label = Class_Codification::getInstance()->getLibelleFacette('T'.$type_doc); @@ -107,10 +108,24 @@ class ZendAfi_View_Helper_ListeNotices_Vignettes extends ZendAfi_View_Helper_Lis ['entete' => str_replace('T', '', $fields)]), ['class' => 'vignette_info']); } + + protected function _pcTag($record) { return $this->_tag('div',$this->view->premierChapitre_Lien($record),['style' => 'margin-left:70px;']); } + + protected function _link($record, $type_doc) { + if(!$type_doc == Class_TypeDoc::SITE || !$type_doc == Class_TypeDoc::WEBSITE) + return ''; + + if(!$website = $record->getSite()) + return ''; + + return $this->view->tagAnchor($website->getUrl(), $this->view->_('Voir le site')); + } + + protected function _readSpeakerTagFor($record) { if (!$this->_read_speaker) $this->_read_speaker = new ZendAfi_View_Helper_ReadSpeaker(); diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 09c65e3f7290f37f674223d1ac4e6a1c2ca43b73..303af44d9af0eed2a1def08991a90846dcb01fe8 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -3061,4 +3061,48 @@ class RechercheControllerSimpleActionDisableSuggestionTest 'Suggérer un achat'); } } -?> \ No newline at end of file + + + +class RechercheControlleSiteInResultAndModeThumbnailTest extends RechercheControllerNoticeTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Catalogue', + ['id'=>3, + 'libelle' => 'Nouveautés']); + + $this->fixture('Class_Sitotheque', + ['id' => 1, + 'titre' => 'Mon lien', + 'url' => 'http://monlien.com', + 'domaine_ids' => 3, + ]); + + Class_Sitotheque::find(1)->index(); + + $this->mock_sql + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where MATCH(facettes) AGAINST('Q3' IN BOOLEAN MODE) order by annee desc", true, false) + ->answers([ [1, ''] ]) + ->whenCalled('fetchOne') + ->answers(1) + ->whenCalled('fetchAll') + ->answers([Class_Notice::find(1)->toArray()]) + ->beStrict(); + + + Class_Profil::getCurrentProfil() + ->setCfgModules(['recherche' => + ['resultatsimple' => + ['liste_format' => Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES]]]); + + $this->dispatch('/recherche/simple/id_catalogue/3/id_module/9/aleatoire/1', true); + } + + + /** @test */ + public function anchorWithMonLienShouldBePresent() { + $this->assertXPathContentContains('//div[@class="resultat_recherche"]//a[contains(@href,"://monlien.com")]', 'Voir le site'); + } +} \ No newline at end of file