ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDclTextFieldModel Class Reference
+ 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)
 
 checkValidityFromForm (ilPropertyFormGUI &$form, ?int $record_id=null)
 
 checkFieldCreationInput (ilPropertyFormGUI $form)
 
 getValidFieldProperties ()
 
 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 (int $order)
 
 hasProperty (string $key)
 Checks if a certain property for a field is set. More...
 
 getProperty (string $key)
 
 getPropertyInstance (string $key)
 
 setProperty (string $key, $value)
 
 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 (mixed $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 $datatype_id = 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

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

Member Function Documentation

◆ checkFieldCreationInput()

ilDclTextFieldModel::checkFieldCreationInput ( ilPropertyFormGUI  $form)

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

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

110  : bool
111  {
112  $return = true;
113  // Additional check for text fields: The length property should be max 200 if the textarea option is not set
114  if ((int) $form->getInput('prop_' . ilDclBaseFieldModel::PROP_LENGTH) > 200 && !$form->getInput('prop_' . ilDclBaseFieldModel::PROP_TEXTAREA)) {
115  $inputObj = $form->getItemByPostVar('prop_' . ilDclBaseFieldModel::PROP_LENGTH);
116  $inputObj->setAlert($this->lng->txt("form_msg_value_too_high"));
117  $return = false;
118  }
119 
120  return $return;
121  }
getItemByPostVar(string $a_post_var)
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-...
const PROP_LENGTH
General properties.
+ Here is the call graph for this function:

◆ checkRegexAndLength()

ilDclTextFieldModel::checkRegexAndLength ( string  $value)
protected

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

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

137  : void
138  {
139  if ($this->getProperty(ilDclBaseFieldModel::PROP_LENGTH) < $this->strlen($value)
140  && is_numeric($this->getProperty(ilDclBaseFieldModel::PROP_LENGTH))
141  ) {
143  }
144 
147  if (substr($regex, 0, 1) != "/") {
148  $regex = "/" . $regex;
149  }
150  if (substr($regex, -1) != "/") {
151  $regex .= "/";
152  }
153 
154  try {
155  $preg_match = preg_match($regex, $value);
156  } catch (ErrorException) {
158  }
159 
160  if ($preg_match == false) {
162  }
163  }
164  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
strlen(string $value, string $encoding='UTF-8')
const PROP_LENGTH
General properties.
+ Here is the call graph for this function:

◆ checkTitlesForImport()

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

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

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

187  : void
188  {
189  foreach ($titles as $k => $title) {
190  if (!mb_detect_encoding($title, "UTF-8", true) == "UTF-8") {
191  $title = mb_convert_encoding($title, 'UTF-8', 'ISO-8859-1');
192  }
193  if ($title == $this->getTitle()) {
194  $import_fields[$k] = $this;
195  if ($this->hasProperty(ilDclBaseFieldModel::PROP_URL) && $titles[$k + 1] == $this->getTitle() . '_title') {
196  unset($titles[$k + 1]);
197  }
198  }
199  }
200  }
hasProperty(string $key)
Checks if a certain property for a field is set.
+ Here is the call graph for this function:

◆ checkValidityFromForm()

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

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

References checkValidityOfURLField(), ilDclBaseFieldModel\getId(), ilPropertyFormGUI\getInput(), ilDclBaseFieldModel\getProperty(), and ilDclBaseFieldModel\PROP_URL.

57  : void
58  {
59  $has_url_property = $this->getProperty(ilDclBaseFieldModel::PROP_URL);
60  if ($has_url_property) {
61  $values = [
62  'link' => $form->getInput("field_" . $this->getId()),
63  'title' => $form->getInput("field_" . $this->getId() . "_title"),
64  ];
65  $this->checkValidityOfURLField($values, $record_id);
66  } else {
67  parent::checkValidityFromForm($form, $record_id);
68  }
69  }
checkValidityOfURLField($value, ?int $record_id)
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-...
+ Here is the call graph for this function:

◆ checkValidityOfURLField()

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

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

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

Referenced by checkValidityFromForm().

77  : bool
78  {
79  //Don't check empty values
80  if (!$value['link']) {
81  return true;
82  }
83 
84  // TODO: value should always be an array with url fields, can we remove the check & json_decode?
85  if (!is_array($value)) {
86  $value = ['link' => $value, 'title' => ''];
87  }
88 
89  //check url/email
90  $link = (substr($value['link'], 0, 3) === 'www') ? 'https://' . $value['link'] : $value['link'];
91  if (!filter_var($link, FILTER_VALIDATE_URL) && !filter_var($link, FILTER_VALIDATE_EMAIL) && $link != '') {
93  }
94 
95  if ($this->isUnique()) {
96  $table = ilDclCache::getTableCache($this->getTableId());
97  foreach ($table->getRecords() as $record) {
98  if (($record->getId() !== $record_id) && !empty($record_id)) {
99  $record_value = $record->getRecordFieldValue($this->getId());
100  if (!empty($record_value['link']) && $record_value['link'] === $link) {
102  }
103  }
104  }
105  }
106 
107  return true;
108  }
static getTableCache(?int $table_id=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillHeaderExcel()

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

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

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

178  : void
179  {
180  parent::fillHeaderExcel($worksheet, $row, $col);
182  $worksheet->setCell($row, $col, $this->getTitle() . '_title');
183  $col++;
184  }
185  }
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
+ Here is the call graph for this function:

◆ getRecordQueryFilterObject()

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

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

References ilDclBaseFieldModel\getId().

30  $join_str
31  = "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 = "
32  . $this->db->quote($this->getId(), 'integer') . ") ";
33  $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 "
34  . $this->db->quote("%$filter_value%", 'text') . ") ";
35 
36  $sql_obj = new ilDclRecordQueryObject();
37  $sql_obj->setJoinStatement($join_str);
38 
39  return $sql_obj;
40  }
+ Here is the call graph for this function:

◆ getRecordQuerySortObject()

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

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

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

46  // use custom record sorting for url-fields
48  return new ilDclTextRecordQueryObject();
49  } else {
50  return parent::getRecordQuerySortObject($direction, $sort_by_status);
51  }
52  }
hasProperty(string $key)
Checks if a certain property for a field is set.
+ Here is the call graph for this function:

◆ getValidFieldProperties()

◆ strlen()

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

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

Referenced by checkRegexAndLength().

166  : int
167  {
168  switch (true) {
169  case function_exists('mb_strlen'):
170  return mb_strlen($value, $encoding);
171  case function_exists('iconv_strlen'):
172  return iconv_strlen($value, $encoding);
173  default:
174  return strlen($value);
175  }
176  }
return['delivery_method'=> 'php',]
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')
+ Here is the caller graph for this function:

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