ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclFileuploadRecordRepresentation.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  } else {
31  if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
32  return "";
33  }
34  }
35 
36  $file_obj = new ilObjFile($value, false);
37  $this->ctrl->setParameterByClass("ildclrecordlistgui", "record_id", $this->getRecordField()->getRecord()->getId());
38  $this->ctrl->setParameterByClass("ildclrecordlistgui", "field_id", $this->getRecordField()->getField()->getId());
39 
40  $html = '<a href="' . $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "sendFile") . '">' . $file_obj->getFileName() . '</a>';
41  if (ilPreview::hasPreview($file_obj->getId())) {
42  ilPreview::createPreview($file_obj); // Create preview if not already existing
43  $preview = new ilPreviewGUI((int) $_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $this->access);
44  $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
45  $preview_status_class = "";
46  $preview_text_topic = "preview_show";
47  if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
48  $preview_status_class = "ilPreviewStatusNone";
49  $preview_text_topic = "preview_none";
50  }
51  $wrapper_html_id = 'record_field_' . $this->getRecordField()->getId();
52  $script_preview_click = $preview->getJSCall($wrapper_html_id);
53  $preview_title = $this->lng->txt($preview_text_topic);
54  $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
55  $html = '<div id="' . $wrapper_html_id . '">' . $html;
56  $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="'
57  . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon
58  . '" height="16" width="16"></a></span></div>';
59  }
60 
61  return $html;
62  }
63 
64 
72  public function parseFormInput($value)
73  {
74  if (is_array($value)) {
75  return $value;
76  }
77 
78  if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
79  return "";
80  }
81 
82  $file_obj = new ilObjFile($value, false);
83 
84  //$input = ilObjFile::_lookupAbsolutePath($value);
85  return $file_obj->getFileName();
86  }
87 }
$_GET["client_id"]
$preview
Class ilDclFileuploadRecordRepresentation.
const RENDER_STATUS_NONE
static lookupRenderStatus($a_obj_id)
Gets the render status for the object with the specified id.
static hasPreview($a_obj_id, $a_type="")
Determines whether the object with the specified reference id has a preview.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.
Class ilDclBaseRecordRepresentation.
static _lookupType($a_id, $a_reference=false)
static _exists($a_id, $a_reference=false, $a_type=null)
getHTML($link=true)
Outputs html of a certain field.
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