diff --git a/VERSIONS_HOTLINE/hotline_#17941_fix_noreply_adress_workflow_cms b/VERSIONS_HOTLINE/hotline_#17941_fix_noreply_adress_workflow_cms deleted file mode 100644 index b8e811d20b51478c7f079a14e8bafe164e92e5c8..0000000000000000000000000000000000000000 --- a/VERSIONS_HOTLINE/hotline_#17941_fix_noreply_adress_workflow_cms +++ /dev/null @@ -1,3 +0,0 @@ -- ticket hotline #17941 - - Workflow de création des articles - - correction de l'adresse email utilisée pour envoyer les messages de trnasition d'état (no-reply@afi-sa.fr) \ No newline at end of file diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 67b81992a84c426cc45d7c76d388a08c68232cd8..0b62a560662ba3640981ddf5e977369dc46d1ca4 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1341,9 +1341,6 @@ class Class_Notice extends Storm_Model_Abstract { } -// ---------------------------------------------------------------- -// Résumé -// ---------------------------------------------------------------- public function getResume() { if (isset($this->_resume)) return $this->_resume; @@ -1351,15 +1348,45 @@ class Class_Notice extends Storm_Model_Abstract { if ($album = $this->getAlbum()) return $album->getDescription(); - $resume = ''; - $data = $this->get_subfield("330", "a"); - foreach ($data as $item) - if (strlen($item) > strlen($resume)) $resume = trim($item); + $data = $this->get_subfield('330', 'a'); + return $this->_resume = ($resume = $this->_getHtmlSummary($data)) ? + $resume : $this->_getTextSummary($data); + } + + + protected function _getHtmlSummary($values) { + return $this->_getSummaryWith( + $values, + function($value) { + return $this->_containsTags($value); + }); + } + + + protected function _getTextSummary($values) { + $summary = $this->_getSummaryWith( + $values, + function($value) { + return !$this->_containsTags($value); + }); + + if ($summary && substr($summary, -1) != '.') + $summary .= '.'; + return $summary; + } + + + protected function _getSummaryWith($values, $closure) { + $summary = ''; + foreach($values as $value) + if ($closure($value) && strlen($value) > strlen($summary)) + $summary = $value; + return $summary; + } - if ($resume && substr($resume, -1) != ".") - $resume.="."; - return $this->_resume = $resume; + protected function _containsTags($value) { + return $value != (new Zend_Filter_StripTags())->filter($value); } diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 1933eb0f69df2bab040fc4b1ee8af19c660f038b..f89d9e5c1a0cc26639aa0071d4ac27f914ba4970 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -386,6 +386,24 @@ class NoticeAjaxControllerInterviewsTest extends AbstractControllerTestCase { } + + +/** @see http://forge.afi-sa.fr/issues/16741 */ +class NoticeAjaxControllerResumeGamWidgetTest extends AbstractControllerTestCase { + /** @test */ + public function shouldDisplayGamWidget() { + $this->fixture('Class_Notice', + ['id' => 3800226, + 'unimarc' => file_get_contents(dirname(__FILE__) + . '/sous_la_peau.uni')]); + $this->dispatch('noticeajax/resume/id/3800226', true); + $this->assertXPath('//iframe[contains(@src, "gamannecy.com")]', + $this->_response->getBody()); + } +} + + + class NoticeAjaxControllerResumeAlbumTest extends AbstractControllerTestCase { protected $_notice;