diff --git a/AmFormsPlugin.php b/AmFormsPlugin.php index 7093229..e6a691d 100644 --- a/AmFormsPlugin.php +++ b/AmFormsPlugin.php @@ -28,7 +28,15 @@ public function getName() */ public function getVersion() { - return '1.2.10'; + return '1.3.0'; + } + + /** + * @return string + */ + public function getSchemaVersion() + { + return '1.3.0'; } /** diff --git a/config.php b/config.php index 379a51d..0ea3be1 100644 --- a/config.php +++ b/config.php @@ -27,6 +27,10 @@ ), ), 'export' => array( + array( + 'name' => 'Delimiter', + 'value' => ';', + ), array( 'name' => 'Export rows per set', 'value' => 50, diff --git a/migrations/m151222_111300_amforms_addDelimiterSetting.php b/migrations/m151222_111300_amforms_addDelimiterSetting.php new file mode 100644 index 0000000..6cab6e6 --- /dev/null +++ b/migrations/m151222_111300_amforms_addDelimiterSetting.php @@ -0,0 +1,25 @@ + 'Delimiter', + 'value' => ';', + ), + ); + return craft()->amForms_install->installSettings($settings, AmFormsModel::SettingExport); + } +} diff --git a/services/AmForms_ExportsService.php b/services/AmForms_ExportsService.php index 70f0bb0..1995a22 100644 --- a/services/AmForms_ExportsService.php +++ b/services/AmForms_ExportsService.php @@ -6,11 +6,17 @@ */ class AmForms_ExportsService extends BaseApplicationComponent { + private $_delimiter; private $_exportFiles = array(); private $_exportFields = array(); private $_exportColumns = array(); private $_exportSpaceCounter = array(); + public function __construct() + { + $this->_delimiter = craft()->amForms_settings->getSettingsValueByHandleAndType('delimiter', AmFormsModel::SettingExport, ';'); + } + /** * Get all exports. * @@ -360,7 +366,7 @@ public function runExport(AmForms_ExportModel $export, $limit = null, $offset = $this->_exportFiles['manual'] = fopen('php://output', 'w'); // Create columns - fputcsv($this->_exportFiles['manual'], $this->_getExportColumns($export, $form), ';'); + fputcsv($this->_exportFiles['manual'], $this->_getExportColumns($export, $form), $this->_delimiter); } else { $this->_exportFiles[$export->id] = fopen($export->file, 'a'); @@ -540,7 +546,7 @@ private function _createExportFile(AmForms_ExportModel $export, AmForms_FormMode if (! $export->submissions) { // Add columns to export file $exportFile = fopen($file, 'w'); - fputcsv($exportFile, $this->_getExportColumns($export, $form), ';'); + fputcsv($exportFile, $this->_getExportColumns($export, $form), $this->_delimiter); fclose($exportFile); } @@ -805,7 +811,7 @@ private function _exportSubmission(AmForms_ExportModel $export, $submission, $re if ($returnData) { return $data; } - fputcsv($this->_exportFiles[ ($export->startRightAway ? 'manual' : $export->id) ], $data, ';'); + fputcsv($this->_exportFiles[ ($export->startRightAway ? 'manual' : $export->id) ], $data, $this->_delimiter); // Add more rows? if ($hasMoreRows) { @@ -824,7 +830,7 @@ private function _exportSubmission(AmForms_ExportModel $export, $submission, $re } // Add row to CSV - fputcsv($this->_exportFiles[ ($export->startRightAway ? 'manual' : $export->id) ], $data, ';'); + fputcsv($this->_exportFiles[ ($export->startRightAway ? 'manual' : $export->id) ], $data, $this->_delimiter); } } } diff --git a/templates/settings/exports.twig b/templates/settings/exports.twig index 96e5dcf..23b9e0f 100644 --- a/templates/settings/exports.twig +++ b/templates/settings/exports.twig @@ -4,6 +4,13 @@ {% set selectedTab = 'exports' %} {% block fields %} + {{ forms.textField({ + label: exports.delimiter.name|t, + id: exports.delimiter.handle, + name: exports.delimiter.handle, + value: exports.delimiter.value, + instructions: 'Which character should be used as delimiter?'|t + }) }} {{ forms.textField({ label: exports.exportRowsPerSet.name|t, id: exports.exportRowsPerSet.handle, diff --git a/translations/nl.php b/translations/nl.php index 20fe3e8..9035787 100644 --- a/translations/nl.php +++ b/translations/nl.php @@ -56,6 +56,7 @@ 'Date' => 'Datum', 'Date created' => 'Aanmaakdatum', 'Date updated' => 'Wijzigingsdatum', + 'Delimiter' => 'Scheidingsteken', 'Design your form' => 'Stel uw formulier samen', 'Don’t include the field and block names in the column name.' => 'De naam van het veld en de blokken niet opnemen in de kolomnaam.', 'Don’t show' => 'Niet weergeven', @@ -183,6 +184,7 @@ 'Whether to silently log an error or throw an exception if a form does not exist. By default, it will throw an exception.' => 'Of er stil gefaald en de fout gelogd moet worden als het formulier niet bestaat, of de fout door middel van een exception wordt getoond. Standaard wordt de exception getoond.', 'Whether to email form submissions.' => 'Of formulier inzendingen via e-mail verstuurd moeten worden.', 'Whether to store form submissions.' => 'Of formulier inzendingen opgeslagen moeten worden.', + 'Which character should be used as delimiter?' => 'Welk karakter moet worden gebruikt als scheidingsteken?', 'Which fields do you want to export?' => 'Welke velden wilt u exporteren?', 'Which form do you want to export?' => 'Welk formulier wilt u exporteren?', 'Which form do you want to see submissions from?' => 'Van welk formulier wilt u de laatste inzendingen zien?',