ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 65 of file class.ilDclBaseRecordFieldModel.php.

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

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

Member Function Documentation

◆ addHiddenItemsToConfirmation()

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

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

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

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

◆ afterClone()

ilDclBaseRecordFieldModel::afterClone ( )

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

412  {
413  }

◆ cloneStructure()

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

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

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

402  {
403  $this->setValue($old_record_field->getValue());
404  $this->doUpdate();
405  }
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 155 of file class.ilDclBaseRecordFieldModel.php.

References $query, and getField().

156  {
157  $datatype = $this->getField()->getDatatype();
158  $storage_location = ($this->getField()->getStorageLocationOverride() !== null) ? $this->getField()->getStorageLocationOverride() : $datatype->getStorageLocation();
159 
160  if ($storage_location != 0) {
161  $query = "DELETE FROM il_dcl_stloc" . $storage_location . "_value WHERE record_field_id = "
162  . $this->db->quote($this->id, "integer");
163  $this->db->manipulate($query);
164  }
165 
166  $query2 = "DELETE FROM il_dcl_record_field WHERE id = " . $this->db->quote($this->id, "integer");
167  $this->db->manipulate($query2);
168  }
$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 215 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by loadValue().

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

◆ doCreate()

ilDclBaseRecordFieldModel::doCreate ( )

Creates an Id and a database entry.

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

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

Referenced by doUpdate().

105  {
106  $id = $this->db->nextId("il_dcl_record_field");
107  $query = "INSERT INTO il_dcl_record_field (id, record_id, field_id) VALUES (" . $this->db->quote($id, "integer") . ", "
108  . $this->db->quote($this->getRecord()->getId(), "integer") . ", " . $this->db->quote($this->getField()->getId(), "text") . ")";
109  $this->db->manipulate($query);
110  $this->id = $id;
111  }
$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 85 of file class.ilDclBaseRecordFieldModel.php.

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

Referenced by __construct().

86  {
87  if (!$this->getRecord()->getId()) {
88  return;
89  }
90 
91  $query = "SELECT * FROM il_dcl_record_field WHERE field_id = " . $this->db->quote($this->getField()->getId(), "integer") . " AND record_id = "
92  . $this->db->quote($this->getRecord()->getId(), "integer");
93  $set = $this->db->query($query);
94  $rec = $this->db->fetchAssoc($set);
95  $this->id = $rec['id'];
96 
97  $this->loadValue();
98  }
$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 117 of file class.ilDclBaseRecordFieldModel.php.

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

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

118  {
119  //$this->loadValue(); //Removed Mantis #0011799
120  $datatype = $this->getField()->getDatatype();
121  $storage_location = ($this->getField()->getStorageLocationOverride() !== null) ? $this->getField()->getStorageLocationOverride() : $datatype->getStorageLocation();
122 
123  if ($storage_location != 0) {
124  $query = "DELETE FROM il_dcl_stloc" . $storage_location . "_value WHERE record_field_id = "
125  . $this->db->quote($this->id, "integer");
126  $this->db->manipulate($query);
127 
128  $next_id = $this->db->nextId("il_dcl_stloc" . $storage_location . "_value");
129 
130  // This is a workaround to ensure that date values in stloc3 are never stored as NULL, which is not allowed
131  if ($storage_location == 3 && (is_null($this->value) || empty($this->value))) {
132  $this->value = '0000-00-00 00:00:00';
133  }
134 
135  $value = $this->serializeData($this->value);
136 
137  if ($this->getId() == 0) {
138  $this->doCreate();
139  }
140 
141  $insert_params = array(
142  "value" => array($datatype->getDbType(), $value),
143  "record_field_id" => array("integer", $this->getId()),
144  "id" => array("integer", $next_id),
145  );
146 
147  $this->db->insert("il_dcl_stloc" . $storage_location . "_value", $insert_params);
148  }
149  }
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 323 of file class.ilDclBaseRecordFieldModel.php.

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

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

◆ getExportValue()

ilDclBaseRecordFieldModel::getExportValue ( )
Returns
int|string

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

References getValue(), and parseExportValue().

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

313  {
314  return $this->parseExportValue($this->getValue());
315  }
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 419 of file class.ilDclBaseRecordFieldModel.php.

References $field.

Referenced by ilDclIliasReferenceRecordFieldModel\__construct(), ilDclRatingRecordFieldModel\__construct(), ilDclReferenceRecordFieldModel\__construct(), ilDclFormulaRecordFieldModel\__construct(), ilDclReferenceRecordFieldModel\afterClone(), ilDclFileuploadRecordFieldModel\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 262 of file class.ilDclBaseRecordFieldModel.php.

References getExportValue().

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

◆ getId()

◆ getPlainText()

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

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

References getExportValue().

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

◆ getRecord()

◆ getRecordRepresentation()

ilDclBaseRecordFieldModel::getRecordRepresentation ( )

◆ getSortingValue()

ilDclBaseRecordFieldModel::getSortingValue (   $link = true)

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

References getValue(), and parseSortingValue().

340  {
341  return $this->parseSortingValue($this->getValue(), $this, $link);
342  }
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 185 of file class.ilDclBaseRecordFieldModel.php.

References getValue().

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

◆ getValueFromExcel()

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

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

References $value.

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

◆ loadValue()

ilDclBaseRecordFieldModel::loadValue ( )
protected

Load the value.

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

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

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

380  {
381  if ($this->value === null) {
382  $datatype = $this->getField()->getDatatype();
383 
384  $storage_location = ($this->getField()->getStorageLocationOverride() !== null) ? $this->getField()->getStorageLocationOverride() : $datatype->getStorageLocation();
385  if ($storage_location != 0) {
386  $query = "SELECT * FROM il_dcl_stloc" . $storage_location . "_value WHERE record_field_id = "
387  . $this->db->quote($this->id, "integer");
388 
389  $set = $this->db->query($query);
390  $rec = $this->db->fetchAssoc($set);
391  $value = $this->deserializeData($rec['value']);
392  $this->value = $value;
393  }
394  }
395  }
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 275 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 370 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 303 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 198 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by doUpdate().

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

◆ setFieldRepresentation()

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

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

References $field_representation.

474  {
475  $this->field_representation = $field_representation;
476  }

◆ setRecordRepresentation()

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

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

References $record_representation.

456  {
457  $this->record_representation = $record_representation;
458  }

◆ 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 232 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().

233  {
234  $this->loadValue();
235  if (!$omit_parsing) {
236  $tmp = $this->parseValue($value, $this);
237  $old = $this->value;
238  //if parse value fails keep the old value
239  if ($tmp !== false) {
240  $this->value = $tmp;
241  }
242  } else {
243  $this->value = $value;
244  }
245  }
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 251 of file class.ilDclBaseRecordFieldModel.php.

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

252  {
253  $value = $form->getInput("field_" . $this->getField()->getId());
254 
255  $this->setValue($value);
256  }
setValue($value, $omit_parsing=false)
Set value for record field.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilDclBaseRecordFieldModel::$ctrl
protected

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

◆ $db

ilDclBaseRecordFieldModel::$db
protected

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

◆ $field

◆ $field_representation

ilDclBaseRecordFieldModel::$field_representation
protected

◆ $id

ilDclBaseRecordFieldModel::$id
protected

Definition at line 22 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 46 of file class.ilDclBaseRecordFieldModel.php.

◆ $value

ilDclBaseRecordFieldModel::$value
protected

Definition at line 42 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(), ilDclFileuploadRecordFieldModel\parseExportValue(), ilDclMobRecordFieldModel\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: