ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclTextRecordFieldModel.php
Go to the documentation of this file.
1<?php
2
4
11{
12
16 public function setValueFromForm($form)
17 {
18 if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
19 $value = array(
20 "link" => $form->getInput("field_" . $this->getField()->getId()),
21 "title" => $form->getInput("field_" . $this->getField()->getId() . '_title'));
22 } else {
23 $value = $form->getInput("field_" . $this->getField()->getId());
24 }
25 $this->setValue($value);
26 }
27
28
34 public function fillExcelExport(ilExcel $worksheet, &$row, &$col)
35 {
36 $value = $this->getExportValue();
37
38 if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
39 if (is_array($value)) {
40 $worksheet->setCell($row, $col, $value['link']);
41 $col++;
42 $worksheet->setCell($row, $col, $value['title']);
43 $col++;
44 } else {
45 $worksheet->setCell($row, $col, $value);
46 $col += 2;
47 }
48 } else {
49 $worksheet->setCell($row, $col, $value, DataType::TYPE_STRING);
50 $col++;
51 }
52 }
53
54
55 public function addHiddenItemsToConfirmation(ilConfirmationGUI &$confirmation)
56 {
57 if ($this->field->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
58 $value = $this->getValue();
59 if (is_array($value)) {
60 $confirmation->addHiddenItem('field_' . $this->field->getId(), $value['link']);
61 $confirmation->addHiddenItem('field_' . $this->field->getId() . '_title', $value['title']);
62 }
63
64 return;
65 }
66 parent::addHiddenItemsToConfirmation($confirmation);
67 }
68
69
73 public function getPlainText()
74 {
75 $value = $this->getValue();
76
77 if (is_array($value)) {
78 if ($value['title']) {
79 return $value['title'];
80 }
81
82 return isset($value['link']) ? $value['link'] : '';
83 } else {
84 return $value;
85 }
86 }
87
88
92 public function getExportValue()
93 {
94 $value = $this->getValue();
95
96 // TODO: Handle line-breaks for excel
97 if (is_array($value) && !$this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
98 return $value['link'];
99 } else {
100 return $value;
101 }
102 }
103
104
105 public function getValueFromExcel($excel, $row, $col)
106 {
107 $value = parent::getValueFromExcel($excel, $row, $col);
108 if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
109 $title = '';
110 if ($excel->getCell(1, $col + 1) == $this->getField()->getTitle() . '_title') {
111 $title = $excel->getCell($row, $col + 1);
112 }
113 $value = array('link' => $value, 'title' => $title);
114 }
115
116 return $value;
117 }
118
119
120 public function parseValue($value)
121 {
122 if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_TEXTAREA)
123 && !$this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)
124 ) {
125 return nl2br($value);
126 }
127
128 return $value;
129 }
130
131
141 public function parseSortingValue($value, $link = true)
142 {
143 if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
144 if (is_array($value)) {
145 return isset($value['title']) ? $value['title'] : $value['link'];
146 } else {
147 return $value;
148 }
149 } else {
150 return $value;
151 }
152 }
153}
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
addHiddenItem($a_post_var, $a_value)
Add hidden item.
setValue($value, $omit_parsing=false)
Set value for record field.
Class ilDclTextRecordFieldModel.
fillExcelExport(ilExcel $worksheet, &$row, &$col)
parseValue($value)
Function to parse incoming data from form input value $value.
parseSortingValue($value, $link=true)
Returns sortable value for the specific field-types.
addHiddenItemsToConfirmation(ilConfirmationGUI &$confirmation)
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
$row
if(isset($_POST['submit'])) $form