ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclMobRecordRepresentation.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
20  public function getHTML($link = true)
21  {
22  $value = $this->getRecordField()->getValue();
23 
24  // the file is only temporary uploaded. Still need to be confirmed before stored
25  if (is_array($value) && $_POST['ilfilehash']) {
26  $this->ctrl->setParameterByClass("ildclrecordlistgui", "ilfilehash", $_POST['ilfilehash']);
27  $this->ctrl->setParameterByClass("ildclrecordlistgui", "field_id", $this->getRecordField()->getField()->getId());
28 
29  return '<a href="' . $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "sendFile") . '">' . $value['name'] . '</a>';
30  }
31 
32  $mob = new ilObjMediaObject($value, false);
33  $med = $mob->getMediaItem('Standard');
34 
35  if (!$med || $med->getLocation() == null) {
36  return "";
37  }
38 
39  $field = $this->getRecordField()->getField();
40 
41  $is_linked_field = $field->getProperty(ilDclBaseFieldModel::PROP_LINK_DETAIL_PAGE_TEXT);
42  $has_view = ilDclDetailedViewDefinition::isActive($_GET['tableview_id']);
43 
44  if (in_array($med->getSuffix(), array('jpg', 'jpeg', 'png', 'gif'))) {
45  // Image
46  $dir = ilObjMediaObject::_getDirectory($mob->getId());
47  $width = (int) $field->getProperty(ilDclBaseFieldModel::PROP_WIDTH);
48  $height = (int) $field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT);
49 
50  $html = ilUtil::img(ilWACSignedPath::signFile($dir . "/" . $med->getLocation()), '', $width, $height);
51 
52  if ($is_linked_field && $has_view && $link) {
53  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'record_id', $this->getRecordField()->getRecord()->getId());
54  $html = '<a href="' . $this->ctrl->getLinkTargetByClass("ilDclDetailedViewGUI", 'renderRecord') . '">' . $html . '</a>';
55  }
56  } else {
57  // Video/Audio
58  $mpl = new ilMediaPlayerGUI($med->getId(), '');
59  $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
60  $mpl->setMimeType($med->getFormat());
61  $mpl->setDisplayWidth((int) $field->getProperty(ilDclBaseFieldModel::PROP_WIDTH) . 'px');
62  $mpl->setDisplayHeight((int) $field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT) . 'px');
63  $mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
64  $html = $mpl->getPreviewHtml();
65 
66  if ($is_linked_field && $has_view) {
67  $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'record_id', $this->getRecordField()->getRecord()->getId());
68  $html = $html . '<a href="' . $this->ctrl->getLinkTargetByClass("ilDclDetailedViewGUI", 'renderRecord') . '">' . $this->lng->txt('details') . '</a>';
69  }
70  }
71 
72  return $html;
73  }
74 
75 
83  public function parseFormInput($value)
84  {
85  if (is_array($value)) {
86  return $value;
87  }
88 
89  if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "mob") {
90  return "";
91  }
92 
93  return $value;
94  }
95 }
setFile($a_file)
Set File.
$_GET["client_id"]
Class ilDclFileuploadRecordRepresentation.
static _getURL($a_mob_id)
get directory for files of media object (static)
getHTML($link=true)
Outputs html of a certain field.
static _getDirectory($a_mob_id)
Get absolute directory.
Class ilDclMobRecordRepresentation.
Class ilObjMediaObject.
static signFile($path_to_file)
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
User interface for media player.
static _lookupType($a_id, $a_reference=false)
static _exists($a_id, $a_reference=false, $a_type=null)
parseFormInput($value)
function parses stored value to the variable needed to fill into the form for editing.
$_POST["username"]
$html
Definition: example_001.php:87