76 $this->_sCsvFilePath = null;
78 $sNavStep = $oConfig->getRequestParameter(
'sNavStep');
95 $configValidator =
oxNew(
'oxNoJsValidator');
97 $sTerminator = $oConfig->getRequestParameter(
'sGiCsvFieldTerminator');
98 if ($sTerminator && !$configValidator->isValid($sTerminator)) {
101 $this->_sStringTerminator = $sTerminator;
102 $oConfig->saveShopConfVar(
'str',
'sGiCsvFieldTerminator', $sTerminator);
105 $sEncloser = $oConfig->getRequestParameter(
'sGiCsvFieldEncloser');
106 if ($sEncloser && !$configValidator->isValid($sEncloser)) {
109 $this->_sStringEncloser = $sEncloser;
110 $oConfig->saveShopConfVar(
'str',
'sGiCsvFieldEncloser', $sEncloser);
113 $sType = $oConfig->getRequestParameter(
'sType');
114 $oType = $oErpImport->getImportObject($sType);
115 $this->_aViewData[
'sType'] = $sType;
116 $this->_aViewData[
'sImportTable'] = $oType->getBaseTableName();
118 $this->_aViewData[
'aDbFieldsList'] = $oType->getFieldList();
121 if ($sNavStep == 3) {
122 $aCsvFields = $oConfig->getRequestParameter(
'aCsvFields');
123 $sType = $oConfig->getRequestParameter(
'sType');
126 $oErpImport->setImportTypePrefix($sType);
127 $oErpImport->setCsvFileFieldsOrder($aCsvFields);
131 $this->_aViewData[
'iTotalRows'] = $oErpImport->getTotalImportedRowsNumber();
140 if ($oConfig->getRequestParameter(
'iRepeatImport')) {
141 $this->_aViewData[
'iRepeatImport'] = 1;
146 if ($sNavStep == 1) {
147 $this->_aViewData[
'aImportTables'] = $oErpImport->getImportObjectsList();
148 asort($this->_aViewData[
'aImportTables']);
152 $this->_aViewData[
'sNavStep'] = $sNavStep;
163 if (is_file($sPath)) {
176 $blCsvContainsHeader = $this->
getConfig()->getRequestParameter(
'blContainsHeader');
182 if (!$blCsvContainsHeader) {
184 foreach ($aFirstRow as $sValue) {
185 $aCsvFields[$iIndex] =
'Column ' . $iIndex++;
188 foreach ($aFirstRow as $sKey => $sValue) {
192 $aCsvFields = $aFirstRow;
206 $iMaxLineLength = 8192;
209 if (($rFile = @fopen($sPath,
"r")) !==
false) {
222 $this->_sCsvFilePath = null;
237 if ($iNavStep == 2) {
239 $oEx =
oxNew(
"oxExceptionToDisplay");
240 $oEx->setMessage(
'GENIMPORT_ERRORUPLOADINGFILE');
241 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay($oEx,
false,
true,
'genimport');
246 if ($iNavStep == 3) {
248 $aCsvFields = $this->
getConfig()->getRequestParameter(
'aCsvFields');
249 foreach ($aCsvFields as $sValue) {
257 $oEx =
oxNew(
"oxExceptionToDisplay");
258 $oEx->setMessage(
'GENIMPORT_ERRORASSIGNINGFIELDS');
259 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay($oEx,
false,
true,
'genimport');
276 if ($this->_sCsvFilePath !== null) {
283 $aFile = $oConfig->getUploadedFile(
'csvfile');
284 if (isset($aFile[
'name']) && $aFile[
'name']) {
285 $this->_sCsvFilePath = $oConfig->getConfigParam(
'sCompileDir') . basename($aFile[
'tmp_name']);
286 move_uploaded_file($aFile[
'tmp_name'], $this->_sCsvFilePath);
300 foreach ($oErpImport->getStatistics() as $aValue) {
301 if (!$aValue [
'r']) {
302 $oEx =
oxNew(
"oxExceptionToDisplay");
303 $oEx->setMessage($aValue [
'm']);
304 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay($oEx,
false,
true,
'genimport');
317 if ($this->_sStringTerminator === null) {
319 if ($sChar = $this->
getConfig()->getConfigParam(
'sGiCsvFieldTerminator')) {
320 $this->_sStringTerminator = $sChar;
334 if ($this->_sStringEncloser === null) {
336 if ($sChar = $this->
getConfig()->getConfigParam(
'sGiCsvFieldEncloser')) {
337 $this->_sStringEncloser = $sChar;
349 $error =
oxNew(
'oxDisplayError');
350 $error->setFormatParameters(htmlspecialchars($sInvalidData));
351 $error->setMessage(
"SHOP_CONFIG_ERROR_INVALID_VALUE");