70 $this->_sCsvFilePath = null;
72 $sNavStep = $oConfig->getParameter(
'sNavStep' );
83 if ( $sNavStep == 1 ) {
90 $sTerminator = $oConfig->getRequestParameter(
'sGiCsvFieldTerminator');
91 if ($sTerminator && !$configValidator->isValid($sTerminator)) {
94 $this->_sStringTerminator = $sTerminator;
95 $oConfig->saveShopConfVar(
'str',
'sGiCsvFieldTerminator', $sTerminator );
98 $sEncloser = $oConfig->getRequestParameter(
'sGiCsvFieldEncloser');
99 if ($sEncloser && !$configValidator->isValid($sEncloser)) {
102 $this->_sStringEncloser = $sEncloser;
103 $oConfig->saveShopConfVar(
'str',
'sGiCsvFieldEncloser', $sEncloser );
106 $sType = $oConfig->getParameter(
'sType' );
107 $oType = $oErpImport->getImportObject( $sType );
108 $this->_aViewData[
'sType'] = $sType;
109 $this->_aViewData[
'sImportTable'] = $oType->getBaseTableName();
111 $this->_aViewData[
'aDbFieldsList'] = $oType->getFieldList();
114 if ( $sNavStep == 3 ) {
115 $aCsvFields = $oConfig->getParameter(
'aCsvFields' );
116 $sType = $oConfig->getParameter(
'sType' );
119 $oErpImport->setImportTypePrefix( $sType );
120 $oErpImport->setCsvFileFieldsOrder( $aCsvFields );
124 $this->_aViewData[
'iTotalRows'] = $oErpImport->getTotalImportedRowsNumber();
133 if ( $oConfig->getParameter(
'iRepeatImport' ) ) {
134 $this->_aViewData[
'iRepeatImport'] = 1;
139 if ( $sNavStep == 1 ) {
140 $this->_aViewData[
'aImportTables'] = $oErpImport->getImportObjectsList();
141 asort( $this->_aViewData[
'aImportTables'] );
145 $this->_aViewData[
'sNavStep'] = $sNavStep;
159 if ( is_file( $sPath ) ) {
172 $blCsvContainsHeader = $this->
getConfig()->getParameter(
'blContainsHeader' );
178 if ( !$blCsvContainsHeader ) {
180 foreach ( $aFirstRow as $sValue ) {
181 $aCsvFields[$iIndex] =
'Column ' . $iIndex++;
184 foreach ( $aFirstRow as $sKey => $sValue ) {
185 $aFirstRow[$sKey] = htmlentities( $sValue );
188 $aCsvFields = $aFirstRow;
202 $iMaxLineLength = 8192;
205 if ( ( $rFile = @fopen( $sPath,
"r" ) ) !==
false ) {
220 $this->_sCsvFilePath = null;
235 if ( $iNavStep == 2 ) {
237 $oEx =
oxNew(
"oxExceptionToDisplay" );
238 $oEx->setMessage(
'GENIMPORT_ERRORUPLOADINGFILE' );
239 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay( $oEx,
false,
true,
'genimport' );
244 if ( $iNavStep == 3 ) {
246 $aCsvFields = $this->
getConfig()->getParameter(
'aCsvFields' );
247 foreach ( $aCsvFields as $sValue ) {
255 $oEx =
oxNew(
"oxExceptionToDisplay" );
256 $oEx->setMessage(
'GENIMPORT_ERRORASSIGNINGFIELDS' );
257 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay( $oEx,
false,
true,
'genimport' );
274 if ( $this->_sCsvFilePath !== null ) {
281 $aFile = $oConfig->getUploadedFile(
'csvfile' );
282 if ( isset( $aFile[
'name'] ) && $aFile[
'name'] ) {
283 $this->_sCsvFilePath = $oConfig->getConfigParam(
'sCompileDir' ) . basename( $aFile[
'tmp_name'] );
284 move_uploaded_file( $aFile[
'tmp_name'], $this->_sCsvFilePath );
299 foreach ( $oErpImport->getStatistics() as $aValue ) {
300 if ( !$aValue [
'r'] ) {
301 $oEx =
oxNew(
"oxExceptionToDisplay" );
302 $oEx->setMessage( $aValue [
'm'] );
303 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay( $oEx,
false,
true,
'genimport' );
316 if ( $this->_sStringTerminator === null ) {
318 if ( $sChar = $this->
getConfig()->getConfigParam(
'sGiCsvFieldTerminator' ) ) {
319 $this->_sStringTerminator = $sChar;
332 if ( $this->_sStringEncloser === null ) {
334 if ( $sChar = $this->
getConfig()->getConfigParam(
'sGiCsvFieldEncloser' ) ) {
335 $this->_sStringEncloser = $sChar;
346 $error =
oxNew(
'oxDisplayError');
347 $error->setFormatParameters(htmlspecialchars($sInvalidData));
348 $error->setMessage(
"SHOP_CONFIG_ERROR_INVALID_VALUE");