ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDclFileuploadRecordRepresentation Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilDclFileuploadRecordRepresentation:
+ Collaboration diagram for ilDclFileuploadRecordRepresentation:

Public Member Functions

 getHTML (bool $link=true, array $options=[])
 Outputs html of a certain field. More...
 
 parseFormInput ($value)
 function parses stored value to the variable needed to fill into the form for editing. More...
 
- Public Member Functions inherited from ilDclBaseRecordRepresentation
 __construct (ilDclBaseRecordFieldModel $record_field)
 
 getFormGUI (ilPropertyFormGUI $formGUI)
 
 parseFormInput ($value)
 function parses stored value to the variable needed to fill into the form for editing. More...
 
 fillFormInput (ilPropertyFormGUI $form)
 Fills the form with the value of a record. More...
 
 getHTML (bool $link=true, array $options=[])
 Outputs html of a certain field. More...
 
 getSingleHTML (?array $options=null, bool $link=true)
 Returns data for single record view. More...
 
 getConfirmationHTML ()
 Returns data for confirmation list When returning false, attribute is ignored in list. More...
 
 fillRow (ilTemplate $tpl)
 Fills row with record data. More...
 
 getRecordField ()
 Get Record Field. More...
 
 getField ()
 Getter shortcut for field. More...
 
 getRecord ()
 Getter shortcut for record. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ilDclBaseRecordRepresentation
 getFormInput ()
 Gets the value from from the record field. More...
 
- Protected Attributes inherited from ilDclBaseRecordRepresentation
ilDclBaseRecordFieldModel $record_field
 
ilLanguage $lng
 
ilAccess $access
 
ilCtrl $ctrl
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ILIAS UI Renderer $renderer
 
ilObjUser $user
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 of file class.ilDclFileuploadRecordRepresentation.php.

Member Function Documentation

◆ getHTML()

ilDclFileuploadRecordRepresentation::getHTML ( bool  $link = true,
array  $options = [] 
)

Outputs html of a certain field.

Definition at line 24 of file class.ilDclFileuploadRecordRepresentation.php.

References ilDclBaseRecordRepresentation\$access, $preview, $ref_id, ilObject\_exists(), ilObject\_lookupType(), ilPreviewGUI\CONTEXT_REPOSITORY, ilPreview\createPreview(), ILIAS\Repository\ctrl(), ilDclBaseRecordRepresentation\getField(), ILIAS\Survey\Mode\getId(), ilUtil\getImagePath(), ilDclBaseRecordRepresentation\getRecord(), ilDclBaseRecordRepresentation\getRecordField(), ilPreview\hasPreview(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilPreview\lookupRenderStatus(), ILIAS\Repository\refinery(), and ilPreview\RENDER_STATUS_NONE.

24  : string
25  {
26  $value = $this->getRecordField()->getValue();
27 
28  // the file is only temporary uploaded. Still need to be confirmed before stored
29  $has_ilfilehash = $this->http->wrapper()->post()->has('ilfilehash');
30  if (is_array($value) && $has_ilfilehash) {
31  $ilfilehash = $this->http->wrapper()->post()->retrieve('ilfilehash', $this->refinery->kindlyTo()->string());
32  $this->ctrl->setParameterByClass("ildclrecordlistgui", "ilfilehash", $ilfilehash);
33  $this->ctrl->setParameterByClass(
34  "ildclrecordlistgui",
35  "field_id",
36  $this->getRecordField()->getField()->getId()
37  );
38 
39  return '<a href="' . $this->ctrl->getLinkTargetByClass(
40  "ildclrecordlistgui",
41  "sendFile"
42  ) . '">' . $value['name'] . '</a>';
43  } else {
44  if (!ilObject2::_exists((int) $value) || ilObject2::_lookupType((int) $value, false) !== 'file') {
45  return "";
46  }
47  }
48 
49  $file_obj = new ilObjFile($value, false);
50  $this->ctrl->setParameterByClass(
51  "ildclrecordlistgui",
52  "record_id",
53  $this->getRecordField()->getRecord()->getId()
54  );
55  $this->ctrl->setParameterByClass(
56  "ildclrecordlistgui",
57  "field_id",
58  $this->getRecordField()->getField()->getId()
59  );
60 
61  $html = '<a href="' . $this->ctrl->getLinkTargetByClass(
62  "ildclrecordlistgui",
63  "sendFile"
64  ) . '">' . $file_obj->getFileName() . '</a>';
65  if (ilPreview::hasPreview($file_obj->getId())) {
66  ilPreview::createPreview($file_obj); // Create preview if not already existing
67 
68  $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
69 
70  $preview = new ilPreviewGUI(
71  $ref_id,
73  $file_obj->getId(),
75  );
76  $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
77  $preview_status_class = "";
78  $preview_text_topic = "preview_show";
79  if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
80  $preview_status_class = "ilPreviewStatusNone";
81  $preview_text_topic = "preview_none";
82  }
83  $wrapper_html_id = 'record_field_' . $this->getRecordField()->getId();
84  $script_preview_click = $preview->getJSCall($wrapper_html_id);
85  $preview_title = $this->lng->txt($preview_text_topic);
86  $preview_icon = ilUtil::getImagePath("preview.png");
87  $html = '<div id="' . $wrapper_html_id . '">' . $html;
88  $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="'
89  . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon
90  . '" height="16" width="16"></a></span></div>';
91  }
92 
93  return $html;
94  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const RENDER_STATUS_NONE
static createPreview(\ilObject $a_obj, bool $a_force=false)
Creates the preview for the object with the specified id.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
$ref_id
Definition: ltiauth.php:67
static http()
Fetches the global http state from ILIAS.
$preview
Definition: imgupload.php:81
Class ilObjFile.
static lookupRenderStatus(int $a_obj_id)
Gets the render status for the object with the specified id.
static hasPreview(int $a_obj_id, string $a_type="")
Determines whether the object with the specified reference id has a preview.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ parseFormInput()

ilDclFileuploadRecordRepresentation::parseFormInput (   $value)

function parses stored value to the variable needed to fill into the form for editing.

Parameters
array | string$value
Returns
array|string

Definition at line 101 of file class.ilDclFileuploadRecordRepresentation.php.

References ilObject\_exists(), and ilObject\_lookupType().

102  {
103  if (is_array($value)) {
104  return $value;
105  }
106 
107  if (!ilObject2::_exists((int) $value) || ilObject2::_lookupType((int) $value) !== 'file') {
108  return "";
109  }
110 
111  $file_obj = new ilObjFile($value, false);
112 
113  //$input = ilObjFile::_lookupAbsolutePath($value);
114  return $file_obj->getFileName();
115  }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Class ilObjFile.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: