35 ilDclDataType::INPUTFORMAT_TEXT_SELECTION,
80 public function import(
$file, $simulate =
false)
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);
192 $this->warnings[] = $field->getTitle() .
": " . $this->lng->txt(
"dcl_not_supported_in_import");
207 $fields =
$table->getRecordFields();
208 $import_fields =
array();
209 foreach ($fields as $field) {
212 $field->checkTitlesForImport($titles, $import_fields);
216 foreach ($titles as
$key => $value) {
219 foreach ($importable_titles as $identifier => $values) {
220 if (in_array($value, $values)) {
222 $std_field->setId(substr($identifier, 4));
223 $import_fields[
$key] = $std_field;
227 if (in_array($value, $not_importable_titles)) {
229 } elseif (!isset($import_fields[
$key])) {
234 return $import_fields;
static _getNonImportableStandardFieldTitles()
__construct($ref_id, $table_id=null)
const INPUTFORMAT_BOOLEAN
Hook-Class for exporting data-collections (used in SOAP-Class) This Class avoids duplicated code by r...
const INPUTFORMAT_DATE_SELECTION
$supported_import_datatypes
static _getImportableStandardFieldTitle()
Class ilDclBaseFieldModel.
const INPUTFORMAT_DATETIME
Create styles array
The data for the language used.
const INPUTFORMAT_REFERENCE
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
Class ilObjDataCollection.
getImportFieldsFromTitles($table, $titles)