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

Give data exporters a header row

Summary:
Depends on D18951. Ref T13049. When we export to CSV or plain text, add a header row in the first line of the file to explain what each column means. This often isn't obvious with PHIDs, etc.

JSON has keys and is essentially self-labeling, so don't do anything special.

Test Plan: Exported CSV and text, saw new headers. Exported JSON, no changes.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13049

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

+35 -5
+1
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 454 454 $field_list = $engine->newExportFieldList(); 455 455 $field_list = mpull($field_list, null, 'getKey'); 456 456 457 + $format->addHeaders($field_list); 457 458 for ($ii = 0; $ii < count($objects); $ii++) { 458 459 $format->addObject($objects[$ii], $field_list, $export_data[$ii]); 459 460 }
+15 -2
src/infrastructure/export/PhabricatorCSVExportFormat.php
··· 23 23 return 'text/csv'; 24 24 } 25 25 26 + public function addHeaders(array $fields) { 27 + $headers = mpull($fields, 'getLabel'); 28 + $this->addRow($headers); 29 + } 30 + 26 31 public function addObject($object, array $fields, array $map) { 27 32 $values = array(); 28 33 foreach ($fields as $key => $field) { 29 34 $value = $map[$key]; 30 35 $value = $field->getTextValue($value); 36 + $values[] = $value; 37 + } 31 38 39 + $this->addRow($values); 40 + } 41 + 42 + private function addRow(array $values) { 43 + $row = array(); 44 + foreach ($values as $value) { 32 45 if (preg_match('/\s|,|\"/', $value)) { 33 46 $value = str_replace('"', '""', $value); 34 47 $value = '"'.$value.'"'; 35 48 } 36 49 37 - $values[] = $value; 50 + $row[] = $value; 38 51 } 39 52 40 - $this->rows[] = implode(',', $values); 53 + $this->rows[] = implode(',', $row); 41 54 } 42 55 43 56 public function newFileData() {
+4
src/infrastructure/export/PhabricatorExportFormat.php
··· 22 22 abstract public function getMIMEContentType(); 23 23 abstract public function getFileExtension(); 24 24 25 + public function addHeaders(array $fields) { 26 + return; 27 + } 28 + 25 29 abstract public function addObject($object, array $fields, array $map); 26 30 abstract public function newFileData(); 27 31
+15 -3
src/infrastructure/export/PhabricatorTextExportFormat.php
··· 23 23 return 'text/plain'; 24 24 } 25 25 26 + public function addHeaders(array $fields) { 27 + $headers = mpull($fields, 'getLabel'); 28 + $this->addRow($headers); 29 + } 30 + 26 31 public function addObject($object, array $fields, array $map) { 27 32 $values = array(); 28 33 foreach ($fields as $key => $field) { 29 34 $value = $map[$key]; 30 35 $value = $field->getTextValue($value); 31 - $value = addcslashes($value, "\0..\37\\\177..\377"); 32 - 33 36 $values[] = $value; 34 37 } 35 38 36 - $this->rows[] = implode("\t", $values); 39 + $this->addRow($values); 40 + } 41 + 42 + private function addRow(array $values) { 43 + $row = array(); 44 + foreach ($values as $value) { 45 + $row[] = addcslashes($value, "\0..\37\\\177..\377"); 46 + } 47 + 48 + $this->rows[] = implode("\t", $row); 37 49 } 38 50 39 51 public function newFileData() {