Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
b9a09a25
Commit
b9a09a25
authored
15 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Try to remove html tags only if required by truncation. Avoid if not required.
parent
e4c402c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/lib/functions.lib.php
+10
-8
10 additions, 8 deletions
htdocs/lib/functions.lib.php
with
10 additions
and
8 deletions
htdocs/lib/functions.lib.php
+
10
−
8
View file @
b9a09a25
...
...
@@ -863,32 +863,34 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='')
global
$conf
;
if
(
$size
==
0
)
return
$string
;
if
(
dol_textishtml
(
$string
))
$string
=
dol_string_nohtmltag
(
$string
,
1
);
if
(
!
defined
(
'USE_SHORT_TITLE'
)
||
(
defined
(
'USE_SHORT_TITLE'
)
&&
USE_SHORT_TITLE
))
if
(
!
defined
(
'USE_SHORT_TITLE'
)
||
USE_SHORT_TITLE
)
{
// We go always here
if
(
$trunc
==
'right'
)
{
if
(
dol_strlen
(
$string
,
$stringencoding
)
>
$size
)
return
dol_substr
(
$string
,
0
,
$size
,
$stringencoding
)
.
'...'
;
$newstring
=
dol_textishtml
(
$string
)
?
dol_string_nohtmltag
(
$string
,
1
)
:
$string
;
if
(
dol_strlen
(
$newstring
,
$stringencoding
)
>
$size
)
return
dol_substr
(
$newstring
,
0
,
$size
,
$stringencoding
)
.
'...'
;
else
return
$string
;
}
if
(
$trunc
==
'middle'
)
{
if
(
dol_strlen
(
$string
,
$stringencoding
)
>
2
&&
dol_strlen
(
$string
,
$stringencoding
)
>
$size
)
$newstring
=
dol_textishtml
(
$string
)
?
dol_string_nohtmltag
(
$string
,
1
)
:
$string
;
if
(
dol_strlen
(
$newstring
,
$stringencoding
)
>
2
&&
dol_strlen
(
$newstring
,
$stringencoding
)
>
$size
)
{
$size1
=
round
(
$size
/
2
);
$size2
=
round
(
$size
/
2
);
return
dol_substr
(
$string
,
0
,
$size1
,
$stringencoding
)
.
'...'
.
dol_substr
(
$string
,
dol_strlen
(
$string
,
$stringencoding
)
-
$size2
,
$size2
,
$stringencoding
);
return
dol_substr
(
$
new
string
,
0
,
$size1
,
$stringencoding
)
.
'...'
.
dol_substr
(
$
new
string
,
dol_strlen
(
$
new
string
,
$stringencoding
)
-
$size2
,
$size2
,
$stringencoding
);
}
else
return
$string
;
}
if
(
$trunc
==
'left'
)
{
if
(
dol_strlen
(
$string
,
$stringencoding
)
>
$size
)
return
'...'
.
dol_substr
(
$string
,
dol_strlen
(
$string
,
$stringencoding
)
-
$size
,
$size
,
$stringencoding
);
$newstring
=
dol_textishtml
(
$string
)
?
dol_string_nohtmltag
(
$string
,
1
)
:
$string
;
if
(
dol_strlen
(
$newstring
,
$stringencoding
)
>
$size
)
return
'...'
.
dol_substr
(
$newstring
,
dol_strlen
(
$newstring
,
$stringencoding
)
-
$size
,
$size
,
$stringencoding
);
else
return
$string
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment