ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDclBaseRecordFieldModel Class Reference

Class ilDclBaseFieldModel. More...

+ Inheritance diagram for ilDclBaseRecordFieldModel:
+ Collaboration diagram for ilDclBaseRecordFieldModel:

Public Member Functions

 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 doCreate ()
 Creates an Id and a database entry. More...
 
 doUpdate ()
 Update object in database. More...
 
 delete ()
 Delete record field in database. More...
 
 getValue ()
 
 getValueForRepresentation ()
 
 serializeData ($value)
 Serialize data before storing to db. More...
 
 deserializeData ($value)
 Deserialize data before applying to field. More...
 
 setValue ($value, $omit_parsing=false)
 Set value for record field. More...
 
 setValueFromForm ($form)
 
 getFormulaValue ()
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getValueFromExcel ($excel, $row, $col)
 
 parseValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getExportValue ()
 
 fillExcelExport (ilExcel $worksheet, &$row, &$col)
 
 getPlainText ()
 
 getSortingValue ($link=true)
 
 addHiddenItemsToConfirmation (ilConfirmationGUI &$confirmation)
 
 parseSortingValue ($value, $link=true)
 Returns sortable value for the specific field-types. More...
 
 cloneStructure (ilDclBaseRecordFieldModel $old_record_field)
 
 afterClone ()
 
 getField ()
 
 getId ()
 
 getRecord ()
 
 getRecordRepresentation ()
 
 setRecordRepresentation ($record_representation)
 
 getFieldRepresentation ()
 
 setFieldRepresentation ($field_representation)
 

Protected Member Functions

 doRead ()
 Read object data from database. More...
 
 loadValue ()
 Load the value. More...
 

Protected Attributes

 $id
 
 $field
 
 $record
 
 $record_representation
 
 $field_representation
 
 $value
 
 $user
 
 $ctrl
 
 $db
 
 $lng
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclBaseRecordFieldModel::__construct ( ilDclBaseRecordModel  $record,
ilDclBaseFieldModel  $field 
)
Parameters
ilDclBaseRecordModel$record
ilDclBaseFieldModel$field

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

References $DIC, $field, $ilCtrl, $ilDB, $ilUser, $lng, $record, doRead(), and user().

68  {
69  global $DIC;
70  $ilCtrl = $DIC['ilCtrl'];
71  $ilUser = $DIC['ilUser'];
72  $ilDB = $DIC['ilDB'];
73  $lng = $DIC['lng'];
74  $this->record = $record;
75  $this->field = $field;
76  $this->ctrl = $ilCtrl;
77  $this->user = $ilUser;
78  $this->db = $ilDB;
79  $this->lng = $lng;
80  $this->doRead();
81  }
global $DIC
Definition: saml.php:7
doRead()
Read object data from database.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ addHiddenItemsToConfirmation()

ilDclBaseRecordFieldModel::addHiddenItemsToConfirmation ( ilConfirmationGUI $confirmation)
Parameters
ilConfirmationGUI$confirmation

Definition at line 350 of file class.ilDclBaseRecordFieldModel.php.

References $key, $value, ilConfirmationGUI\addHiddenItem(), and getValue().

351  {
352  ;
353  if (!is_array($this->getValue())) {
354  $confirmation->addHiddenItem('field_' . $this->field->getId(), $this->getValue());
355  } else {
356  foreach ($this->getValue() as $key => $value) {
357  $confirmation->addHiddenItem('field_' . $this->field->getId() . "[$key]", $value);
358  }
359  }
360  }
addHiddenItem($a_post_var, $a_value)
Add hidden item.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ afterClone()

ilDclBaseRecordFieldModel::afterClone ( )

Definition at line 413 of file class.ilDclBaseRecordFieldModel.php.

414  {
415  }

◆ cloneStructure()

ilDclBaseRecordFieldModel::cloneStructure ( ilDclBaseRecordFieldModel  $old_record_field)
Parameters
ilDclBaseRecordFieldModel$old_record_field

Definition at line 403 of file class.ilDclBaseRecordFieldModel.php.

References doUpdate(), getValue(), and setValue().

404  {
405  $this->setValue($old_record_field->getValue());
406  $this->doUpdate();
407  }
setValue($value, $omit_parsing=false)
Set value for record field.
doUpdate()
Update object in database.
+ Here is the call graph for this function:

◆ delete()

ilDclBaseRecordFieldModel::delete ( )

Delete record field in database.

Definition at line 157 of file class.ilDclBaseRecordFieldModel.php.

References $query, and getField().

158  {
159  $datatype = $this->getField()->getDatatype();
160  $storage_location = ($this->getField()->getStorageLocationOverride() !== null) ? $this->getField()->getStorageLocationOverride() : $datatype->getStorageLocation();
161 
162  if ($storage_location != 0) {
163  $query = "DELETE FROM il_dcl_stloc" . $storage_location . "_value WHERE record_field_id = "
164  . $this->db->quote($this->id, "integer");
165  $this->db->manipulate($query);
166  }
167 
168  $query2 = "DELETE FROM il_dcl_record_field WHERE id = " . $this->db->quote($this->id, "integer");
169  $this->db->manipulate($query2);
170  }
$query
+ Here is the call graph for this function:

◆ deserializeData()

ilDclBaseRecordFieldModel::deserializeData (   $value)

Deserialize data before applying to field.

Parameters
$valuemixed
Returns
mixed

Definition at line 217 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by loadValue().

218  {
219  $deserialize = json_decode($value, true);
220  if (is_array($deserialize)) {
221  return $deserialize;
222  }
223 
224  return $value;
225  }
+ Here is the caller graph for this function:

◆ doCreate()

ilDclBaseRecordFieldModel::doCreate ( )

Creates an Id and a database entry.

Definition at line 106 of file class.ilDclBaseRecordFieldModel.php.

References $id, $query, getField(), getId(), and getRecord().

Referenced by doUpdate().

107  {
108  $id = $this->db->nextId("il_dcl_record_field");
109  $query = "INSERT INTO il_dcl_record_field (id, record_id, field_id) VALUES (" . $this->db->quote($id, "integer") . ", "
110  . $this->db->quote($this->getRecord()->getId(), "integer") . ", " . $this->db->quote($this->getField()->getId(), "text") . ")";
111  $this->db->manipulate($query);
112  $this->id = $id;
113  }
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doRead()

ilDclBaseRecordFieldModel::doRead ( )
protected

Read object data from database.

Definition at line 87 of file class.ilDclBaseRecordFieldModel.php.

References $query, getField(), getId(), getRecord(), and loadValue().

Referenced by __construct().

88  {
89  if (!$this->getRecord()->getId()) {
90  return;
91  }
92 
93  $query = "SELECT * FROM il_dcl_record_field WHERE field_id = " . $this->db->quote($this->getField()->getId(), "integer") . " AND record_id = "
94  . $this->db->quote($this->getRecord()->getId(), "integer");
95  $set = $this->db->query($query);
96  $rec = $this->db->fetchAssoc($set);
97  $this->id = $rec['id'];
98 
99  $this->loadValue();
100  }
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilDclBaseRecordFieldModel::doUpdate ( )

Update object in database.

Definition at line 119 of file class.ilDclBaseRecordFieldModel.php.

References $query, $value, doCreate(), getField(), getId(), and serializeData().

Referenced by ilDclFileuploadRecordFieldModel\afterClone(), ilDclReferenceRecordFieldModel\afterClone(), ilDclMobRecordFieldModel\afterClone(), and cloneStructure().

120  {
121  //$this->loadValue(); //Removed Mantis #0011799
122  $datatype = $this->getField()->getDatatype();
123  $storage_location = ($this->getField()->getStorageLocationOverride() !== null) ? $this->getField()->getStorageLocationOverride() : $datatype->getStorageLocation();
124 
125  if ($storage_location != 0) {
126  $query = "DELETE FROM il_dcl_stloc" . $storage_location . "_value WHERE record_field_id = "
127  . $this->db->quote($this->id, "integer");
128  $this->db->manipulate($query);
129 
130  $next_id = $this->db->nextId("il_dcl_stloc" . $storage_location . "_value");
131 
132  // This is a workaround to ensure that date values in stloc3 are never stored as NULL, which is not allowed
133  if ($storage_location == 3 && (is_null($this->value) || empty($this->value))) {
134  $this->value = '0000-00-00 00:00:00';
135  }
136 
137  $value = $this->serializeData($this->value);
138 
139  if ($this->getId() == 0) {
140  $this->doCreate();
141  }
142 
143  $insert_params = array(
144  "value" => array($datatype->getDbType(), $value),
145  "record_field_id" => array("integer", $this->getId()),
146  "id" => array("integer", $next_id),
147  );
148 
149  $this->db->insert("il_dcl_stloc" . $storage_location . "_value", $insert_params);
150  }
151  }
doCreate()
Creates an Id and a database entry.
$query
serializeData($value)
Serialize data before storing to db.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillExcelExport()

