class XMLExporter in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/XMLExporter.php \AKlump\LoftDataGrids\XMLExporter
Class XMLExporter
Hierarchy
- class \AKlump\LoftDataGrids\Exporter implements ExporterInterface
- class \AKlump\LoftDataGrids\XMLExporter implements ExporterInterface
Expanded class hierarchy of XMLExporter
File
- vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ XMLExporter.php, line 7
Namespace
AKlump\LoftDataGridsView source
class XMLExporter extends Exporter implements ExporterInterface {
protected $extension = '.xml';
public function getInfo() {
$info = parent::getInfo();
$info = array(
'name' => 'XML Format',
'shortname' => 'XML',
'description' => 'Export data in XML file format.',
) + $info;
return $info;
}
public function compile($page_id = NULL) {
$data = $this
->getData()
->get();
$xml = new \SimpleXMLElement('<data/>');
$pages = $this
->getData()
->get();
if ($page_id && array_key_exists($page_id, $pages)) {
$pages = array(
$pages[$page_id],
);
}
foreach ($pages as $page_id => $data) {
$page = $xml
->addChild('page');
$page
->addAttribute('id', $page_id);
foreach ($data as $id => $data_set) {
$set = $page
->addChild('record');
$set
->addAttribute('id', $id);
foreach ($data_set as $key => $value) {
// make sure the key is in good format
$key = preg_replace('/[^a-z0-9_-]/', '_', strtolower($key));
// Wrap cdata as needed
if (strstr($value, '<') || strstr($value, '&')) {
$value = '<![CDATA[' . $value . ']]>';
}
$set
->addChild($key, $value);
}
}
}
$this->output = $xml
->asXML();
$this->output = str_replace('<![CDATA[', '<![CDATA[', $this->output);
$this->output = str_replace(']]></', ']]></', $this->output);
}
}
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:: |
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:: |
public | function |
Get the filename Overrides ExporterInterface:: |
|
Exporter:: |
public | function |
Return an array containing the header row values for 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 |
Save as a file to the server Overrides ExporterInterface:: |
1 |
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. | 1 |
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 | 4 |
XMLExporter:: |
protected | property | ||
XMLExporter:: |
public | function |
Build $this->output in prep for export/save Overrides Exporter:: |
|
XMLExporter:: |
public | function |
Return info about this class Overrides Exporter:: |