ILIAS  release_8 Revision v8.24
ilDclTextFieldModel Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilDclTextFieldModel:
+ Collaboration diagram for ilDclTextFieldModel:

Public Member Functions

 getRecordQueryFilterObject ( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
 
 getRecordQuerySortObject (string $direction="asc", bool $sort_by_status=false)
 Returns a query-object for building the record-loader-sql-query. More...
 
 checkValidityFromForm (ilPropertyFormGUI &$form, ?int $record_id=null)
 
 checkValidity ($value, ?int $record_id=null)
 
 checkFieldCreationInput (ilPropertyFormGUI $form)
 Checks input of specific fields befor saving. More...
 
 getValidFieldProperties ()
 @inheritDoc More...
 
 strlen (string $value, string $encoding='UTF-8')
 
 fillHeaderExcel (ilExcel $worksheet, int &$row, int &$col)
 
 checkTitlesForImport (array &$titles, array &$import_fields)
 
- Public Member Functions inherited from ilDclBaseFieldModel
 __construct (int $a_id=0)
 
 setId ($a_id)
 Set field id. More...
 
 getId ()
 Get field id. More...
 
 setTableId (int $a_id)
 Set table id. More...
 
 getTableId ()
 Get table id. More...
 
 setTitle (string $a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription (string $a_desc)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setDatatypeId (int $a_id)
 Set datatype id. More...
 
 getDatatypeId ()
 Get datatype_id. More...
 
 isUnique ()
 
 setUnique (?bool $unique)
 
 getDatatype ()
 
 getDatatypeTitle ()
 
 getPresentationTitle ()
 
 getPresentationDescription ()
 
 getStorageLocation ()
 Get storage location for the model. More...
 
 getExportable ()
 
 toArray ()
 
 isStandardField ()
 
 doRead ()
 
 buildFromDBRecord (array $rec)
 Builds model from db record. More...
 
 doCreate ()
 
 doUpdate ()
 
 updateProperties ()
 Update properties of this field in Database. More...
 
 doDelete ()
 Remove field and properties. More...
 
 getViewSettings ()
 
 getViewSetting (int $tableview_id)
 
 getOrder ()
 
 setOrder (string $order)
 
 hasProperty (string $key)
 Checks if a certain property for a field is set. More...
 
 getProperty (string $key)
 Returns a certain property of a field. More...
 
 getPropertyInstance (string $key)
 Return ActiveRecord of property. More...
 
 setProperty (string $key, $value)
 Set a property for a field (does not save) More...
 
 getValidFieldProperties ()
 Returns all valid properties for a field-type. More...
 
 checkValidityFromForm (ilPropertyFormGUI &$form, ?int $record_id=null)
 
 checkValidity ($value, ?int $record_id=null)
 Check if input is valid. More...
 
 cloneStructure (int $original_id)
 
 afterClone (array $records)
 
 cloneProperties (ilDclBaseFieldModel $originalField)
 
 setExportable (bool $exportable)
 
 allowFilterInListView ()
 
 getRecordQuerySortObject (string $direction="asc", bool $sort_by_status=false)
 Returns a query-object for building the record-loader-sql-query. More...
 
 getRecordQueryFilterObject ( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
 Returns a query-object for building the record-loader-sql-query. More...
 
 getSortField ()
 Returns the sort-field id. More...
 
 hasNumericSorting ()
 Set to true, when the sorting should be handled numerical. More...
 
 checkFieldCreationInput (ilPropertyFormGUI $form)
 Checks input of specific fields befor saving. More...
 
 getStorageLocationOverride ()
 
 setStorageLocationOverride (?int $storage_location_override)
 
 fillHeaderExcel (ilExcel $worksheet, int &$row, int &$col)
 
 checkTitlesForImport (array &$titles, array &$import_fields)
 
 storePropertiesFromForm (ilPropertyFormGUI $form)
 called when saving the 'edit field' form More...
 
 fillPropertiesForm (ilPropertyFormGUI &$form)
 called to fill the 'edit field' form More...
 
 isConfirmationRequired (ilPropertyFormGUI $form)
 called by ilDclFieldEditGUI when updating field properties if you overwrite this method, remember to also overwrite getConfirmationGUI More...
 
 getConfirmationGUI (ilPropertyFormGUI $form)
 called by ilDclFieldEditGUI if isConfirmationRequired returns true More...
 

Protected Member Functions

 checkValidityOfURLField ($value, ?int $record_id)
 
 checkRegexAndLength (string $value)
 
- Protected Member Functions inherited from ilDclBaseFieldModel
 loadDatatype ()
 Load datatype for model. More...
 
 loadTableFieldSetting ()
 loadTableFieldSetting More...
 
 addToTableViews ()
 create ilDclTableViewFieldSettings for this field in each tableview More...
 
 updateTableFieldSetting ()
 update exportable and fieldorder More...
 
 loadProperties ()
 Get all properties of a field. More...
 
 normalizeValue ($value)
 

Additional Inherited Members

- Static Public Member Functions inherited from ilDclBaseFieldModel
static _getTitleInvalidChars (bool $a_as_regex=true)
 All valid chars for filed titles. More...
 
static _getFieldIdByTitle (string $title, int $table_id)
 
- Data Fields inherited from ilDclBaseFieldModel
const PROP_LENGTH = "lenght"
 General properties. More...
 
const PROP_REGEX = "regex"
 
const PROP_REFERENCE = "table_id"
 
const PROP_URL = "url"
 
const PROP_TEXTAREA = "text_area"
 
const PROP_REFERENCE_LINK = "reference_link"
 
const PROP_WIDTH = "width"
 
const PROP_HEIGHT = "height"
 
const PROP_LEARNING_PROGRESS = "learning_progress"
 
const PROP_ILIAS_REFERENCE_LINK = "ILIAS_reference_link"
 
const PROP_N_REFERENCE = "multiple_selection"
 
const PROP_FORMULA_EXPRESSION = "expression"
 
const PROP_DISPLAY_COPY_LINK_ACTION_MENU = "display_action_menu"
 
const PROP_LINK_DETAIL_PAGE_TEXT = "link_detail_page_text"
 
const PROP_LINK_DETAIL_PAGE_MOB = "link_detail_page_mob"
 
const PROP_SUPPORTED_FILE_TYPES = "supported_file_types"
 
const PROP_PLUGIN_HOOK_NAME = "plugin_hook_name"
 
const EDIT_VIEW = 2
 
const EXPORTABLE_VIEW = 4
 
- Protected Attributes inherited from ilDclBaseFieldModel
string $id = ""
 
int $table_id = 0
 
string $title = ""
 
string $description = ""
 
int $datatypeId = 0
 
int $order = null
 
bool $unique = false
 
array $property = []
 
bool $exportable = false
 
ilDclDatatype $datatype = null
 
int $storage_location_override = null
 With this property the datatype-storage-location can be overwritten. More...
 
ilDBInterface $db
 
ilLanguage $lng
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 of file class.ilDclTextFieldModel.php.

Member Function Documentation

◆ checkFieldCreationInput()

ilDclTextFieldModel::checkFieldCreationInput ( ilPropertyFormGUI  $form)

Checks input of specific fields befor saving.

Parameters
ilPropertyFormGUI$form
Returns
bool if checkInput was successful

Reimplemented from ilDclBaseFieldModel.

Definition at line 145 of file class.ilDclTextFieldModel.php.

145 : bool
146 {
147 $return = true;
148 // Additional check for text fields: The length property should be max 200 if the textarea option is not set
149 if ((int) $form->getInput('prop_' . ilDclBaseFieldModel::PROP_LENGTH) > 200 && !$form->getInput('prop_' . ilDclBaseFieldModel::PROP_TEXTAREA)) {
150 $inputObj = $form->getItemByPostVar('prop_' . ilDclBaseFieldModel::PROP_LENGTH);
151 $inputObj->setAlert($this->lng->txt("form_msg_value_too_high"));
152 $return = false;
153 }
154
155 return $return;
156 }
const PROP_LENGTH
General properties.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)

References ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), ILIAS\Repository\lng(), ilDclBaseFieldModel\PROP_LENGTH, and ilDclBaseFieldModel\PROP_TEXTAREA.

+ Here is the call graph for this function:

◆ checkRegexAndLength()

ilDclTextFieldModel::checkRegexAndLength ( string  $value)
protected

Definition at line 172 of file class.ilDclTextFieldModel.php.

172 : void
173 {
175 if (substr($regex, 0, 1) != "/") {
176 $regex = "/" . $regex;
177 }
178 if (substr($regex, -1) != "/") {
179 $regex .= "/";
180 }
181
182 if ($this->getProperty(ilDclBaseFieldModel::PROP_LENGTH) < $this->strlen($value)
183 && is_numeric($this->getProperty(ilDclBaseFieldModel::PROP_LENGTH))
184 ) {
186 }
187
188 if ($this->getProperty(ilDclBaseFieldModel::PROP_REGEX) != null) {
189 try {
190 $preg_match = preg_match($regex, $value);
191 } catch (ErrorException $e) {
193 }
194
195 if ($preg_match == false) {
197 }
198 }
199 }
getProperty(string $key)
Returns a certain property of a field.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
strlen(string $value, string $encoding='UTF-8')

References Vendor\Package\$e, ilDclInputException\LENGTH_EXCEPTION, ilDclBaseFieldModel\PROP_LENGTH, ilDclBaseFieldModel\PROP_REGEX, ilDclInputException\REGEX_CONFIG_EXCEPTION, and ilDclInputException\REGEX_EXCEPTION.

◆ checkTitlesForImport()

ilDclTextFieldModel::checkTitlesForImport ( array &  $titles,
array &  $import_fields 
)

Reimplemented from ilDclBaseFieldModel.

Definition at line 222 of file class.ilDclTextFieldModel.php.

222 : void
223 {
224 foreach ($titles as $k => $title) {
225 if (!ilStr::isUtf8($title)) {
226 $title = utf8_encode($title);
227 }
228 if ($title == $this->getTitle()) {
229 $import_fields[$k] = $this;
230 if ($this->hasProperty(ilDclBaseFieldModel::PROP_URL) && $titles[$k + 1] == $this->getTitle() . '_title') {
231 unset($titles[$k + 1]);
232 }
233 }
234 }
235 }
hasProperty(string $key)
Checks if a certain property for a field is set.
static isUtf8(string $a_str)
Check whether string is utf-8.

References ilStr\isUtf8(), and ilDclBaseFieldModel\PROP_URL.

+ Here is the call graph for this function:

◆ checkValidity()

ilDclTextFieldModel::checkValidity (   $value,
?int  $record_id = null 
)
Parameters
null | string$value
Exceptions
ilDclInputException

Reimplemented from ilDclBaseFieldModel.

Definition at line 70 of file class.ilDclTextFieldModel.php.

70 : bool
71 {
72 $has_url_property = $this->getProperty(ilDclBaseFieldModel::PROP_URL);
73 if ($has_url_property) {
74 return $this->checkValidityOfURLField($value, $record_id);
75 }
76
77 // Don't check empty values
78 if ($value === null) {
79 return true;
80 }
81
82 $this->checkRegexAndLength($value);
83
84 if ($this->isUnique()) {
85 $table = ilDclCache::getTableCache($this->getTableId());
86 foreach ($table->getRecords() as $record) {
87 //for text it has to be case insensitive.
88 $record_value = $record->getRecordFieldValue($this->getId());
89
90 if (strtolower($this->normalizeValue($record_value)) == strtolower($this->normalizeValue($value))
91 && ($record->getId() != $record_id
92 || $record_id == 0)
93 ) {
95 }
96 }
97 }
98
99 return false;
100 }
static getTableCache(int $table_id=null)
checkValidityOfURLField($value, ?int $record_id)

References ILIAS\Survey\Mode\getId(), ilDclCache\getTableCache(), ilDclBaseFieldModel\PROP_URL, and ilDclInputException\UNIQUE_EXCEPTION.

+ Here is the call graph for this function:

◆ checkValidityFromForm()

ilDclTextFieldModel::checkValidityFromForm ( ilPropertyFormGUI $form,
?int  $record_id = null 
)

Reimplemented from ilDclBaseFieldModel.

Definition at line 52 of file class.ilDclTextFieldModel.php.

52 : void
53 {
54 $has_url_property = $this->getProperty(ilDclBaseFieldModel::PROP_URL);
55 if ($has_url_property) {
56 $values = [
57 'link' => $form->getInput("field_" . $this->getId()),
58 'title' => $form->getInput("field_" . $this->getId() . "_title"),
59 ];
60 $this->checkValidityOfURLField($values, $record_id);
61 } else {
62 parent::checkValidityFromForm($form, $record_id);
63 }
64 }

References ILIAS\Survey\Mode\getId(), ilPropertyFormGUI\getInput(), and ilDclBaseFieldModel\PROP_URL.

+ Here is the call graph for this function:

◆ checkValidityOfURLField()

ilDclTextFieldModel::checkValidityOfURLField (   $value,
?int  $record_id 
)
protected
Parameters
null | string | array$value
int$record_id
Returns
bool
Exceptions
ilDclInputException

Definition at line 108 of file class.ilDclTextFieldModel.php.

108 : bool
109 {
110 // TODO: value should always be an array with url fields, can we remove the check & json_decode?
111 if (!is_array($value)) {
112 $value = ['link' => $value, 'title' => ''];
113 }
114
115 //Don't check empty values
116 if (!$value['link']) {
117 return true;
118 }
119
120 $this->checkRegexAndLength($value['link']);
121
122 //check url/email
123 $link = (substr($value['link'], 0, 3) === 'www') ? 'https://' . $value['link'] : $value['link'];
124 if (!filter_var($link, FILTER_VALIDATE_URL) && !filter_var($link, FILTER_VALIDATE_EMAIL) && $link != '') {
126 }
127
128 if ($this->isUnique()) {
129 $table = ilDclCache::getTableCache($this->getTableId());
130 foreach ($table->getRecords() as $record) {
131 $record_value = $record->getRecordFieldValue($this->getId());
132
133 if ($record_value == $value
134 && ($record->getId() != $record_id
135 || !$record_id)
136 ) {
138 }
139 }
140 }
141
142 return true;
143 }

References ILIAS\Survey\Mode\getId(), ilDclCache\getTableCache(), ilDclInputException\NOT_URL, and ilDclInputException\UNIQUE_EXCEPTION.

+ Here is the call graph for this function:

◆ fillHeaderExcel()

ilDclTextFieldModel::fillHeaderExcel ( ilExcel  $worksheet,
int &  $row,
int &  $col 
)

Reimplemented from ilDclBaseFieldModel.

Definition at line 213 of file class.ilDclTextFieldModel.php.

213 : void
214 {
215 parent::fillHeaderExcel($worksheet, $row, $col);
217 $worksheet->setCell($row, $col, $this->getTitle() . '_title');
218 $col++;
219 }
220 }
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.

