ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilDataCollectionTextField.php
Go to the documentation of this file.
1<?php
2
9{
10
14 public function fillFormInput(&$form)
15 {
16 $value = $this->getValue();
17 $input = $value;
18
19 if ($this->hasProperty(ilDataCollectionField::PROPERTYID_URL) && $json = json_decode($value)) {
20 $input = $json->link;
21 $input_title = $json->title;
22 $form->getItemByPostVar('field_' . $this->field->getId() . '_title')->setValue($input_title);
23 }
24
26 $breaks = array( "<br />" );
27 $input = str_ireplace($breaks, "", $input);
28 }
29
30 $form->getItemByPostVar('field_' . $this->field->getId())->setValue($input);
31 }
32
36 public function setValueFromForm(&$form) {
38 $value = json_encode(array(
39 "link" => $form->getInput("field_" . $this->field->getId()),
40 "title" => $form->getInput("field_" . $this->field->getId() . '_title')));
41 } else {
42 $value = $form->getInput("field_" . $this->field->getId());
43 }
44 $this->setValue($value);
45 }
46
52 public function fillExcelExport($worksheet, &$row, &$col) {
53 $value = $this->getExportValue();
55 if ($value instanceof stdClass) {
56 $worksheet->writeString($row, $col, $value->link);
57 $col++;
58 $worksheet->writeString($row, $col, $value->title);
59 $col++;
60 } else {
61 $worksheet->writeString($row, $col, $value);
62 $col++;
63 $col++;
64 }
65 } else {
66 $worksheet->writeString($row, $col, $value);
67 $col++;
68 }
69 }
70
74 public function getExportValue() {
75 if (json_decode($this->getValue()) instanceof stdClass) {
76 $json = json_decode($this->getValue());
77 return $json->link;
78 } else {
79 return $this->getValue();
80 }
81 }
82
83 public function getValueFromExcel($excel, $row, $col) {
84 $value = $excel->val($row, $col);
86 $title = '';
87 if ($excel->val(1, $col+1) == $this->field->getTitle().'_title') {
88 $title = $excel->val($row, $col + 1);
89 }
90 $value = json_encode(array('link' => $value, 'title' => $title));
91 }
92 return $value;
93 }
94
99 protected function hasProperty($prop_id) {
100 $properties = $this->getField()->getProperties();
101 return $properties[$prop_id];
102 }
103}
setValue($value, $omit_parsing=false)
Set value for record field.
Class ilDataCollectionTextField.
fillExcelExport($worksheet, &$row, &$col)