From e2f3be9f0df0593eff6b4d185f6cf533a9cc6c0c Mon Sep 17 00:00:00 2001 From: iszmais Date: Tue, 2 Jul 2024 17:05:19 +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.ilDataCollectionDBUpdateSteps80.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 11ece5d69edb..2b8f9b558e1e 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->dclUi->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 6ec9f82cb234..d9e7d212b9d8 100644 --- a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextFieldModel.php +++ b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextFieldModel.php @@ -91,7 +91,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($this->normalizeValue($record_value)) == strtolower($this->normalizeValue(nl2br($value))) + if (strtolower($this->normalizeValue($record_value)) == strtolower($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 f66e0d721a5d..7c0cf554525f 100644 --- a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordFieldModel.php +++ b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordFieldModel.php @@ -135,7 +135,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 cc8983dc4f8d..866bc5305287 100644 --- a/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php +++ b/Modules/DataCollection/classes/Fields/Text/class.ilDclTextRecordRepresentation.php @@ -86,7 +86,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.ilDataCollectionDBUpdateSteps80.php b/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps80.php index 16f4d986b305..026b1c215dbe 100644 --- a/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps80.php +++ b/Modules/DataCollection/classes/Setup/class.ilDataCollectionDBUpdateSteps80.php @@ -128,4 +128,16 @@ public function step_8(): void [ilDclDatatype::INPUTFORMAT_MOB] ); } + + public function step_9(): void + { + $this->db->manipulateF( + 'UPDATE il_dcl_stloc1_value value '. + 'INNER JOIN il_dcl_record_field rf ON rf.id = value.record_field_id ' . + 'INNER JOIN il_dcl_field field ON field.id = rf.field_id ' . + 'SET value.name = REPLACE(value.name, "
", "\r\n") WHERE field.datatype_id = %s', + [ilDBConstants::T_INTEGER], + [ilDclDatatype::INPUTFORMAT_TEXT] + ); + } }