19 declare(strict_types=1);
23 protected string $id =
"";
67 $this->db = $DIC->database();
68 $this->
lng = $DIC->language();
71 $this->
id = (string) $a_id;
82 return '/^[^<>\\\\":]*$/i';
91 $ilDB = $DIC->database();
93 $result =
$ilDB->query(
94 'SELECT id FROM il_dcl_field WHERE title = ' .
$ilDB->quote($title,
'text') .
' AND table_id = ' 95 .
$ilDB->quote($table_id,
'integer')
98 while ($rec =
$ilDB->fetchAssoc($result)) {
111 $this->
id = (string) $a_id;
127 $this->table_id = $a_id;
144 if (substr($a_title, 0, 1) ==
"_" && substr($a_title, 0, 2) !=
"__") {
145 $a_title =
"_" . $a_title;
147 $this->title = $a_title;
163 $this->description = $a_desc;
180 $this->datatype =
null;
181 $this->datatype_id = $a_id;
206 return $this->datatype->getTitle();
230 return $this->datatype->getStorageLocation();
238 if ($this->datatype ==
null) {
249 $this->exportable = $tablefield_setting->isExportable();
250 $this->order = $tablefield_setting->getFieldOrder();
258 if (!isset($this->exportable)) {
270 if ($this->exportable ==
null) {
277 return (array) $this;
288 $query =
"SELECT * FROM il_dcl_field WHERE id = " . $this->db->quote($this->
getId(),
"integer");
289 $set = $this->db->query($query);
290 $rec = $this->db->fetchAssoc($set);
294 if (
null !== $rec[
"title"]) {
297 if (
null !== $rec[
"description"]) {
312 $this->
setId($rec[
"id"]);
322 throw new ilException(
"The field does not have a related table!");
325 $id = $this->db->nextId(
"il_dcl_field");
327 $query =
"INSERT INTO il_dcl_field (" .
"id" .
", table_id" .
", datatype_id" .
", title" .
", description" 328 .
" ) VALUES (" . $this->db->quote($this->
getId(),
"integer") .
"," . $this->db->quote(
332 . $this->db->quote($this->
getDatatypeId(),
"integer") .
"," . $this->db->quote($this->
getTitle(),
"text") .
"," 334 $this->db->manipulate($query);
347 $tableview->createFieldSetting($this->
id);
389 foreach ($this->property as $prop) {
400 $tablefield_setting->setExportable($this->exportable);
401 $tablefield_setting->setFieldOrder($this->
getOrder());
402 $tablefield_setting->store();
413 $query =
"DELETE FROM il_dcl_field_prop WHERE field_id = " . $this->db->quote($this->
getId(),
"text");
414 $this->db->manipulate($query);
416 $query =
"DELETE FROM il_dcl_field WHERE id = " . $this->db->quote($this->
getId(),
"text");
417 $this->db->manipulate($query);
420 $field_setting->delete();
439 if ($this->order ==
null) {
466 return (isset($this->property[$key]) && $this->property[$key]->
getValue() !=
null);
473 return ($instance !==
null) ? $instance->getValue() :
null;
480 return $this->
property[$key];
489 if (isset($this->property[$key])) {
490 $this->
property[$key]->setValue($value);
493 $property->setName($key);
494 $property->setFieldId((
int) $this->
getId());
495 $property->setValue($value);
500 return $this->
property[$key];
527 protected function areEqual($value_1, $value_2): bool
534 if (is_string($value)) {
535 $value = trim(preg_replace(
"/\\s+/uism",
" ", $value));
547 $this->
setTitle($original->getTitle());
550 $this->
setOrder($original->getOrder());
561 foreach ($records as $rec) {
569 if (count($orgProps) == 0) {
572 foreach ($orgProps as $prop_name) {
574 $fieldprop_obj->setFieldId((
int) $this->
getId());
575 $fieldprop_obj->setName($prop_name);
590 $fieldprop_obj->setValue($value);
591 $fieldprop_obj->create();
611 string $direction =
"asc",
612 bool $sort_by_status =
false 616 $select_str =
"sort_stloc_{$this->getId()}.value AS field_{$this->getId()}";
618 =
"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 = " 619 . $this->db->quote($this->
getId(),
'integer') .
") ";
620 $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)";
622 $sql_obj->setSelectStatement($select_str);
623 $sql_obj->setJoinStatement($join_str);
624 $sql_obj->setOrderStatement(
"field_{$this->getId()} $direction, ID ASC");
675 $new = $record->getRecordFieldValue($this->
getId());
676 foreach ($values as $value) {
677 if ($this->
areEqual($new, $value)) {
692 if ($record->getId() !== $record_id) {
693 $x = $record->getRecordFieldValue($this->
getId());
694 if ($this->
areEqual($record->getRecordFieldValue($this->getId()), $value)) {
728 foreach ($titles as $k => $title) {
729 if (!mb_detect_encoding($title,
"UTF-8",
true) ==
"UTF-8") {
730 $title = mb_convert_encoding($title,
'UTF-8',
'ISO-8859-1');
733 $import_fields[$k] = $this;
746 foreach ($field_props as $property) {
747 $value = $form->
getInput($representation->getPropertyInputFieldId($property));
750 if (!empty($value) || ($this->
getPropertyInstance($property) !=
null && $property != self::PROP_PLUGIN_HOOK_NAME)) {
763 'field_id' => $this->
getId(),
770 foreach ($properties as $prop) {
771 $values[
'prop_' . $prop] = $this->
getProperty($prop);
795 $ilConfirmationGUI->addHiddenItem(
'confirmed',
"1");
796 $ilConfirmationGUI->addHiddenItem(
'field_id', $form->
getInput(
'field_id'));
797 $ilConfirmationGUI->addHiddenItem(
'title', $form->
getInput(
'title'));
798 $ilConfirmationGUI->addHiddenItem(
'description', $form->
getInput(
'description'));
799 $ilConfirmationGUI->addHiddenItem(
'datatype', $form->
getInput(
'datatype'));
800 $ilConfirmationGUI->setConfirm($this->
lng->txt(
'dcl_update_field'),
'update');
801 $ilConfirmationGUI->setCancel($this->
lng->txt(
'cancel'),
'edit');
803 return $ilConfirmationGUI;
getPropertyInstance(string $key)
hasProperty(string $key)
Checks if a certain property for a field is set.
const PROP_REFERENCE_LINK
checkTitlesForImport(array &$titles, array &$import_fields)
getConfirmationGUI(ilPropertyFormGUI $form)
called by ilDclFieldEditGUI if isConfirmationRequired returns true
checkFieldCreationInput(ilPropertyFormGUI $form)
Checks input of specific fields befor saving.
checkUniqueProp(ilPropertyFormGUI $form)
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
getPresentationDescription()
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
isConfirmationRequired(ilPropertyFormGUI $form)
called by ilDclFieldEditGUI when updating field properties if you overwrite this method, remember to also overwrite getConfirmationGUI
const PROP_SUPPORTED_FILE_TYPES
doDelete()
Remove field and properties.
storePropertiesFromForm(ilPropertyFormGUI $form)
called when saving the 'edit field' form
buildFromDBRecord(array $rec)
Builds model from db record.
loadTableFieldSetting()
loadTableFieldSetting
static getFieldCache(int $field_id=0)
updateProperties()
Update properties of this field in Database.
getSortField()
Returns the sort-field id.
const PROP_PLUGIN_HOOK_NAME
static _getDatatypeForId(string $id)
gives you the datatype id of a specified standard field.
checkValidityFromForm(ilPropertyFormGUI &$form, ?int $record_id)
fillPropertiesForm(ilPropertyFormGUI &$form)
called to fill the 'edit field' form
static _getFieldIdByTitle(string $title, int $table_id)
getStorageLocation()
Get storage location for the model.
static where($where, $operator=null)
setExportable(bool $exportable)
checkUnique($value, ?int $record_id)
addToTableViews()
create ilDclTableViewFieldSettings for this field in each tableview
getTableId()
Get table id.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const PROP_FORMULA_EXPRESSION
loadExportability()
Load exportability.
static getDatatype(int $datatyp_id)
Get cached datatypes.
const PROP_LINK_DETAIL_PAGE_TEXT
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
loadProperties()
Get all properties of a field.
setDatatypeId(int $a_id)
Set datatype id.
static getTableViewFieldSetting(string $id, int $tableview_id)
cloneProperties(ilDclBaseFieldModel $originalField)
cloneStructure(int $original_id)
const PROP_LENGTH
General properties.
const PROP_LEARNING_PROGRESS
const PROP_DISPLAY_COPY_LINK_ACTION_MENU
static getTableCache(?int $table_id=null)
getViewSetting(int $tableview_id)
static setCloneOf(int $old, int $new, string $type)
static getInstance(int $table_id, string $field)
getDescription()
Get description.
loadDatatype()
Load datatype for model.
afterClone(array $records)
updateTableFieldSetting()
update exportable and fieldorder
const INPUTFORMAT_REFERENCE
int $storage_location_override
With this property the datatype-storage-location can be overwritten.
hasNumericSorting()
Set to true, when the sorting should be handled numerical.
fillHeaderExcel(ilExcel $worksheet, int &$row, int &$col)
areEqual($value_1, $value_2)
normalizeValue(mixed $value)
getRecordQuerySortObject(string $direction="asc", bool $sort_by_status=false)
Returns a query-object for building the record-loader-sql-query.
const PROP_LINK_DETAIL_PAGE_MOB
setStorageLocationOverride(?int $storage_location_override)
setTitle(string $a_title)
Set title.
setDescription(string $a_desc)
Set description.
getValidFieldProperties()
Returns all valid properties for a field-type.
static getRecordFieldCache(object $record, object $field)
static getAllForTableId(int $table_id)
setTableId(int $a_id)
Set table id.
getStorageLocationOverride()
const PROP_ILIAS_REFERENCE_LINK
static _tableExists(int $table_id)
setProperty(string $key, $value)
static getFieldProperties(string $field_id)
Cache Field properties.
setId($a_id)
Set field id.
getDatatypeId()
Get datatype_id.
checkValidity($value, ?int $record_id)
Check if input is valid.
static _getTitleInvalidChars(bool $a_as_regex=true)
All valid chars for filed titles.