/** * 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; } }