@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.

Add link custom field.

Summary: Ref T3868. Adds a link custom field that verifies and links to the text provided.

Test Plan: Add a custom field with type "link", then enter a well-formed URL in the provided box in the edit task screen. Verify that the URL displays correctly on the task display page.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T3868

Differential Revision: https://secure.phabricator.com/D12543

authored by

root and committed by
epriestley
1ab6ad3e 7196d29c

+86
+2
src/__phutil_library_map__.php
··· 2544 2544 'PhabricatorStandardCustomFieldHeader' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php', 2545 2545 'PhabricatorStandardCustomFieldInt' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php', 2546 2546 'PhabricatorStandardCustomFieldInterface' => 'infrastructure/customfield/interface/PhabricatorStandardCustomFieldInterface.php', 2547 + 'PhabricatorStandardCustomFieldLink' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php', 2547 2548 'PhabricatorStandardCustomFieldPHIDs' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php', 2548 2549 'PhabricatorStandardCustomFieldRemarkup' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php', 2549 2550 'PhabricatorStandardCustomFieldSelect' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php', ··· 5971 5972 'PhabricatorStandardCustomFieldDate' => 'PhabricatorStandardCustomField', 5972 5973 'PhabricatorStandardCustomFieldHeader' => 'PhabricatorStandardCustomField', 5973 5974 'PhabricatorStandardCustomFieldInt' => 'PhabricatorStandardCustomField', 5975 + 'PhabricatorStandardCustomFieldLink' => 'PhabricatorStandardCustomField', 5974 5976 'PhabricatorStandardCustomFieldPHIDs' => 'PhabricatorStandardCustomField', 5975 5977 'PhabricatorStandardCustomFieldRemarkup' => 'PhabricatorStandardCustomField', 5976 5978 'PhabricatorStandardCustomFieldSelect' => 'PhabricatorStandardCustomField',
+84
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
··· 1 + <?php 2 + 3 + final class PhabricatorStandardCustomFieldLink 4 + extends PhabricatorStandardCustomField { 5 + 6 + public function getFieldType() { 7 + return 'link'; 8 + } 9 + 10 + public function buildFieldIndexes() { 11 + $indexes = array(); 12 + 13 + $value = $this->getFieldValue(); 14 + if (strlen($value)) { 15 + $indexes[] = $this->newStringIndex($value); 16 + } 17 + 18 + return $indexes; 19 + } 20 + 21 + public function renderPropertyViewValue(array $handles) { 22 + $value = $this->getFieldValue(); 23 + 24 + if (!strlen($value)) { 25 + return null; 26 + } 27 + 28 + if (!PhabricatorEnv::isValidRemoteURIForLink($value)) { 29 + return $value; 30 + } 31 + 32 + return phutil_tag( 33 + 'a', 34 + array('href' => $value, 'target' => '_blank'), 35 + $value); 36 + } 37 + 38 + public function readApplicationSearchValueFromRequest( 39 + PhabricatorApplicationSearchEngine $engine, 40 + AphrontRequest $request) { 41 + 42 + return $request->getStr($this->getFieldKey()); 43 + } 44 + 45 + public function applyApplicationSearchConstraintToQuery( 46 + PhabricatorApplicationSearchEngine $engine, 47 + PhabricatorCursorPagedPolicyAwareQuery $query, 48 + $value) { 49 + 50 + if (strlen($value)) { 51 + $query->withApplicationSearchContainsConstraint( 52 + $this->newStringIndex(null), 53 + $value); 54 + } 55 + } 56 + 57 + public function appendToApplicationSearchForm( 58 + PhabricatorApplicationSearchEngine $engine, 59 + AphrontFormView $form, 60 + $value, 61 + array $handles) { 62 + 63 + $form->appendChild( 64 + id(new AphrontFormTextControl()) 65 + ->setLabel($this->getFieldName()) 66 + ->setName($this->getFieldKey()) 67 + ->setValue($value)); 68 + } 69 + 70 + public function shouldAppearInHerald() { 71 + return true; 72 + } 73 + 74 + public function getHeraldFieldConditions() { 75 + return array( 76 + HeraldAdapter::CONDITION_CONTAINS, 77 + HeraldAdapter::CONDITION_NOT_CONTAINS, 78 + HeraldAdapter::CONDITION_IS, 79 + HeraldAdapter::CONDITION_IS_NOT, 80 + HeraldAdapter::CONDITION_REGEXP, 81 + ); 82 + } 83 + 84 + }