Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GLPI
glpi
Commits
23300137
Commit
23300137
authored
Mar 07, 2021
by
Cédric Anne
Browse files
Remove useless usage of Html::setRichTextContent()
parent
81ad398e
Changes
8
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
23300137
...
...
@@ -32,6 +32,7 @@ The present file will list all changes made to the project; according to the
-
`CommonDBTM::clone()`
-
`CommonDBTM::prepareInputForClone()`
-
`CommonDBTM::post_clone()`
-
`Html::setRichTextContent()`
-
`RuleImportComputer`
class
-
`RuleImportComputerCollection`
class
...
...
inc/change.class.php
View file @
23300137
...
...
@@ -1170,12 +1170,7 @@ class Change extends CommonITILObject {
$content
=
Html
::
cleanPostForTextArea
(
$content
);
}
$content
=
Html
::
setRichTextContent
(
$content_id
,
$content
,
$rand
,
!
$canupdate
);
$content
=
Toolbox
::
getHtmlToDisplay
(
$content
);
echo
"<div id='content
$rand_text
'>"
;
if
(
$canupdate
)
{
...
...
@@ -1191,11 +1186,11 @@ class Change extends CommonITILObject {
'required'
=>
$tt
->
isMandatoryField
(
'content'
),
'rows'
=>
$rows
,
'enable_richtext'
=>
true
,
'value'
=>
$content
,
'value'
=>
Html
::
entities_deep
(
$content
),
// Re-encode entities for textarea
'uploads'
=>
$uploads
,
]);
}
else
{
echo
Toolbox
::
getHtmlToDisplay
(
$content
)
;
echo
$content
;
}
echo
"</div>"
;
...
...
inc/commonitilobject.class.php
View file @
23300137
...
...
@@ -7164,9 +7164,8 @@ abstract class CommonITILObject extends CommonDBTM {
echo
"</p>"
;
echo
"<div class='rich_text_container'>"
;
$richtext
=
Html
::
setRichTextContent
(
''
,
$content
,
''
,
true
);
$richtext
=
Html
::
replaceImagesByGallery
(
$richtext
);
echo
$richtext
;
$content
=
Html
::
replaceImagesByGallery
(
$content
);
echo
$content
;
echo
"</div>"
;
if
(
!
empty
(
$long_text
))
{
...
...
@@ -7446,9 +7445,9 @@ abstract class CommonITILObject extends CommonDBTM {
echo
"</div>"
;
echo
"<div class='rich_text_container'>"
;
$
rich
te
x
t
=
Html
::
s
et
RichTextContent
(
''
,
$this
->
fields
[
'content'
]
,
''
,
true
);
$
rich
te
x
t
=
Html
::
replaceImagesByGallery
(
$
rich
te
x
t
);
echo
$
rich
te
x
t
;
$
con
te
n
t
=
Toolbox
::
g
et
HtmlToDisplay
(
$this
->
fields
[
'content'
]);
$
con
te
n
t
=
Html
::
replaceImagesByGallery
(
$
con
te
n
t
);
echo
$
con
te
n
t
;
echo
"</div>"
;
echo
"</div>"
;
// h_content ITILContent
...
...
inc/html.class.php
View file @
23300137
...
...
@@ -4023,9 +4023,13 @@ JS;
* @param boolean $readonly true will set editor in readonly mode
*
* @return $content
*
* @deprecated x.x.x
**/
static
function
setRichTextContent
(
$name
,
$content
,
$rand
,
$readonly
=
false
)
{
Toolbox
::
deprecated
();
// Init html editor (if name of textarea is provided)
if
(
!
empty
(
$name
))
{
Html
::
initEditorSystem
(
$name
,
$rand
,
true
,
$readonly
);
...
...
inc/problem.class.php
View file @
23300137
...
...
@@ -1634,12 +1634,7 @@ class Problem extends CommonITILObject {
$content
=
Html
::
cleanPostForTextArea
(
$content
);
}
$content
=
Html
::
setRichTextContent
(
$content_id
,
$content
,
$rand
,
!
$canupdate
);
$content
=
Toolbox
::
getHtmlToDisplay
(
$content
);
echo
"<div id='content
$rand_text
'>"
;
if
(
$canupdate
)
{
...
...
@@ -1655,11 +1650,11 @@ class Problem extends CommonITILObject {
'required'
=>
$tt
->
isMandatoryField
(
'content'
),
'rows'
=>
$rows
,
'enable_richtext'
=>
true
,
'value'
=>
$content
,
'value'
=>
Html
::
entities_deep
(
$content
),
// Re-encode entities for textarea
'uploads'
=>
$uploads
,
]);
}
else
{
echo
Toolbox
::
getHtmlToDisplay
(
$content
)
;
echo
$content
;
}
echo
"</div>"
;
...
...
inc/ticket.class.php
View file @
23300137
...
...
@@ -4027,7 +4027,6 @@ class Ticket extends CommonITILObject {
if
(
!
$ticket_template
)
{
$content
=
Html
::
cleanPostForTextArea
(
$options
[
'content'
]);
}
$content
=
Html
::
setRichTextContent
(
$content_id
,
$content
,
$rand
);
echo
"<div id='content
$rand_text
'>"
;
$uploads
=
[];
...
...
@@ -4950,12 +4949,7 @@ class Ticket extends CommonITILObject {
$content
=
Html
::
cleanPostForTextArea
(
$content
);
}
$content
=
Html
::
setRichTextContent
(
$content_id
,
$content
,
$rand
,
!
$canupdate
);
$content
=
Toolbox
::
getHtmlToDisplay
(
$content
);
echo
"<div id='content
$rand_text
'>"
;
if
(
$canupdate
||
$can_requester
)
{
...
...
@@ -4971,11 +4965,11 @@ class Ticket extends CommonITILObject {
'required'
=>
$tt
->
isMandatoryField
(
'content'
),
'rows'
=>
$rows
,
'enable_richtext'
=>
true
,
'value'
=>
$content
,
'value'
=>
Html
::
entities_deep
(
$content
),
// Re-encode entities for textarea
'uploads'
=>
$uploads
,
]);
}
else
{
echo
Toolbox
::
getHtmlToDisplay
(
$content
)
;
echo
$content
;
}
echo
"</div>"
;
echo
$tt
->
getEndHiddenFieldValue
(
'content'
,
$this
);
...
...
inc/toolbox.class.php
View file @
23300137
...
...
@@ -2999,11 +2999,17 @@ class Toolbox {
*/
public
static
function
getHtmlToDisplay
(
$content
)
{
$content
=
Toolbox
::
unclean_cross_side_scripting_deep
(
Html
::
entity_decode_deep
(
$content
)
$content
);
$content
=
nl2br
(
Html
::
clean
(
$content
,
false
,
1
));
$content
=
Html
::
clean
(
$content
,
false
,
1
);
// If content does not contain <br> or <p> html tag, use nl2br
// Required to correctly render linebreaks from "simple text mode" from GLPI prior to 9.4.0.
if
(
!
preg_match
(
'/<br\s?\/?>/'
,
$content
)
&&
!
preg_match
(
'/<p>/'
,
$content
))
{
$content
=
nl2br
(
$content
);
}
return
$content
;
}
...
...
tests/functionnal/Ticket.php
View file @
23300137
...
...
@@ -3056,7 +3056,7 @@ class Ticket extends DbTestCase {
$instance
=
new
\
Ticket
();
$instance
->
showForm
(
'-1'
);
}
)
->
contains
(
'src=
"
data:image/png;base64,'
.
$base64Image
.
'
"
'
);
)
->
contains
(
'src=
"
data:image/png;base64,'
.
$base64Image
.
'
"
'
);
}
public
function
testScreenshotConvertedIntoDocument
()
{
...
...
@@ -3189,7 +3189,7 @@ class Ticket extends DbTestCase {
$instance
->
showForm
(
'0'
);
$_SESSION
[
'glpiactiveprofile'
][
'tickettemplates_id'
]
=
$session_tpl_id_back
;
}
)
->
contains
(
'src=
"
data:image/png;base64,'
.
$base64Image
.
'
"
'
);
)
->
contains
(
'src=
"
data:image/png;base64,'
.
$base64Image
.
'
"
'
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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