diff --git a/components/ILIAS/DataCollection/classes/Content/class.ilDclRecordEditGUI.php b/components/ILIAS/DataCollection/classes/Content/class.ilDclRecordEditGUI.php
index 62a26c79e2d8..34b10b36c9a4 100755
--- a/components/ILIAS/DataCollection/classes/Content/class.ilDclRecordEditGUI.php
+++ b/components/ILIAS/DataCollection/classes/Content/class.ilDclRecordEditGUI.php
@@ -447,9 +447,7 @@ public function saveConfirmation(ilDclBaseRecordModel $record_obj, string $fileh
/** @var ilDclBaseRecordFieldModel $record_field */
$record_field->addHiddenItemsToConfirmation($confirmation);
- if (($record_field instanceof ilDclFileuploadRecordFieldModel || $record_field instanceof ilDclMobRecordFieldModel)
- && $record_field->getValue() == null
- ) {
+ if ($record_field instanceof ilDclFileRecordFieldModel && $record_field->getValue() == null) {
$empty_fileuploads['field_' . $field->getId()] = [
"name" => "",
"type" => "",
@@ -460,7 +458,7 @@ public function saveConfirmation(ilDclBaseRecordModel $record_obj, string $fileh
}
$record_representation = ilDclFieldFactory::getRecordRepresentationInstance($record_field);
- if ($record_representation->getConfirmationHTML() != false) {
+ if ($record_representation->getConfirmationHTML() !== '') {
$record_data .= $field->getTitle() . ": " . $record_representation->getConfirmationHTML() . "
";
}
}
diff --git a/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldModel.php
index 57f4c1cbc458..193b4ea1e9c4 100755
--- a/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldModel.php
+++ b/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldModel.php
@@ -23,24 +23,6 @@
*/
class ilDclFileFieldModel extends ilDclBaseFieldModel
{
- public function getRecordQuerySortObject(
- string $direction = "asc",
- bool $sort_by_status = false
- ): ?ilDclRecordQueryObject {
- $join_str = "LEFT JOIN il_dcl_record_field AS sort_record_field_{$this->getId()} ON (sort_record_field_{$this->getId()}.record_id = record.id AND sort_record_field_{$this->getId()}.field_id = "
- . $this->db->quote($this->getId(), 'integer') . ") ";
- $join_str .= "LEFT JOIN il_dcl_stloc{$this->getStorageLocation()}_value AS sort_stloc_{$this->getId()} ON (sort_stloc_{$this->getId()}.record_field_id = sort_record_field_{$this->getId()}.id) ";
- $join_str .= "LEFT JOIN il_resource_revision AS sort_object_data_{$this->getId()} ON (sort_object_data_{$this->getId()}.rid = sort_stloc_{$this->getId()}.value) ";
- $select_str = " sort_object_data_{$this->getId()}.title AS field_{$this->getId()},";
-
- $record_query = new ilDclRecordQueryObject();
- $record_query->setSelectStatement($select_str);
- $record_query->setJoinStatement($join_str);
- $record_query->setOrderStatement("field_{$this->getId()} " . $direction . ", ID ASC");
-
- return $record_query;
- }
-
public function allowFilterInListView(): bool
{
return false;
diff --git a/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldRepresentation.php b/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldRepresentation.php
index 50a917054fab..6c7813304dc1 100755
--- a/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldRepresentation.php
+++ b/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileFieldRepresentation.php
@@ -18,15 +18,12 @@
declare(strict_types=1);
-/**
- * @noinspection AutoloadingIssuesInspection
- */
class ilDclFileFieldRepresentation extends ilDclBaseFieldRepresentation
{
public function getInputField(
ilPropertyFormGUI $form,
?int $record_id = null
- ): ?ilFormPropertyGUI {
+ ): ilFileInputGUI {
$input = new ilFileInputGUI(
$this->getField()->getTitle(),
'field_' . $this->getField()->getId()
diff --git a/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileRecordFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileRecordFieldModel.php
index 52a78eb5b644..127e83c59c01 100755
--- a/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileRecordFieldModel.php
+++ b/components/ILIAS/DataCollection/classes/Fields/File/class.ilDclFileRecordFieldModel.php
@@ -44,11 +44,6 @@ public function __construct(ilDclBaseRecordModel $record, ilDclBaseFieldModel $f
$this->upload = $DIC->upload();
}
- public function getRecordRepresentation(): ?ilDclBaseRecordRepresentation
- {
- return new ilDclFileRecordRepresentation($this);
- }
-
public function parseValue($value)
{
if ($value === -1) { // marked for deletion.
diff --git a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadFieldModel.php
deleted file mode 100755
index 20ce1ff5c1f6..000000000000
--- a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadFieldModel.php
+++ /dev/null
@@ -1,125 +0,0 @@
-getId()} ON (sort_record_field_{$this->getId()}.record_id = record.id AND sort_record_field_{$this->getId()}.field_id = "
- . $ilDB->quote($this->getId(), 'integer') . ") ";
- $join_str .= "LEFT JOIN il_dcl_stloc{$this->getStorageLocation()}_value AS sort_stloc_{$this->getId()} ON (sort_stloc_{$this->getId()}.record_field_id = sort_record_field_{$this->getId()}.id) ";
- $join_str .= "LEFT JOIN object_data AS sort_object_data_{$this->getId()} ON (sort_object_data_{$this->getId()}.obj_id = sort_stloc_{$this->getId()}.value) ";
- $select_str = " sort_object_data_{$this->getId()}.title AS field_{$this->getId()},";
-
- $sql_obj = new ilDclRecordQueryObject();
- $sql_obj->setSelectStatement($select_str);
- $sql_obj->setJoinStatement($join_str);
- $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction);
-
- return $sql_obj;
- }
-
- /**
- * Returns a query-object for building the record-loader-sql-query
- */
- public function getRecordQueryFilterObject(
- $filter_value = "",
- ?ilDclBaseFieldModel $sort_field = null
- ): ?ilDclRecordQueryObject {
- global $DIC;
- $ilDB = $DIC['ilDB'];
-
- $join_str
- = "INNER JOIN il_dcl_record_field AS filter_record_field_{$this->getId()} ON (filter_record_field_{$this->getId()}.record_id = record.id AND filter_record_field_{$this->getId()}.field_id = "
- . $ilDB->quote($this->getId(), 'integer') . ") ";
- $join_str .= "INNER JOIN il_dcl_stloc{$this->getStorageLocation()}_value AS filter_stloc_{$this->getId()} ON (filter_stloc_{$this->getId()}.record_field_id = filter_record_field_{$this->getId()}.id) ";
- $join_str .= "INNER JOIN object_data AS filter_object_data_{$this->getId()} ON (filter_object_data_{$this->getId()}.obj_id = filter_stloc_{$this->getId()}.value AND filter_object_data_{$this->getId()}.title LIKE "
- . $ilDB->quote("%$filter_value%", 'text') . ") ";
-
- $sql_obj = new ilDclRecordQueryObject();
- $sql_obj->setJoinStatement($join_str);
-
- return $sql_obj;
- }
-
- public function getSupportedExtensions(): array
- {
- if (!$this->hasProperty(ilDclBaseFieldModel::PROP_SUPPORTED_FILE_TYPES)) {
- return [];
- }
-
- $file_types = $this->getProperty(ilDclBaseFieldModel::PROP_SUPPORTED_FILE_TYPES);
-
- return $this->parseSupportedExtensions($file_types);
- }
-
- protected function parseSupportedExtensions(string $input_value): array
- {
- $supported_extensions = explode(",", $input_value);
-
- $trim_function = function ($value) {
- return trim(trim(strtolower($value)), ".");
- };
-
- return array_map($trim_function, $supported_extensions);
- }
-
- /**
- * @param array|null $value
- * @throws ilDclInputException$
- */
- public function checkValidity($value, ?int $record_id = null): bool
- {
- //Don't check empty values
- if ($value == null || $value['size'] == 0) {
- return true;
- }
-
- if ($this->isUnique()) {
- $title = $value['name'];
- $table = ilDclCache::getTableCache($this->getTableId());
- foreach ($table->getRecords() as $record) {
- if ($this->normalizeValue($record->getRecordFieldExportValue($this->getId())) == $this->normalizeValue($title) && ($record->getId() != $record_id || $record_id == 0)) {
- throw new ilDclInputException(ilDclInputException::UNIQUE_EXCEPTION);
- }
- }
- }
-
- return true;
- }
-
- public function getValidFieldProperties(): array
- {
- return [ilDclBaseFieldModel::PROP_SUPPORTED_FILE_TYPES];
- }
-
- public function allowFilterInListView(): bool
- {
- return false;
- }
-}
diff --git a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadFieldRepresentation.php b/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadFieldRepresentation.php
deleted file mode 100755
index 2409550e8b62..000000000000
--- a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadFieldRepresentation.php
+++ /dev/null
@@ -1,113 +0,0 @@
-getField()->getTitle(), 'field_' . $this->getField()->getId());
- $input->setInfo($this->lng->txt('fileupload_not_migrated'));
- $input->setDisabled(true);
-
- return $input;
- }
-
- protected function requiredWorkaroundForInputField(ilFileInputGUI $input, ?int $record_id): void
- {
- if ($record_id) {
- $record = ilDclCache::getRecordCache($record_id);
- }
-
- $this->setupInputField($input, $this->getField());
-
- //WORKAROUND
- // If field is from type file: if it's required but already has a value it is no longer required as the old value is taken as default without the form knowing about it.
- if ($record_id && $record->getId()) {
- $field_value = $record->getRecordFieldValue($this->getField()->getId());
- if ($field_value) {
- $input->setRequired(false);
- }
- }
- // If this is an ajax request to return the form, input files are currently not supported
- if ($this->ctrl->isAsynch()) {
- $input->setDisabled(true);
- }
- }
-
- /**
- * @return array|string|null
- * @throws Exception
- */
- public function addFilterInputFieldToTable(ilTable2GUI $table) //todo
- {
- $input = $table->addFilterItemByMetaType(
- "filter_" . $this->getField()->getId(),
- ilTable2GUI::FILTER_TEXT,
- false,
- $this->getField()->getId()
- );
- $input->setSubmitFormOnEnter(true);
-
- $this->setupFilterInputField($input);
-
- return $this->getFilterInputFieldValue($input);
- }
-
- /**
- * @param string $filter
- */
- public function passThroughFilter(ilDclBaseRecordModel $record, $filter): bool //todo
- {
- $value = $record->getRecordFieldValue($this->getField()->getId());
- $pass = false;
- if (!ilObject2::_exists($value) || ilObject2::_lookupType($value) != "file") {
- $pass = true;
- }
-
- $file_obj = new ilObjFile($value, false);
- $file_name = $file_obj->getTitle();
- if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
- $pass = true;
- }
-
- return $pass;
- }
-
- /**
- * @inheritDoc
- */
- protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ilRadioOption
- {
- $opt = parent::buildFieldCreationInput($dcl, $mode);
-
- $prop_filetype = new ilTextInputGUI(
- $this->lng->txt('dcl_supported_filetypes'),
- 'prop_' . ilDclBaseFieldModel::PROP_SUPPORTED_FILE_TYPES
- );
- $prop_filetype->setInfo($this->lng->txt('dcl_supported_filetypes_desc'));
-
- $opt->addSubItem($prop_filetype);
-
- return $opt;
- }
-}
diff --git a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadRecordFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadRecordFieldModel.php
deleted file mode 100755
index 7060e8606d8e..000000000000
--- a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadRecordFieldModel.php
+++ /dev/null
@@ -1,199 +0,0 @@
-upload = $DIC->upload();
- }
-
- /**
- * @param null|array|int $value
- */
- public function parseValue($value)
- {
- if ($value === -1) { //marked for deletion.
- return null;
- }
-
- $file = $value;
-
- $has_record_id = $this->http->wrapper()->query()->has('record_id');
- $is_confirmed = $this->http->wrapper()->post()->has('save_confirmed');
- $has_save_confirmation = ($this->getRecord()->getTable()->getSaveConfirmation() && !$has_record_id);
-
- if (
- is_array($file)
- && isset($file['tmp_name'])
- && $file['tmp_name'] !== ""
- && (!$has_save_confirmation || $is_confirmed)
- ) {
- if ($has_save_confirmation) {
- $ilfilehash = $this->http->wrapper()->post()->retrieve(
- 'ilfilehash',
- $this->refinery->kindlyTo()->string()
- );
-
- $move_file = ilDclPropertyFormGUI::getTempFilename(
- $ilfilehash,
- 'field_' . $this->getField()->getId(),
- $file["name"],
- $file["type"]
- );
-
- $file_stream = ILIAS\Filesystem\Stream\Streams::ofResource(fopen($move_file, 'rb'));
- } else {
- $move_file = $file['tmp_name'];
-
- if (false === $this->upload->hasBeenProcessed()) {
- $this->upload->process();
- }
-
- if (false === $this->upload->hasUploads()) {
- throw new ilException($this->lng->txt('upload_error_file_not_found'));
- }
-
- $file_stream = Streams::ofResource(fopen($move_file, 'rb'));
- }
-
- $file_title = $file["name"] ?? basename($move_file);
-
- $file_obj = new ilObjFile();
- $file_obj->setType("file");
- $file_obj->setTitle($file_title);
- $file_obj->setFileName($file_title);
- $file_obj->setMode(ilObjFile::MODE_OBJECT);
- $file_obj->create();
-
- $file_obj->appendStream($file_stream, $file_title);
- $file_obj->setTitle($file_title);
- $file_obj->setFileName($file_title);
-
- $file_obj->update();
-
- $file_id = $file_obj->getId();
- $return = $file_id;
- // handover for save-confirmation
- } else {
- if (is_array($file) && isset($file['tmp_name']) && $file['tmp_name'] != "") {
- $return = $file;
- } else {
- $return = $this->getValue();
- }
- }
-
- return $return;
- }
-
- /**
- * Set value for record field
- * @param string|int $value
- * @param bool $omit_parsing If true, does not parse the value and stores it in the given format
- */
- public function setValue($value, bool $omit_parsing = false): void
- {
- $this->loadValue();
-
- if (!$omit_parsing) {
- $tmp = $this->parseValue($value);
- $old = $this->value;
- //if parse value fails keep the old value
- if ($tmp !== false) {
- $this->value = $tmp;
- //delete old file from filesystem
- if ($old && $old != $tmp) {
- $this->getRecord()->deleteFile($old);
- }
- }
- } else {
- $this->value = $value;
- }
- }
-
- /**
- * @param string $value
- */
- public function parseExportValue($value): ?string
- {
- if (!$value || !ilObject2::_exists((int) $value) || ilObject2::_lookupType((int) $value) != "file") {
- return null;
- }
-
- $file = $value;
- if ($file != "-") {
- $file_obj = new ilObjFile((int) $file, false);
- return $file_obj->getFileName();
- }
-
- return $file;
- }
-
- /**
- * Returns sortable value for the specific field-types
- */
- public function parseSortingValue($value, bool $link = true): string
- {
- if (!ilObject2::_exists($value) || ilObject2::_lookupType($value) != "file") {
- return '';
- }
- $file_obj = new ilObjFile($value, false);
-
- return $file_obj->getTitle();
- }
-
- public function setValueFromForm(ilPropertyFormGUI $form): void
- {
- $value = $form->getInput("field_" . $this->getField()->getId());
- if ($form->getItemByPostVar("field_" . $this->getField()->getId())->getDeletionFlag()) {
- $value = -1;
- }
- $this->setValue($value);
- }
-
- /**
- *
- */
- public function afterClone(): void
- {
- $field = ilDclCache::getCloneOf((int) $this->getField()->getId(), ilDclCache::TYPE_FIELD);
- $record = ilDclCache::getCloneOf($this->getRecord()->getId(), ilDclCache::TYPE_RECORD);
- $record_field = ilDclCache::getRecordFieldCache($record, $field);
-
- if (!$record_field->getValue()) {
- return;
- }
-
- $file_old = new ilObjFile($record_field->getValue(), false);
- $file_new = $file_old->cloneObject(0, 0, true);
-
- $this->setValue($file_new->getId(), true);
- $this->doUpdate();
- }
-}
diff --git a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadRecordRepresentation.php b/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadRecordRepresentation.php
deleted file mode 100755
index a655bdcb94a2..000000000000
--- a/components/ILIAS/DataCollection/classes/Fields/Fileupload/class.ilDclFileuploadRecordRepresentation.php
+++ /dev/null
@@ -1,54 +0,0 @@
-lng->txt('fileupload_not_migrated');
- }
-
- /**
- * function parses stored value to the variable needed to fill into the form for editing.
- * @param array|string $value
- * @return array|string
- */
- public function parseFormInput($value)
- {
- if (is_array($value)) {
- return $value;
- }
-
- if (!ilObject2::_exists((int) $value) || ilObject2::_lookupType((int) $value) != "file") {
- return "";
- }
-
- $file_obj = new ilObjFile((int) $value, false);
-
- //$input = ilObjFile::_lookupAbsolutePath($value);
- return $file_obj->getFileName();
- }
-}
diff --git a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldModel.php
index 28e8e6273c58..af9190511a8d 100755
--- a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldModel.php
+++ b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldModel.php
@@ -18,10 +18,8 @@
declare(strict_types=1);
-class ilDclMobFieldModel extends ilDclFileuploadFieldModel
+class ilDclMobFieldModel extends ilDclFileFieldModel
{
- public static array $mob_suffixes = ['jpg', 'jpeg', 'gif', 'png', 'mp3', 'flx', 'mp4', 'm4v', 'mov', 'wmv'];
-
public function getValidFieldProperties(): array
{
return [
@@ -31,8 +29,8 @@ public function getValidFieldProperties(): array
];
}
- public function allowFilterInListView(): bool
+ public function getSupportedExtensions(): array
{
- return false;
+ return ['jpg', 'jpeg', 'gif', 'png', 'mp3', 'flx', 'mp4', 'm4v', 'mov', 'wmv'];
}
}
diff --git a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldRepresentation.php b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldRepresentation.php
index c813d1ac7edc..9aea609f8e94 100755
--- a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldRepresentation.php
+++ b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobFieldRepresentation.php
@@ -18,23 +18,8 @@
declare(strict_types=1);
-class ilDclMobFieldRepresentation extends ilDclFileuploadFieldRepresentation
+class ilDclMobFieldRepresentation extends ilDclFileFieldRepresentation
{
- public function getInputField(ilPropertyFormGUI $form, ?int $record_id = null): ilFileInputGUI
- {
- $input = new ilFileInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
- $input->setSuffixes(ilDclMobFieldModel::$mob_suffixes);
- $input->setAllowDeletion(true);
-
- $this->requiredWorkaroundForInputField($input, $record_id);
-
- return $input;
- }
-
- /**
- * @return array|string|null
- * @throws Exception
- */
public function addFilterInputFieldToTable(ilTable2GUI $table)
{
$input = $table->addFilterItemByMetaType(
@@ -50,9 +35,6 @@ public function addFilterInputFieldToTable(ilTable2GUI $table)
return $this->getFilterInputFieldValue($input);
}
- /**
- * @param string $filter
- */
public function passThroughFilter(ilDclBaseRecordModel $record, $filter): bool
{
$value = $record->getRecordFieldValue($this->getField()->getId());
@@ -74,7 +56,7 @@ protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mod
);
$opt->setInfo($this->lng->txt('dcl_' . $this->getField()->getDatatype()->getTitle() . '_desc'));
- $opt->setInfo(sprintf($opt->getInfo(), implode(", ", ilDclMobFieldModel::$mob_suffixes)));
+ $opt->setInfo(sprintf($opt->getInfo(), implode(", ", $this->getField()->getSupportedExtensions())));
$prop_width = new ilNumberInputGUI($this->lng->txt('dcl_width'), 'prop_' . ilDclBaseFieldModel::PROP_WIDTH);
$prop_width->setSize(5);
diff --git a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordFieldModel.php b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordFieldModel.php
index 6a9154494f30..739f0c7a67ed 100755
--- a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordFieldModel.php
+++ b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordFieldModel.php
@@ -18,7 +18,7 @@
declare(strict_types=1);
-class ilDclMobRecordFieldModel extends ilDclBaseRecordFieldModel
+class ilDclMobRecordFieldModel extends ilDclFileRecordFieldModel
{
private ilGlobalTemplateInterface $main_tpl;
private \ILIAS\FileUpload\FileUpload $upload;
diff --git a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordRepresentation.php b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordRepresentation.php
index 4fe03275ca32..66aefbe9b53e 100755
--- a/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordRepresentation.php
+++ b/components/ILIAS/DataCollection/classes/Fields/Mob/class.ilDclMobRecordRepresentation.php
@@ -18,7 +18,7 @@
declare(strict_types=1);
-class ilDclMobRecordRepresentation extends ilDclFileuploadRecordRepresentation
+class ilDclMobRecordRepresentation extends ilDclFileRecordRepresentation
{
/**
* Outputs html of a certain field
@@ -121,22 +121,14 @@ public function getHTML(bool $link = true, array $options = []): string
return "