Exemple #1
0
 /**
  * Export dialog action for categoris
  */
 public function categories()
 {
     if (!$this->_jbrequest->isPost()) {
         $this->exportParams = $this->_config->getGroup('export.categories', $this->_jbuser->getParam('export-categories'));
         $this->_setExportParams();
         $this->renderView();
     } else {
         try {
             $request = $this->app->data->create($this->_jbrequest->getAdminForm());
             $data['separator'] = $request->get('separator');
             $data['enclosure'] = $request->get('enclosure');
             $data['separator'] = empty($data['separator']) ? $this->_defaultParams['separator'] : $data['separator'];
             $data['enclosure'] = empty($data['enclosure']) ? $this->_defaultParams['enclosure'] : $data['enclosure'];
             $request->remove('separator');
             $request->remove('enclosure');
             $this->_config->setGroup('export.categories', $request);
             $this->_config->setGroup('export', $data);
             list($appId) = explode(':', $request->get('category_app', '0:'));
             $files = $this->_jbexport->categoriesToCSV($appId, $request);
             if (!empty($files)) {
                 $tmpArch = $this->app->jbarch->compress($files, 'jbzoo-export-categories-' . date('Y-m-d_H-i'));
             } else {
                 throw new AppException(JText::_('JBZOO_EXPORT_CATEGORIES_NOT_FOUND'));
             }
             if (is_readable($tmpArch) && JFile::exists($tmpArch)) {
                 $this->app->filesystem->output($tmpArch);
                 JFile::delete($tmpArch);
                 JFolder::delete($this->app->jbpath->sysPath('tmp', '/jbzoo-export'));
                 JExit();
             } else {
                 throw new AppException(JText::sprintf('Unable to create file %s', $tmpArch));
             }
         } catch (AppException $e) {
             $this->app->jbnotify->notice(JText::_('Error create export file') . ' (' . $e . ')');
             $this->setRedirect($this->app->jbrouter->admin(array('task' => 'categories')));
         }
     }
 }