ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclTextRecordFieldModel.php
Go to the documentation of this file.
1 <?php
2 
9 {
13  public function setValueFromForm($form)
14  {
15  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
16  $value = array(
17  "link" => $form->getInput("field_" . $this->getField()->getId()),
18  "title" => $form->getInput("field_" . $this->getField()->getId() . '_title'));
19  } else {
20  $value = $form->getInput("field_" . $this->getField()->getId());
21  }
22  $this->setValue($value);
23  }
24 
31  public function fillExcelExport(ilExcel $worksheet, &$row, &$col)
32  {
33  $value = $this->getExportValue();
34 
35  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
36  if (is_array($value)) {
37  $worksheet->setCell($row, $col, $value['link']);
38  $col++;
39  $worksheet->setCell($row, $col, $value['title']);
40  $col++;
41  } else {
42  $worksheet->setCell($row, $col, $value);
43  $col+= 2;
44  }
45  } else {
47  $col++;
48  }
49  }
50 
51 
52  public function addHiddenItemsToConfirmation(ilConfirmationGUI &$confirmation)
53  {
54  if ($this->field->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
55  $value = $this->getValue();
56  if (is_array($value)) {
57  $confirmation->addHiddenItem('field_' . $this->field->getId(), $value['link']);
58  $confirmation->addHiddenItem('field_' . $this->field->getId() . '_title', $value['title']);
59  }
60  return;
61  }
62  parent::addHiddenItemsToConfirmation($confirmation);
63  }
64 
65 
69  public function getPlainText()
70  {
71  $value = $this->getValue();
72 
73  if (is_array($value)) {
74  if ($value['title']) {
75  return $value['title'];
76  }
77  return isset($value['link']) ? $value['link'] : '';
78  } else {
79  return $value;
80  }
81  }
82 
86  public function getExportValue()
87  {
88  $value = $this->getValue();
89 
90  // TODO: Handle line-breaks for excel
91  if (is_array($value) && !$this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
92  return $value['link'];
93  } else {
94  return $value;
95  }
96  }
97 
98  public function getValueFromExcel($excel, $row, $col)
99  {
100  $value = parent::getValueFromExcel($excel, $row, $col);
101  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
102  $title = '';
103  if ($excel->getCell(1, $col+1) == $this->getField()->getTitle() . '_title') {
104  $title = $excel->getCell($row, $col + 1);
105  }
106  $value = array('link' => $value, 'title' => $title);
107  }
108  return $value;
109  }
110 
111  public function parseValue($value)
112  {
113  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_TEXTAREA)
114  && !$this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
115  return nl2br($value);
116  }
117 
118  return $value;
119  }
120 
130  public function parseSortingValue($value, $link = true)
131  {
132  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
133  if (is_array($value)) {
134  return isset($value['title']) ? $value['title'] : $value['link'];
135  } else {
136  return $value;
137  }
138  } else {
139  return $value;
140  }
141  }
142 }
$worksheet
addHiddenItem($a_post_var, $a_value)
Add hidden item.
fillExcelExport(ilExcel $worksheet, &$row, &$col)
setValue($value, $omit_parsing=false)
Set value for record field.
addHiddenItemsToConfirmation(ilConfirmationGUI &$confirmation)
if(isset($_POST['submit'])) $form
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
parseSortingValue($value, $link=true)
Returns sortable value for the specific field-types.
Create styles array
The data for the language used.
Class ilDclTextRecordFieldModel.
Confirmation screen class.