Skip to content
Snippets Groups Projects
Commit a2ff8176 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline MT #122660 : Fix article links in search results to access article pages directly

parent 8078afa2
Branches
Tags
2 merge requests!3782Hotline,!3776hotline MT #122660 : Fix article links in search results to access article pages directly
Pipeline #11940 passed with stage
in 53 minutes and 46 seconds
- 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
...@@ -35,10 +35,7 @@ class Class_Notice_Permalink { ...@@ -35,10 +35,7 @@ class Class_Notice_Permalink {
switch($doc_type) { switch($doc_type) {
case Class_TypeDoc::ARTICLE: case Class_TypeDoc::ARTICLE:
return ['module' => 'opac', return $this->paramsForArticle($record);
'controller' => 'cms',
'action' => 'articleview',
'id' => $record->getChamp856b()];
case Class_TypeDoc::RSS: case Class_TypeDoc::RSS:
return ['module' => 'opac', return ['module' => 'opac',
...@@ -53,11 +50,7 @@ class Class_Notice_Permalink { ...@@ -53,11 +50,7 @@ class Class_Notice_Permalink {
'id_items' => $record->getChamp856b()]; 'id_items' => $record->getChamp856b()];
} }
$defaults = ['module' => 'opac', $defaults = $this->paramsForRecord($record);
'controller' => 'recherche',
'action' => 'viewnotice',
'clef' => $record->getClefAlpha(),
'id' => $record->getId()];
$params = ($config = Class_DigitalResource::getInstance()->configFor($doc_type)) $params = ($config = Class_DigitalResource::getInstance()->configFor($doc_type))
? $config->getSearchUrlForRecord($record) ? $config->getSearchUrlForRecord($record)
...@@ -69,6 +62,30 @@ class Class_Notice_Permalink { ...@@ -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() { protected function _searchUrl() {
return ['module' => 'opac', return ['module' => 'opac',
'controller'=>'recherche', 'controller'=>'recherche',
......
...@@ -53,10 +53,11 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra ...@@ -53,10 +53,11 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra
public function getMainLink() { public function getMainLink() {
return new Intonation_Library_Link(['Url' => array_merge($this->_widget_context_params, $url =
['controller' => 'recherche', array_merge($this->_widget_context_params,
'action' => 'viewnotice', (new Class_Notice_Permalink)->absoluteForRecordOrArticle($this->_model));
'id' => $this->_model->getId()]),
return new Intonation_Library_Link(['Url' => $url,
'Image' => Class_Template::current()->getIco($this->_view, 'Image' => Class_Template::current()->getIco($this->_view,
'read-document', 'read-document',
'library'), 'library'),
......
...@@ -27,19 +27,13 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper { ...@@ -27,19 +27,13 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper {
->setModel($article) ->setModel($article)
->setView($this->view); ->setView($this->view);
$osm = $this->view->mapForLieu($article->getLieu(), ['size' => '']); $grid_content = $this->_injectLocation($article->getLieu());
$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)];
if ( ($osm_data = $wrapper->getOsmData()) && ($osm_wrapper = $osm_data->getwrapper())) if ( ($osm_data = $wrapper->getOsmData()) && ($osm_wrapper = $osm_data->getwrapper()))
$grid_content [] = $this->_div(['class' => 'article_location_data'], $grid_content [] = $this->_div(['class' => 'article_location_data'],
$this->view->cardify($osm_wrapper)); $this->view->cardify($osm_wrapper));
$location_content = $this->view->grid(implode($grid_content)); $location_content = $this->view->grid($grid_content);
$body_content = [$article->getCacherTitre() $body_content = [$article->getCacherTitre()
? '' ? ''
...@@ -61,8 +55,19 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper { ...@@ -61,8 +55,19 @@ class Intonation_View_RenderArticle extends ZendAfi_View_Helper_BaseHelper {
$footer = $this->view->renderActionsInRow($wrapper->getActions()); $footer = $this->view->renderActionsInRow($wrapper->getActions());
return $this->_tag('div', return $this->_tag('div',
$body $body . $footer,
. $footer,
['class' => 'card card_article']); ['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
...@@ -682,3 +682,23 @@ class TemplatesArticlesWidgetWithDescriptionLengthTest extends AbstractControlle ...@@ -682,3 +682,23 @@ class TemplatesArticlesWidgetWithDescriptionLengthTest extends AbstractControlle
'La description s\'arrête ici …'); '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
...@@ -671,6 +671,7 @@ abstract class TemplatesSearchDispatchTest extends AbstractControllerTestCase { ...@@ -671,6 +671,7 @@ abstract class TemplatesSearchDispatchTest extends AbstractControllerTestCase {
['id' => 89]), ['id' => 89]),
$this->fixture('Class_Notice', $this->fixture('Class_Notice',
['id' => 99])]; ['id' => 99])];
ZendAfi_Auth::getInstance()->clearIdentity(); ZendAfi_Auth::getInstance()->clearIdentity();
Zend_Registry::set('sql', Zend_Registry::set('sql',
$this->mock() $this->mock()
...@@ -719,4 +720,29 @@ class TemplatesSearchDispatchWithWallDefaultRenderingTest extends TemplatesSearc ...@@ -719,4 +720,29 @@ class TemplatesSearchDispatchWithWallDefaultRenderingTest extends TemplatesSearc
public function defaultRenderingShouldBeListMode() { public function defaultRenderingShouldBeListMode() {
$this->assertXPath('//main//div[contains(@class,"search_records_col")]//div[contains(@class, "masonry")]//div[contains(@class, "card")]'); $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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment