ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclFileuploadRecordRepresentation.php
Go to the documentation of this file.
1<?php
2
10{
11
19 public function getHTML($link = true)
20 {
21 $value = $this->getRecordField()->getValue();
22
23 // the file is only temporary uploaded. Still need to be confirmed before stored
24 if (is_array($value) && $_POST['ilfilehash']) {
25 $this->ctrl->setParameterByClass("ildclrecordlistgui", "ilfilehash", $_POST['ilfilehash']);
26 $this->ctrl->setParameterByClass("ildclrecordlistgui", "field_id", $this->getRecordField()->getField()->getId());
27 return '<a href="' . $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "sendFile") . '">' . $value['name'] . '</a>';
28 } elseif (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
29 return "";
30 }
31
32 $file_obj = new ilObjFile($value, false);
33 $this->ctrl->setParameterByClass("ildclrecordlistgui", "record_id", $this->getRecordField()->getRecord()->getId());
34 $this->ctrl->setParameterByClass("ildclrecordlistgui", "field_id", $this->getRecordField()->getField()->getId());
35
36 $html = '<a href="' . $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "sendFile") . '">' . $file_obj->getFileName() . '</a>';
37 if (ilPreview::hasPreview($file_obj->getId())) {
38 ilPreview::createPreview($file_obj); // Create preview if not already existing
39 $preview = new ilPreviewGUI((int) $_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $this->access);
40 $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
41 $preview_status_class = "";
42 $preview_text_topic = "preview_show";
43 if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
44 $preview_status_class = "ilPreviewStatusNone";
45 $preview_text_topic = "preview_none";
46 }
47 $wrapper_html_id = 'record_field_' . $this->getRecordField()->getId();
48 $script_preview_click = $preview->getJSCall($wrapper_html_id);
49 $preview_title = $this->lng->txt($preview_text_topic);
50 $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
51 $html = '<div id="' . $wrapper_html_id . '">' . $html;
52 $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="'
53 . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon
54 . '" height="16" width="16"></a></span></div>';
55 }
56
57 return $html;
58 }
59
60
68 public function parseFormInput($value)
69 {
70 if (is_array($value)) {
71 return $value;
72 }
73
74 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
75 return "";
76 }
77
78 $file_obj = new ilObjFile($value, false);
79 //$input = ilObjFile::_lookupAbsolutePath($value);
80 return $file_obj->getFileName();
81 }
82}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilDclBaseRecordRepresentation.
parseFormInput($value)
function parses stored value to the variable needed to fill into the form for editing.
getHTML($link=true)
Outputs html of a certain field.
Class ilObjFile.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static hasPreview($a_obj_id, $a_type="")
Determines whether the object with the specified reference id has a preview.
const RENDER_STATUS_NONE
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.
static lookupRenderStatus($a_obj_id)
Gets the render status for the object with the specified id.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$html
Definition: example_001.php:87
$preview