19declare(strict_types=1);
23 protected string $id =
"";
65 $this->db =
$DIC->database();
66 $this->
lng = $DIC->language();
69 $this->
id = (string) $a_id;
80 return '/^[^<>\\\\":]*$/i';
91 $result =
$ilDB->query(
92 'SELECT id FROM il_dcl_field WHERE title = ' .
$ilDB->quote(
$title,
'text') .
' AND table_id = '
96 while ($rec =
$ilDB->fetchAssoc($result)) {
109 $this->
id = (string) $a_id;
125 $this->table_id = $a_id;
142 if (substr($a_title, 0, 1) ==
"_" && substr($a_title, 0, 2) !=
"__") {
143 $a_title =
"_" . $a_title;
145 $this->title = $a_title;
161 $this->description = $a_desc;
178 $this->datatype =
null;
179 $this->datatype_id = $a_id;
204 return $this->datatype->getTitle();
228 return $this->datatype->getStorageLocation();
236 if ($this->datatype ==
null) {
247 $this->exportable = $tablefield_setting->isExportable();
248 $this->order = $tablefield_setting->getFieldOrder();
256 if (!isset($this->exportable)) {
268 if ($this->exportable ==
null) {
275 return (array) $this;
286 $query =
"SELECT * FROM il_dcl_field WHERE id = " . $this->db->quote($this->
getId(),
"integer");
287 $set = $this->db->query($query);
288 $rec = $this->db->fetchAssoc($set);
292 if (
null !== $rec[
"title"]) {
295 if (
null !== $rec[
"description"]) {
310 $this->
setId($rec[
"id"]);
320 throw new ilException(
"The field does not have a related table!");
323 $id = $this->db->nextId(
"il_dcl_field");
325 $query =
"INSERT INTO il_dcl_field (" .
"id" .
", table_id" .
", datatype_id" .
", title" .
", description"
326 .
" ) VALUES (" . $this->db->quote($this->
getId(),
"integer") .
"," . $this->db->quote(
330 . $this->db->quote($this->
getDatatypeId(),
"integer") .
"," . $this->db->quote($this->
getTitle(),
"text") .
","
332 $this->db->manipulate($query);
345 $tableview->createFieldSetting($this->
id);
387 foreach ($this->property as $prop) {
398 $tablefield_setting->setExportable($this->exportable);
399 $tablefield_setting->setFieldOrder($this->
getOrder());
400 $tablefield_setting->store();
411 $query =
"DELETE FROM il_dcl_field_prop WHERE field_id = " . $this->db->quote($this->
getId(),
"text");
412 $this->db->manipulate($query);
414 $query =
"DELETE FROM il_dcl_field WHERE id = " . $this->db->quote($this->
getId(),
"text");
415 $this->db->manipulate($query);
418 $field_setting->delete();
437 if ($this->order ==
null) {
464 return (isset($this->property[$key]) && $this->property[$key]->
getValue() !=
null);
471 return ($instance !==
null) ? $instance->getValue() :
null;
478 return $this->
property[$key];
487 if (isset($this->property[$key])) {
488 $this->
property[$key]->setValue($value);
493 $property->setValue($value);
498 return $this->
property[$key];
525 protected function areEqual($value_1, $value_2): bool
532 if (is_string($value)) {
533 $value = trim(preg_replace(
"/\\s+/uism",
" ", $value));
545 $this->
setTitle($original->getTitle());
548 $this->
setOrder($original->getOrder());
559 foreach ($records as $rec) {
567 if (count($orgProps) == 0) {
570 foreach ($orgProps as $prop_name) {
572 $fieldprop_obj->setFieldId((
int) $this->
getId());
573 $fieldprop_obj->setName($prop_name);
588 $fieldprop_obj->setValue($value);
589 $fieldprop_obj->create();
609 string $direction =
"asc",
610 bool $sort_by_status =
false
614 $select_str =
"sort_stloc_{$this->getId()}.value AS field_{$this->getId()}";
616 =
"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 = "
617 . $this->db->quote($this->
getId(),
'integer') .
") ";
618 $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)";
621 $sql_obj->setJoinStatement($join_str);
622 $sql_obj->setOrderStatement(
"field_{$this->getId()} $direction, ID ASC");
673 $new = $record->getRecordFieldValue($this->
getId());
674 foreach ($values as $value) {
675 if ($this->areEqual($new, $value)) {
690 if ($record->getId() !== $record_id) {
691 $x = $record->getRecordFieldValue($this->
getId());
692 if ($this->areEqual($record->getRecordFieldValue($this->getId()), $value)) {
707 return $this->storage_location_override;
715 $this->storage_location_override = $storage_location_override;
726 foreach ($titles as $k => $title) {
727 if (!mb_detect_encoding($title,
"UTF-8",
true) ==
"UTF-8") {
728 $title = mb_convert_encoding($title,
'UTF-8',
'ISO-8859-1');
731 $import_fields[$k] = $this;
741 $field_props = $this->getValidFieldProperties();
744 foreach ($field_props as $property) {
745 $value = $form->
getInput($representation->getPropertyInputFieldId($property));
748 if (!empty($value) || ($this->getPropertyInstance($property) !=
null && $property != self::PROP_PLUGIN_HOOK_NAME)) {
749 $this->setProperty($property, $value)?->store();
760 'table_id' => $this->getTableId(),
761 'field_id' => $this->
getId(),
763 'datatype' => $this->getDatatypeId(),
764 'description' => $this->getDescription(),
767 $properties = $this->getValidFieldProperties();
768 foreach ($properties as $prop) {
769 $values[
'prop_' . $prop] = $this->getProperty($prop);
793 $ilConfirmationGUI->addHiddenItem(
'confirmed',
"1");
794 $ilConfirmationGUI->addHiddenItem(
'field_id', $form->
getInput(
'field_id'));
795 $ilConfirmationGUI->addHiddenItem(
'title', $form->
getInput(
'title'));
796 $ilConfirmationGUI->addHiddenItem(
'description', $form->
getInput(
'description'));
797 $ilConfirmationGUI->addHiddenItem(
'datatype', $form->
getInput(
'datatype'));
798 $ilConfirmationGUI->setConfirm($this->
lng->txt(
'dcl_update_field'),
'update');
799 $ilConfirmationGUI->setCancel($this->
lng->txt(
'cancel'),
'edit');
801 return $ilConfirmationGUI;
static where($where, $operator=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDatatypeId(int $a_id)
Set datatype id.
setTitle(string $a_title)
Set title.
normalizeValue(mixed $value)
getViewSetting(int $tableview_id)
int $storage_location_override
With this property the datatype-storage-location can be overwritten.
hasProperty(string $key)
Checks if a certain property for a field is set.
doDelete()
Remove field and properties.
const PROP_SUPPORTED_FILE_TYPES
getRecordQuerySortObject(string $direction="asc", bool $sort_by_status=false)
Returns a query-object for building the record-loader-sql-query.
updateTableFieldSetting()
update exportable and fieldorder
const PROP_PLUGIN_HOOK_NAME
updateProperties()
Update properties of this field in Database.
const PROP_FORMULA_EXPRESSION
const PROP_LINK_DETAIL_PAGE_TEXT
setProperty(string $key, $value)
getPresentationDescription()
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
getDescription()
Get description.
getStorageLocationOverride()
afterClone(array $records)
static _getFieldIdByTitle(string $title, int $table_id)
fillPropertiesForm(ilPropertyFormGUI &$form)
called to fill the 'edit field' form
const PROP_LINK_DETAIL_PAGE_MOB
loadTableFieldSetting()
loadTableFieldSetting
const PROP_DISPLAY_COPY_LINK_ACTION_MENU
loadDatatype()
Load datatype for model.
static _getTitleInvalidChars(bool $a_as_regex=true)
All valid chars for filed titles.
getPropertyInstance(string $key)
getConfirmationGUI(ilPropertyFormGUI $form)
called by ilDclFieldEditGUI if isConfirmationRequired returns true
addToTableViews()
create ilDclTableViewFieldSettings for this field in each tableview
storePropertiesFromForm(ilPropertyFormGUI $form)
called when saving the 'edit field' form
isConfirmationRequired(ilPropertyFormGUI $form)
called by ilDclFieldEditGUI when updating field properties if you overwrite this method,...
const PROP_LEARNING_PROGRESS
checkValidity($value, ?int $record_id)
Check if input is valid.
getValidFieldProperties()
Returns all valid properties for a field-type.
const PROP_REFERENCE_LINK
checkUniqueProp(ilPropertyFormGUI $form)
cloneProperties(ilDclBaseFieldModel $originalField)
loadProperties()
Get all properties of a field.
const PROP_ILIAS_REFERENCE_LINK
setExportable(bool $exportable)
getTableId()
Get table id.
getStorageLocation()
Get storage location for the model.
checkValidityFromForm(ilPropertyFormGUI &$form, ?int $record_id)
loadExportability()
Load exportability.
cloneStructure(int $original_id)
setDescription(string $a_desc)
Set description.
buildFromDBRecord(array $rec)
Builds model from db record.
hasNumericSorting()
Set to true, when the sorting should be handled numerical.
areEqual($value_1, $value_2)
setStorageLocationOverride(?int $storage_location_override)
checkTitlesForImport(array &$titles, array &$import_fields)
const PROP_LENGTH
General properties.
getSortField()
Returns the sort-field id.
getDatatypeId()
Get datatype_id.
setTableId(int $a_id)
Set table id.
fillHeaderExcel(ilExcel $worksheet, int &$row, int &$col)
checkFieldCreationInput(ilPropertyFormGUI $form)
Checks input of specific fields befor saving.
checkUnique($value, ?int $record_id)
setId($a_id)
Set field id.
static getRecordFieldCache(object $record, object $field)
static getFieldProperties(string $field_id)
Cache Field properties.
static getTableCache(?int $table_id=null)
static getFieldCache(int $field_id=0)
static setCloneOf(int $old, int $new, string $type)
static getDatatype(int $datatyp_id)
Get cached datatypes.
const INPUTFORMAT_REFERENCE
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
setSelectStatement(string $selectStatement)
static _getDatatypeForId(string $id)
gives you the datatype id of a specified standard field.
static getInstance(int $table_id, string $field)
static getTableViewFieldSetting(string $id, int $tableview_id)
static getAllForTableId(int $table_id)
static _tableExists(int $table_id)
setCell(int $a_row, int $col, $value, ?string $datatype=null)
Set cell value.
Base class for ILIAS Exception handling.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...