ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDclTextFieldModel Class Reference

Class ilDclTextFieldModel. More...

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

Public Member Functions

 getRecordQueryFilterObject ($filter_value="", ilDclBaseFieldModel $sort_field=null)
 Returns a query-object for building the record-loader-sql-query.
Parameters
string$filter_value
ilDclBaseFieldModel | null$sort_field
Returns
null|ilDclRecordQueryObject
More...
 
 getRecordQuerySortObject ($direction="asc", $sort_by_status=false)
 Returns a query-object for building the record-loader-sql-query.
Parameters
string$direction
boolean$sort_by_statusThe specific sort object is a status field
Returns
null|ilDclRecordQueryObject
More...
 
 checkValidityFromForm (ilPropertyFormGUI &$form, $record_id=null)
 
 checkValidity ($value, $record_id=null)
 Check if input is valid.
Parameters
$value
null$record_id
Returns
bool
Exceptions
ilDclInputException
More...
 
 checkFieldCreationInput (ilPropertyFormGUI $form)
 @inheritDoc More...
 
 getValidFieldProperties ()
 @inheritDoc More...
 
 strlen ($value, $encoding='UTF-8')
 
 fillHeaderExcel (ilExcel $worksheet, &$row, &$col)
 
 checkTitlesForImport (array &$titles, array &$import_fields)
 
