From 4a9a9e51db44ca8c9adbd8571f2d02289955d7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Ho=CC=88rrmann?= Date: Wed, 24 Jun 2015 15:12:17 +0200 Subject: [PATCH 1/2] Fix workspace path --- data-sources/datasource.remote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-sources/datasource.remote.php b/data-sources/datasource.remote.php index bb9c7bb..5dcdfb2 100644 --- a/data-sources/datasource.remote.php +++ b/data-sources/datasource.remote.php @@ -590,7 +590,7 @@ public function execute(array &$param_pool = null) if (empty($this->_env)) { $this->_env['env']['pool'] = array( 'root' => URL, - 'workspace' => WORKSPACE + 'workspace' => URL . '/workspace' ); } From d502eb5224dcb10780aba00aa1afba92f781aa5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Ho=CC=88rrmann?= Date: Wed, 24 Jun 2015 15:12:31 +0200 Subject: [PATCH 2/2] Make CSV style configurable --- extension.driver.php | 14 ++++++++++++++ extension.meta.xml | 4 ++++ lib/class.csv.php | 12 ++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/extension.driver.php b/extension.driver.php index beaff9a..39d89d3 100644 --- a/extension.driver.php +++ b/extension.driver.php @@ -59,4 +59,18 @@ public function addCachingOpportunity($context) $context['wrapper']->appendChild($label); } + + public function install() + { + Symphony::Configuration()->set('csv-delimiter', ',', 'remote_datasource'); + Symphony::Configuration()->set('csv-enclosure', '"', 'remote_datasource'); + Symphony::Configuration()->set('csv-escape', '\\', 'remote_datasource'); + Symphony::Configuration()->write(); + } + + public function uninstall() + { + Symphony::Configuration()->remove('remote_datasource'); + } + } diff --git a/extension.meta.xml b/extension.meta.xml index 73ee107..9c68111 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -10,6 +10,10 @@ + + - Make CSV style configurable. + - Fix `{$workspace}` path + - Fix a bug with late static binding on PHP 5.3. diff --git a/lib/class.csv.php b/lib/class.csv.php index 2f76aa7..3f19819 100644 --- a/lib/class.csv.php +++ b/lib/class.csv.php @@ -33,6 +33,14 @@ public static function convertToXML($data) { $headers = array(); + // Get CSV settings + $settings = array( + 'csv-delimiter' => ',', + 'csv-enclosure' => '"', + 'csv-escape' => '\\' + ); + $settings = array_merge($settings, (array) Symphony::Configuration()->get('remote_datasource')); + // DOMDocument $doc = new DOMDocument('1.0', 'utf-8'); $doc->formatOutput = true; @@ -46,14 +54,14 @@ public static function convertToXML($data) } if ($i == 0) { - foreach (str_getcsv($row) as $i => $head) { + foreach (str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']) as $i => $head) { if (class_exists('Lang')) { $head = Lang::createHandle($head); } $headers[] = $head; } } else { - self::addRow($doc, $root, str_getcsv($row), $headers); + self::addRow($doc, $root, str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']), $headers); } }