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

Support exporting custom "Options/Select" fields to Excel/JSON/CSV/etc

Summary:
See <https://discourse.phabricator-community.org/t/exporting-custom-select-fields-as-part-of-query-exports/2466/>.

In JSON, export both the internal key and the visible value. For other formats, export the visible label.

Test Plan:
- Added a custom options/select field.
- Exported CSV, JSON, Text, got sensible output.

Reviewers: amckinley

Reviewed By: amckinley

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

+54
+2
src/__phutil_library_map__.php
··· 3692 3692 'PhabricatorOlderInlinesSetting' => 'applications/settings/setting/PhabricatorOlderInlinesSetting.php', 3693 3693 'PhabricatorOneTimeTriggerClock' => 'infrastructure/daemon/workers/clock/PhabricatorOneTimeTriggerClock.php', 3694 3694 'PhabricatorOpcodeCacheSpec' => 'applications/cache/spec/PhabricatorOpcodeCacheSpec.php', 3695 + 'PhabricatorOptionExportField' => 'infrastructure/export/field/PhabricatorOptionExportField.php', 3695 3696 'PhabricatorOptionGroupSetting' => 'applications/settings/setting/PhabricatorOptionGroupSetting.php', 3696 3697 'PhabricatorOwnerPathQuery' => 'applications/owners/query/PhabricatorOwnerPathQuery.php', 3697 3698 'PhabricatorOwnersApplication' => 'applications/owners/application/PhabricatorOwnersApplication.php', ··· 9687 9688 'PhabricatorOlderInlinesSetting' => 'PhabricatorSelectSetting', 9688 9689 'PhabricatorOneTimeTriggerClock' => 'PhabricatorTriggerClock', 9689 9690 'PhabricatorOpcodeCacheSpec' => 'PhabricatorCacheSpec', 9691 + 'PhabricatorOptionExportField' => 'PhabricatorExportField', 9690 9692 'PhabricatorOptionGroupSetting' => 'PhabricatorSetting', 9691 9693 'PhabricatorOwnerPathQuery' => 'Phobject', 9692 9694 'PhabricatorOwnersApplication' => 'PhabricatorApplication',
+5
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php
··· 153 153 ->setOptions($this->getOptions()); 154 154 } 155 155 156 + protected function newExportFieldType() { 157 + return id(new PhabricatorOptionExportField()) 158 + ->setOptions($this->getOptions()); 159 + } 160 + 156 161 }
+47
src/infrastructure/export/field/PhabricatorOptionExportField.php
··· 1 + <?php 2 + 3 + final class PhabricatorOptionExportField 4 + extends PhabricatorExportField { 5 + 6 + private $options; 7 + 8 + public function setOptions(array $options) { 9 + $this->options = $options; 10 + return $this; 11 + } 12 + 13 + public function getOptions() { 14 + return $this->options; 15 + } 16 + 17 + public function getNaturalValue($value) { 18 + if ($value === null) { 19 + return $value; 20 + } 21 + 22 + if (!strlen($value)) { 23 + return null; 24 + } 25 + 26 + $options = $this->getOptions(); 27 + 28 + return array( 29 + 'value' => (string)$value, 30 + 'name' => (string)idx($options, $value, $value), 31 + ); 32 + } 33 + 34 + public function getTextValue($value) { 35 + $natural_value = $this->getNaturalValue($value); 36 + if ($natural_value === null) { 37 + return null; 38 + } 39 + 40 + return $natural_value['name']; 41 + } 42 + 43 + public function getPHPExcelValue($value) { 44 + return $this->getTextValue($value); 45 + } 46 + 47 + }