- Public Member Functions inherited from ilDclBaseFieldModel
 __construct ($a_id=0)
 
 setId ($a_id)
 Set field id. More...
 
 getId ()
 Get field id. More...
 
 setTableId ($a_id)
 Set table id. More...
 
 getTableId ()
 Get table id. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription ($a_desc)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setDatatypeId ($a_id)
 Set datatype id. More...
 
 getDatatypeId ()
 Get datatype_id. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required Required. More...
 
 isUnique ()
 
 setUnique ($unique)
 
 getDatatype ()
 
 getDatatypeTitle ()
 
 getStorageLocation ()
 Get storage location for the model. More...
 
 getExportable ()
 
 toArray ()
 
 isStandardField ()
 
 doRead ()
 Read field. More...
 
 buildFromDBRecord ($rec)
 Builds model from db record. More...
 
 doCreate ()
 Create new field. More...
 
 doUpdate ()
 Update field. More...
 
 updateProperties ()
 Update properties of this field in Database. More...
 
 doDelete ()
 Remove field and properties. More...
 
 getFieldSettings ()
 
 getOrder ()
 
 setOrder ($order)
 
 hasProperty ($key)
 Checks if a certain property for a field is set. More...
 
 getProperty ($key)
 Returns a certain property of a field. More...
 
 getPropertyInstance ($key)
 Return ActiveRecord of property. More...
 
 setProperty ($key, $value)
 Set a property for a field (does not save) More...
 
 getValidFieldProperties ()
 Returns all valid properties for a field-type. More...
 
 setLocked ($locked)
 
 getLocked ()
 
 checkValidityFromForm (ilPropertyFormGUI &$form, $record_id=null)
 
 checkValidity ($value, $record_id=null)
 Check if input is valid. More...
 
 cloneStructure ($original_id)
 
 afterClone ($records)
 
 cloneProperties (ilDclBaseFieldModel $originalField)
 
 setExportable ($exportable)
 
 allowFilterInListView ()
 
 getRecordQuerySortObject ($direction="asc", $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 ($storage_location_override)
 
 fillHeaderExcel (ilExcel $worksheet, &$row, &$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, $record_id)
 
 checkRegexAndLength ($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 ($a_as_regex=true)
 All valid chars for filed titles. More...
 
static _getFieldIdByTitle ($title, $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"
 
const PROP_SUPPORTED_FILE_TYPES = "supported_file_types"
 
const PROP_PLUGIN_HOOK_NAME = "plugin_hook_name"
 
const PROP_TEXT_SELECTION_OPTIONS = "text_selection_options"
 
const PROP_TEXT_SELECTION_TYPE = "text_selection_type"
 
const PROP_DATE_SELECTION_OPTIONS = "date_selection_options"
 
const PROP_DATE_SELECTION_TYPE = "date_selection_type"
 
const EDIT_VIEW = 2
 
const EXPORTABLE_VIEW = 4
 
- Protected Attributes inherited from ilDclBaseFieldModel
 $id
 
 $table_id
 
 $title
 
 $description
 
 $datatypeId
 
 $required
 
 $order
 
 $unique
 
 $locked
 
 $property = array()
 
 $exportable
 
 $datatype
 
 $storage_location_override = null
 

Detailed Description

Class ilDclTextFieldModel.

Author
Michael Herren mh@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

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

Member Function Documentation

◆ checkFieldCreationInput()

ilDclTextFieldModel::checkFieldCreationInput ( ilPropertyFormGUI  $form)

@inheritDoc

Reimplemented from ilDclBaseFieldModel.

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

144 {
145 global $DIC;
146 $lng = $DIC['lng'];
147
148 $return = true;
149 // Additional check for text fields: The length property should be max 200 if the textarea option is not set
150 if ((int) $form->getInput('prop_' . ilDclBaseFieldModel::PROP_LENGTH) > 200 && !$form->getInput('prop_' . ilDclBaseFieldModel::PROP_TEXTAREA)) {
151 $inputObj = $form->getItemByPostVar('prop_' . ilDclBaseFieldModel::PROP_LENGTH);
152 $inputObj->setAlert($lng->txt("form_msg_value_too_high"));
153 $return = false;
154 }
155
156 return $return;
157 }
const PROP_LENGTH
General properties.
global $lng
Definition: privfeed.php:17
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7

References $DIC, $form, $lng, ilDclBaseFieldModel\PROP_LENGTH, and ilDclBaseFieldModel\PROP_TEXTAREA.

◆ checkRegexAndLength()

ilDclTextFieldModel::checkRegexAndLength (   $value)
protected
Parameters
$value
Exceptions
ilDclInputException

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

175 {
177 if (substr($regex, 0, 1) != "/") {
178 $regex = "/" . $regex;
179 }
180 if (substr($regex, -1) != "/") {
181 $regex .= "/";
182 }
183
184 if ($this->getProperty(ilDclBaseFieldModel::PROP_LENGTH) < $this->strlen($value, 'UTF-8')
185 && is_numeric($this->getProperty(ilDclBaseFieldModel::PROP_LENGTH))
186 ) {
188 }
189
190 if ($this->getProperty(ilDclBaseFieldModel::PROP_REGEX) != null) {
191 try {
192 $preg_match = preg_match($regex, $value);
193 } catch (ErrorException $e) {
195 }
196
197 if ($preg_match == false) {
199 }
200 }
201 }
getProperty($key)
Returns a certain property of a field.
Class ilDclBaseFieldModel.
strlen($value, $encoding='UTF-8')

References ilDclBaseFieldModel\getProperty(), ilDclInputException\LENGTH_EXCEPTION, ilDclBaseFieldModel\PROP_LENGTH, ilDclBaseFieldModel\PROP_REGEX, ilDclInputException\REGEX_CONFIG_EXCEPTION, ilDclInputException\REGEX_EXCEPTION, and strlen().

Referenced by checkValidity(), and checkValidityOfURLField().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTitlesForImport()

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

Reimplemented from ilDclBaseFieldModel.

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

235 {
236 foreach ($titles as $k => $title) {
237 if (!ilStr::isUtf8($title)) {
238 $title = utf8_encode($title);
239 }
240 if ($title == $this->getTitle()) {
241 $import_fields[$k] = $this;
242 if ($this->hasProperty(ilDclBaseFieldModel::PROP_URL) && $titles[$k+1] == $this->getTitle() . '_title') {
243 unset($titles[$k+1]);
244 }
245 }
246 }
247 }
hasProperty($key)
Checks if a certain property for a field is set.
static isUtf8($a_str)
Check whether string is utf-8.

References ilDclBaseFieldModel\$title, ilDclBaseFieldModel\getTitle(), ilDclBaseFieldModel\hasProperty(), ilStr\isUtf8(), and ilDclBaseFieldModel\PROP_URL.

+ Here is the call graph for this function:

◆ checkValidity()

ilDclTextFieldModel::checkValidity (   $value,
  $record_id = null 
)

Check if input is valid.

Parameters
$value
null$record_id
Returns
bool
Exceptions
ilDclInputException

Reimplemented from ilDclBaseFieldModel.

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

68 {
69 $has_url_property = $this->getProperty(ilDclBaseFieldModel::PROP_URL);
70 if ($has_url_property) {
71 return $this->checkValidityOfURLField($value, $record_id);
72 }
73
74 //Don't check empty values
75 if ($value == null) {
76 return true;
77 }
78
79 $this->checkRegexAndLength($value);
80
81 if ($this->isUnique()) {
83 foreach ($table->getRecords() as $record) {
84 //for text it has to be case insensitive.
85 $record_value = $record->getRecordFieldValue($this->getId());
86
87 if (strtolower($this->normalizeValue($record_value)) == strtolower($this->normalizeValue(nl2br($value)))
88 && ($record->getId() != $record_id
89 || $record_id == 0)
90 ) {
92 }
93 }
94 }
95 }
static getTableCache($table_id=0)
checkValidityOfURLField($value, $record_id)
if(empty($password)) $table
Definition: pwgen.php:24

References $table, checkRegexAndLength(), checkValidityOfURLField(), ilDclBaseFieldModel\getId(), ilDclBaseFieldModel\getProperty(), ilDclCache\getTableCache(), ilDclBaseFieldModel\getTableId(), ilDclBaseFieldModel\isUnique(), ilDclBaseFieldModel\normalizeValue(), ilDclBaseFieldModel\PROP_URL, and ilDclInputException\UNIQUE_EXCEPTION.

+ Here is the call graph for this function:

◆ checkValidityFromForm()

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

Reimplemented from ilDclBaseFieldModel.

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

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

References $form, checkValidityOfURLField(), ilDclBaseFieldModel\getProperty(), and ilDclBaseFieldModel\PROP_URL.

+ Here is the call graph for this function:

◆ checkValidityOfURLField()

ilDclTextFieldModel::checkValidityOfURLField (   $value,
  $record_id 
)
protected
Parameters
$value
$record_id
Returns
bool
Exceptions
ilDclInputException

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

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

References $table, checkRegexAndLength(), ilDclBaseFieldModel\getId(), ilDclCache\getTableCache(), ilDclBaseFieldModel\getTableId(), ilDclBaseFieldModel\isUnique(), ilDclInputException\NOT_URL, and ilDclInputException\UNIQUE_EXCEPTION.

Referenced by checkValidity(), and checkValidityFromForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillHeaderExcel()

ilDclTextFieldModel::fillHeaderExcel ( ilExcel  $worksheet,
$row,
$col 
)
Parameters
ilExcel$worksheet
$row
$col

Reimplemented from ilDclBaseFieldModel.

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

222 {
223 parent::fillHeaderExcel($worksheet, $row, $col);
225 $worksheet->setCell($row, $col, $this->getTitle() . '_title');
226 $col++;
227 }
228 }
$worksheet
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.

References $row, $worksheet, ilDclBaseFieldModel\getProperty(), ilDclBaseFieldModel\getTitle(), ilDclBaseFieldModel\PROP_URL, and ilExcel\setCell().

+ Here is the call graph for this function:

◆ getRecordQueryFilterObject()

ilDclTextFieldModel::getRecordQueryFilterObject (   $filter_value = "",
ilDclBaseFieldModel  $sort_field = null 
)

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

Parameters
string$filter_value
ilDclBaseFieldModel | null$sort_field
Returns
null|ilDclRecordQueryObject

Reimplemented from ilDclBaseFieldModel.

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

16 {
17 global $DIC;
18 $ilDB = $DIC['ilDB'];
19
20 $join_str = "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 = "
21 . $ilDB->quote($this->getId(), 'integer') . ") ";
22 $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 "
23 . $ilDB->quote("%$filter_value%", 'text') . ") ";
24
25 $sql_obj = new ilDclRecordQueryObject();
26 $sql_obj->setJoinStatement($join_str);
27
28 return $sql_obj;
29 }
Class ilDclRecordQueryObject.
global $ilDB

References $DIC, $ilDB, and ilDclBaseFieldModel\getId().

+ Here is the call graph for this function:

◆ getRecordQuerySortObject()

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

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

Parameters
string$direction
boolean$sort_by_statusThe specific sort object is a status field
Returns
null|ilDclRecordQueryObject

Reimplemented from ilDclBaseFieldModel.

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

35 {
36 // use custom record sorting for url-fields
38 return new ilDclTextRecordQueryObject();
39 } else {
40 return parent::getRecordQuerySortObject($direction, $sort_by_status);
41 }
42 }
Class ilDclTextRecordQueryObject.

References ilDclBaseFieldModel\hasProperty(), and ilDclBaseFieldModel\PROP_URL.

+ Here is the call graph for this function:

◆ getValidFieldProperties()

◆ strlen()

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

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

210 {
211 switch (true) {
212 case function_exists('mb_strlen'):
213 return mb_strlen($value, $encoding);
214 case function_exists('iconv_strlen'):
215 return iconv_strlen($value, $encoding);
216 default:
217 return strlen($value);
218 }
219 }

References strlen().

Referenced by checkRegexAndLength(), and strlen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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