85 $this->warnings =
array();
88 $excel->loadFromFile(
$file);
90 $this->warnings[] = $this->lng->txt(
"dcl_file_not_readable");
93 $sheet_count = $excel->getSheetCount();
94 $excel->setActiveSheet(0);
96 if ($sheet_count != count($this->tables)) {
97 $this->warnings[] = $this->lng->txt(
'dcl_file_not_readable');
100 if (count($this->warnings)) {
101 return array(
'line'=>0,
'warnings'=>$this->warnings);
104 for ($sheet = 0; $sheet < $sheet_count; $sheet++) {
105 $excel->setActiveSheet($sheet);
106 $table = $this->tables[$sheet];
109 $sheet_title = substr(
$table->getTitle(), 0, 31);
110 if ($excel->getSheetTitle() != $sheet_title) {
111 $this->warnings[] = $this->lng->txt(
'dcl_table_title_not_matching');
115 $field_names =
array();
116 $sheet_data = $excel->getSheetAsArray();
118 foreach ($sheet_data[0] as
$column) {
124 for (
$i = 2;
$i <= count($sheet_data);
$i++) {
126 $record->setOwner(
$ilUser->getId());
129 $record->setTableId(
$table->getId());
134 foreach ($fields as $col => $field) {
136 if ($field->isStandardField()) {
137 $record->setStandardFieldValueFromExcel($excel,
$i, $col, $field);
139 $value = $record->getRecordFieldValueFromExcel($excel,
$i, $col, $field);
141 if (is_array($value) && isset($value[
'warning'])) {
142 $this->warnings[] = $value[
'warning'];
146 $field->checkValidity($value, $record->getId());
148 $record->setRecordFieldValue($field->getId(), $value);
157 if ($fields_failed < count($fields)) {
158 $record_imported =
true;
161 $record_imported =
false;
165 if (!$record_imported) {
166 $record->doDelete(
true);
171 if ((
$i - 1) - $records_failed > $this->max_imports) {
172 $this->warnings[] = $this->lng->txt(
"dcl_max_import") . (count($sheet_data) - 1) .
" > " . $this->max_imports;
179 return array(
'line'=>(
$i-2 < 0 ? 0 :
$i-2),
'warnings'=>$this->warnings);
Create styles array
The data for the language used.
Class ilDclBaseRecordModel.
static getExcelCharForInteger($int)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
if(empty($password)) $table
getImportFieldsFromTitles($table, $titles)