79 $this->warnings = array();
82 $excel->loadFromFile($file);
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);
Class ilDclBaseRecordModel.
static getExcelCharForInteger($int)
if(empty($password)) $table
getImportFieldsFromTitles($table, $titles)