protected function _initJoomlaSession($fileInfo) { $sesData = array('file' => $fileInfo['path'], 'count' => $fileInfo['count'], 'header' => $this->_config->find('csv.header', 1), 'separator' => $this->_config->find('csv.separator', ','), 'enclosure' => $this->_config->find('csv.enclosure', '"'), 'import-type' => 'items', 'step' => $this->_getStepSize(), 'appid' => $this->_config->find('params.appid', '1'), 'typeid' => $this->_config->find('params.typeid', 'product'), 'lose' => $this->_config->find('params.lose', '0'), 'key' => $this->_config->find('params.key', '0'), 'create' => $this->_config->find('params.create', '0'), 'checkOptions' => $this->_config->find('params.checkOptions', '1'), 'createAlias' => $this->_config->find('params.createAlias', '0'), 'assign' => $this->_config->find('assign', array())); $this->_jbsession->setGroup($sesData, 'import'); if ($this->_isDebug()) { $this->_('Current import params: ' . print_r($sesData, true), 'Info'); } return new Data($sesData); }
/** * Import dialog action */ public function assign() { $csvfile = $this->_jbrequest->getFile('csvfile', JBRequestHelper::ADMIN_FORM_KEY); $request = $this->_jbrequest->getAdminForm(); $importType = isset($request['import-type']) ? $request['import-type'] : null; if (empty($request['separator'])) { $request['separator'] = $this->_defaultParams['separator']; } if (empty($request['enclosure'])) { $request['enclosure'] = $this->_defaultParams['enclosure']; } // validate upload file try { $userfile = $this->app->validator->create('file', array('extension' => array('csv')))->clean($csvfile); } catch (AppException $e) { $this->app->jbnotify->notice(JText::_('JBZOO_UNABLE_TO_UPLOAD_FILE') . ' (' . $e . ')'); $this->setRedirect($this->app->jbrouter->admin(array('task' => $importType))); return; } // upload file $file = $this->_jbimport->getTmpFilename(); if (JFile::upload($userfile['tmp_name'], $file)) { // prepare session data $this->_config->setGroup('import.' . $importType, $request); $request['file'] = $file; // save to session $this->_jbsession->setGroup($request, 'import'); // prepare data $this->info = $this->_jbimport->getInfo($file, $request); $this->_jbsession->set('count', $this->info['count'], 'import'); // render pseudo template if ($importType == 'items') { // some vars for template $this->controls = $this->_jbimport->itemsControls($this->info); $this->prevParams = $this->_config->getGroup('import.last.items', $this->_jbuser->getParam('lastImport-items')); $this->renderView('items'); } else { if ($importType == 'categories') { // some vars for template $this->controls = $this->_jbimport->categoriesControls($this->info); $this->prevParams = $this->_config->getGroup('import.last.categories', $this->_jbuser->getParam('lastImport-categories')); $this->renderView('categories'); } else { jexit('Unknown import type!'); // TODO replace to exception } } } else { $this->app->error->raiseNotice(0, JText::_('JBZOO_CHECK_TEMP_PERMISIONS')); $this->setRedirect($this->baseurl . '&task=index'); return; } }