ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilDataCollectionRecordField Class Reference

Class ilDataCollectionField. More...

+ Inheritance diagram for ilDataCollectionRecordField:
+ Collaboration diagram for ilDataCollectionRecordField:

Public Member Functions

 __construct (ilDataCollectionRecord $record, ilDataCollectionField $field)
 
 doUpdate ()
 Update object in database. More...
 
 delete ()
 Delete record field in database. More...
 
 getValue ()
 
 setValue ($value, $omit_parsing=false)
 Set value for record field. More...
 
 setValueFromForm (&$form)
 
 getValueFromExcel ($excel, $row, $col)
 
 fillFormInput (&$form)
 
 getExportValue ()
 
 fillExcelExport ($worksheet, &$row, &$col)
 
 getPlainText ()
 
 getHTML ($link=true)
 
 getSortingValue ($link=true)
 
 getSingleHTML ()
 
 getField ()
 
 getId ()
 
 getRecord ()
 

Protected Member Functions

 doRead ()
 Read object data from database. More...
 
 doCreate ()
 Creates an Id and a database entry. More...
 
 getFormInput ()
 
 loadValue ()
 Load the value. More...
 

Protected Attributes

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDataCollectionRecordField::__construct ( ilDataCollectionRecord  $record,
ilDataCollectionField  $field 
)
Parameters
ilDataCollectionRecord$record
ilDataCollectionField$field

Definition at line 58 of file class.ilDataCollectionRecordField.php.

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

58  {
59  global $ilCtrl, $ilUser, $ilDB, $lng;
60  $this->record = $record;
61  $this->field = $field;
62  $this->ctrl = $ilCtrl;
63  $this->user = $ilUser;
64  $this->db = $ilDB;
65  $this->lng = $lng;
66  $this->doRead();
67  }
global $ilCtrl
Definition: ilias.php:18
doRead()
Read object data from database.
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilDataCollectionRecordField::delete ( )

Delete record field in database.

Definition at line 133 of file class.ilDataCollectionRecordField.php.

References $query.

133  {
134  $datatype = $this->field->getDatatype();
135  $query = "DELETE FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
136  . $this->db->quote($this->id, "integer");
137  $this->db->manipulate($query);
138 
139  $query2 = "DELETE FROM il_dcl_record_field WHERE id = " . $this->db->quote($this->id, "integer");
140  $this->db->manipulate($query2);
141  }

◆ doCreate()

ilDataCollectionRecordField::doCreate ( )
protected

Creates an Id and a database entry.

Definition at line 94 of file class.ilDataCollectionRecordField.php.

References $id, and $query.

Referenced by doRead(), and doUpdate().

94  {
95  $id = $this->db->nextId("il_dcl_record_field");
96  $query = "INSERT INTO il_dcl_record_field (id, record_id, field_id) VALUES (" . $this->db->quote($id, "integer") . ", "
97  . $this->db->quote($this->record->getId(), "integer") . ", " . $this->db->quote($this->field->getId(), "text") . ")";
98  $this->db->manipulate($query);
99  $this->id = $id;
100  }
+ Here is the caller graph for this function:

◆ doRead()

ilDataCollectionRecordField::doRead ( )
protected

Read object data from database.

Definition at line 73 of file class.ilDataCollectionRecordField.php.

References $query, doCreate(), and loadValue().

Referenced by __construct().

73  {
74  if(!$this->record->getId())
75  return;
76 
77  $query = "SELECT * FROM il_dcl_record_field WHERE field_id = " . $this->db->quote($this->field->getId(), "integer") . " AND record_id = "
78  . $this->db->quote($this->record->getId(), "integer");
79  $set = $this->db->query($query);
80  $rec = $this->db->fetchAssoc($set);
81  $this->id = $rec['id'];
82 
83  if ($this->id == null) {
84  $this->doCreate();
85  }
86 
87  $this->loadValue();
88  }
doCreate()
Creates an Id and a database entry.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilDataCollectionRecordField::doUpdate ( )

