class TextListExporter in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/TextListExporter.php \AKlump\LoftDataGrids\TextListExporter
Class TextListExporter
Hierarchy
- class \AKlump\LoftDataGrids\Exporter implements ExporterInterface
- class \AKlump\LoftDataGrids\TextListExporter implements ExporterInterface
Expanded class hierarchy of TextListExporter
File
- vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ TextListExporter.php, line 7
Namespace
AKlump\LoftDataGridsView source
class TextListExporter extends Exporter implements ExporterInterface {
public $line_break = '-';
public $separator = ' ';
public $pad_char = ' ';
protected $extension = '.txt';
public function getInfo() {
$info = parent::getInfo();
$info = array(
'name' => 'Plaintext List',
'shortname' => 'List',
'description' => 'Export data in plaintext list file format.',
) + $info;
return $info;
}
public function compile($page_id = null) {
$pages = $this
->getData()
->get();
$this->output = '';
$output = '';
$longest_key = $longest_value = 0;
// Determine spacing
foreach ($pages as $page_id => $page) {
foreach ($page as $record) {
foreach ($record as $key => $value) {
$longest_key = max($longest_key, strlen($key));
$longest_value = max($longest_value, strlen($value));
}
}
}
// Apply spacing and build output
foreach ($pages as $page_id => $page) {
if ($this
->getShowPageIds()) {
$output .= $page_id . PHP_EOL;
}
foreach ($page as $record) {
$output .= "<hr />\n";
foreach ($record as $key => $value) {
$output .= str_pad($key, $longest_key, $this->pad_char) . $this->separator . $value . PHP_EOL;
}
$output .= "\n";
}
$output .= "\n";
}
$line_break = str_repeat($this->line_break, $longest_key + strlen($this->separator) + $longest_value + 2);
$output = str_replace('<hr />', $line_break, $output);
$this->output = $output;
return $this;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Exporter:: |
protected | property | ||
Exporter:: |
protected | property | ||
Exporter:: |
protected | property | ||
Exporter:: |
public | function |
Adds/Updates a single setting by name. Overrides ExporterInterface:: |
|
Exporter:: |
protected | function | ||
Exporter:: |
protected | function | Iterate over all cells and transform data as appropriate. | |
Exporter:: |
public | function |
Export data as a string Overrides ExporterInterface:: |
1 |
Exporter:: |
protected | function | Return a string as a safe filename | |
Exporter:: |
public | function |
Format a single column with format by string Overrides ExporterInterface:: |
1 |
Exporter:: |
public | function |
Return the ExportDataInterface object Overrides ExporterInterface:: |
|
Exporter:: |
protected | function | Convert ExportData to an array transforming every cell. | |
Exporter:: |
public | function |
Get the filename Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Return an array each of the keys present in the data on a page. Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Return the settings object. Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Return the showPageIds. Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Set the exporter to hide page ids. Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Stream as a file to the server with headers. Overrides ExporterInterface:: |
1 |
Exporter:: |
public | function |
Compile and and save to a filepath. Overrides ExporterInterface:: |
2 |
Exporter:: |
public | function |
Set the export data object Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Getter/Setter for the filename Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Set the settings object. Overrides ExporterInterface:: |
|
Exporter:: |
protected | function | Setup default values on object data. | 4 |
Exporter:: |
public | function |
Set a title for the exported document Overrides ExporterInterface:: |
1 |
Exporter:: |
public | function |
Set the exporter to display page ids. Overrides ExporterInterface:: |
|
Exporter:: |
public | function | Constructor | 5 |
TextListExporter:: |
protected | property | ||
TextListExporter:: |
public | property | ||
TextListExporter:: |
public | property | ||
TextListExporter:: |
public | property | ||
TextListExporter:: |
public | function |
Build the string content of $this->output and return $this for chaining. Overrides ExporterInterface:: |
|
TextListExporter:: |
public | function |
Return info about this class Overrides Exporter:: |