21 if (!is_array($values)) {
22 $values = array( $values );
24 $datatype = $this->field->getDatatype();
26 $query =
"DELETE FROM il_dcl_stloc" . $datatype->getStorageLocation() .
"_value WHERE record_field_id = "
27 . $ilDB->quote($this->
id,
"integer");
30 if (!count($values) || $values[0] == 0) {
34 $query =
"INSERT INTO il_dcl_stloc" . $datatype->getStorageLocation() .
"_value (value, record_field_id, id) VALUES";
35 foreach ($values as
$value) {
36 $next_id = $ilDB->nextId(
"il_dcl_stloc" . $datatype->getStorageLocation() .
"_value");
37 $query .=
" (" . $ilDB->quote($value, $datatype->getDbType()) .
", " . $ilDB->quote($this->getId(),
"integer") .
", "
38 . $ilDB->quote($next_id,
"integer") .
"),";
46 if ($this->value === NULL) {
48 $datatype = $this->field->getDatatype();
49 $query =
"SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() .
"_value WHERE record_field_id = "
50 . $ilDB->quote($this->
id,
"integer");
51 $set = $ilDB->query(
$query);
52 $this->value = array();
53 while ($rec = $ilDB->fetchAssoc($set)) {
54 $this->value[] = $rec[
'value'];
69 $record_field = $this;
71 if (!$values || !count($values)) {
89 $tpl =
new ilTemplate(
"tpl.reference_list.html",
true,
true,
"Modules/DataCollection");
90 $tpl->setCurrentBlock(
"reference_list");
91 foreach ($values as
$value) {
93 if (!$ref_record->getTableId() || !$record_field->getField() || !$record_field->getField()->getTableId()) {
95 $record_field->setValue(0);
96 $record_field->doUpdate();
98 $tpl->setCurrentBlock(
"reference");
100 $tpl->setVariable(
"CONTENT", $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()));
104 $tpl->parseCurrentBlock();
107 $tpl->parseCurrentBlock();
120 if ($link ==
"[" . $this->
getField()->getTitle() .
"]") {
133 $record_field = $this;
135 if (!$values OR !count($values)) {
141 $tpl =
new ilTemplate(
"tpl.reference_hover.html",
true,
true,
"Modules/DataCollection");
142 $tpl->setCurrentBlock(
"reference_list");
144 foreach ($values as
$value) {
146 if (!$ref_record->getTableId() OR !$record_field->getField() OR !$record_field->getField()->getTableId()) {
148 $record_field->setValue(NULL);
149 $record_field->doUpdate();
151 $elements[] = array(
'value' => $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()),
152 'sort' => $ref_record->getRecordFieldSortingValue($this->getField()->getFieldRef()));
159 switch ($ref_field->getDatatypeId()) {
168 foreach($elements as $element) {
169 if ((strlen($html) < $this->max_reference_length)) {
170 $html .= $element[
'value'] .
", ";
174 $tpl->setCurrentBlock(
"reference");
175 $tpl->setVariable(
"CONTENT", $element[
'value']);
176 $tpl->parseCurrentBlock();
179 $html = substr($html, 0, - 2);
184 $tpl->setVariable(
"ALL", $html);
185 $tpl->parseCurrentBlock();
197 foreach ($values as
$value) {
200 $names[] = $ref_rec->getRecordField($this->
getField()->getFieldRef())->getValue();
204 foreach ($names as $name) {
205 $string .= $name .
", ";
207 if (!count($names)) {
210 $string = substr($string, 0, - 2);