Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14030075
D18952.id45476.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D18952.id45476.diff
View Options
diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php
--- a/src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php
@@ -454,6 +454,7 @@
$field_list = $engine->newExportFieldList();
$field_list = mpull($field_list, null, 'getKey');
+ $format->addHeaders($field_list);
for ($ii = 0; $ii < count($objects); $ii++) {
$format->addObject($objects[$ii], $field_list, $export_data[$ii]);
}
diff --git a/src/infrastructure/export/PhabricatorCSVExportFormat.php b/src/infrastructure/export/PhabricatorCSVExportFormat.php
--- a/src/infrastructure/export/PhabricatorCSVExportFormat.php
+++ b/src/infrastructure/export/PhabricatorCSVExportFormat.php
@@ -23,21 +23,34 @@
return 'text/csv';
}
+ public function addHeaders(array $fields) {
+ $headers = mpull($fields, 'getLabel');
+ $this->addRow($headers);
+ }
+
public function addObject($object, array $fields, array $map) {
$values = array();
foreach ($fields as $key => $field) {
$value = $map[$key];
$value = $field->getTextValue($value);
+ $values[] = $value;
+ }
+ $this->addRow($values);
+ }
+
+ private function addRow(array $values) {
+ $row = array();
+ foreach ($values as $value) {
if (preg_match('/\s|,|\"/', $value)) {
$value = str_replace('"', '""', $value);
$value = '"'.$value.'"';
}
- $values[] = $value;
+ $row[] = $value;
}
- $this->rows[] = implode(',', $values);
+ $this->rows[] = implode(',', $row);
}
public function newFileData() {
diff --git a/src/infrastructure/export/PhabricatorExportFormat.php b/src/infrastructure/export/PhabricatorExportFormat.php
--- a/src/infrastructure/export/PhabricatorExportFormat.php
+++ b/src/infrastructure/export/PhabricatorExportFormat.php
@@ -22,6 +22,10 @@
abstract public function getMIMEContentType();
abstract public function getFileExtension();
+ public function addHeaders(array $fields) {
+ return;
+ }
+
abstract public function addObject($object, array $fields, array $map);
abstract public function newFileData();
diff --git a/src/infrastructure/export/PhabricatorTextExportFormat.php b/src/infrastructure/export/PhabricatorTextExportFormat.php
--- a/src/infrastructure/export/PhabricatorTextExportFormat.php
+++ b/src/infrastructure/export/PhabricatorTextExportFormat.php
@@ -23,17 +23,29 @@
return 'text/plain';
}
+ public function addHeaders(array $fields) {
+ $headers = mpull($fields, 'getLabel');
+ $this->addRow($headers);
+ }
+
public function addObject($object, array $fields, array $map) {
$values = array();
foreach ($fields as $key => $field) {
$value = $map[$key];
$value = $field->getTextValue($value);
- $value = addcslashes($value, "\0..\37\\\177..\377");
-
$values[] = $value;
}
- $this->rows[] = implode("\t", $values);
+ $this->addRow($values);
+ }
+
+ private function addRow(array $values) {
+ $row = array();
+ foreach ($values as $value) {
+ $row[] = addcslashes($value, "\0..\37\\\177..\377");
+ }
+
+ $this->rows[] = implode("\t", $row);
}
public function newFileData() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 11:47 PM (1 w, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6761035
Default Alt Text
D18952.id45476.diff (3 KB)
Attached To
Mode
D18952: Give data exporters a header row
Attached
Detach File
Event Timeline
Log In to Comment