/**
  * Prepares the default DataCollector instance based on the configuration.
  *
  * @param \Database\Result $config
  * @param array|null       $ids
  *
  * @return DataCollector
  */
 protected function prepareDefaultDataCollector($config, $ids = null)
 {
     $dataCollector = new DataCollector($config->master);
     // Limit the fields
     if ('fields' === $config->export) {
         $limitFields = array();
         foreach ($config->fields as $fieldsConfig) {
             $limitFields[] = $fieldsConfig['field'];
         }
         $dataCollector->setFieldIds($limitFields);
     }
     if (null !== $ids) {
         $dataCollector->setLeadDataIds($ids);
     }
     $this->newLastRun = \Date::floorToMinute();
     if ($config->skipLastRun) {
         $dataCollector->setFrom($config->lastRun);
         $dataCollector->setTo($this->newLastRun - 1);
     }
     return $dataCollector;
 }
示例#2
0
 /**
  * Get the export fields
  *
  * @param object
  * @param array
  * @return ArrayReader
  *
  * @deprecated Use the DataCollector class instead.
  */
 protected function getExportData($objConfig, $arrIds = null)
 {
     $dataCollector = new DataCollector($objConfig->master);
     // Limit the fields
     if ($objConfig->export != 'all') {
         $arrLimitFields = array_keys($objConfig->fields);
         $dataCollector->setFieldIds(array_map('intval', $arrLimitFields));
     }
     if (null !== $arrIds) {
         $dataCollector->setLeadDataIds($arrIds);
     }
     $objReader = new ArrayReader($dataCollector->getExportData());
     // Add header fields
     if ($objConfig->headerFields) {
         $arrHeader = array();
         // Add base information columns
         if ($objConfig->export == 'all') {
             \System::loadLanguageFile('tl_lead_export');
             $arrHeader[] = $GLOBALS['TL_LANG']['tl_lead_export']['field_form'];
             $arrHeader[] = $GLOBALS['TL_LANG']['tl_lead_export']['field_created'];
             $arrHeader[] = $GLOBALS['TL_LANG']['tl_lead_export']['field_member'];
         } else {
             if ($objConfig->fields['_form']) {
                 $arrHeader[] = $objConfig->fields['_form']['name'];
             }
             if ($objConfig->fields['_created']) {
                 $arrHeader[] = $objConfig->fields['_created']['name'];
             }
             if ($objConfig->fields['_member']) {
                 $arrHeader[] = $objConfig->fields['_member']['name'];
             }
         }
         // Add export data header fields
         foreach ($dataCollector->getHeaderFields() as $fieldId => $label) {
             // Use a custom header field
             if ($objConfig->fields[$fieldId]['name'] != '') {
                 $arrHeader[] = $objConfig->fields[$fieldId]['name'];
             } else {
                 $arrHeader[] = $label;
             }
         }
         $objReader->setHeaderFields($arrHeader);
     }
     return $objReader;
 }