33            ilDclDataType::INPUTFORMAT_TEXT_SELECTION,
 
   70        $this->tables = (
$table_id) ? array($this->dcl->getTableById(
$table_id)) : $this->dcl->getTables();
 
   74    public function import($file, $simulate = 
false)
 
   79        $this->warnings = array();
 
   82            $excel->loadFromFile($file);
 
   83        } 
catch (Exception $e) {
 
   84            $this->warnings[] = $this->lng->txt(
"dcl_file_not_readable");
 
   87        $sheet_count = $excel->getSheetCount();
 
   88        $excel->setActiveSheet(0);
 
   90        if ($sheet_count != count($this->tables)) {
 
   91            $this->warnings[] = $this->lng->txt(
'dcl_file_not_readable');
 
   94        if (count($this->warnings)) {
 
   95            return array(
'line' => 0, 
'warnings' => $this->warnings);
 
   98        for ($sheet = 0; $sheet < $sheet_count; $sheet++) {
 
   99            $excel->setActiveSheet($sheet);
 
  100            $table = $this->tables[$sheet];
 
  103            $sheet_title = substr(
$table->getTitle(), 0, 31);
 
  104            if ($excel->getSheetTitle() != $sheet_title) {
 
  105                $this->warnings[] = $this->lng->txt(
'dcl_table_title_not_matching');
 
  109            $field_names = array();
 
  110            $sheet_data = $excel->getSheetAsArray();
 
  112            foreach ($sheet_data[0] as $column) {
 
  113                $field_names[] = $column;
 
  118            for (
$i = 2; 
$i <= count($sheet_data); 
$i++) {
 
  120                $record->setOwner(
$ilUser->getId());
 
  123                $record->setTableId(
$table->getId());
 
  128                foreach ($fields as $col => $field) {
 
  130                        if ($field->isStandardField()) {
 
  131                            $record->setStandardFieldValueFromExcel($excel, 
$i, $col, $field);
 
  133                            $value = $record->getRecordFieldValueFromExcel($excel, 
$i, $col, $field);
 
  135                            if (is_array($value) && isset($value[
'warning'])) {
 
  136                                $this->warnings[] = $value[
'warning'];
 
  140                            $field->checkValidity($value, $record->getId());
 
  142                                $record->setRecordFieldValue($field->getId(), $value);
 
  151                if ($fields_failed < count($fields)) {
 
  152                    $record_imported = 
true;
 
  155                    $record_imported = 
false;
 
  159                    if (!$record_imported) { 
 
  160                        $record->doDelete(
true); 
 
  165                if ((
$i - 1) - $records_failed > $this->max_imports) {
 
  166                    $this->warnings[] = $this->lng->txt(
"dcl_max_import") . (count($sheet_data) - 1) . 
" > " . $this->max_imports;
 
  172        return array(
'line' => (
$i - 2 < 0 ? 0 : 
$i - 2), 
'warnings' => $this->warnings);
 
  183        if (in_array($field->getDatatypeId(), $this->supported_import_datatypes)) {
 
  186            $this->warnings[] = $field->getTitle() . 
": " . $this->lng->txt(
"dcl_not_supported_in_import");
 
  201        $fields = 
$table->getRecordFields();
 
  202        $import_fields = array();
 
  203        foreach ($fields as $field) {
 
  206                $field->checkTitlesForImport($titles, $import_fields);
 
  210        foreach ($titles as 
$key => $value) {
 
  213            foreach ($importable_titles as $identifier => 
$values) {
 
  214                if (in_array($value, 
$values)) {
 
  216                    $std_field->setId(substr($identifier, 4));
 
  217                    $import_fields[
$key] = $std_field;
 
  221            if (in_array($value, $not_importable_titles)) {
 
  224                if (!isset($import_fields[
$key])) {
 
  230        return $import_fields;
 
An exception for terminatinating execution or to throw for unit testing.
static getExcelCharForInteger($int)
@classDescription Date and time handling
Class ilDclBaseRecordModel.
Hook-Class for exporting data-collections (used in SOAP-Class) This Class avoids duplicated code by r...
getImportFieldsFromTitles($table, $titles)
__construct($ref_id, $table_id=null)
$supported_import_datatypes
const INPUTFORMAT_BOOLEAN
const INPUTFORMAT_DATETIME
const INPUTFORMAT_REFERENCE
const INPUTFORMAT_DATE_SELECTION
Class ilDclBaseFieldModel.
static _getNonImportableStandardFieldTitles()
static _getImportableStandardFieldTitle()
Class ilObjDataCollection.
if(empty($password)) $table