87 $this->warnings =
array();
90 $excel->loadFromFile(
$file);
92 $this->warnings[] = $this->lng->txt(
"dcl_file_not_readable");
95 $sheet_count = $excel->getSheetCount();
96 $excel->setActiveSheet(0);
98 if($sheet_count != count($this->tables)) {
99 $this->warnings[] = $this->lng->txt(
'dcl_file_not_readable');
102 if (count($this->warnings)) {
103 return array(
'line'=>0,
'warnings'=>$this->warnings);
106 for($sheet = 0; $sheet < $sheet_count; $sheet++) {
107 $excel->setActiveSheet($sheet);
108 $table = $this->tables[$sheet];
111 $sheet_title = substr($table->getTitle(), 0, 31);
112 if($excel->getSheetTitle() != $sheet_title) {
113 $this->warnings[] = $this->lng->txt(
'dcl_table_title_not_matching');
117 $field_names =
array();
118 $sheet_data = $excel->getSheetAsArray();
120 foreach ($sheet_data[0] as
$column) {
126 for ($i = 2; $i <= count($sheet_data); $i ++) {
128 $record->setOwner(
$ilUser->getId());
131 $record->setTableId($table->getId());
136 foreach ($fields as $col => $field) {
138 $value = $record->getRecordFieldValueFromExcel($excel, $i, $col, $field);
140 if (is_array($value) && isset($value[
'warning'])) {
141 $this->warnings[] = $value[
'warning'];
145 $field->checkValidity($value, $record->getId());
147 $record->setRecordFieldValue($field->getId(), $value);
155 if ($fields_failed < count($fields)) {
156 $record_imported =
true;
159 $record_imported =
false;
163 if (!$record_imported) {
164 $record->doDelete(
true);
169 if (($i - 1) - $records_failed > $this->max_imports) {
170 $this->warnings[] = $this->lng->txt(
"dcl_max_import") . (count($sheet_data) - 1) .
" > " . $this->max_imports;
177 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
getImportFieldsFromTitles($table, $titles)