Do not shorten comments in the activity sidebar
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
parent
66ae43880b
commit
b8cf2fb58b
|
@ -159,7 +159,7 @@ class Extension implements IExtension {
|
||||||
}
|
}
|
||||||
return (string) $l->t('%1$s commented', $params);
|
return (string) $l->t('%1$s commented', $params);
|
||||||
case self::ADD_COMMENT_MESSAGE:
|
case self::ADD_COMMENT_MESSAGE:
|
||||||
return $this->convertParameterToComment($params[0], 120);
|
return $this->convertParameterToComment($params[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -300,21 +300,12 @@ class Extension implements IExtension {
|
||||||
* @param string $parameter
|
* @param string $parameter
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function convertParameterToComment($parameter, $maxLength = 0) {
|
protected function convertParameterToComment($parameter) {
|
||||||
if (preg_match('/^\<parameter\>(\d*)\<\/parameter\>$/', $parameter, $matches)) {
|
if (preg_match('/^\<parameter\>(\d*)\<\/parameter\>$/', $parameter, $matches)) {
|
||||||
try {
|
try {
|
||||||
$comment = $this->commentsManager->get((int) $matches[1]);
|
$comment = $this->commentsManager->get((int) $matches[1]);
|
||||||
$message = $comment->getMessage();
|
$message = $comment->getMessage();
|
||||||
$message = str_replace("\n", '<br />', str_replace(['<', '>'], ['<', '>'], $message));
|
$message = str_replace("\n", '<br />', str_replace(['<', '>'], ['<', '>'], $message));
|
||||||
|
|
||||||
if ($maxLength && isset($message[$maxLength + 20])) {
|
|
||||||
$findSpace = strpos($message, ' ', $maxLength);
|
|
||||||
if ($findSpace !== false && $findSpace < $maxLength + 20) {
|
|
||||||
return substr($message, 0, $findSpace) . '…';
|
|
||||||
}
|
|
||||||
return substr($message, 0, $maxLength + 20) . '…';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
return '';
|
return '';
|
||||||
|
|
Loading…
Reference in New Issue