Commit 2c1bff96 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#155100_images_manquantes_lors_de_l_affichage_du_portail' into 'master'

hotline #155100 fix images URLs in themes from absolute to relative

See merge request !4467
parents 6df214c7 c02a3e05
Pipeline #17589 passed with stage
in 20 minutes and 19 seconds
- correctif #155100 : Magasin de thèmes : correction de la génération des URLs des images.
\ No newline at end of file
......@@ -634,6 +634,12 @@ class Class_Article extends Storm_Model_Abstract {
}
public function getFirstImageRelativeURL() : string {
return $this->withFirstImageDo(function($url) {return Class_Url::relative($url);});
}
public function getFirstImagePath() {
return $this->withFirstImageDo(function($url) {return $this->getPathFromURL($url);});
}
......
......@@ -588,6 +588,11 @@ class Class_FileManager extends Class_Entity {
}
public function getRelativeUrl() : string {
return Class_Url::relative($this->getPath(), null, true);
}
public function getRealpath() {
return $this->_attribs['Realpath'];
}
......
......@@ -547,7 +547,7 @@ class Herisson_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher
'position_fixed_top_left',
'no_border_widget',
'no_border_radius'],
'image' => Class_Url::absolute('/library/templates/Herisson/Assets/images/herisson_logo.png'),
'image' => Class_Url::relative('/library/templates/Herisson/Assets/images/herisson_logo.png'),
'link' => $this->_('/accueil'),
$this->_template->withNameSpace('width_xsmall') => 4,
$this->_template->withNameSpace('width_medium') => 2,
......@@ -585,7 +585,7 @@ class Herisson_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher
Class_Profil::DIV_BANNIERE,
array_merge(['titre' => $this->_('Image banniere'),
$this->_template->withNameSpace('styles_pack') => $this->_style_pack_image_banniere->getId(),
'image' => Class_Url::absolute('/library/templates/Herisson/Assets/images/banniere_herisson.jpg'),
'image' => Class_Url::relative('/library/templates/Herisson/Assets/images/banniere_herisson.jpg'),
'link' => $this->_('/accueil'),
$this->_template->withNameSpace('width_xsmall') => 12],
$this->_disable_widget_template))
......@@ -698,7 +698,7 @@ class Herisson_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher
'm-auto',
'py-3',
'align-items-center'],
'image' => Class_Url::absolute('/library/templates/Herisson/Assets/images/herisson_logo.png'),
'image' => Class_Url::relative('/library/templates/Herisson/Assets/images/herisson_logo.png'),
'link' => $this->_('/accueil'),
$this->_template->withNameSpace('width_xsmall') => 8,
$this->_template->withNameSpace('width_medium') => 5,
......
......@@ -70,7 +70,7 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr
public function getPicture() {
return $this->_model->getFirstImageAbsoluteURL();
return $this->_model->getFirstImageRelativeURL();
}
......
......@@ -58,7 +58,7 @@ class Intonation_Library_View_Wrapper_User extends Intonation_Library_View_Wrapp
if (!$img)
return '';
return Class_Url::absolute($img);
return Class_Url::relative($img);
}
......
......@@ -79,7 +79,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_ChangeImage extends Inton
protected function _cardify($image, $current) {
$url = $image->getUrl();
$url = $image->getRelativeUrl();
$selected = ($current == $url) ? ' border border-primary disabled shadow-lg selected btn btn-primary' : '';
return $this->_view->div(['class' => 'card shadow-sm' . $selected],
......
......@@ -132,7 +132,7 @@ class Intonation_Library_Widget_Accessibility_View extends Zendafi_View_Helper_A
'title' => $option->getText(),
'data-name' => $file]);
$icon = $this->view->tagImg(Class_Url::absolute(sprintf('public/opac/images/buttons/%s.png',
$icon = $this->view->tagImg(Class_Url::relative(sprintf('public/opac/images/buttons/%s.png',
$option->getIcon())));
$attribs = ['data-cookie-key' => $option->getCookieKey(),
......@@ -140,7 +140,7 @@ class Intonation_Library_Widget_Accessibility_View extends Zendafi_View_Helper_A
'onclick' => ''];
if ($file)
$attribs['data-stylesheet-url'] = Class_Url::absolute('/public/opac/css/' . $file . '.css');
$attribs['data-stylesheet-url'] = Class_Url::relative('/public/opac/css/' . $file . '.css');
if ($option->getDefaultStyle())
$attribs['data-stylesheet-default'] = 1;
......@@ -163,14 +163,14 @@ class Intonation_Library_Widget_Accessibility_View extends Zendafi_View_Helper_A
return
$this->view->button((new Class_Button)
->setImage($this->view->tagImg(Class_Url::absolute('public/opac/images/buttons/default_font_size.png')))
->setImage($this->view->tagImg(Class_Url::relative('public/opac/images/buttons/default_font_size.png')))
->setText($this->_('Réinitialiser la police'))
->setAttribs(['class' => 'accessibility default_font_size',
'data-font-size' => 'default',
'onclick' => '']))
. $this->view->button((new Class_Button)
->setImage($this->view->tagImg(Class_Url::absolute('public/opac/images/buttons/decrease_font_size.png')))
->setImage($this->view->tagImg(Class_Url::relative('public/opac/images/buttons/decrease_font_size.png')))
->setText($this->_('Diminuer la police'))
->setAttribs(['class' => 'accessibility',
'data-font-size' => 'decrease_font_size',
......@@ -186,7 +186,7 @@ class Intonation_Library_Widget_Accessibility_View extends Zendafi_View_Helper_A
'data-font-size' => 'current_font_size'])
. $this->view->button((new Class_Button)
->setImage($this->view->tagImg(Class_Url::absolute('public/opac/images/buttons/increase_font_size.png')))
->setImage($this->view->tagImg(Class_Url::relative('public/opac/images/buttons/increase_font_size.png')))
->setText($this->_('Augmenter la police'))
->setAttribs(['class' => 'accessibility',
'data-font-size' => 'increase_font_size',
......
......@@ -62,7 +62,7 @@ class Intonation_Library_Widget_Carousel_LibraryNovelties_View extends Intonatio
protected function _getRSSUrl() {
$profile = Class_Profil::getCurrentProfil();
return Class_Url::absolute(['module' => 'opac',
return Class_Url::relative(['module' => 'opac',
'controller' => 'rss',
'action' => 'library-novelties',
'id' => $this->_extractLibraryIdFromSettings(),
......
......@@ -35,11 +35,11 @@ class Intonation_Library_Widget_Image_View extends Zendafi_View_Helper_Accueil_B
$files = Class_FileManager::files(USERFILES . '/bannieres/');
$files = array_filter($files, function($file) { return $file->isImage();});
$file = reset($files);
$image = $file ? $file->getUrl() : '';
$image = $file ? $file->getRelativeUrl() : '';
}
$img = $image
? $this->view->tagImg(Class_Url::absolute($image),
? $this->view->tagImg(Class_Url::relative($image),
['class' => 'image_widget',
'alt' => $this->_settings->getImageAlt()])
: '';
......
......@@ -292,7 +292,7 @@ class Muscle_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher {
->_addWidget(Intonation_Library_Widget_Image_Definition::CODE,
Class_Profil::DIV_BANNIERE,
['titre' => $this->_('Logo du réseau'),
'image' => Class_Url::absolute('/library/templates/Muscle/Assets/images/logo.png'),
'image' => Class_Url::relative('/library/templates/Muscle/Assets/images/logo.png'),
'link' => '',
$this->_template->withNameSpace('styles_pack') => $this->_no_border_no_radius_no_shadow_no_background_content_center->getId(),
$this->_nameSpaced('responsive_pack') => $this->_full_width_responsive_pack->getId(),
......
......@@ -262,7 +262,7 @@ class Polygone_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher
'menus' => [
['type_menu' => 'ACCUEIL',
'libelle' => $this->_('Le Polygone'),
'picto' => Class_Url::absolute('/library/templates/Polygone/Assets/images/logo_footer.png'),
'picto' => Class_Url::relative('/library/templates/Polygone/Assets/images/logo_footer.png'),
'use_profil' => $this->_profile_id],
['type_menu' => 'URL',
......@@ -289,16 +289,16 @@ class Polygone_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher
'menus' => [
['type_menu' => 'URL',
'libelle' => $this->_('Se documenter'),
'picto' => Class_Url::absolute('/library/templates/Polygone/Assets/images/se_documenter.jpg'),
'picto' => Class_Url::relative('/library/templates/Polygone/Assets/images/se_documenter.jpg'),
'url' => ''],
['type_menu' => 'URL',
'libelle' => $this->_('S\'exercer'),
'picto' => Class_Url::absolute('/library/templates/Polygone/Assets/images/s_exercer.jpg'),
'picto' => Class_Url::relative('/library/templates/Polygone/Assets/images/s_exercer.jpg'),
'url' => ''],
['type_menu' => 'URL',
'picto' => Class_Url::absolute('/library/templates/Polygone/Assets/images/se_divertir.jpg'),
'picto' => Class_Url::relative('/library/templates/Polygone/Assets/images/se_divertir.jpg'),
'libelle' => $this->_('Se divertir'),
'url' => ''],
]
......@@ -356,7 +356,7 @@ class Polygone_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher
Class_Profil::DIV_BANNIERE,
['titre' => $this->_('Logo du réseau'),
'boite' => ['no_background'],
'image' => Class_Url::absolute('/library/templates/Polygone/Assets/images/logo.png'),
'image' => Class_Url::relative('/library/templates/Polygone/Assets/images/logo.png'),
'link' => '',
$this->_template->withNameSpace('styles_pack') => $this->_no_border_no_radius_no_shadow_content_center->getId(),
$this->_nameSpaced('responsive_pack') => $this->_half_and_quarter_responsive_pack->getId(),
......@@ -532,7 +532,7 @@ class Polygone_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher
->_addWidget(Intonation_Library_Widget_Image_Definition::CODE,
Class_Profil::DIV_FOOTER,
['titre' => $this->_('Logo du réseau'),
'image' => Class_Url::absolute('/library/templates/Polygone/Assets/images/logo_footer.png'),
'image' => Class_Url::relative('/library/templates/Polygone/Assets/images/logo_footer.png'),
'link' => '',
$this->_template->withNameSpace('styles_pack') => $this->_no_border_no_radius_no_shadow->getId(),
$this->_template->withNameSpace('width_xsmall') => 2,
......
......@@ -217,7 +217,7 @@ class TerreDuMilieu_Library_ProfilePatcher extends Intonation_Library_ProfilePat
['type_menu' => 'URL',
'libelle' => $this->_('France Connect'),
'url' => 'https://fcp.integ01.dev-franceconnect.fr/',
'picto' => Class_Url::absolute('/library/templates/TerreDuMilieu/Assets/images/franceconnect.jpg')]
'picto' => Class_Url::relative('/library/templates/TerreDuMilieu/Assets/images/franceconnect.jpg')]
]
]);
......@@ -228,7 +228,7 @@ class TerreDuMilieu_Library_ProfilePatcher extends Intonation_Library_ProfilePat
['type_menu' => 'URL',
'libelle' => $this->_('Bokeh'),
'url' => '',
'picto' => Class_Url::absolute('/library/templates/TerreDuMilieu/Assets/images/bokeh.png')],
'picto' => Class_Url::relative('/library/templates/TerreDuMilieu/Assets/images/bokeh.png')],
['type_menu' => 'URL',
'libelle' => $this->_('Facebook'),
......@@ -320,7 +320,7 @@ class TerreDuMilieu_Library_ProfilePatcher extends Intonation_Library_ProfilePat
Class_Profil::DIV_BANNIERE,
['titre' => $this->_('Logo du réseau'),
'boite' => ['justify-content-center', 'admin_tools_invert_colors'],
'image' => Class_Url::absolute('/library/templates/TerreDuMilieu/Assets/images/nav.png'),
'image' => Class_Url::relative('/library/templates/TerreDuMilieu/Assets/images/nav.png'),
'link' => '',
$this->_template->withNameSpace('styles_pack') => $this->_no_border_no_radius_no_shadow_no_background->getId(),
$this->_template->withNameSpace('responsive_pack') => $this->_full_width_responsive_pack->getId(),
......
......@@ -172,6 +172,14 @@ class HerissonTemplateIndexTest extends HerissonTemplateTestCase {
public function navigationAgendaEntryShouldHaveUrlAgenda() {
$this->assertXPathContentContains('//body//header//div[contains(@class, "boite nav")]//li//a[contains(@href,"/agenda")]', 'Agenda');
}
/** @test */
public function logoFooterUrlShouldBeRelative() {
$this->assertXPath('//footer//img[@src="'
. Class_Url::relative('/library/templates/Herisson/Assets/images/herisson_logo.png')
. '"]');
}
}
......
......@@ -184,6 +184,14 @@ class PolygoneTemplateOpacIndexWithUserAgentTest extends PolygoneTemplateTestCas
public function pageShouldBeAccessible() {
$this->assertAccessible(false);
}
/** @test */
public function logoFooterUrlShouldBeRelative() {
$this->assertXPath('//footer//img[@src="'
. Class_Url::relative('/library/templates/Polygone/Assets/images/logo_footer.png')
. '"]');
}
}
......
......@@ -1335,7 +1335,10 @@ class TemplatesAbonneDispatchAccountTest extends TemplatesIntonationAccountTestC
/** @test */
public function paulProfileImageShouldBeReadBlack() {
$this->assertXpath('//img[contains(@src, "/public/opac/images/abonnes/read_black.png")]');
$this->assertXpath('//img[@src="'
. Class_Url::relative("/public/opac/images/abonnes/read_black.png")
. '"]',
$this->_response->getBody());
}
......
......@@ -371,7 +371,7 @@ class TemplatesLibraryNoveltiesTabWidgetShowFooterTest extends TemplatesLibraryN
/** @test */
public function rssLinkShouldUseCacheKey() {
$this->assertXPath('//div//a[contains(@href, "/rss/library-novelties/id/1/language/fr/id_profil/23")]');
$this->assertXPath('//div//a[@href="/rss/library-novelties/id/1/language/fr/id_profil/23"]');
}
}
......
......@@ -79,7 +79,7 @@ class TemplatesProfileWithPageTest extends AbstractControllerTestCase {
/** @test */
public function agendaPageHeaderShouldContainsWidgetImageWithWeDontCareDotJPG() {
$this->dispatch('/agenda');
$this->assertXPath('//header//div[contains(@class, "boite image")]//img[@src="' . Class_Url::absolute('wedontcare.jpg') . '"]');
$this->assertXPath('//header//div[contains(@class, "boite image")]//img[@src="' . Class_Url::relative('wedontcare.jpg') . '"]');
}
......
......@@ -103,6 +103,14 @@ class TerreDuMilieuTemplateProfilePatcherTest extends TerreDuMilieuTemplateTestC
. '//a[@target="_blank"][contains(@href, "/admin/file-manager")]',
'Explorateur de fichiers');
}
/** @test */
public function logoHeaderUrlShouldBeRelative() {
$this->assertXPath('//header//img[@src="'
. Class_Url::relative('/library/templates/TerreDuMilieu/Assets/images/nav.png')
. '"]');
}
}
......
......@@ -639,3 +639,72 @@ class WidgetsEditAlbumsWidgetTest extends WidgetsSimpleTestCase {
$this->assertXPath('//button[text()="Valider"]');
}
}
class WidgetsCacheTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->clearIdentity();
Class_AdminVar::set('CACHE_ACTIF', 1);
Storm_Cache::beVolatile();
Storm_Cache::setSeed('test');
Storm_Cache::getDefaultZendCache()->save('seed', 'test');
$profile = $this->_buildTemplateProfil(['id' => 877987]);
(new Muscle_Template)->tryOn($profile);
$this
->onLoaderOfModel(Class_Article::class)
->whenCalled('getArticlesByPreferences')
->answers([$this->fixture(Class_Article::class,
['id' => 7,
'titre' => 'Parlez-vous français ?',
'description' => '<img src="/userfiles/test.png"></img>La description s\'arrête ici et pas plus loin.',
'contenu' => '<p>Une b...</p>',
'categorie' => $this->fixture(Class_ArticleCategorie::class,
['id' => 3,
'libelle' => 'Animations langues'])
])
]);
$this->dispatch('/');
}
/** @test */
public function pageShouldContainsImgWithRelativeUrlTestPng() {
$this->assertXPath('//body//div//img[@src="'
. Class_Url::relative('/userfiles/test.png')
. '"]',
$this->_response->getBody());
}
/** @test */
public function imageUrlShouldBeRelativeInCache() {
$this->assertContains('<img src="' . Class_Url::relative('/userfiles/test.png'),
Storm_Cache::getDefaultZendCache()
->load('seed_cd8b07c4c219ffe0566ca53bcecd90c2'));
}
/** @test */
public function logoImgUrlShouldBeRelative() {
$this->assertXPath('//body//img[@class="image_widget img-fluid"][@src="'
. Class_Url::relative('library/templates/Muscle/Assets/images/logo.png')
. '"]');
}
/** @test */
public function accessibilityIconsUrlShouldBeRelative() {
$this->assertXPath('//body//div[contains(@id, "accessibility_widget_tools_")]//img[@src="'
. Class_Url::relative('public/opac/images/buttons/increase_font_size.png')
. '"]');
}
}
\ No newline at end of file
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