Skip to content

Commit 8349240

Browse files
committed
Merge pull request #30 from hananils/integration
Custom CSV Styles
2 parents b36489f + c548c18 commit 8349240

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

data-sources/datasource.remote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ public function execute(array &$param_pool = null)
790790
if (empty($this->_env)) {
791791
$this->_env['env']['pool'] = array(
792792
'root' => URL,
793-
'workspace' => WORKSPACE
793+
'workspace' => URL . '/workspace'
794794
);
795795
}
796796

extension.driver.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,18 @@ public function addCachingOpportunity($context)
5959

6060
$context['wrapper']->appendChild($label);
6161
}
62+
63+
public function install()
64+
{
65+
Symphony::Configuration()->set('csv-delimiter', ',', 'remote_datasource');
66+
Symphony::Configuration()->set('csv-enclosure', '"', 'remote_datasource');
67+
Symphony::Configuration()->set('csv-escape', '\\', 'remote_datasource');
68+
Symphony::Configuration()->write();
69+
}
70+
71+
public function uninstall()
72+
{
73+
Symphony::Configuration()->remove('remote_datasource');
74+
}
75+
6276
}

extension.meta.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
</author>
1212
</authors>
1313
<releases>
14+
<release version="2.2.0" date="2015-06-24" min="2.4" max="2.6.x">
15+
- Make CSV style configurable.
16+
- Fix `{$workspace}` path
17+
</release>
1418
<release version="2.1.3" date="2015-05-13" min="2.4" max="2.6.x">
1519
- Fix a bug with late static binding on PHP 5.3.
1620
</release>

lib/class.csv.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public static function convertToXML($data)
3333
{
3434
$headers = array();
3535

36+
// Get CSV settings
37+
$settings = array(
38+
'csv-delimiter' => ',',
39+
'csv-enclosure' => '"',
40+
'csv-escape' => '\\'
41+
);
42+
$settings = array_merge($settings, (array) Symphony::Configuration()->get('remote_datasource'));
43+
3644
// DOMDocument
3745
$doc = new DOMDocument('1.0', 'utf-8');
3846
$doc->formatOutput = true;
@@ -46,14 +54,14 @@ public static function convertToXML($data)
4654
}
4755

4856
if ($i == 0) {
49-
foreach (str_getcsv($row) as $i => $head) {
57+
foreach (str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']) as $i => $head) {
5058
if (class_exists('Lang')) {
5159
$head = Lang::createHandle($head);
5260
}
5361
$headers[] = $head;
5462
}
5563
} else {
56-
self::addRow($doc, $root, str_getcsv($row), $headers);
64+
self::addRow($doc, $root, str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']), $headers);
5765
}
5866
}
5967

0 commit comments

Comments
 (0)