Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Kudos-Donations
Commits
01d8260f
Commit
01d8260f
authored
Oct 20, 2021
by
Michael Iseard
Browse files
Add ellipsis to message/context if longer than 255 chars
parent
5874621a
Changes
2
Show whitespace changes
Inline
Side-by-side
app/Helpers/Utils.php
View file @
01d8260f
...
...
@@ -292,4 +292,19 @@ class Utils {
return
$image_url
;
}
/**
* Truncates string at specified length and return with ellipsis
* if longer.
*
* @param string $string
* @param int $length
*
* @return string
*/
public
static
function
truncate_string
(
string
$string
,
int
$length
):
string
{
return
strlen
(
$string
)
>
$length
?
substr
(
$string
,
0
,
$length
)
.
"..."
:
$string
;
}
}
app/View/kudos-admin-debug.php
View file @
01d8260f
<?php
use
Kudos\Helpers\Utils
;
use
Kudos\Service\LoggerService
;
/**
...
...
@@ -93,10 +94,10 @@ $tab = $_GET['tab'] ?? $default_tab;
<?php
echo
esc_attr
(
$level
);
?>
</td>
<td
title=
"
<?php
echo
(
$message
);
?>
"
>
<?php
echo
(
substr
(
$message
,
0
,
255
)
);
?>
<?php
echo
(
Utils
::
truncate_string
(
$message
,
255
)
);
?>
</td>
<td
title=
"
<?php
echo
(
$context
);
?>
"
>
<?php
echo
(
substr
(
$context
,
0
,
255
)
);
?>
<?php
echo
(
Utils
::
truncate_string
(
$context
,
255
)
);
?>
</td>
</tr>
...
...
Write
Preview
Supports
Markdown
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