ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
 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 68 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  }
doRead()
Read object data from database.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
global $ilDB
global $DIC
+ Here is the call graph for this function:

Member Function Documentation

◆ addHiddenItemsToConfirmation()

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

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

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

309  {;
310  if (!is_array($this->getValue())) {
311  $confirmation->addHiddenItem('field_'.$this->field->getId(), $this->getValue());
312  } else {
313  foreach ($this->getValue() as $key => $value) {
314  $confirmation->addHiddenItem('field_'.$this->field->getId() . "[$key]", $value);
315  }
316  }
317  }
addHiddenItem($a_post_var, $a_value)
Add hidden item.
+ Here is the call graph for this function:

◆ afterClone()

ilDclBaseRecordFieldModel::afterClone ( )

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

365  {
366 
367  }

◆ cloneStructure()

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

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

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

356  {
357  $this->setValue($old_record_field->getValue());
358  $this->doUpdate();
359  }
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 153 of file class.ilDclBaseRecordFieldModel.php.

References $query, and getField().

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

References $value.

Referenced by loadValue().

205  {
206  $deserialize = json_decode($value, true);
207  if(is_array($deserialize)) {
208  return $deserialize;
209  }
210  return $value;
211  }
+ 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().

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

87  {
88  if(!$this->getRecord()->getId())
89  return;
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  }
+ 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 116 of file class.ilDclBaseRecordFieldModel.php.

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

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

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

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

289  {
290  $worksheet->setCell($row, $col, $this->getExportValue());
291  $col ++;
292  }
setCell($a_row, $a_col, $a_value)
Set cell value.
+ Here is the call graph for this function:

◆ getExportValue()

ilDclBaseRecordFieldModel::getExportValue ( )
Returns
int|string

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

References getValue(), and parseExportValue().

Referenced by fillExcelExport(), and getPlainText().

280  {
281  return $this->parseExportValue($this->getValue());
282  }
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 373 of file class.ilDclBaseRecordFieldModel.php.

References $field.

Referenced by ilDclIliasReferenceRecordFieldModel\__construct(), ilDclRatingRecordFieldModel\__construct(), ilDclReferenceRecordFieldModel\__construct(), ilDclFormulaRecordFieldModel\__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(), ilDclFieldFactory\getRecordRepresentationInstance(), ilDclReferenceRecordFieldModel\getReferenceFromValue(), ilDclRatingRecordFieldModel\getValue(), ilDclReferenceRecordFieldModel\getValueFromExcel(), ilDclTextRecordFieldModel\getValueFromExcel(), ilDclNReferenceRecordFieldModel\loadValue(), loadValue(), ilDclNReferenceRecordFieldModel\loadValueSorted(), ilDclFormulaRecordFieldModel\parse(), ilDclTextRecordFieldModel\parseSortingValue(), ilDclFileuploadRecordFieldModel\parseValue(), ilDclMobRecordFieldModel\parseValue(), ilDclTextRecordFieldModel\parseValue(), ilDclTextRecordFieldModel\setValueFromForm(), ilDclFileuploadRecordFieldModel\setValueFromForm(), ilDclMobRecordFieldModel\setValueFromForm(), and setValueFromForm().

+ Here is the caller graph for this function:

◆ getFieldRepresentation()

ilDclBaseRecordFieldModel::getFieldRepresentation ( )

◆ getId()

◆ getPlainText()

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

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

References getExportValue().

297  {
298  return $this->getExportValue();
299  }
+ Here is the call graph for this function:

◆ getRecord()

◆ getRecordRepresentation()

ilDclBaseRecordFieldModel::getRecordRepresentation ( )

◆ getSortingValue()

ilDclBaseRecordFieldModel::getSortingValue (   $link = true)

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

References getValue(), and parseSortingValue().

301  {
302  return $this->parseSortingValue($this->getValue(), $this, $link);
303  }
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 181 of file class.ilDclBaseRecordFieldModel.php.

References getValue().

181  {
182  return $this->getValue();
183  }
+ Here is the call graph for this function:

◆ getValueFromExcel()

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

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

References $row, and $value.

259  {
260  $value = $excel->getCell($row, $col);
261 
262  return $value;
263  }

◆ loadValue()

ilDclBaseRecordFieldModel::loadValue ( )
protected

Load the value.

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

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

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

335  {
336  if ($this->value === NULL) {
337  $datatype = $this->getField()->getDatatype();
338 
339  $storage_location = ($this->getField()->getStorageLocationOverride() !== null)? $this->getField()->getStorageLocationOverride() : $datatype->getStorageLocation();
340  if($storage_location != 0) {
341  $query = "SELECT * FROM il_dcl_stloc" . $storage_location . "_value WHERE record_field_id = "
342  . $this->db->quote($this->id, "integer");
343 
344  $set = $this->db->query($query);
345  $rec = $this->db->fetchAssoc($set);
346  $value = $this->deserializeData($rec['value']);
347  $this->value = $value;
348  }
349  }
350  }
deserializeData($value)
Deserialize data before applying to field.
+ 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 249 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 328 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 272 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by 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 191 of file class.ilDclBaseRecordFieldModel.php.

References $value.

Referenced by doUpdate().

191  {
192  if(is_array($value)) {
193  $value = json_encode($value);
194  }
195  return $value;
196  }
+ Here is the caller graph for this function:

◆ setFieldRepresentation()

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

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

References $field_representation.

420  {
421  $this->field_representation = $field_representation;
422  }

◆ setRecordRepresentation()

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

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

References $record_representation.

404  {
405  $this->record_representation = $record_representation;
406  }

◆ 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 219 of file class.ilDclBaseRecordFieldModel.php.

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

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

219  {
220  $this->loadValue();
221  if (! $omit_parsing) {
222  $tmp = $this->parseValue($value, $this);
223  $old = $this->value;
224  //if parse value fails keep the old value
225  if ($tmp !== false) {
226  $this->value = $tmp;
227  }
228  } else {
229  $this->value = $value;
230  }
231  }
parseValue($value)
Function to parse incoming data from form input value $value.
$old
+ 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 236 of file class.ilDclBaseRecordFieldModel.php.

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

236  {
237  $value = $form->getInput("field_" . $this->getField()->getId());
238 
239  $this->setValue($value);
240  }
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 53 of file class.ilDclBaseRecordFieldModel.php.

◆ $db

ilDclBaseRecordFieldModel::$db
protected

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

◆ $field

◆ $field_representation

ilDclBaseRecordFieldModel::$field_representation
protected

◆ $id

ilDclBaseRecordFieldModel::$id
protected

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

◆ $value

ilDclBaseRecordFieldModel::$value
protected

Definition at line 45 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(), ilDclNReferenceRecordFieldModel\getValue(), getValue(), ilDclDatetimeRecordFieldModel\getValueFromExcel(), ilDclReferenceRecordFieldModel\getValueFromExcel(), ilDclTextRecordFieldModel\getValueFromExcel(), getValueFromExcel(), loadValue(), ilDclBooleanRecordFieldModel\parseExportValue(), ilDclDatetimeRecordFieldModel\parseExportValue(), ilDclFileuploadRecordFieldModel\parseExportValue(), ilDclMobRecordFieldModel\parseExportValue(), parseExportValue(), ilDclDatetimeRecordFieldModel\parseSortingValue(), ilDclTextRecordFieldModel\parseSortingValue(), ilDclFileuploadRecordFieldModel\parseSortingValue(), ilDclMobRecordFieldModel\parseSortingValue(), parseSortingValue(), ilDclNumberRecordFieldModel\parseValue(), ilDclFileuploadRecordFieldModel\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: