diff --git a/VERSIONS_HOTLINE/148110 b/VERSIONS_HOTLINE/148110 new file mode 100644 index 0000000000000000000000000000000000000000..89ad8af906f4846b928663874bd22c22fbd8dd34 --- /dev/null +++ b/VERSIONS_HOTLINE/148110 @@ -0,0 +1 @@ + - ticket #148110 : Magasin de Thème : Les articles de periodiques sont maintenant affichés, et limités à 20 \ No newline at end of file diff --git a/library/Class/Notice/Authors.php b/library/Class/Notice/Authors.php index ae1ce7313535058fed0af3a1e6b2b3abc627713d..43db09a8204c1ff49e99b2f6b005552dac8a74d7 100644 --- a/library/Class/Notice/Authors.php +++ b/library/Class/Notice/Authors.php @@ -44,6 +44,12 @@ class Class_Notice_Authors extends Class_Authors { } + public function displayAllAuthors() : array { + return array_map(function($element){return $element->getLabel();}, + $this->getAllAuthors(true)); + } + + protected function _init($record) { foreach ($this->_zones as $zone) $this->_getAuthorsInZone($record, $zone); diff --git a/library/Class/NoticeHtml.php b/library/Class/NoticeHtml.php index 54fdc46c4a483de2236a148c3173e778aba5307e..86dcf47ba45d0d21b7d70ae75b01cbdb50cd45a9 100644 --- a/library/Class/NoticeHtml.php +++ b/library/Class/NoticeHtml.php @@ -97,7 +97,7 @@ class Class_NoticeHtml { if ($article['matieres']) { $first = true; - foreach($article['matiere'] as $sujet) { + foreach($article['matieres'] as $sujet) { $html .= '<tr>'; $label = ''; diff --git a/library/templates/Intonation/Library/View/Wrapper/SerialArticle.php b/library/templates/Intonation/Library/View/Wrapper/SerialArticle.php new file mode 100644 index 0000000000000000000000000000000000000000..68602cf759db596939daf47c5626dc5a22b39530 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/SerialArticle.php @@ -0,0 +1,94 @@ +<?php +/** + * Copyright (c) 2012-2022, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_View_Wrapper_SerialArticle extends Intonation_Library_View_Wrapper_Record { + public function getPicture() { + } + + public function getPictureAction() { + } + + + public function getActions() { + return []; + } + + + public function getSecondaryLink() { + $object = $this->_model; + + $text = sprintf($this->_view->_("paru dans %s %s %s"), + $object->getTitreChapeau(), + $object->getTomeAlpha(), + $object->getCollation()); + + $headkey = Class_Indexation::getInstance()->serialCodeAlphaChapeau($object->getClefChapeau(), + $object->getTomeAlpha()); + + $search = Class_Url::relative(['controller' => 'recherche', + 'action' => 'simple', + 'rech_titres' => $headkey, + 'type_doc' => 'per_art']); + + return (new Intonation_Library_Link()) + ->setText($text) + ->setUrl($search) + ->setTitle($text); + } + + + public function getDescription() { + $description_length = $this->_widget_context + ? $this->_widget_context->getDescriptionLength() + : null; + + $description = $this->_view->truncate($this->_model->getResume(), + ['class' => 'model_description_' . get_class($this->_model)], + 20); + + if ($this->_model->getNotes()) + $description .= $this->_view->truncate(implode("; ", + array_filter($this->_model->getNotes())), + ['class' => 'model_note_' . get_class($this->_model)], + 20); + + return ($this->_description = $this->getBadges() . $description); + } + + + public function getFullDescription() { + $description_length = $this->_widget_context + ? $this->_widget_context->getDescriptionLength() + : null; + + $description = $this->_view->truncate($this->_model->getResume(), + ['class' => 'model_description_' . get_class($this->_model)], + 20, true); + + if ($this->_model->getNotes()) + $description .= $this->_view->truncate(implode("; ",$this->_model->getNotes()), + ['class' => 'model_note_' . get_class($this->_model)], + 20, true); + + return ($this->_description = $this->getBadges() . $description); + } +} diff --git a/library/templates/Intonation/View/Notice/ArticlesPeriodiques.php b/library/templates/Intonation/View/Notice/ArticlesPeriodiques.php new file mode 100644 index 0000000000000000000000000000000000000000..b03e31245af1d99905b3a0f6cb009f322b70dc52 --- /dev/null +++ b/library/templates/Intonation/View/Notice/ArticlesPeriodiques.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright (c) 2012-2024, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_View_Notice_ArticlesPeriodiques extends ZendAfi_View_Helper_BaseHelper { + const LIMIT = 20; + public function Notice_ArticlesPeriodiques($notice) { + return $this->_renderArticles($notice); + } + + + protected function _renderArticles($notice) { + $headkey = + Class_Indexation::getInstance()->serialCodeAlphaChapeau($notice->getClefChapeau(), + $notice->getTomeAlpha()); + + + $count_articles = Class_Notice::countBy(['clef_chapeau' => $headkey, + 'type_doc' => Class_TypeDoc::PERIODIQUE_ARTICLE, + 'order' => 'id_notice']); + + $articles = Class_Notice::findAllBy(['clef_chapeau' => $headkey, + 'type_doc' => Class_TypeDoc::PERIODIQUE_ARTICLE, + 'limit' => static::LIMIT, + 'order' => 'id_notice']); + + $articles = + (new Storm_Collection($articles)) + ->collect(function ($article) + { + return new Intonation_Library_View_Wrapper_SerialArticle($article, + $this->view); + }); + + $html = $this->view->renderCollection($articles, + [], + (function($item) + { + return $this->view->cardifyOnlyDescription($item); + })); + + + if ($count_articles > static::LIMIT) + $html .= $this->view->tagAction((new Intonation_Library_Link()) + ->setText($this->view->_('Voir les %d articles', $count_articles)) + ->setImage($this->view->templateIco('search_more','library')) + ->setTitle($this->view->_('Rechercher dans le catalogue')) + ->setUrl(Class_Url::relative(['controller' => 'recherche', + 'action' => 'simple', + 'rech_titres' => $headkey, + 'type_doc' => 'per_art'])) + + + ); + + return $html; + + } +} diff --git a/tests/scenarios/Serials/SerialsDetailsTest.php b/tests/scenarios/Serials/SerialsDetailsTest.php index 616e4bd0f4ee10db0891ba8d3ffc437297b0f627..4c7c2c73b379918e64eb214816adbd012d7f9cb1 100644 --- a/tests/scenarios/Serials/SerialsDetailsTest.php +++ b/tests/scenarios/Serials/SerialsDetailsTest.php @@ -172,14 +172,111 @@ class SerialsDetailsNoticeAjaxControllerPeriodiqueSerieXsltTest extends SerialsD -class SerialsDetailsInTemplatesTest extends SerialsDetailsWithXsltTestCase { +class SerialsDetailsRecordDescriptionPeriodiqueSerieTest extends SerialsDetailsTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/recherche/viewnotice/id/234/id_profil/21'); + $this->_buildTemplateProfil(['id' => 78]); + + Storm_Cache::beVolatile(); + + $this + ->onLoaderOfModel(Class_Notice_SerialArticles::class) + ->whenCalled('findAllBy') + ->answers([]); + + $abdelkrim = $this->fixture(Class_CodifAuteur::class, + ['id' => 42, + 'libelle' => 'Abdelkrim Samir', + 'formes'=> 'ABDELKRIMxSAMIR', + 'mot_renvois' => '']); + + $aberkane = $this->fixture(Class_CodifAuteur::class, + ['id' => 43, + 'libelle' => 'Aberkane Idriss', + 'formes'=> 'ABERKANExIDRISS', + 'mot_renvois' => '']); + + + $this + ->onLoaderOfModel(Class_CodifAuteur::class) + ->whenCalled('findByCodeAlpha') + ->with(['ABDELKRIMxSAMIR']) + ->answers([$abdelkrim]) + ->whenCalled('findByCodeAlpha') + ->with(['ABERKANExIDRISS']) + ->answers([$aberkane]); + + Class_CosmoVar::setValueOf('unimarc_zone_matiere',"610a"); + + foreach (range(1, 105) as $id) + $this->fixture(Class_Notice::class, + ['id' => $id, + 'clef_chapeau' => 'FAKIR 58', + 'tome_alpha' => '58', + 'auteurs' => 'Djamel, Farid', + 'description' => 'petite description', + 'unimarc' => (new Class_NoticeUnimarc_Fluent()) + ->zoneWithChildren('200',['a' => "Mon Article $id", + 'e' => 'complement titre', + 'f' => 'Auteur Article']) + ->zoneWithChildren('300',['a' => 'Ma Petite Note']) + ->zoneWithChildren('330',['a' => 'Un résumé succinct']) + ->zoneWithChildren('215',['a' => sprintf("pp. %d %d",$id,$id+2)]) + ->zoneWithChildren('610',['a' => 'Sujet Brûlant']) + ->zoneWithChildren('461',['t' => 'Fakir', 'v'=>'58']) + ->zoneWithChildren('700',['a' => 'Abdelkrim', 'b' => "Samir"]) + ->zoneWithChildren('701',['a' => 'Aberkane', 'b' => "Idriss"]) + ->render(), + 'type_doc' => Class_TypeDoc::PERIODIQUE_ARTICLE + ]); + + $this->dispatch('/record/description/id/234/id_profil/78'); } - public function getProfile() { - return $this->_buildTemplateProfil(['id' => 21]); + /** @test */ + public function pageShouldContainsMonArticle() { + $this->assertXPathContentContains('//a[@href="/recherche/viewnotice/id/1"]', 'Mon Article 1 : complement titre'); + } + + + /** @test */ + public function pageShouldDisplay20Articles() { + $this->assertXPathCount('//div[contains(@class,"card_title_Intonation_Library_View_Wrapper_SerialArticle")]' + ,20); + } + + + /** @test */ + public function pageShouldDisplayLinkToRechercheSimpleWithTitleAndTypeDocPerArticle() { + $this->assertXPath('//a[contains(@href,"/simple/rech_titres/FAKIR+58/type_doc/per_art")]'); + } + + + /** @test */ + public function LinkToRechercheSimpleShouldDisplayVoirles() { + $this->assertXPathContentContains('//a[contains(@href,"/simple/rech_titres/FAKIR+58/type_doc/per_art")]', + 'Voir les 105 articles'); + } + + + public function getElementsToTest() { + return [['note','Ma Petite Note'], + ['description', 'Un résumé succinct']]; + } + + /** @test + @dataProvider getElementsToTest + */ + public function modelElementShouldCorrespondingExpectedString($element, $expected_result) { + $this->assertXPathContentContains('//p[@class="model_'.$element.'_Class_Notice"]', + $expected_result); + } + + + /** @test */ + public function cardTitleShouldContainsParuDansFakir58AndCollation() { + $this->assertXPathContentContains('//div[@class="card-subtitle card_subtitle card_subtitle_Intonation_Library_View_Wrapper_SerialArticle"]', + 'paru dans Fakir 58 pp. 1 3'); } }