@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 161 lines 4.2 kB view raw
1<?php 2 3final class PhabricatorStandardCustomFieldSelect 4 extends PhabricatorStandardCustomField { 5 6 public function getFieldType() { 7 return 'select'; 8 } 9 10 public function buildFieldIndexes() { 11 $indexes = array(); 12 13 $value = $this->getFieldValue(); 14 if (($value !== null) && (strlen($value))) { 15 $indexes[] = $this->newStringIndex($value); 16 } 17 18 return $indexes; 19 } 20 21 public function readApplicationSearchValueFromRequest( 22 PhabricatorApplicationSearchEngine $engine, 23 AphrontRequest $request) { 24 return $request->getArr($this->getFieldKey()); 25 } 26 27 public function applyApplicationSearchConstraintToQuery( 28 PhabricatorApplicationSearchEngine $engine, 29 PhabricatorCursorPagedPolicyAwareQuery $query, 30 $value) { 31 if ($value) { 32 $query->withApplicationSearchContainsConstraint( 33 $this->newStringIndex(null), 34 $value); 35 } 36 } 37 38 public function appendToApplicationSearchForm( 39 PhabricatorApplicationSearchEngine $engine, 40 AphrontFormView $form, 41 $value) { 42 43 if (!is_array($value)) { 44 $value = array(); 45 } 46 $value = array_fuse($value); 47 48 $control = id(new AphrontFormCheckboxControl()) 49 ->setLabel($this->getFieldName()); 50 51 foreach ($this->getOptions() as $name => $option) { 52 $control->addCheckbox( 53 $this->getFieldKey().'[]', 54 $name, 55 $option, 56 isset($value[$name])); 57 } 58 59 $form->appendChild($control); 60 } 61 62 public function getOptions() { 63 return $this->getFieldConfigValue('options', array()); 64 } 65 66 public function renderEditControl(array $handles) { 67 return id(new AphrontFormSelectControl()) 68 ->setLabel($this->getFieldName()) 69 ->setCaption($this->getCaption()) 70 ->setName($this->getFieldKey()) 71 ->setValue($this->getFieldValue()) 72 ->setOptions($this->getOptions()); 73 } 74 75 protected function renderValue() { 76 if (!phutil_nonempty_string($this->getFieldValue())) { 77 return null; 78 } 79 return idx($this->getOptions(), $this->getFieldValue()); 80 } 81 82 public function getApplicationTransactionTitle( 83 PhabricatorApplicationTransaction $xaction) { 84 $author_phid = $xaction->getAuthorPHID(); 85 $old = $xaction->getOldValue(); 86 $new = $xaction->getNewValue(); 87 88 $old = idx($this->getOptions(), $old, $old); 89 $new = idx($this->getOptions(), $new, $new); 90 91 if (!$old) { 92 return pht( 93 '%s set %s to %s.', 94 $xaction->renderHandleLink($author_phid), 95 $this->getFieldName(), 96 $new); 97 } else if (!$new) { 98 return pht( 99 '%s removed %s.', 100 $xaction->renderHandleLink($author_phid), 101 $this->getFieldName()); 102 } else { 103 return pht( 104 '%s changed %s from %s to %s.', 105 $xaction->renderHandleLink($author_phid), 106 $this->getFieldName(), 107 $old, 108 $new); 109 } 110 } 111 112 public function shouldAppearInHerald() { 113 return true; 114 } 115 116 public function getHeraldFieldConditions() { 117 return array( 118 HeraldAdapter::CONDITION_IS_ANY, 119 HeraldAdapter::CONDITION_IS_NOT_ANY, 120 ); 121 } 122 123 public function getHeraldFieldValueType($condition) { 124 $parameters = array( 125 'object' => get_class($this->getObject()), 126 'role' => PhabricatorCustomField::ROLE_HERALD, 127 'key' => $this->getFieldKey(), 128 ); 129 130 $datasource = id(new PhabricatorStandardSelectCustomFieldDatasource()) 131 ->setParameters($parameters); 132 133 return id(new HeraldTokenizerFieldValue()) 134 ->setKey('custom.'.$this->getFieldKey()) 135 ->setDatasource($datasource) 136 ->setValueMap($this->getOptions()); 137 } 138 139 protected function getHTTPParameterType() { 140 return new AphrontSelectHTTPParameterType(); 141 } 142 143 protected function newConduitSearchParameterType() { 144 return new ConduitStringListParameterType(); 145 } 146 147 protected function newConduitEditParameterType() { 148 return new ConduitStringParameterType(); 149 } 150 151 protected function newBulkParameterType() { 152 return id(new BulkSelectParameterType()) 153 ->setOptions($this->getOptions()); 154 } 155 156 protected function newExportFieldType() { 157 return id(new PhabricatorOptionExportField()) 158 ->setOptions($this->getOptions()); 159 } 160 161}