Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/export/PhabricatorTextExportFormat.php
Show All 17 Lines | final class PhabricatorTextExportFormat | ||||
public function getFileExtension() { | public function getFileExtension() { | ||||
return 'txt'; | return 'txt'; | ||||
} | } | ||||
public function getMIMEContentType() { | public function getMIMEContentType() { | ||||
return 'text/plain'; | return 'text/plain'; | ||||
} | } | ||||
public function addHeaders(array $fields) { | |||||
$headers = mpull($fields, 'getLabel'); | |||||
$this->addRow($headers); | |||||
} | |||||
public function addObject($object, array $fields, array $map) { | public function addObject($object, array $fields, array $map) { | ||||
$values = array(); | $values = array(); | ||||
foreach ($fields as $key => $field) { | foreach ($fields as $key => $field) { | ||||
$value = $map[$key]; | $value = $map[$key]; | ||||
$value = $field->getTextValue($value); | $value = $field->getTextValue($value); | ||||
$value = addcslashes($value, "\0..\37\\\177..\377"); | |||||
$values[] = $value; | $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() { | public function newFileData() { | ||||
return implode("\n", $this->rows)."\n"; | return implode("\n", $this->rows)."\n"; | ||||
} | } | ||||
} | } |