mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Use phutil_utf8_shorten() in PhabricatorProjectListController
Summary: This is a little cleaner and more general than textWrap(). See also D559. Test Plan: Loaded project list page, edited a project description to have >100 characters of text, reloaded list page, it was correctly shortened. Reviewed By: tuomaspelkonen Reviewers: cadamo, jungejason, aran, tuomaspelkonen CC: aran, tuomaspelkonen Differential Revision: 584
This commit is contained in:
parent
6eed2ad2bb
commit
f61a02e342
1 changed files with 1 additions and 15 deletions
|
@ -74,7 +74,7 @@ class PhabricatorProjectListController
|
||||||
$blurb = nonempty(
|
$blurb = nonempty(
|
||||||
$profile->getBlurb(),
|
$profile->getBlurb(),
|
||||||
'Oops!, nothing is known about this elusive project.');
|
'Oops!, nothing is known about this elusive project.');
|
||||||
$blurb = $this->textWrap($blurb, $columns = 100);
|
$blurb = phutil_utf8_shorten($blurb, $columns = 100);
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
phutil_escape_html($project->getName()),
|
phutil_escape_html($project->getName()),
|
||||||
|
@ -129,18 +129,4 @@ class PhabricatorProjectListController
|
||||||
'title' => 'Projects',
|
'title' => 'Projects',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function textWrap($text, $length) {
|
|
||||||
if (strlen($text) <= $length) {
|
|
||||||
return $text;
|
|
||||||
} else {
|
|
||||||
// TODO: perhaps this could be improved, adding the ability to get the
|
|
||||||
// last letter and suppress it, if it is one of [(,:; ,etc.
|
|
||||||
// making "blurb" looks a little bit better. :)
|
|
||||||
$wrapped = wordwrap($text, $length, '__#END#__');
|
|
||||||
$end_position = strpos($wrapped, '__#END#__');
|
|
||||||
$wrapped = substr($text, 0, $end_position).'...';
|
|
||||||
return $wrapped;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue