Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / project / order / PhabricatorProjectColumnStatusOrder.php
blob2cb156aa92a10c4b190308f0caf44b2005d67ad2
1 <?php
3 final class PhabricatorProjectColumnStatusOrder
4 extends PhabricatorProjectColumnOrder {
6 const ORDERKEY = 'status';
8 public function getDisplayName() {
9 return pht('Group by Status');
12 protected function newMenuIconIcon() {
13 return 'fa-check';
16 public function getHasHeaders() {
17 return true;
20 public function getCanReorder() {
21 return true;
24 public function getMenuOrder() {
25 return 4000;
28 protected function newHeaderKeyForObject($object) {
29 return $this->newHeaderKeyForStatus($object->getStatus());
32 private function newHeaderKeyForStatus($status) {
33 return sprintf('status(%s)', $status);
36 protected function newSortVectorsForObjects(array $objects) {
37 $status_sequence = $this->newStatusSequence();
39 $vectors = array();
40 foreach ($objects as $object_key => $object) {
41 $vectors[$object_key] = array(
42 (int)idx($status_sequence, $object->getStatus(), 0),
46 return $vectors;
49 private function newStatusSequence() {
50 $statuses = ManiphestTaskStatus::getTaskStatusMap();
51 return array_combine(
52 array_keys($statuses),
53 range(1, count($statuses)));
56 protected function newHeadersForObjects(array $objects) {
57 $headers = array();
59 $statuses = ManiphestTaskStatus::getTaskStatusMap();
60 $sequence = $this->newStatusSequence();
62 foreach ($statuses as $status_key => $status_name) {
63 $header_key = $this->newHeaderKeyForStatus($status_key);
65 $sort_vector = array(
66 (int)idx($sequence, $status_key, 0),
69 $status_icon = ManiphestTaskStatus::getStatusIcon($status_key);
70 $status_color = ManiphestTaskStatus::getStatusColor($status_key);
72 $icon_view = id(new PHUIIconView())
73 ->setIcon($status_icon, $status_color);
75 $drop_effect = $this->newEffect()
76 ->setIcon($status_icon)
77 ->setColor($status_color)
78 ->addCondition('status', '!=', $status_key)
79 ->setContent(
80 pht(
81 'Change status to %s.',
82 phutil_tag('strong', array(), $status_name)));
84 $header = $this->newHeader()
85 ->setHeaderKey($header_key)
86 ->setSortVector($sort_vector)
87 ->setName($status_name)
88 ->setIcon($icon_view)
89 ->setEditProperties(
90 array(
91 'value' => $status_key,
93 ->addDropEffect($drop_effect);
95 $headers[] = $header;
98 return $headers;
101 protected function newColumnTransactions($object, array $header) {
102 $new_status = idx($header, 'value');
104 if ($object->getStatus() === $new_status) {
105 return null;
108 $xactions = array();
109 $xactions[] = $this->newTransaction($object)
110 ->setTransactionType(ManiphestTaskStatusTransaction::TRANSACTIONTYPE)
111 ->setNewValue($new_status);
113 return $xactions;