[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final 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 getValueForStorage() { 26 $value = $this->getFieldValue(); 27 if (strlen($value)) { 28 return (int)$value; 29 } else { 30 return null; 31 } 32 } 33 34 public function setValueFromStorage($value) { 35 if (strlen($value)) { 36 $value = (bool)$value; 37 } else { 38 $value = null; 39 } 40 return $this->setFieldValue($value); 41 } 42 43 public function readApplicationSearchValueFromRequest( 44 PhabricatorApplicationSearchEngine $engine, 45 AphrontRequest $request) { 46 47 return $request->getStr($this->getFieldKey()); 48 } 49 50 public function applyApplicationSearchConstraintToQuery( 51 PhabricatorApplicationSearchEngine $engine, 52 PhabricatorCursorPagedPolicyAwareQuery $query, 53 $value) { 54 if ($value == 'require') { 55 $query->withApplicationSearchContainsConstraint( 56 $this->newNumericIndex(null), 57 1); 58 } 59 } 60 61 public function appendToApplicationSearchForm( 62 PhabricatorApplicationSearchEngine $engine, 63 AphrontFormView $form, 64 $value, 65 array $handles) { 66 67 $form->appendChild( 68 id(new AphrontFormSelectControl()) 69 ->setLabel($this->getFieldName()) 70 ->setName($this->getFieldKey()) 71 ->setValue($value) 72 ->setOptions( 73 array( 74 '' => $this->getString('search.default', pht('(Any)')), 75 'require' => $this->getString('search.require', pht('Require')), 76 ))); 77 } 78 79 public function renderEditControl(array $handles) { 80 return id(new AphrontFormCheckboxControl()) 81 ->setLabel($this->getFieldName()) 82 ->setCaption($this->getCaption()) 83 ->addCheckbox( 84 $this->getFieldKey(), 85 1, 86 $this->getString('edit.checkbox'), 87 (bool)$this->getFieldValue()); 88 } 89 90 public function renderPropertyViewValue(array $handles) { 91 $value = $this->getFieldValue(); 92 if ($value) { 93 return $this->getString('view.yes', pht('Yes')); 94 } else { 95 return null; 96 } 97 } 98 99 public function getApplicationTransactionTitle( 100 PhabricatorApplicationTransaction $xaction) { 101 $author_phid = $xaction->getAuthorPHID(); 102 $old = $xaction->getOldValue(); 103 $new = $xaction->getNewValue(); 104 105 if ($new) { 106 return pht( 107 '%s checked %s.', 108 $xaction->renderHandleLink($author_phid), 109 $this->getFieldName()); 110 } else { 111 return pht( 112 '%s unchecked %s.', 113 $xaction->renderHandleLink($author_phid), 114 $this->getFieldName()); 115 } 116 } 117 118 public function shouldAppearInHerald() { 119 return true; 120 } 121 122 public function getHeraldFieldConditions() { 123 return array( 124 HeraldAdapter::CONDITION_IS_TRUE, 125 HeraldAdapter::CONDITION_IS_FALSE, 126 ); 127 } 128 129 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |