ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclFileuploadFieldRepresentation.php
Go to the documentation of this file.
1<?php
2
10{
11
15 public function getInputField(ilPropertyFormGUI $form, $record_id = 0)
16 {
17 $input = new ilFileInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
18 $input->setSuffixes($this->getField()->getSupportedExtensions());
19 $input->setAllowDeletion(true);
20
21 $this->requiredWorkaroundForInputField($input, $record_id);
22
23 return $input;
24 }
25
26 protected function requiredWorkaroundForInputField($input, $record_id)
27 {
28 if ($record_id) {
29 $record = ilDclCache::getRecordCache($record_id);
30 }
31
32 $this->setupInputField($input, $this->getField());
33
34 //WORKAROUND
35 // If field is from type file: if it's required but already has a value it is no longer required as the old value is taken as default without the form knowing about it.
36 if ($record_id && $record->getId()) {
37 $field_value = $record->getRecordFieldValue($this->getField()->getId());
38 if ($field_value) {
39 $input->setRequired(false);
40 }
41 }
42 // If this is an ajax request to return the form, input files are currently not supported
43 if ($this->ctrl->isAsynch()) {
44 $input->setDisabled(true);
45 }
46 }
47
48
53 {
54 $input = $table->addFilterItemByMetaType("filter_" . $this->getField()->getId(), ilTable2GUI::FILTER_TEXT, false, $this->getField()->getId());
55 $input->setSubmitFormOnEnter(true);
56
57 $this->setupFilterInputField($input);
58
59 return $this->getFilterInputFieldValue($input);
60 }
61
62
66 public function passThroughFilter(ilDclBaseRecordModel $record, $filter)
67 {
68 $value = $record->getRecordFieldValue($this->getField()->getId());
69 $pass = false;
70 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
71 $pass = true;
72 }
73
74 $file_obj = new ilObjFile($value, false);
75 $file_name = $file_obj->getTitle();
76 if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
77 $pass = true;
78 }
79
80 return $pass;
81 }
82
86 public function buildFieldCreationInput(ilObjDataCollection $dcl, $mode = 'create')
87 {
88 $opt = parent::buildFieldCreationInput($dcl, $mode);
89
90 $prop_filetype = new ilTextInputGUI($this->lng->txt('dcl_supported_filetypes'), 'prop_' . ilDclBaseFieldModel::PROP_SUPPORTED_FILE_TYPES);
91 $prop_filetype->setInfo($this->lng->txt('dcl_supported_filetypes_desc'));
92
93 $opt->addSubItem($prop_filetype);
94
95 return $opt;
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
Class ilDclBaseFieldRepresentation.
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
setupFilterInputField(ilFormPropertyGUI $input)
Set basic settings for filter-input-gui.
Class ilDclBaseRecordModel.
getRecordFieldValue($field_id)
Get Field Value.
static getRecordCache($record_id=0)
passThroughFilter(ilDclBaseRecordModel $record, $filter)
Checks if a filter affects a record.bool
addFilterInputFieldToTable(ilTable2GUI $table)
Add filter input to TableGUI.null
buildFieldCreationInput(ilObjDataCollection $dcl, $mode='create')
@inheritDoc
getInputField(ilPropertyFormGUI $form, $record_id=0)
Returns field-input.null
This class represents a file property in a property form.
Class ilObjDataCollection.
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
This class represents a property form user interface.
Class ilTable2GUI.
This class represents a text property in a property form.
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form