ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 getFormInput ()
 
 getExportValue ()
 
 getPlainText ()
 
 getHTML ($link=true)
 
 getSortingValue ($link=true)
 
 getSingleHTML ()
 
 getField ()
 
 getId ()
 
 getRecord ()
 

Protected Member Functions

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

Protected Attributes

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

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 $lng, $ilCtrl, $ilUser, $ilDB;
60  $this->record = $record;
61  $this->field = $field;
62  $this->lng = $lng;
63  $this->ctrl = $ilCtrl;
64  $this->user = $ilUser;
65  $this->db = $ilDB;
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 126 of file class.ilDataCollectionRecordField.php.

References $query.

126  {
127  $datatype = $this->field->getDatatype();
128  $query = "DELETE FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
129  . $this->db->quote($this->id, "integer");
130  $this->db->manipulate($query);
131 
132  $query2 = "DELETE FROM il_dcl_record_field WHERE id = " . $this->db->quote($this->id, "integer");
133  $this->db->manipulate($query2);
134  }

◆ doCreate()

ilDataCollectionRecordField::doCreate ( )
protected

Create object in database.

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

References $id, and $query.

Referenced by doRead().

90  {
91  $id = $this->db->nextId("il_dcl_record_field");
92  $query = "INSERT INTO il_dcl_record_field (id, record_id, field_id) VALUES (" . $this->db->quote($id, "integer") . ", "
93  . $this->db->quote($this->record->getId(), "integer") . ", " . $this->db->quote($this->field->getId(), "text") . ")";
94  $this->db->manipulate($query);
95  $this->id = $id;
96  }
+ 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  $query = "SELECT * FROM il_dcl_record_field WHERE field_id = " . $this->db->quote($this->field->getId(), "integer") . " AND record_id = "
75  . $this->db->quote($this->record->getId(), "integer");
76  $set = $this->db->query($query);
77  $rec = $this->db->fetchAssoc($set);
78  $this->id = $rec['id'];
79 
80  if ($this->id == NULL) {
81  $this->doCreate();
82  }
83  $this->loadValue();
84  }
+ 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 102 of file class.ilDataCollectionRecordField.php.

References $query, and $value.

102  {
103  //$this->loadValue(); //Removed Mantis #0011799
104  $datatype = $this->field->getDatatype();
105  $query = "DELETE FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
106  . $this->db->quote($this->id, "integer");
107  $this->db->manipulate($query);
108  $next_id = $this->db->nextId("il_dcl_stloc" . $datatype->getStorageLocation() . "_value");
109 
110  // This is a workaround to ensure that date values in stloc3 are never stored as NULL, which is not allowed
111  if ($datatype->getStorageLocation() == 3 && (is_null($this->value) || empty($this->value))) {
112  $this->value = '0000-00-00 00:00:00';
113  }
114 
115  $this->db->insert("il_dcl_stloc" . $datatype->getStorageLocation() . "_value", array(
116  "value" => array( $datatype->getDbType(), $this->value ),
117  "record_field_id " => array( "integer", $this->id ),
118  "id" => array( "integer", $next_id )
119  ));
120  }

◆ getExportValue()

ilDataCollectionRecordField::getExportValue ( )
Returns
int|string

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

References getValue().

Referenced by getPlainText().

186  {
187  $datatype = $this->field->getDatatype();
188 
189  return $datatype->parseExportValue($this->getValue());
190  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getField()

◆ getFormInput()

ilDataCollectionRecordField::getFormInput ( )
Returns
mixed

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

References getValue().

176  {
177  $datatype = $this->field->getDatatype();
178 
179  return $datatype->parseFormInput($this->getValue(), $this);
180  }
+ Here is the call graph for this function:

◆ getHTML()

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

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

References getValue().

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

204  {
205  $datatype = $this->field->getDatatype();
206 
207  return $datatype->parseHTML($this->getValue(), $this, $link);
208  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

◆ getPlainText()

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

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

References getExportValue().

196  {
197  return $this->getExportValue();
198  }
+ 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 224 of file class.ilDataCollectionRecordField.php.

References getHTML().

224  {
225  return $this->getHTML(false);
226  }
+ Here is the call graph for this function:

◆ getSortingValue()

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

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

References getValue().

213  {
214  $datatype = $this->field->getDatatype();
215 
216  return $datatype->parseSortingValue($this->getValue(), $this, $link);
217  }
+ Here is the call graph for this function:

◆ getValue()

◆ loadValue()

ilDataCollectionRecordField::loadValue ( )
protected

Load the value.

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

References $query, and ilDataCollectionDatatype\INPUTFORMAT_RATING.

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

232  {
233  if ($this->value === NULL) {
234  $datatype = $this->field->getDatatype();
235  switch ($datatype->getId()) {
237  return true;
238  }
239  $query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
240  . $this->db->quote($this->id, "integer");
241 
242  $set = $this->db->query($query);
243  $rec = $this->db->fetchAssoc($set);
244  $this->value = $rec['value'];
245  }
246  }
+ 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 153 of file class.ilDataCollectionRecordField.php.

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

153  {
154  $this->loadValue();
155  if (! $omit_parsing) {
156  $tmp = $this->field->getDatatype()->parseValue($value, $this);
157  $old = $this->value;
158  //if parse value fails keep the old value
159  if ($tmp !== false) {
160  $this->value = $tmp;
161  //delete old file from filesystem
162  // TODO Does not belong here, create separate class ilDataCollectionFileField and overwrite setValue method
163  if ($old && $old != $this->value && $this->field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_FILE) {
164  $this->record->deleteFile($old);
165  }
166  }
167  } else {
168  $this->value = $value;
169  }
170  }
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilDataCollectionRecordField::$ctrl
protected

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

◆ $db

ilDataCollectionRecordField::$db
protected

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

◆ $field

ilDataCollectionRecordField::$field
protected

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

Referenced by __construct(), and getField().

◆ $id

ilDataCollectionRecordField::$id
protected

◆ $lng

ilDataCollectionRecordField::$lng
protected

◆ $record

ilDataCollectionRecordField::$record
protected

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

Referenced by __construct(), and getRecord().

◆ $user

ilDataCollectionRecordField::$user
protected

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

◆ $value


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