ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclFileuploadRecordRepresentation.php
Go to the documentation of this file.
1 <?php
2 require_once('./Modules/DataCollection/classes/Fields/Base/class.ilDclBaseRecordRepresentation.php');
3 
11 
19  public function getHTML($link = true) {
20  $value = $this->getRecordField()->getValue();
21 
22  // the file is only temporary uploaded. Still need to be confirmed before stored
23  if(is_array($value) && $_POST['ilfilehash']) {
24  $this->ctrl->setParameterByClass("ildclrecordlistgui", "ilfilehash", $_POST['ilfilehash']);
25  $this->ctrl->setParameterByClass("ildclrecordlistgui", "field_id", $this->getRecordField()->getField()->getId());
26  return '<a href="' . $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "sendFile") . '">' . $value['name'] . '</a>';
27  } else if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
28  return "";
29  }
30 
31  $file_obj = new ilObjFile($value, false);
32  $this->ctrl->setParameterByClass("ildclrecordlistgui", "record_id", $this->getRecordField()->getRecord()->getId());
33  $this->ctrl->setParameterByClass("ildclrecordlistgui", "field_id", $this->getRecordField()->getField()->getId());
34 
35  $html = '<a href="' . $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "sendFile") . '">' . $file_obj->getFileName() . '</a>';
36  if (ilPreview::hasPreview($file_obj->getId())) {
37  ilPreview::createPreview($file_obj); // Create preview if not already existing
38  $preview = new ilPreviewGUI((int)$_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $this->access);
39  $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
40  $preview_status_class = "";
41  $preview_text_topic = "preview_show";
42  if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
43  $preview_status_class = "ilPreviewStatusNone";
44  $preview_text_topic = "preview_none";
45  }
46  $wrapper_html_id = 'record_field_' . $this->getRecordField()->getId();
47  $script_preview_click = $preview->getJSCall($wrapper_html_id);
48  $preview_title = $this->lng->txt($preview_text_topic);
49  $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
50  $html = '<div id="' . $wrapper_html_id . '">' . $html;
51  $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="'
52  . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon
53  . '" height="16" width="16"></a></span></div>';
54  }
55 
56  return $html;
57  }
58 
59 
67  public function parseFormInput($value) {
68 
69  if(is_array($value)) {
70  return $value;
71  }
72 
73  if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
74  return "";
75  }
76 
77  $file_obj = new ilObjFile($value, false);
78  //$input = ilObjFile::_lookupAbsolutePath($value);
79  return $file_obj->getFileName();
80  }
81 }
$_GET["client_id"]
$preview
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)
Class ilObjFile.
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