ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclTextRecordFieldModel.php
Go to the documentation of this file.
1 <?php
2 
9 {
13  public function setValueFromForm($form) {
14  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
15  $value = array(
16  "link" => $form->getInput("field_" . $this->getField()->getId()),
17  "title" => $form->getInput("field_" . $this->getField()->getId() . '_title'));
18  } else {
19  $value = $form->getInput("field_" . $this->getField()->getId());
20  }
21  $this->setValue($value);
22  }
23 
29  public function fillExcelExport(ilExcel $worksheet, &$row, &$col) {
30  $value = $this->getExportValue();
31 
32  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
33  if (is_array($value)) {
34  $worksheet->setCell($row, $col, $value['link']);
35  $col++;
36  $worksheet->setCell($row, $col, $value['title']);
37  $col++;
38  } else {
39  $worksheet->setCell($row, $col, $value);
40  $col+= 2;
41  }
42  } else {
43  $worksheet->setCell($row, $col, $value);
44  $col++;
45  }
46  }
47 
48 
49  public function addHiddenItemsToConfirmation(ilConfirmationGUI &$confirmation) {
50  if ($this->field->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
51  $value = $this->getValue();
52  if (is_array($value)) {
53  $confirmation->addHiddenItem('field_'.$this->field->getId(), $value['link']);
54  $confirmation->addHiddenItem('field_'.$this->field->getId().'_title', $value['title']);
55  }
56  return;
57  }
58  parent::addHiddenItemsToConfirmation($confirmation);
59  }
60 
61 
65  public function getPlainText() {
66  $value = $this->getValue();
67 
68  if (is_array($value)) {
69  if ($value['title']) {
70  return $value['title'];
71  }
72  return isset($value['link']) ? $value['link'] : '';
73  } else {
74  return $value;
75  }
76  }
77 
81  public function getExportValue() {
82  $value = $this->getValue();
83 
84  // TODO: Handle line-breaks for excel
85  if (is_array($value) && !$this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
86  return $value['link'];
87  } else {
88  return $value;
89  }
90  }
91 
92  public function getValueFromExcel($excel, $row, $col) {
93  $value = parent::getValueFromExcel($excel, $row, $col);
94  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
95  $title = '';
96  if ($excel->getCell(1, $col+1) == $this->getField()->getTitle().'_title') {
97  $title = $excel->getCell($row, $col + 1);
98  }
99  $value = array('link' => $value, 'title' => $title);
100  }
101  return $value;
102  }
103 
104  public function parseValue($value) {
105  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_TEXTAREA)
106  && !$this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
107  return nl2br($value);
108  }
109 
110  return $value;
111  }
112 
122  public function parseSortingValue($value, $link = true) {
123  if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_URL)) {
124  if (is_array($value)) {
125  return isset($value['title']) ? $value['title'] : $value['link'];
126  } else {
127  return $value;
128  }
129  } else {
130  return $value;
131  }
132  }
133 }
$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)
parseSortingValue($value, $link=true)
Returns sortable value for the specific field-types.
Create styles array
The data for the language used.
setCell($a_row, $a_col, $a_value)
Set cell value.
Class ilDclTextRecordFieldModel.
Confirmation screen class.