References ilDclBaseFieldModel\PROP_URL, and ilExcel\setCell().

+ Here is the call graph for this function:

◆ getRecordQueryFilterObject()

ilDclTextFieldModel::getRecordQueryFilterObject (   $filter_value = "",
?ilDclBaseFieldModel  $sort_field = null 
)
Parameters
string | int$filter_value

Reimplemented from ilDclBaseFieldModel.

Definition at line 24 of file class.ilDclTextFieldModel.php.

28 $join_str
29 = "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 = "
30 . $this->db->quote($this->getId(), 'integer') . ") ";
31 $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 AND filter_stloc_{$this->getId()}.value LIKE "
32 . $this->db->quote("%$filter_value%", 'text') . ") ";
33
34 $sql_obj = new ilDclRecordQueryObject();
35 $sql_obj->setJoinStatement($join_str);
36
37 return $sql_obj;
38 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getRecordQuerySortObject()

ilDclTextFieldModel::getRecordQuerySortObject ( string  $direction = "asc",
bool  $sort_by_status = false 
)

Returns a query-object for building the record-loader-sql-query.

Parameters
bool$sort_by_statusThe specific sort object is a status field

Reimplemented from ilDclBaseFieldModel.

Definition at line 40 of file class.ilDclTextFieldModel.php.

44 // use custom record sorting for url-fields
46 return new ilDclTextRecordQueryObject();
47 } else {
48 return parent::getRecordQuerySortObject($direction, $sort_by_status);
49 }
50 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getValidFieldProperties()

◆ strlen()

ilDclTextFieldModel::strlen ( string  $value,
string  $encoding = 'UTF-8' 
)

Definition at line 201 of file class.ilDclTextFieldModel.php.

201 : int
202 {
203 switch (true) {
204 case function_exists('mb_strlen'):
205 return mb_strlen($value, $encoding);
206 case function_exists('iconv_strlen'):
207 return iconv_strlen($value, $encoding);
208 default:
209 return strlen($value);
210 }
211 }
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']

The documentation for this class was generated from the following file: