mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 19:32:40 +01:00
c7079b52a2
Summary: Ref T4430. This just deploys it on the property lists. (Help on how to do translations better? I tried a more traditional pht('%s, %s, %s, and %d other(s)') but I think the string lookup assumes the %d comes as the second param or something?) Test Plan: Made a Maniphest Task with a hojillion subscribers and noted the working dialogue. Also made a Pholio Mock with lots of subscribers and it worked. Reviewers: epriestley Reviewed By: epriestley Subscribers: aran, epriestley, Korvin, chad Maniphest Tasks: T4430 Differential Revision: https://secure.phabricator.com/D8525
64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
|
|
|
final class SubscriptionListStringBuilder {
|
|
|
|
private $handles;
|
|
private $objectPHID;
|
|
|
|
public function setHandles(array $handles) {
|
|
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
|
$this->handles = $handles;
|
|
return $this;
|
|
}
|
|
|
|
public function getHandles() {
|
|
return $this->handles;
|
|
}
|
|
|
|
public function setObjectPHID($object_phid) {
|
|
$this->objectPHID = $object_phid;
|
|
return $this;
|
|
}
|
|
|
|
public function getObjectPHID() {
|
|
return $this->objectPHID;
|
|
}
|
|
|
|
public function buildPropertyString() {
|
|
$phid = $this->getObjectPHID();
|
|
$handles = $this->getHandles();
|
|
|
|
if (!$handles) {
|
|
return phutil_tag('em', array(), pht('None'));
|
|
}
|
|
|
|
$html = array();
|
|
$show_count = 3;
|
|
$subscribers_count = count($handles);
|
|
if ($subscribers_count <= $show_count) {
|
|
return phutil_implode_html(', ', mpull($handles, 'renderLink'));
|
|
}
|
|
|
|
$args = array('%s, %s, %s, and %s');
|
|
$shown = 0;
|
|
foreach ($handles as $handle) {
|
|
$shown++;
|
|
if ($shown > $show_count) {
|
|
break;
|
|
}
|
|
$args[] = $handle->renderLink();
|
|
}
|
|
$not_shown_count = $subscribers_count - $show_count;
|
|
$not_shown_txt = pht('%d other(s)', $not_shown_count);
|
|
$args[] = javelin_tag(
|
|
'a',
|
|
array(
|
|
'href' => '/subscriptions/list/'.$phid.'/',
|
|
'sigil' => 'workflow'
|
|
),
|
|
$not_shown_txt);
|
|
|
|
return call_user_func_array('pht', $args);
|
|
}
|
|
|
|
}
|