ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclReferenceRecordRepresentation.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
15  public function getHTML($link = true)
16  {
17  $value = $this->getRecordField()->getValue();
18  $record_field = $this->getRecordField();
19 
20  if (!$value || $value == "-") {
21  return "";
22  }
23 
24  if (!is_array($value)) {
25  $value = array($value);
26  }
27 
28  $html = "";
29 
30  foreach ($value as $k => $v) {
31  $ref_record = ilDclCache::getRecordCache($v);
32  if (!$ref_record->getTableId() || !$record_field->getField() || !$record_field->getField()->getTableId()) {
33  //the referenced record_field does not seem to exist.
34  unset($value[$k]);
35  $value = array_values($value); // resets the keys
36  $record_field->setValue($value);
37  $record_field->doUpdate();
38  continue;
39  } else {
40  $field = $this->getRecordField()->getField();
41  if ($field->getProperty(ilDclBaseFieldModel::PROP_REFERENCE_LINK)) {
42  $ref_record = ilDclCache::getRecordCache($v);
43  $ref_table = $ref_record->getTable();
44 
45  if ($ref_table->getVisibleTableViews($_GET['ref_id'], true)) {
46  $html .= $this->getLinkHTML(null, $v);
47  } else {
48  $html .= $ref_record->getRecordFieldHTML($field->getProperty(ilDclBaseFieldModel::PROP_REFERENCE));
49  }
50  } else {
51  $html .= $ref_record->getRecordFieldHTML($field->getProperty(ilDclBaseFieldModel::PROP_REFERENCE));
52  }
53  }
54  $html .= '<br>';
55  }
56 
57  $html = substr($html, 0, -4); // cut away last <br>
58 
59  return $html;
60  }
61 
62 
69  protected function getLinkHTML($link_name = null, $value)
70  {
71  global $DIC;
72  $ilCtrl = $DIC['ilCtrl'];
73 
74  if (!$value || $value == "-") {
75  return "";
76  }
77  $record_field = $this;
78  $ref_record = ilDclCache::getRecordCache($value);
79  if (!$link_name) {
80  $link_name = $ref_record->getRecordFieldHTML($record_field->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE));
81  }
82  $ilCtrl->clearParametersByClass(ilDclDetailedViewGUI::class);
83  $ilCtrl->setParameterByClass(ilDclDetailedViewGUI::class, "record_id", $ref_record->getId());
84  $ilDCLTableView = ilDCLTableView::createOrGetStandardView($ref_record->getTableId());
85  $ilCtrl->setParameterByClass(ilDclDetailedViewGUI::class, "tableview_id", $ilDCLTableView->getId());
86  $ilCtrl->setParameterByClass(ilDclDetailedViewGUI::class, "back_tableview_id", $_GET['tableview_id']);
87  $html = "<a href='" . $ilCtrl->getLinkTargetByClass(ilDclDetailedViewGUI::class, "renderRecord") . "&disable_paging=1'>" . $link_name . "</a>";
88 
89  return $html;
90  }
91 }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
Class ilDclReferenceRecordRepresentation.
static getRecordCache($record_id=0)
Class ilDclBaseRecordRepresentation.
$html
Definition: example_001.php:87