Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
afi
opacce
Commits
169385aa
Commit
169385aa
authored
Apr 23, 2019
by
efalcy
Committed by
Ghislain Loas
Apr 29, 2019
Browse files
hotline#91113 : fix newsletter image articles display
parent
7e7ca8fd
Pipeline
#6868
passed with stage
in 36 minutes and 11 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
13 deletions
+52
-13
VERSIONS_HOTLINE/91113
VERSIONS_HOTLINE/91113
+2
-0
library/Class/Article/MailRenderer.php
library/Class/Article/MailRenderer.php
+2
-2
library/Class/CmsUrlTransformer.php
library/Class/CmsUrlTransformer.php
+12
-0
tests/application/modules/admin/controllers/NewsletterControllerTest.php
...on/modules/admin/controllers/NewsletterControllerTest.php
+36
-11
No files found.
VERSIONS_HOTLINE/91113
0 → 100644
View file @
169385aa
- ticket #91113 : Lettre d'information : correction de l'affichage des images d'articles.
\ No newline at end of file
library/Class/Article/MailRenderer.php
View file @
169385aa
...
...
@@ -41,8 +41,8 @@ class Class_Article_MailRenderer {
return
''
;
return
'<div style="padding:5px">'
.
'<h1>'
.
$article
->
getLabel
()
.
'</h1>'
.
'<div>'
.
$article
->
getFullContent
()
.
'</div>'
.
'<h1>'
.
Class_CmsUrlTransformer
::
transformLinksToAbsoluteUrl
(
$article
->
getLabel
()
)
.
'</h1>'
.
'<div>'
.
Class_CmsUrlTransformer
::
transformLinksToAbsoluteUrl
(
$article
->
getFullContent
()
)
.
'</div>'
.
'<div style="clear:both"></div>'
.
'</div>'
;
}
...
...
library/Class/CmsUrlTransformer.php
View file @
169385aa
...
...
@@ -46,6 +46,18 @@ class Class_CmsUrlTransformer {
:
$content
;
}
public
function
transformLinksToAbsoluteUrl
(
$content
)
{
preg_match_all
(
'/< *(img|a)[^>]*(src|href) *= *["\']?(\/[^"\']*)/i'
,
$content
,
$matches
);
foreach
(
$matches
[
3
]
as
$match
)
$content
=
preg_replace
(
"@(href|src)=('|
\"
)"
.
$match
.
"@i"
,
"$1=$2"
.
Class_Url
::
absolute
(
$match
),
$content
);
return
$content
;
}
public
function
forSaving
(
$content
)
{
return
$this
->
imgUrlAbsoluteToRelative
(
$content
);
...
...
tests/application/modules/admin/controllers/NewsletterControllerTest.php
View file @
169385aa
...
...
@@ -841,8 +841,8 @@ class Admin_NewsletterControllerSendActionWithCommandFailureTest extends Admin_N
class
Admin_NewsletterControllerPreviewActionTest
extends
Admin_NewsletterControllerTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
parent
::
setUp
();
$marcus
=
$this
->
fixture
(
'Class_Users'
,
[
'id'
=>
345
,
'login'
=>
'mmiller'
,
'password'
=>
'pass'
,
...
...
@@ -882,7 +882,7 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
$l_arnaque
=
$this
->
fixture
(
'Class_Article'
,
[
'id'
=>
13
,
'titre'
=>
'Gilets Jaunes'
,
'contenu'
=>
'
La révolution a commencé.'
]);
'contenu'
=>
'
<a href="'
.
BASE_URL
.
'/viewarticle/gilets-jaunes"> La révolution a commencé.<img src=\'/userfiles/jaunes.gif\' /> . <img SRC="/userfiles/gilets.gif" /></a><a href="http://lienexterne/maquereau"><img src=\'http://imageexterne/maquereau.gif\' /></a>'
,
]);
$this
->
fixture
(
'Class_ArticleCategorie'
,
[
'id'
=>
89
,
...
...
@@ -925,11 +925,6 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
}
public
function
testBodyHtml
()
{
$this
->
assertXPath
(
'//div//img[@src="zork.jpg"]'
,
$this
->
_response
->
getBody
());
}
/** @test */
public
function
noticeShouldBePresent
()
{
$this
->
assertQueryContentContains
(
'p'
,
'Martine à la plage'
,
$this
->
_response
->
getBody
());
...
...
@@ -950,26 +945,56 @@ class Admin_NewsletterControllerPreviewActionTest extends Admin_NewsletterContro
/** @test */
public
function
leRoiDesConsShouldBeDisplay
()
{
$this
->
assertXPathContentContains
(
'//div'
,
'Le Roi des cons'
,
$this
->
_response
->
getBody
()
);
$this
->
assertXPathContentContains
(
'//div'
,
'Le Roi des cons'
);
}
/** @test */
public
function
lArnaqueShouldBeDisplay
()
{
$this
->
assertXPathContentContains
(
'//div'
,
'L\'arnaque'
,
$this
->
_response
->
getBody
()
);
$this
->
assertXPathContentContains
(
'//div'
,
'L\'arnaque'
);
}
/** @test */
public
function
GiletsJaunesShouldBeDisplay
()
{
$this
->
assertXPathContentContains
(
'//div'
,
'Gilets Jaunes'
,
$this
->
_response
->
getBody
());
$this
->
assertXPathContentContains
(
'//div'
,
'Gilets Jaunes'
);
}
/** @test */
public
function
giletsImageUrlShouldContainsDomain
()
{
$this
->
assertXPath
(
'//div//img[@src="http://localhost'
.
BASE_URL
.
'/userfiles/gilets.gif"]'
);
}
/** @test */
public
function
jaunesImageUrlShouldContainsDomain
()
{
$this
->
assertXPath
(
'//div//img[@src=\'http://localhost'
.
BASE_URL
.
'/userfiles/jaunes.gif\']'
);
}
/** @test */
public
function
imageMaquereauShouldKeepSameUrl
()
{
$this
->
assertXPath
(
'//div//img[@src=\'http://imageexterne/maquereau.gif\']'
);
}
/** @test */
public
function
linkMaquereauShouldKeepSameUrl
()
{
$this
->
assertXPath
(
'//div//a[@href=\'http://lienexterne/maquereau\']'
);
}
/** @test */
public
function
linkArticleGiletJauneShouldContainsDomain
()
{
$this
->
assertXPath
(
'//div//a[@href="http://localhost'
.
BASE_URL
.
'/viewarticle/gilets-jaunes"]'
);
}
/** @test */
public
function
septanteMillionsShouldBeDisplay
()
{
$this
->
assertXPathContentContains
(
'//div'
,
'70 millions'
,
$this
->
_response
->
getBody
()
);
$this
->
assertXPathContentContains
(
'//div'
,
'70 millions'
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment