From 19a68bae09e6006e98caf803d27082289fe46647 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 26 Jul 2015 21:49:36 -0400 Subject: [PATCH] CRM-9084 - Add field separator option to import --- CRM/Import/Form/DataSource.php | 8 +++++--- templates/CRM/Activity/Import/Form/DataSource.tpl | 4 ++++ templates/CRM/Contribute/Import/Form/DataSource.tpl | 4 ++++ templates/CRM/Custom/Import/Form/DataSource.tpl | 5 +++++ templates/CRM/Event/Import/Form/DataSource.tpl | 5 +++++ templates/CRM/Member/Import/Form/DataSource.tpl | 4 ++++ 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php index d5f6a81806..87f3a24a08 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -79,6 +79,9 @@ abstract class CRM_Import_Form_DataSource extends CRM_Core_Form { $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); + $this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE); + $this->setDefaults(array('fieldSeparator' => $config->fieldSeparator)); + //get the saved mapping details $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import ' . static::IMPORT_ENTITY, @@ -164,15 +167,14 @@ abstract class CRM_Import_Form_DataSource extends CRM_Core_Form { $session = CRM_Core_Session::singleton(); $session->set("dateTypes", $this->get('dateFormats')); - $config = CRM_Core_Config::singleton(); - $seperator = $config->fieldSeparator; + $separator = $this->controller->exportValue($this->_name, 'fieldSeparator'); $mapper = array(); $parser = new $parserClassName($mapper); $parser->setMaxLinesToProcess(100); $parser->run($fileName, - $seperator, + $separator, $mapper, $skipColumnHeader, CRM_Import_Parser::MODE_MAPFIELD, diff --git a/templates/CRM/Activity/Import/Form/DataSource.tpl b/templates/CRM/Activity/Import/Form/DataSource.tpl index 6902891247..e2ad49586f 100644 --- a/templates/CRM/Activity/Import/Form/DataSource.tpl +++ b/templates/CRM/Activity/Import/Form/DataSource.tpl @@ -52,6 +52,10 @@ {ts}Check this box if the first row of your file consists of field names (Example: 'Contact ID', 'Activity Type', 'Activity Date').{/ts} + + {$form.fieldSeparator.label} {help id='id-fieldSeparator' file='CRM/Contact/Import/Form/DataSource'} + {$form.fieldSeparator.html} + {include file="CRM/Core/Date.tpl"} {if $savedMapping} diff --git a/templates/CRM/Contribute/Import/Form/DataSource.tpl b/templates/CRM/Contribute/Import/Form/DataSource.tpl index d410fbed00..58af9dd745 100644 --- a/templates/CRM/Contribute/Import/Form/DataSource.tpl +++ b/templates/CRM/Contribute/Import/Form/DataSource.tpl @@ -45,6 +45,10 @@ {ts}Select 'Individual' if you are importing contributions made by individual persons.{/ts} {ts}Select 'Organization' or 'Household' if you are importing contributions made by contacts of that type. (NOTE: Some built-in contact types may not be enabled for your site.){/ts} {$form.onDuplicate.label}{$form.onDuplicate.html} {help id="id-onDuplicate"} + + {$form.fieldSeparator.label} {help id='id-fieldSeparator' file='CRM/Contact/Import/Form/DataSource'} + {$form.fieldSeparator.html} + {include file="CRM/Core/Date.tpl"} {if $savedMapping} {if $loadedMapping}{ts}Select a Different Field Mapping{/ts}{else}{ts}Load Saved Field Mapping{/ts}{/if}{$form.savedMapping.html}
{ts}Select a saved field mapping if this file format matches a previous import.{/ts} diff --git a/templates/CRM/Custom/Import/Form/DataSource.tpl b/templates/CRM/Custom/Import/Form/DataSource.tpl index 73accd3577..889607c17f 100644 --- a/templates/CRM/Custom/Import/Form/DataSource.tpl +++ b/templates/CRM/Custom/Import/Form/DataSource.tpl @@ -75,6 +75,11 @@ + + + {$form.fieldSeparator.label} {help id='id-fieldSeparator' file='CRM/Contact/Import/Form/DataSource'} + {$form.fieldSeparator.html} + {include file="CRM/Core/Date.tpl"} diff --git a/templates/CRM/Event/Import/Form/DataSource.tpl b/templates/CRM/Event/Import/Form/DataSource.tpl index 92315f5f56..b48d10f5d4 100644 --- a/templates/CRM/Event/Import/Form/DataSource.tpl +++ b/templates/CRM/Event/Import/Form/DataSource.tpl @@ -70,6 +70,11 @@ {$form.onDuplicate.label} {$form.onDuplicate.html} {help id="id-onDuplicate"} + + + {$form.fieldSeparator.label} {help id='id-fieldSeparator' file='CRM/Contact/Import/Form/DataSource'} + {$form.fieldSeparator.html} + {include file="CRM/Core/Date.tpl"} diff --git a/templates/CRM/Member/Import/Form/DataSource.tpl b/templates/CRM/Member/Import/Form/DataSource.tpl index 538f613cd2..50b1e665d3 100644 --- a/templates/CRM/Member/Import/Form/DataSource.tpl +++ b/templates/CRM/Member/Import/Form/DataSource.tpl @@ -62,6 +62,10 @@ {$form.onDuplicate.label} {$form.onDuplicate.html} {help id="id-onDuplicate"} + + {$form.fieldSeparator.label} {help id='id-fieldSeparator' file='CRM/Contact/Import/Form/DataSource'} + {$form.fieldSeparator.html} + {include file="CRM/Core/Date.tpl"} {if $savedMapping} -- 2.25.1