1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02: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:
epriestley 2011-07-03 12:24:56 -07:00
parent 6eed2ad2bb
commit f61a02e342

View file

@ -74,7 +74,7 @@ class PhabricatorProjectListController
$blurb = nonempty(
$profile->getBlurb(),
'Oops!, nothing is known about this elusive project.');
$blurb = $this->textWrap($blurb, $columns = 100);
$blurb = phutil_utf8_shorten($blurb, $columns = 100);
$rows[] = array(
phutil_escape_html($project->getName()),
@ -129,18 +129,4 @@ class PhabricatorProjectListController
'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;
}
}
}