ilDclBaseRecordFieldModel::fillExcelExport ( ilExcel  $worksheet,
$row,
$col 
)
Parameters
$worksheet
$row
$col

Definition at line 325 of file class.ilDclBaseRecordFieldModel.php.

References $row, getExportValue(), and ilExcel\setCell().

326  {
327  $worksheet->setCell($row, $col, $this->getExportValue());
328  $col++;
329  }
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
$row
+ Here is the call graph for this function:

◆ getExportValue()

ilDclBaseRecordFieldModel::getExportValue ( )
Returns
int|string

Definition at line 314 of file class.ilDclBaseRecordFieldModel.php.

References getValue(), and parseExportValue().

Referenced by ilDclTextSelectionRecordFieldModel\fillExcelExport(), fillExcelExport(), getFormulaValue(), and getPlainText().

315  {
316  return $this->parseExportValue($this->getValue());
317  }
parseExportValue($value)
Function to parse incoming data from form input value $value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getField()

ilDclBaseRecordFieldModel::getField ( )
Returns
ilDclBaseFieldModel

Definition at line 421 of file class.ilDclBaseRecordFieldModel.php.

References $field.

Referenced by ilDclIliasReferenceRecordFieldModel\__construct(), ilDclRatingRecordFieldModel\__construct(), ilDclFormulaRecordFieldModel\__construct(), ilDclReferenceRecordFieldModel\__construct(), ilDclFileuploadRecordFieldModel\afterClone(), ilDclReferenceRecordFieldModel\afterClone(), ilDclMobRecordFieldModel\afterClone(), ilDclNReferenceFieldGUI\buildTemplate(), ilDclRatingRecordFieldModel\delete(), delete(), doCreate(), doRead(), ilDclNReferenceRecordFieldModel\doUpdate(), doUpdate(), ilDclTextRecordFieldModel\fillExcelExport(), ilDclReferenceRecordFieldModel\getExportValue(), ilDclRatingRecordFieldModel\getExportValue(), ilDclTextRecordFieldModel\getExportValue(), ilDclNReferenceRecordFieldModel\getExportValue(), ilDclNReferenceRecordFieldModel\getLinkHTML(), ilDclSelectionRecordFieldModel\getMultipleValuesFromString(), ilDclFieldFactory\getRecordRepresentationInstance(), ilDclReferenceRecordFieldModel\getReferenceFromValue(), ilDclSelectionRecordFieldModel\getValue(), ilDclRatingRecordFieldModel\getValue(), ilDclSelectionRecordFieldModel\getValueFromExcel(), ilDclReferenceRecordFieldModel\getValueFromExcel(), ilDclTextRecordFieldModel\getValueFromExcel(), ilDclNReferenceRecordFieldModel\loadValue(), loadValue(), ilDclNReferenceRecordFieldModel\loadValueSorted(), ilDclFormulaRecordFieldModel\parse(), ilDclSelectionRecordFieldModel\parseExportValue(), ilDclTextRecordFieldModel\parseSortingValue(), ilDclMobRecordFieldModel\parseValue(), ilDclTextRecordFieldModel\parseValue(), ilDclTextRecordFieldModel\setValueFromForm(), ilDclFileuploadRecordFieldModel\setValueFromForm(), ilDclMobRecordFieldModel\setValueFromForm(), and setValueFromForm().

+ Here is the caller graph for this function:

◆ getFieldRepresentation()

ilDclBaseRecordFieldModel::getFieldRepresentation ( )

◆ getFormulaValue()

ilDclBaseRecordFieldModel::getFormulaValue ( )
Returns
string

Definition at line 264 of file class.ilDclBaseRecordFieldModel.php.

References getExportValue().

265  {
266  return $this->getExportValue();
267  }
+ Here is the call graph for this function:

◆ getId()

◆ getPlainText()

ilDclBaseRecordFieldModel::getPlainText ( )
Returns
mixed used for the sorting.

Definition at line 335 of file class.ilDclBaseRecordFieldModel.php.

References getExportValue().

336  {
337  return $this->getExportValue();
338  }
+ Here is the call graph for this function:

◆ getRecord()

◆ getRecordRepresentation()

ilDclBaseRecordFieldModel::getRecordRepresentation ( )

◆ getSortingValue()

ilDclBaseRecordFieldModel::getSortingValue (   $link = true)

