Commit 989a8bfb authored by Patrick Barroca's avatar Patrick Barroca 🐧

hotline #114141 : fix libraries url in templates libraries widget

parent f91e68fb
Pipeline #10650 passed with stage
in 45 minutes and 54 seconds
- ticket #114141 : Magasin de thèmes : Boite Bibliothèque : Correction de la prise en compte des URL dédiées aux bibliothèques
\ No newline at end of file
......@@ -412,24 +412,28 @@ class Class_Bib extends Storm_Model_Abstract {
public function getUrl() {
if (!Class_Template::current()->isLegacy())
return Class_Url::assemble(['controller' => 'bib',
'action' => 'en-lire-plus',
'id' => $this->getId()]);
if ($this->hasRewriteUrl())
return Class_Url::assemble(['module' => $this->getRewriteUrl()], null, true);
$parts = ($profil = $this->_getProfilForUrl())
? $profil->getUrlParts()
: ['controller' => 'bib',
'action' => 'bibview',
'id' => $this->getId()];
: $this->_defaultUrlParts();
return Class_Url::assemble($parts, null, true);
}
protected function _defaultUrlParts() {
$action = Class_Template::current()->isLegacy()
? 'bibview'
: 'en-lire-plus';
return ['controller' => 'bib',
'action' => $action,
'id' => $this->getId()];
}
protected function _getProfilForUrl() {
return $this->hasLinkToProfil()
? $this->getLinkToProfil()
......
......@@ -29,17 +29,9 @@ class Intonation_View_LibrariesWidget extends ZendAfi_View_Helper_BaseHelper {
public function librariesWidget($settings) {
$temp_settings = [];
if (is_array($settings)) {
foreach($settings as $key => $value)
$temp_settings[Storm_Inflector::camelize(Storm_Inflector::underscorize($key))] = $value;
$settings = Class_Template::current()->getWidgetSettingsWrapper($temp_settings);
}
$this->_libraries = null;
$this->_filter_settings = null;
$this->_settings = $settings;
$this->_settings = $this->_ensureSettingsWrapper($settings);
return $this->view->div(['class' => 'ajax_content'],
$this->_renderFilters()
......@@ -48,6 +40,18 @@ class Intonation_View_LibrariesWidget extends ZendAfi_View_Helper_BaseHelper {
}
protected function _ensureSettingsWrapper($settings) {
if (!is_array($settings))
return $settings;
$temp = [];
foreach($settings as $key => $value)
$temp[Storm_Inflector::camelize(Storm_Inflector::underscorize($key))] = $value;
return Class_Template::current()->getWidgetSettingsWrapper($temp);
}
protected function _renderLibraries() {
return (new Intonation_Library_Widget_Carousel_Library_View($this->_settings->getIdModule(),
$this->_settings->toArray()))
......
......@@ -5531,10 +5531,12 @@ class TemplatesSuggestionAchatAddPostWithSearchRecordTest extends TemplatesInton
class TemplatesDispatchLibraryWidgetWithOSMTest extends TemplatesIntonationTestCase {
class TemplatesDispatchLibraryWidgetWithOSMAndLinkToProfileTest extends TemplatesIntonationTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Profil', ['id' => 123]);
$this->fixture('Class_Bib',
['id' => 1,
'libelle' => 'Annecy',
......@@ -5542,7 +5544,8 @@ class TemplatesDispatchLibraryWidgetWithOSMTest extends TemplatesIntonationTestC
['id' => 9,
'libelle' => 'Annecy',
'latitude' => '1',
'longitude' => '1'])]);
'longitude' => '1']),
'link_to_profil_id' => 123]);
Class_Profil::find(72)
->setCfgAccueil(['modules' =>
......@@ -5578,4 +5581,15 @@ class TemplatesDispatchLibraryWidgetWithOSMTest extends TemplatesIntonationTestC
public function dataOsmLayerShouldBe1() {
$this->assertXPath('//div[contains(@data-osm-layer, "1")]');
}
}
\ No newline at end of file
/**
* @test
* @see https://forge.afi-sa.net/issues/114141
*/
public function linkToDetailShouldTargetProfile123() {
$this->assertXPathContentContains('//div[@id="boite_21"]//a[contains(@href, "/id_profil/123")]',
'Annecy',
$this->_response->getBody());
}
}
Markdown is supported
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