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;
   203         $this->unique = (bool) $unique;
   216         return $this->datatype->getTitle();
   240         return $this->datatype->getStorageLocation();
   248         if ($this->datatype == null) {
   259         $this->exportable = $tablefield_setting->isExportable();
   260         $this->order = $tablefield_setting->getFieldOrder();
   268         if (!isset($this->exportable)) {
   280         if ($this->exportable == null) {
   287         return (array) $this;
   298         $query = 
"SELECT * FROM il_dcl_field WHERE id = " . $this->db->quote($this->
getId(), 
"integer");
   299         $set = $this->db->query($query);
   300         $rec = $this->db->fetchAssoc($set);
   304             if (null !== $rec[
"title"]) {
   307             if (null !== $rec[
"description"]) {
   311             $this->
setUnique((
bool) $rec[
"is_unique"]);
   323         $this->
setId($rec[
"id"]);
   328         $this->
setUnique($rec[
"is_unique"] ?? null);
   334             throw new ilException(
"The field does not have a related table!");
   337         $id = $this->db->nextId(
"il_dcl_field");
   339         $query = 
"INSERT INTO il_dcl_field (" . 
"id" . 
", table_id" . 
", datatype_id" . 
", title" . 
", description" . 
", is_unique"   340             . 
" ) VALUES (" . $this->db->quote($this->
getId(), 
"integer") . 
"," . $this->db->quote(
   344             . $this->db->quote($this->
getDatatypeId(), 
"integer") . 
"," . $this->db->quote($this->
getTitle(), 
"text") . 
","   345             . $this->db->quote($this->
getDescription(), 
"text") . 
"," . $this->db->quote($this->
isUnique(), 
"integer") . 
")";
   346         $this->db->manipulate($query);
   359             $tableview->createFieldSetting($this->
id);
   405         foreach ($this->property as $prop) {
   416         $tablefield_setting->setExportable($this->exportable);
   417         $tablefield_setting->setFieldOrder($this->
getOrder());
   418         $tablefield_setting->store();
   429         $query = 
"DELETE FROM il_dcl_field_prop WHERE field_id = " . $this->db->quote($this->
getId(), 
"text");
   430         $this->db->manipulate($query);
   432         $query = 
"DELETE FROM il_dcl_field WHERE id = " . $this->db->quote($this->
getId(), 
"text");
   433         $this->db->manipulate($query);
   436             $field_setting->delete();
   455         if ($this->order == null) {
   482         return (isset($this->property[$key]) && $this->property[$key]->
getValue() != null);
   489         return ($instance !== null) ? $instance->getValue() : null;
   496             return $this->
property[$key];
   505         if (isset($this->property[$key])) {
   506             $this->
property[$key]->setValue($value);
   509             $property->setName($key);
   510             $property->setFieldId((
int) $this->
getId());
   511             $property->setValue($value);
   516         return $this->
property[$key];
   541         if (!isset($value)) {
   547             foreach ($table->getRecords() as $record) {
   548                 if ($record->getId() !== $record_id || $record_id === 0) {
   549                     if ($this->
areEqual($record->getRecordFieldValue($this->getId()), $value)) {
   559     protected function areEqual($value_1, $value_2): bool
   566         if (is_string($value)) {
   567             $value = trim(preg_replace(
"/\\s+/uism", 
" ", $value));
   579         $this->
setTitle($original->getTitle());
   582         $this->
setOrder($original->getOrder());
   594         foreach ($records as $rec) {
   602         if (count($orgProps) == 0) {
   605         foreach ($orgProps as $prop_name) {
   607             $fieldprop_obj->setFieldId((
int) $this->
getId());
   608             $fieldprop_obj->setName($prop_name);
   623                 $fieldprop_obj->setValue($value);
   624                 $fieldprop_obj->create();
   644         string $direction = 
"asc",
   645         bool $sort_by_status = 
false   649         $select_str = 
"sort_stloc_{$this->getId()}.value AS field_{$this->getId()}";
   651             = 
"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 = "   652             . $this->db->quote($this->
getId(), 
'integer') . 
") ";
   653         $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)";
   655         $sql_obj->setSelectStatement($select_str);
   656         $sql_obj->setJoinStatement($join_str);
   657         $sql_obj->setOrderStatement(
"field_{$this->getId()} $direction, ID ASC");
   727         foreach ($titles as $k => $title) {
   728             if (!mb_detect_encoding($title, 
"UTF-8", 
true) == 
"UTF-8") {
   729                 $title = mb_convert_encoding($title, 
'UTF-8', 
'ISO-8859-1');
   732                 $import_fields[$k] = $this;
   745         foreach ($field_props as $property) {
   746             $value = $form->
getInput($representation->getPropertyInputFieldId($property));
   749             if (!empty($value) || ($this->
getPropertyInstance($property) != null && $property != self::PROP_PLUGIN_HOOK_NAME)) {
   762             '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->addHiddenItem(
'unique', $form->
getInput(
'unique'));
   801         $ilConfirmationGUI->setConfirm($this->
lng->txt(
'dcl_update_field'), 
'update');
   802         $ilConfirmationGUI->setCancel($this->
lng->txt(
'cancel'), 
'edit');
   804         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. 
 
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query. 
 
getPresentationDescription()
 
checkValidityFromForm(ilPropertyFormGUI &$form, ?int $record_id=null)
 
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. 
 
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)
 
checkValidity($value, ?int $record_id=null)
Check if input is valid. 
 
setExportable(bool $exportable)
 
addToTableViews()
create ilDclTableViewFieldSettings for this field in each tableview 
 
getTableId()
Get table id. 
 
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 getTableCache(int $table_id=null)
 
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
 
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. 
 
static _getTitleInvalidChars(bool $a_as_regex=true)
All valid chars for filed titles.