ILIAS  release_8 Revision v8.24
class.ilDclFileuploadFieldModel.php
Go to the documentation of this file.
1<?php
2
20{
21 public function getRecordQuerySortObject(
22 string $direction = "asc",
23 bool $sort_by_status = false
25 global $DIC;
26 $ilDB = $DIC['ilDB'];
27 $join_str
28 = "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 = "
29 . $ilDB->quote($this->getId(), 'integer') . ") ";
30 $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) ";
31 $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) ";
32 $select_str = " sort_object_data_{$this->getId()}.title AS field_{$this->getId()},";
33
34 $sql_obj = new ilDclRecordQueryObject();
35 $sql_obj->setSelectStatement($select_str);
36 $sql_obj->setJoinStatement($join_str);
37 $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction);
38
39 return $sql_obj;
40 }
41
46 $filter_value = "",
47 ?ilDclBaseFieldModel $sort_field = null
49 global $DIC;
50 $ilDB = $DIC['ilDB'];
51
52 $join_str
53 = "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 = "
54 . $ilDB->quote($this->getId(), 'integer') . ") ";
55 $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) ";
56 $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 "
57 . $ilDB->quote("%$filter_value%", 'text') . ") ";
58
59 $sql_obj = new ilDclRecordQueryObject();
60 $sql_obj->setJoinStatement($join_str);
61
62 return $sql_obj;
63 }
64
65 public function getSupportedExtensions(): array
66 {
67 if (!$this->hasProperty(ilDclBaseFieldModel::PROP_SUPPORTED_FILE_TYPES)) {
68 return [];
69 }
70
71 $file_types = $this->getProperty(ilDclBaseFieldModel::PROP_SUPPORTED_FILE_TYPES);
72
73 return $this->parseSupportedExtensions($file_types);
74 }
75
76 protected function parseSupportedExtensions(string $input_value): array
77 {
78 $supported_extensions = explode(",", $input_value);
79
80 $trim_function = function ($value) {
81 return trim(trim(strtolower($value)), ".");
82 };
83
84 return array_map($trim_function, $supported_extensions);
85 }
86
91 public function checkValidity($value, ?int $record_id = null): bool
92 {
93 //Don't check empty values
94 if ($value == null || $value['size'] == 0) {
95 return true;
96 }
97
98 if ($this->isUnique()) {
99 $title = $value['name'];
100 $table = ilDclCache::getTableCache($this->getTableId());
101 foreach ($table->getRecords() as $record) {
102 if ($this->normalizeValue($record->getRecordFieldExportValue($this->getId())) == $this->normalizeValue($title) && ($record->getId() != $record_id || $record_id == 0)) {
104 }
105 }
106 }
107
108 return true;
109 }
110
111 public function getValidFieldProperties(): array
112 {
114 }
115
116 public function allowFilterInListView(): bool
117 {
118 return false;
119 }
120}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTableCache(int $table_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRecordQuerySortObject(string $direction="asc", bool $sort_by_status=false)
Returns a query-object for building the record-loader-sql-query.
getValidFieldProperties()
Returns all valid properties for a field-type.
checkValidity($value, ?int $record_id=null)
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28