From 5d4804d6c81db9b0f3080d7adfbcac7fe68debf2 Mon Sep 17 00:00:00 2001 From: iszmais Date: Tue, 2 Jul 2024 17:38:11 +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 ce3b9dc31516..ebbc92ad319c 100644 --- a/Modules/DataCollection/classes/Content/class.ilDclRecordListGUI.php +++ b/Modules/DataCollection/classes/Content/class.ilDclRecordListGUI.php @@ -203,7 +203,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 782594f4bb4e..bb75f8278ee0 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 39837ff0dcbc..ff3428ad3ac2 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 81aa7743a35b..29c435f3b278 100644 --- a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php +++ b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php @@ -83,7 +83,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 290ca5976fd4..1218285b0a9d 100644 --- a/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php +++ b/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps9.php @@ -175,4 +175,16 @@ public function step_11(): void [ilDclDatatype::INPUTFORMAT_MOB] ); } + + public function step_12(): 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] + ); + } }