Definition at line 341 of file class.ilDclBaseRecordFieldModel.php.

References getValue(), and parseSortingValue().

342  {
343  return $this->parseSortingValue($this->getValue(), $this, $link);
344  }
parseSortingValue($value, $link=true)
Returns sortable value for the specific field-types.
+ Here is the call graph for this function:

◆ getValue()

◆ getValueForRepresentation()

ilDclBaseRecordFieldModel::getValueForRepresentation ( )
Returns
array|string

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

References getValue().

188  {
189  return $this->getValue();
190  }
+ Here is the call graph for this function:

◆ getValueFromExcel()

ilDclBaseRecordFieldModel::getValueFromExcel (   $excel,
  $row,
  $col 
)
Parameters
$excel
$row
$col
Returns
array|string

Definition at line 290 of file class.ilDclBaseRecordFieldModel.php.

References $row, and $value.

291  {
292  $value = $excel->getCell($row, $col);
293 
294  return $value;
295  }
$row

◆ loadValue()

ilDclBaseRecordFieldModel::loadValue ( )
protected

Load the value.

Definition at line 381 of file class.ilDclBaseRecordFieldModel.php.

References $query, $value, deserializeData(), and getField().

Referenced by doRead(), getValue(), ilDclFileuploadRecordFieldModel\setValue(), and setValue().

382  {
383  if ($this->value === null) {
384  $datatype = $this->getField()->getDatatype();
385 
386  $storage_location = ($this->getField()->getStorageLocationOverride() !== null) ? $this->getField()->getStorageLocationOverride() : $datatype->getStorageLocation();
387  if ($storage_location != 0) {
388  $query = "SELECT * FROM il_dcl_stloc" . $storage_location . "_value WHERE record_field_id = "
389  . $this->db->quote($this->id, "integer");
390 
391  $set = $this->db->query($query);
392  $rec = $this->db->fetchAssoc($set);
393  $value = $this->deserializeData($rec['value']);
394  $this->value = $value;
395  }
396  }
397  }
deserializeData($value)
Deserialize data before applying to field.
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseExportValue()

ilDclBaseRecordFieldModel::parseExportValue (   $value)

Function to parse incoming data from form input value $value.

returns the string/number/etc. to store in the database.

Parameters
mixed$value
Returns
mixed

Definition at line 277 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by getExportValue().

+ Here is the caller graph for this function:

◆ parseSortingValue()

ilDclBaseRecordFieldModel::parseSortingValue (   $value,
  $link = true 
)

Returns sortable value for the specific field-types.

Parameters
$value
ilDclBaseRecordFieldModel$record_field
bool | true$link
Returns
int|string

Definition at line 372 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by getSortingValue().

+ Here is the caller graph for this function:

◆ parseValue()

ilDclBaseRecordFieldModel::parseValue (   $value)

Function to parse incoming data from form input value $value.

returns the string/number/etc. to store in the database.

Parameters
$value
Returns
int|string

Definition at line 305 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by ilDclFileuploadRecordFieldModel\setValue(), and setValue().

+ Here is the caller graph for this function:

◆ serializeData()

ilDclBaseRecordFieldModel::serializeData (   $value)

Serialize data before storing to db.

Parameters
$valuemixed
Returns
mixed

Definition at line 200 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by doUpdate().

201  {
202  if (is_array($value)) {
203  $value = json_encode($value);
204  }
205 
206  return $value;
207  }
+ Here is the caller graph for this function:

◆ setFieldRepresentation()

ilDclBaseRecordFieldModel::setFieldRepresentation (   $field_representation)
Parameters
ilDclBaseFieldRepresentation$field_representation

Definition at line 475 of file class.ilDclBaseRecordFieldModel.php.

References $field_representation.

476  {
477  $this->field_representation = $field_representation;
478  }

◆ setRecordRepresentation()

ilDclBaseRecordFieldModel::setRecordRepresentation (   $record_representation)
Parameters
ilDclBaseRecordRepresentation$record_representation

Definition at line 457 of file class.ilDclBaseRecordFieldModel.php.

References $record_representation.

458  {
459  $this->record_representation = $record_representation;
460  }

◆ setValue()

ilDclBaseRecordFieldModel::setValue (   $value,
  $omit_parsing = false 
)

Set value for record field.

Parameters
mixed$value
bool$omit_parsingIf true, does not parse the value and stores it in the given format

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

References $value, loadValue(), and parseValue().

