diff --git a/data-sources/datasource.remote.php b/data-sources/datasource.remote.php index dce7aab..a590574 100644 --- a/data-sources/datasource.remote.php +++ b/data-sources/datasource.remote.php @@ -790,7 +790,7 @@ public function execute(array &$param_pool = null) if (empty($this->_env)) { $this->_env['env']['pool'] = array( 'root' => URL, - 'workspace' => WORKSPACE + 'workspace' => URL . '/workspace' ); } 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 37949a1..e949e45 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -11,6 +11,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); } }