Update object in database.

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

References $query, $value, and doCreate().

106  {
107  //$this->loadValue(); //Removed Mantis #0011799
108  if (!$this->id) {
109  $this->doCreate();
110  }
111  $datatype = $this->field->getDatatype();
112  $query = "DELETE FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
113  . $this->db->quote($this->id, "integer");
114  $this->db->manipulate($query);
115  $next_id = $this->db->nextId("il_dcl_stloc" . $datatype->getStorageLocation() . "_value");
116 
117  // This is a workaround to ensure that date values in stloc3 are never stored as NULL, which is not allowed
118  if ($datatype->getStorageLocation() == 3 && (is_null($this->value) || empty($this->value))) {
119  $this->value = '0000-00-00 00:00:00';
120  }
121 
122  $this->db->insert("il_dcl_stloc" . $datatype->getStorageLocation() . "_value", array(
123  "value" => array( $datatype->getDbType(), $this->value ),
124  "record_field_id " => array( "integer", $this->id ),
125  "id" => array( "integer", $next_id )
126  ));
127  }
doCreate()
Creates an Id and a database entry.
+ Here is the call graph for this function:

◆ fillExcelExport()

ilDataCollectionRecordField::fillExcelExport (   $worksheet,
$row,
$col 
)
Parameters
$worksheet
$row
$col

Definition at line 243 of file class.ilDataCollectionRecordField.php.

References $row, and getExportValue().

243  {
244  $worksheet->writeString($row, $col, $this->getExportValue());
245  $col ++;
246  }
+ Here is the call graph for this function:

◆ fillFormInput()

ilDataCollectionRecordField::fillFormInput ( $form)
Parameters
$formilPropertyFormGUI

Definition at line 213 of file class.ilDataCollectionRecordField.php.

References $value, and getFormInput().

213  {
214  $value = $this->getFormInput();
215  $form->getItemByPostVar('field_'.$this->field->getId())->setValueByArray(array("field_".$this->field->getId() => $value));
216  }
+ Here is the call graph for this function:

◆ getExportValue()

ilDataCollectionRecordField::getExportValue ( )
Returns
int|string

Definition at line 232 of file class.ilDataCollectionRecordField.php.

References getValue().

Referenced by fillExcelExport(), and getPlainText().

