/**
  * Prepare for export
  *
  * @copyright
  * @author 		RolandD
  * @todo		Update the output type to include multiple destinations
  * @todo		Is the setting of the export_type in JRequest necessary?
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		3.0
  */
 public function getPrepareExport()
 {
     // Load the form handler
     $app = JFactory::getApplication();
     $jinput = JFactory::getApplication()->input;
     $db = JFactory::getDbo();
     $option = $jinput->get('option');
     $data = $jinput->get('jform', array(), 'array');
     // Prepare the template
     $data['id'] = $jinput->get('template_id', 0, 'int');
     $template = new CsviTemplate($data);
     $jinput->set('template', $template);
     $template->setName($jinput->get('template_name', '', 'string'));
     // Set the export type
     $jinput->set('export_type', $data['options']['operation']);
     // Initiate the log
     $csvilog = new CsviLog();
     // Create a new Import ID in the logger
     $csvilog->setId();
     // Set to collect debug info
     $csvilog->setDebug($template->get('collect_debug_info', 'general'));
     // Set some log info
     $csvilog->SetAction('export');
     $csvilog->SetActionType($jinput->get('export_type'), $template->getName('template_name'));
     // Add the logger to the registry
     $jinput->set('csvilog', $csvilog);
     // Load the fields to export
     $exportfields = $this->getExportFields();
     if (!empty($exportfields)) {
         // Set the last export field
         $jinput->set('export.fields', $exportfields);
         // Allow big SQL selects
         $db->setQuery("SET OPTION SQL_BIG_SELECTS=1");
         $db->query();
         // Get the filename for the export file
         $jinput->set('export.filename', $this->exportFilename());
         // See if we need to get an XML/HTML class
         $export_format = $template->get('export_file', 'general');
         if ($export_format == 'xml' || $export_format == 'html') {
             $exportclass = $this->getExportClass();
             if ($exportclass) {
                 $jinput->set('export.class', $exportclass);
             } else {
                 $csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_EXPORT_CLASS'));
                 $app->enqueueMessage(JText::_('COM_CSVI_NO_EXPORT_CLASS'), 'error');
                 $jinput->set('logcount', array('export' => 0));
                 return false;
             }
         }
         // Return all is good
         return true;
     } else {
         $csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_EXPORT_FIELDS'));
         $app->enqueueMessage(JText::_('COM_CSVI_NO_EXPORT_FIELDS'), 'error');
         $jinput->set('logcount', array('export' => 0));
         return false;
     }
 }
Пример #2
0
 /**
  * Prepare for export
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		3.0
  */
 public function getPrepareExport()
 {
     // Load the basics
     $jinput = JFactory::getApplication()->input;
     $db = JFactory::getDbo();
     $exportfile_model = $this->_getModel('exportfile');
     // Load the backend language file
     $lang = JFactory::getLanguage();
     $lang->load('com_csvi', JPATH_ADMINISTRATOR);
     // Load the template
     $template = new CsviTemplate();
     $template->load($jinput->get('template_id', 0, 'int'));
     $template->set('exportto', 'general', 'tofront');
     $jinput->set('template', $template);
     // Set the export type
     $jinput->set('export_type', $template->get('operation', 'options'));
     // Initiate the log
     $csvilog = new CsviLog();
     // Create a new Import ID in the logger
     $csvilog->setId();
     // Set to collect debug info
     $csvilog->setDebug($template->get('collect_debug_info', 'general'));
     // Set some log info
     $csvilog->SetAction('export');
     $csvilog->SetActionType($template->get('export_type'), $template->getName());
     // Add the logger to the registry
     $jinput->set('csvilog', $csvilog);
     // Load the fields to export
     $exportfields = $exportfile_model->getExportFields();
     if (!empty($exportfields)) {
         $jinput->set('export.fields', $exportfields);
         // Allow big SQL selects
         $db->setQuery("SET OPTION SQL_BIG_SELECTS=1");
         $db->query();
         // Get the filename for the export file
         $jinput->set('export.filename', $exportfile_model->exportFilename());
         // See if we need to get an XML/HTML class
         $export_format = $template->get('export_file', 'general');
         if ($export_format == 'xml' || $export_format == 'html') {
             $exportclass = $exportfile_model->getExportClass();
             if ($exportclass) {
                 $jinput->set('export.class', $exportclass);
             } else {
                 $csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_EXPORT_CLASS'));
                 $jinput->set('logcount', 0);
                 return false;
             }
         }
         // Return all is good
         return true;
     } else {
         $csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_EXPORT_FIELDS'));
         $jinput->set('logcount', 0);
         return false;
     }
 }
Пример #3
0
 /**
  * Prepare maintenance
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		3.3
  */
 public function getPrepareMaintenance()
 {
     $jinput = JFactory::getApplication()->input;
     // Start the log
     $csvilog = new CsviLog();
     $import_id = $csvilog->setId();
     $csvilog->SetAction('Maintenance');
     $csvilog->SetActionType($jinput->get('task') . '_LABEL');
     $jinput->set('import_id', $import_id);
     $jinput->set('csvilog', $csvilog);
 }