From 3a6d0d9139a5b1df9dabf913515feea2c1d2c47a Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Tue, 19 Nov 2019 12:40:10 +0100 Subject: [PATCH] hotline #96803 add article summary, author et creation year in record indexation --- VERSIONS_HOTLINE/96803 | 1 + library/Class/Indexation/PseudoNotice.php | 10 +++++++--- .../opac/controllers/NoticeAjaxControllerTest.php | 4 ++-- tests/library/Class/AlbumTest.php | 2 +- tests/library/Class/Indexation/PseudoNoticeTest.php | 8 ++++---- 5 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 VERSIONS_HOTLINE/96803 diff --git a/VERSIONS_HOTLINE/96803 b/VERSIONS_HOTLINE/96803 new file mode 100644 index 00000000000..20fd72fc66f --- /dev/null +++ b/VERSIONS_HOTLINE/96803 @@ -0,0 +1 @@ + - ticket #96803 : Gestion des simple quotes erronées \ No newline at end of file diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index ddb1be1653f..01d9f4b5f61 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -599,14 +599,18 @@ class Class_Indexation_PseudoNotice_Cms extends Class_Indexation_PseudoNotice{ protected function _prepareDatas() { parent::_prepareDatas(); - $this->_datas['resume'] = strip_tags($this->_datas['description']); - $this->_datas['description'] = strip_tags($this->_datas['contenu']); + $this->_datas['resume'] = $this->_sanitizeString($this->_datas['description']); + $this->_datas['description'] = $this->_sanitizeString($this->_datas['contenu']); $this->_datas['auteur'] = $this->_model->hasAuteur() ? $this->_model->getAuteur()->getNomComplet() : ''; $this->_datas['annee'] = date('Y', strtotime($this->_model->getDateCreation())); } + + protected function _sanitizeString($string) { + return strip_tags(html_entity_decode($string, ENT_QUOTES)); + } } @@ -648,4 +652,4 @@ class Class_Indexation_PseudoNotice_Null extends Class_Indexation_PseudoNotice{ public function isValid() { return false; } -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 7b77a6cccd9..0069e1fe108 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -617,14 +617,14 @@ class NoticeAjaxControllerResumeAlbumTest extends AbstractControllerTestCase { Class_Album::getLoader() ->newInstanceWithId(2) - ->setDescription('Lucky Luke est un grand cow-boy'); + ->setDescription('<p>Lucky Luke est un grand cow-boy de l'Ouest</p>'); } /** @test */ public function contenuShouldContainsResume() { $this->dispatch('noticeajax/resume?id_notice=123'); - $this->assertXPathContentContains('//div', 'Lucky Luke est un grand cow-boy'); + $this->assertXPathContentContains('//div', 'Lucky Luke est un grand cow-boy de l\'Ouest', $this->_response->getBody()); } diff --git a/tests/library/Class/AlbumTest.php b/tests/library/Class/AlbumTest.php index d4d45974fc5..29b02598b51 100644 --- a/tests/library/Class/AlbumTest.php +++ b/tests/library/Class/AlbumTest.php @@ -762,4 +762,4 @@ class AlbumIsbnMarcTest extends ModelTestCase { public function isbnFromAlbumShouldBe9782081377523() { $this->assertEquals('9782081377523', $this->_album->getIsbn()); } -} \ No newline at end of file +} diff --git a/tests/library/Class/Indexation/PseudoNoticeTest.php b/tests/library/Class/Indexation/PseudoNoticeTest.php index 90112ae9396..acacd8d89a4 100644 --- a/tests/library/Class/Indexation/PseudoNoticeTest.php +++ b/tests/library/Class/Indexation/PseudoNoticeTest.php @@ -375,7 +375,7 @@ class Class_Indexation_PseudoNoticeArticleTest ['id' => 1, 'titre' => 'My Article', 'contenu' => 'article is about...', - 'description' => 'This is a test', + 'description' => 'C'est un mégatest.', 'date_creation' => '2018-02-17 10:22:34', 'auteur' => $author, 'domaine_ids' => '17']); @@ -403,8 +403,8 @@ class Class_Indexation_PseudoNoticeArticleTest /** @test */ - public function firstRecordSummaryShouldBeThisIsATest() { - $this->assertEquals('This is a test', Class_Notice::find(1)->getResume()); + public function firstRecordSummaryShouldBeCestUnMegaTest() { + $this->assertEquals('C\'est un mégatest.', Class_Notice::find(1)->getResume()); } @@ -846,4 +846,4 @@ class Class_Indexation_PseudoNoticeSacramentariumTest extends Class_Indexation_P $item = $this->_notice->getExemplaires()[0]; $this->assertEquals(7, $item->getGenre()); } -} \ No newline at end of file +} -- GitLab