diff --git a/VERSIONS_HOTLINE/122660 b/VERSIONS_HOTLINE/122660 new file mode 100644 index 0000000000000000000000000000000000000000..e216e5ec4a18388e7f8720e3ecef99e2fd254321 --- /dev/null +++ b/VERSIONS_HOTLINE/122660 @@ -0,0 +1 @@ + - ticket #122660 : Magasin de thèmes : Correction du lien "Voir" sur les pseudo-notices d'articles. Renvoie sur la page d'article plutôt que sur la pseudo-notice. \ No newline at end of file diff --git a/library/Class/Notice/Permalink.php b/library/Class/Notice/Permalink.php index 29487df8bdfd258b6c593b3486db14832b1f312d..0434700b5eb506835e3d9167679bdcdef9808e7c 100644 --- a/library/Class/Notice/Permalink.php +++ b/library/Class/Notice/Permalink.php @@ -35,10 +35,7 @@ class Class_Notice_Permalink { switch($doc_type) { case Class_TypeDoc::ARTICLE: - return ['module' => 'opac', - 'controller' => 'cms', - 'action' => 'articleview', - 'id' => $record->getChamp856b()]; + return $this->paramsForArticle($record); case Class_TypeDoc::RSS: return ['module' => 'opac', @@ -53,11 +50,7 @@ class Class_Notice_Permalink { 'id_items' => $record->getChamp856b()]; } - $defaults = ['module' => 'opac', - 'controller' => 'recherche', - 'action' => 'viewnotice', - 'clef' => $record->getClefAlpha(), - 'id' => $record->getId()]; + $defaults = $this->paramsForRecord($record); $params = ($config = Class_DigitalResource::getInstance()->configFor($doc_type)) ? $config->getSearchUrlForRecord($record) @@ -69,6 +62,30 @@ class Class_Notice_Permalink { } + public function absoluteForRecordOrArticle($model) { + return $model->isArticleCms() + ? $this->paramsForArticle($model) + : $this->paramsForRecord($model); + } + + + public function paramsForRecord($record) { + return ['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'viewnotice', + 'clef' => $record->getClefAlpha(), + 'id' => $record->getId()]; + } + + + public function paramsForArticle($record) { + return ['module' => 'opac', + 'controller' => 'cms', + 'action' => 'articleview', + 'id' => $record->getChamp856b()]; + } + + protected function _searchUrl() { return ['module' => 'opac', 'controller'=>'recherche', diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 726fd7f94e659ac42009974b8ca098d1559ccfb6..1e75d52d62fc80a95d0e4d0c66aa8f5fa9b280a9 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -53,10 +53,11 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra public function getMainLink() { - return new Intonation_Library_Link(['Url' => array_merge($this->_widget_context_params, - ['controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $this->_model->getId()]), + $url = + array_merge($this->_widget_context_params, + (new Class_Notice_Permalink)->absoluteForRecordOrArticle($this->_model)); + + return new Intonation_Library_Link(['Url' => $url, 'Image' => Class_Template::current()->getIco($this->_view, 'read-document', 'library'), diff --git a/library/templates/Intonation/View/RenderArticle.php b/library/templates/Intonation/View/RenderArticle.php index 97a1a689ac903d1ecca50c3a625be2dfd281519f..a7a2e4f35372f3087ff001ddfd81f1e7da5ea625 100644 --- a/library/templates/Intonation/View/RenderArticle.php +++ b/library/templates/Intonation/View/RenderArticle.php @@ -27,19 +27,13 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper { ->setModel($article) ->setView($this->view); - $osm = $this->view->mapForLieu($article->getLieu(), ['size' => '']); - - $grid_content = [$this->_div(['class' => 'article_location_header'], - $this->_tag('h2', $this->_('Lieu de l\'événement'))), - - $this->_div(['class' => 'article_location_static_map'], - $osm)]; + $grid_content = $this->_injectLocation($article->getLieu()); if ( ($osm_data = $wrapper->getOsmData()) && ($osm_wrapper = $osm_data->getwrapper())) $grid_content [] = $this->_div(['class' => 'article_location_data'], $this->view->cardify($osm_wrapper)); - $location_content = $this->view->grid(implode($grid_content)); + $location_content = $this->view->grid($grid_content); $body_content = [$article->getCacherTitre() ? '' @@ -61,8 +55,19 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper { $footer = $this->view->renderActionsInRow($wrapper->getActions()); return $this->_tag('div', - $body - . $footer, + $body . $footer, ['class' => 'card card_article']); } + + + protected function _injectLocation($location) { + if (!$location) + return []; + + return [$this->_div(['class' => 'article_location_header'], + $this->_tag('h2', $this->_('Lieu de l\'événement'))), + + $this->_div(['class' => 'article_location_static_map'], + $this->view->mapForLieu($location, ['size' => '']))]; + } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesArticlesTest.php b/tests/scenarios/Templates/TemplatesArticlesTest.php index 3e9e213cd23829da8004161571bdbf5f1d75a717..b6a5b0f9904bfa70781628f8a4ba4bd1cf2a7289 100644 --- a/tests/scenarios/Templates/TemplatesArticlesTest.php +++ b/tests/scenarios/Templates/TemplatesArticlesTest.php @@ -682,3 +682,23 @@ class TemplatesArticlesWidgetWithDescriptionLengthTest extends AbstractControlle 'La description s\'arrête ici …'); } } + + + + +class TemplatesArticlesWithNoLocationViewTest extends TemplatesArticlesWithLocationTestCase { + + public function setUp() { + parent::setUp(); + + Class_Article::find(7)->setLieu(null); + + $this->dispatch('/opac/cms/articleview/id/7/id_profil/1'); + } + + + /** @test */ + public function locationDivShouldNotBePresent() { + $this->assertNotXPath('//div[contains(@class, "article_location")]'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index aa122de1db6a801eaae31a45f8712fbdc9b488f6..8c28bdc616a65d236281b8341639cdb0c0bab866 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -671,6 +671,7 @@ abstract class TemplatesSearchDispatchTest extends AbstractControllerTestCase { ['id' => 89]), $this->fixture('Class_Notice', ['id' => 99])]; + ZendAfi_Auth::getInstance()->clearIdentity(); Zend_Registry::set('sql', $this->mock() @@ -719,4 +720,29 @@ class TemplatesSearchDispatchWithWallDefaultRenderingTest extends TemplatesSearc public function defaultRenderingShouldBeListMode() { $this->assertXPath('//main//div[contains(@class,"search_records_col")]//div[contains(@class, "masonry")]//div[contains(@class, "card")]'); } +} + + + + +class TemplatesSearchDispatchWithArticlesIndexedTest extends TemplatesSearchDispatchTest { + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Article', + ['id' => 34, + 'titre' => 'Bonjour les Terriens', + 'contenu' => 'Bienvenue dans le système Solaire', + 'id_notice' => 89]) + ->index(); + + $this->dispatch('/opac/recherche/simple/expressionRecherche/solaire/id_profil/5'); + } + + + /** @test */ + public function linkToBonjourLesTerriensShouldBeCmsArticleViewId34() { + $this->assertXPath('//main//div[contains(@class,"search_records_col")]//a[contains(@href, "/cms/articleview/expressionRecherche/solaire/id_profil/5/id/34")]'); + } } \ No newline at end of file