Referenced by ilDclReferenceRecordFieldModel\afterClone(), ilDclMobRecordFieldModel\afterClone(), ilDclNReferenceFieldGUI\buildTemplate(), cloneStructure(), ilDclTextRecordFieldModel\setValueFromForm(), ilDclMobRecordFieldModel\setValueFromForm(), and setValueFromForm().

235  {
236  $this->loadValue();
237  if (!$omit_parsing) {
238  $tmp = $this->parseValue($value, $this);
239  $old = $this->value;
240  //if parse value fails keep the old value
241  if ($tmp !== false) {
242  $this->value = $tmp;
243  }
244  } else {
245  $this->value = $value;
246  }
247  }
parseValue($value)
Function to parse incoming data from form input value $value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValueFromForm()

ilDclBaseRecordFieldModel::setValueFromForm (   $form)
Parameters
$formilPropertyFormGUI

Definition at line 253 of file class.ilDclBaseRecordFieldModel.php.

References $form, $value, getField(), getId(), and setValue().

254  {
255  $value = $form->getInput("field_" . $this->getField()->getId());
256 
257  $this->setValue($value);
258  }
setValue($value, $omit_parsing=false)
Set value for record field.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilDclBaseRecordFieldModel::$ctrl
protected

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

◆ $db

ilDclBaseRecordFieldModel::$db
protected

Definition at line 56 of file class.ilDclBaseRecordFieldModel.php.

◆ $field

◆ $field_representation

ilDclBaseRecordFieldModel::$field_representation
protected

◆ $id

ilDclBaseRecordFieldModel::$id
protected

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

Referenced by doCreate(), and getId().

◆ $lng

◆ $record

◆ $record_representation

ilDclBaseRecordFieldModel::$record_representation
protected

◆ $user

ilDclBaseRecordFieldModel::$user
protected

Definition at line 48 of file class.ilDclBaseRecordFieldModel.php.

◆ $value

ilDclBaseRecordFieldModel::$value
protected

Definition at line 44 of file class.ilDclBaseRecordFieldModel.php.

Referenced by ilDclTextRecordFieldModel\addHiddenItemsToConfirmation(), ilDclFileuploadRecordFieldModel\addHiddenItemsToConfirmation(), ilDclMobRecordFieldModel\addHiddenItemsToConfirmation(), addHiddenItemsToConfirmation(), deserializeData(), ilDclNReferenceRecordFieldModel\doUpdate(), doUpdate(), ilDclTextRecordFieldModel\fillExcelExport(), ilDclReferenceRecordFieldModel\getExportValue(), ilDclTextRecordFieldModel\getExportValue(), ilDclNReferenceRecordFieldModel\getExportValue(), ilDclNReferenceRecordFieldModel\getLinkHTML(), ilDclTextRecordFieldModel\getPlainText(), ilDclReferenceRecordFieldModel\getReferenceFromValue(), ilDclSelectionRecordFieldModel\getValue(), ilDclNReferenceRecordFieldModel\getValue(), getValue(), ilDclDatetimeRecordFieldModel\getValueFromExcel(), ilDclReferenceRecordFieldModel\getValueFromExcel(), ilDclTextRecordFieldModel\getValueFromExcel(), getValueFromExcel(), loadValue(), ilDclBooleanRecordFieldModel\parseExportValue(), ilDclDatetimeRecordFieldModel\parseExportValue(), ilDclSelectionRecordFieldModel\parseExportValue(), ilDclMobRecordFieldModel\parseExportValue(), ilDclFileuploadRecordFieldModel\parseExportValue(), parseExportValue(), ilDclDatetimeRecordFieldModel\parseSortingValue(), ilDclTextRecordFieldModel\parseSortingValue(), ilDclFileuploadRecordFieldModel\parseSortingValue(), ilDclMobRecordFieldModel\parseSortingValue(), parseSortingValue(), ilDclNumberRecordFieldModel\parseValue(), ilDclMobRecordFieldModel\parseValue(), ilDclBooleanRecordFieldModel\parseValue(), ilDclDatetimeRecordFieldModel\parseValue(), ilDclTextRecordFieldModel\parseValue(), parseValue(), serializeData(), ilDclFormulaRecordFieldModel\setValue(), ilDclFileuploadRecordFieldModel\setValue(), setValue(), ilDclTextRecordFieldModel\setValueFromForm(), ilDclFileuploadRecordFieldModel\setValueFromForm(), ilDclMobRecordFieldModel\setValueFromForm(), and setValueFromForm().


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