232  {
233  $datatype = $this->field->getDatatype();
234 
235  return $datatype->parseExportValue($this->getValue());
236  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getField()

◆ getFormInput()

ilDataCollectionRecordField::getFormInput ( )
protected
Returns
mixed

Definition at line 222 of file class.ilDataCollectionRecordField.php.

References getValue().

Referenced by fillFormInput().

222  {
223  $datatype = $this->field->getDatatype();
224 
225  return $datatype->parseFormInput($this->getValue(), $this);
226  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilDataCollectionRecordField::getHTML (   $link = true)
Returns
string

Definition at line 260 of file class.ilDataCollectionRecordField.php.

References getValue().

Referenced by ilDataCollectionReferenceField\__construct(), and getSingleHTML().

260  {
261  $datatype = $this->field->getDatatype();
262 
263  return $datatype->parseHTML($this->getValue(), $this, $link);
264  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilDataCollectionRecordField::getId ( )

◆ getPlainText()

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

Definition at line 252 of file class.ilDataCollectionRecordField.php.

References getExportValue().

252  {
253  return $this->getExportValue();
254  }
+ Here is the call graph for this function:

◆ getRecord()

◆ getSingleHTML()

ilDataCollectionRecordField::getSingleHTML ( )
Returns
string This method is used in the view definition of a single record (detail view)

Definition at line 279 of file class.ilDataCollectionRecordField.php.

References getHTML().

279  {
280  return $this->getHTML(false);
281  }
+ Here is the call graph for this function:

◆ getSortingValue()

ilDataCollectionRecordField::getSortingValue (   $link = true)
Returns
string

Definition at line 269 of file class.ilDataCollectionRecordField.php.

References getValue().

269  {
270  $datatype = $this->field->getDatatype();
271 
272  return $datatype->parseSortingValue($this->getValue(), $this, $link);
273  }
+ Here is the call graph for this function:

◆ getValue()

◆ getValueFromExcel()

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

Definition at line 199 of file class.ilDataCollectionRecordField.php.

References $row, $value, and ilDataCollectionDatatype\INPUTFORMAT_DATETIME.

199  {
200  $value = $excel->val($row, $col);
201  if ($this->field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
202  $value = array(
203  'date' => date('Y-m-d', strtotime($value)),
204  'time' => '00:00:00',
205  );
206  }
207  return $value;
208  }

◆ loadValue()

ilDataCollectionRecordField::loadValue ( )
protected

Load the value.

Definition at line 287 of file class.ilDataCollectionRecordField.php.

References $query, and ilDataCollectionDatatype\INPUTFORMAT_RATING.

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

287  {
288  if ($this->value === NULL) {
289  $datatype = $this->field->getDatatype();
290  switch ($datatype->getId()) {
292  return true;
293  }
294  $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
295  . $this->db->quote($this->id, "integer");
296 
297  $set = $this->db->query($query);
298  $rec = $this->db->fetchAssoc($set);
299  $this->value = $rec['value'];
300  }
301  }
+ Here is the caller graph for this function:

◆ setValue()

ilDataCollectionRecordField::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 160 of file class.ilDataCollectionRecordField.php.

References $value, ilDataCollectionDatatype\INPUTFORMAT_FILE, and loadValue().

Referenced by ilDataCollectionNReferenceFieldGUI\buildTemplate(), ilDataCollectionTextField\fillFormInput(), ilDataCollectionTextField\setValueFromForm(), and setValueFromForm().

160  {
161  $this->loadValue();
162  if (! $omit_parsing) {
163  $tmp = $this->field->getDatatype()->parseValue($value, $this);
164  $old = $this->value;
165  //if parse value fails keep the old value
166  if ($tmp !== false) {
167  $this->value = $tmp;
168  //delete old file from filesystem
169  // TODO Does not belong here, create separate class ilDataCollectionFileField and overwrite setValue method
170  if ($old && $this->field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_FILE) {
171 // $this->record->deleteFile($old); // Removed due to #0018064
172  }
173  }
174  } else {
175  $this->value = $value;
176  }
177  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValueFromForm()

ilDataCollectionRecordField::setValueFromForm ( $form)
Parameters
$formilPropertyFormGUI

Definition at line 182 of file class.ilDataCollectionRecordField.php.

References $value, ilDataCollectionDatatype\INPUTFORMAT_FILE, ilDataCollectionDatatype\INPUTFORMAT_MOB, and setValue().

182  {
183  if (in_array($this->field->getDatatypeId(), array(ilDataCollectionDatatype::INPUTFORMAT_MOB, ilDataCollectionDatatype::INPUTFORMAT_FILE))
184  && $form->getItemByPostVar("field_" . $this->field->getId())->getDeletionFlag()
185  ) {
186  $value = - 1;
187  } else {
188  $value = $form->getInput("field_" . $this->field->getId());
189  }
190  $this->setValue($value);
191  }
setValue($value, $omit_parsing=false)
Set value for record field.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilDataCollectionRecordField::$ctrl
protected

Definition at line 43 of file class.ilDataCollectionRecordField.php.

◆ $db

ilDataCollectionRecordField::$db
protected

Definition at line 47 of file class.ilDataCollectionRecordField.php.

◆ $field

ilDataCollectionRecordField::$field
protected

◆ $id

ilDataCollectionRecordField::$id
protected

◆ $lng

◆ $record

ilDataCollectionRecordField::$record
protected

◆ $user

ilDataCollectionRecordField::$user
protected

Definition at line 39 of file class.ilDataCollectionRecordField.php.

◆ $value


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