From 40646cf67098ee7a12f62ed2eacf53fabe6da157 Mon Sep 17 00:00:00 2001 From: iszmais Date: Tue, 2 Jul 2024 17:12:34 +0200 Subject: [PATCH] Remove br from save and add to presentation --- .../classes/Content/class.ilDclRecordListGUI.php | 2 +- .../Fields/Text/class.ilDclTextFieldModel.php | 2 +- .../Fields/Text/class.ilDclTextRecordFieldModel.php | 2 +- .../Text/class.ilDclTextRecordRepresentation.php | 2 +- .../Setup/class.ilDataCollectionDBUpdateSteps9.php | 12 ++++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Modules/DataCollection/classes/Content/class.ilDclRecordListGUI.php b/Modules/DataCollection/classes/Content/class.ilDclRecordListGUI.php index ed5689eafcd9..e65cda58f079 100644 --- a/Modules/DataCollection/classes/Content/class.ilDclRecordListGUI.php +++ b/Modules/DataCollection/classes/Content/class.ilDclRecordListGUI.php @@ -195,7 +195,7 @@ public function listRecords(bool $use_tableview_filter = false): void if ($ilSetting->get('advanced_editing_javascript_editor')) { $desc = "
" . $desc . "
"; } else { - $desc = "
" . nl2br(ilUtil::stripSlashes($desc)) . "
"; + $desc = "
" . nl2br(htmlspecialchars($desc, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8')) . "
"; } } $this->tpl->setContent($desc . $list->getHTML()); diff --git a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextFieldModel.php b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextFieldModel.php index 91b1c58a10b8..bdcd494993a7 100644 --- a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextFieldModel.php +++ b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextFieldModel.php @@ -88,7 +88,7 @@ public function checkValidity($value, ?int $record_id = null): bool //for text it has to be case insensitive. $record_value = $record->getRecordFieldValue($this->getId()); - if (strtolower((string)$this->normalizeValue($record_value)) == strtolower((string)$this->normalizeValue(nl2br($value))) + if (strtolower((string)$this->normalizeValue($record_value)) == strtolower((string)$this->normalizeValue($value)) && ($record->getId() != $record_id || $record_id == 0) ) { diff --git a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordFieldModel.php b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordFieldModel.php index 4dc69bca04f1..e18515306521 100644 --- a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordFieldModel.php +++ b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordFieldModel.php @@ -133,7 +133,7 @@ public function parseValue($value) if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_TEXTAREA) && !$this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL) ) { - return nl2br($value); + return $value; } return $value; diff --git a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php index 5264706e0c10..f39df741ea77 100644 --- a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php +++ b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php @@ -69,7 +69,7 @@ public function getHTML(bool $link = true, array $options = []): string 'renderRecord' ) . '">' . $value . ''; } else { - $html = (is_array($value) && isset($value['link'])) ? $value['link'] : $value; + $html = (is_array($value) && isset($value['link'])) ? $value['link'] : nl2br($value); } if (!$html) { diff --git a/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php b/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php index 50e4aa6d627a..b9d248956b8f 100644 --- a/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php +++ b/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php @@ -165,4 +165,16 @@ public function step_10(): void $this->db->addIndex('il_dcl_tfield_set', array('table_id'), 'i4'); } } + + public function step_11(): void + { + $this->db->manipulateF( + 'UPDATE il_dcl_stloc1_value v '. + 'INNER JOIN il_dcl_record_field rf ON rf.id = v.record_field_id ' . + 'INNER JOIN il_dcl_field f ON f.id = rf.field_id ' . + 'SET v.value = REPLACE(v.value, "
", "\r\n") WHERE f.datatype_id = %s', + [ilDBConstants::T_INTEGER], + [ilDclDatatype::INPUTFORMAT_TEXT] + ); + } }