@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at upstream/main 148 lines 3.7 kB view raw
1<?php 2 3final class PhabricatorStandardCustomFieldBool 4 extends PhabricatorStandardCustomField { 5 6 public function getFieldType() { 7 return 'bool'; 8 } 9 10 public function buildFieldIndexes() { 11 $indexes = array(); 12 13 $value = $this->getFieldValue(); 14 if (strlen($value)) { 15 $indexes[] = $this->newNumericIndex((int)$value); 16 } 17 18 return $indexes; 19 } 20 21 public function buildOrderIndex() { 22 return $this->newNumericIndex(0); 23 } 24 25 public function readValueFromRequest(AphrontRequest $request) { 26 $this->setFieldValue((bool)$request->getBool($this->getFieldKey())); 27 } 28 29 public function getValueForStorage() { 30 $value = $this->getFieldValue(); 31 if ($value !== null) { 32 return (int)$value; 33 } else { 34 return null; 35 } 36 } 37 38 public function setValueFromStorage($value) { 39 if (phutil_nonempty_scalar($value)) { 40 $value = (bool)$value; 41 } else { 42 $value = null; 43 } 44 return $this->setFieldValue($value); 45 } 46 47 public function readApplicationSearchValueFromRequest( 48 PhabricatorApplicationSearchEngine $engine, 49 AphrontRequest $request) { 50 51 return $request->getStr($this->getFieldKey()); 52 } 53 54 public function applyApplicationSearchConstraintToQuery( 55 PhabricatorApplicationSearchEngine $engine, 56 PhabricatorCursorPagedPolicyAwareQuery $query, 57 $value) { 58 if ($value == 'require') { 59 $query->withApplicationSearchContainsConstraint( 60 $this->newNumericIndex(null), 61 1); 62 } 63 } 64 65 public function appendToApplicationSearchForm( 66 PhabricatorApplicationSearchEngine $engine, 67 AphrontFormView $form, 68 $value) { 69 70 $form->appendChild( 71 id(new AphrontFormSelectControl()) 72 ->setLabel($this->getFieldName()) 73 ->setName($this->getFieldKey()) 74 ->setValue($value) 75 ->setOptions( 76 array( 77 '' => $this->getString('search.default', pht('(Any)')), 78 'require' => $this->getString('search.require', pht('Require')), 79 ))); 80 } 81 82 public function renderEditControl(array $handles) { 83 return id(new AphrontFormCheckboxControl()) 84 ->setLabel($this->getFieldName()) 85 ->setCaption($this->getCaption()) 86 ->addCheckbox( 87 $this->getFieldKey(), 88 1, 89 $this->getString('edit.checkbox'), 90 (bool)$this->getFieldValue()); 91 } 92 93 protected function renderValue() { 94 $value = $this->getFieldValue(); 95 if ($value) { 96 return $this->getString('view.yes', pht('Yes')); 97 } else { 98 return null; 99 } 100 } 101 102 public function getApplicationTransactionTitle( 103 PhabricatorApplicationTransaction $xaction) { 104 $author_phid = $xaction->getAuthorPHID(); 105 $old = $xaction->getOldValue(); 106 $new = $xaction->getNewValue(); 107 108 if ($new) { 109 return pht( 110 '%s checked %s.', 111 $xaction->renderHandleLink($author_phid), 112 $this->getFieldName()); 113 } else { 114 return pht( 115 '%s unchecked %s.', 116 $xaction->renderHandleLink($author_phid), 117 $this->getFieldName()); 118 } 119 } 120 121 public function shouldAppearInHerald() { 122 return true; 123 } 124 125 public function getHeraldFieldConditions() { 126 return array( 127 HeraldAdapter::CONDITION_IS_TRUE, 128 HeraldAdapter::CONDITION_IS_FALSE, 129 ); 130 } 131 132 public function getHeraldFieldStandardType() { 133 return HeraldField::STANDARD_BOOL; 134 } 135 136 protected function getHTTPParameterType() { 137 return new AphrontBoolHTTPParameterType(); 138 } 139 140 protected function newConduitSearchParameterType() { 141 return new ConduitBoolParameterType(); 142 } 143 144 protected function newConduitEditParameterType() { 145 return new ConduitBoolParameterType(); 146 } 147 148}