ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDclFileuploadRecordFieldModel Class Reference

Class ilDclBaseFieldModel. More...

+ Inheritance diagram for ilDclFileuploadRecordFieldModel:
+ Collaboration diagram for ilDclFileuploadRecordFieldModel:

Public Member Functions

 parseValue ($value)
 
 addHiddenItemsToConfirmation (ilConfirmationGUI &$confirmation)
 
 setValue ($value, $omit_parsing=false)
 Set value for record field. More...
 
 parseExportValue ($value)
 
 parseSortingValue ($value, $link=true)
 Returns sortable value for the specific field-types. More...
 
 setValueFromForm ($form)
 
 afterClone ()
 
- Public Member Functions inherited from ilDclBaseRecordFieldModel
 __construct (ilDclBaseRecordModel $record, ilDclBaseFieldModel $field)
 
 doCreate ()
 Creates an Id and a database entry. More...
 
 doUpdate ()
 Update object in database. More...
 
 delete ()
 Delete record field in database. More...
 
 getValue ()
 
 getValueForRepresentation ()
 
 serializeData ($value)
 Serialize data before storing to db. More...
 
 deserializeData ($value)
 Deserialize data before applying to field. More...
 
 setValue ($value, $omit_parsing=false)
 Set value for record field. More...
 
 setValueFromForm ($form)
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getValueFromExcel ($excel, $row, $col)
 
 parseValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 getExportValue ()
 
 fillExcelExport (ilExcel $worksheet, &$row, &$col)
 
 getPlainText ()
 
 getSortingValue ($link=true)
 
 addHiddenItemsToConfirmation (ilConfirmationGUI &$confirmation)
 
 parseSortingValue ($value, $link=true)
 Returns sortable value for the specific field-types. More...
 
 cloneStructure (ilDclBaseRecordFieldModel $old_record_field)
 
 afterClone ()
 
 getField ()
 
 getId ()
 
 getRecord ()
 
 getRecordRepresentation ()
 
 setRecordRepresentation ($record_representation)
 
 getFieldRepresentation ()
 
 setFieldRepresentation ($field_representation)
 

Additional Inherited Members

- Protected Member Functions inherited from ilDclBaseRecordFieldModel
 doRead ()
 Read object data from database. More...
 
 loadValue ()
 Load the value. More...
 
- Protected Attributes inherited from ilDclBaseRecordFieldModel
 $id
 
 $field
 
 $record
 
 $record_representation
 
 $field_representation
 
 $value
 
 $user
 
 $ctrl
 
 $db
 
 $lng
 

Detailed Description

Member Function Documentation

◆ addHiddenItemsToConfirmation()

ilDclFileuploadRecordFieldModel::addHiddenItemsToConfirmation ( ilConfirmationGUI $confirmation)
Parameters
ilConfirmationGUI$confirmation

Definition at line 63 of file class.ilDclFileuploadRecordFieldModel.php.

References $key, ilDclBaseRecordFieldModel\$value, ilConfirmationGUI\addHiddenItem(), and ilDclBaseRecordFieldModel\getValue().

64  {
65  if (is_array($this->getValue())) {
66  foreach ($this->getValue() as $key=>$value) {
67  $confirmation->addHiddenItem('field_' . $this->field->getId() . '[' . $key . ']', $value);
68  }
69  }
70  }
addHiddenItem($a_post_var, $a_value)
Add hidden item.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ afterClone()

ilDclFileuploadRecordFieldModel::afterClone ( )

Definition at line 154 of file class.ilDclFileuploadRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$field, ilDclBaseRecordFieldModel\$record, ilDclBaseRecordFieldModel\doUpdate(), ilDclCache\getCloneOf(), ilDclBaseRecordFieldModel\getField(), ilObject2\getId(), ilDclBaseRecordFieldModel\getId(), ilDclBaseRecordFieldModel\getRecord(), ilDclCache\getRecordFieldCache(), setValue(), ilDclCache\TYPE_FIELD, and ilDclCache\TYPE_RECORD.

155  {
159 
160  if (!$record_field || !$record_field->getValue()) {
161  return;
162  }
163 
164  $file_old = new ilObjFile($record_field->getValue(), false);
165  $file_new = $file_old->cloneObject(null, null, true);
166 
167  $this->setValue($file_new->getId(), true);
168  $this->doUpdate();
169  }
static getCloneOf($id, $type)
setValue($value, $omit_parsing=false)
Set value for record field.
doUpdate()
Update object in database.
static getRecordFieldCache($record, $field)
+ Here is the call graph for this function:

◆ parseExportValue()

ilDclFileuploadRecordFieldModel::parseExportValue (   $value)

Definition at line 103 of file class.ilDclFileuploadRecordFieldModel.php.

References $file, ilDclBaseRecordFieldModel\$value, ilObject2\_exists(), and ilObject2\_lookupType().

104  {
105  if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
106  return;
107  }
108 
109  $file = $value;
110  if ($file != "-") {
111  $file_obj = new ilObjFile($file, false);
112  $file_name = $file_obj->getFileName();
113 
114  return $file_name;
115  }
116  return $file;
117  }
static _lookupType($a_id, $a_reference=false)
static _exists($a_id, $a_reference=false, $a_type=null)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:

◆ parseSortingValue()

ilDclFileuploadRecordFieldModel::parseSortingValue (   $value,
  $link = true 
)

Returns sortable value for the specific field-types.

Parameters
$value
ilDclBaseRecordFieldModel$record_field
bool | true$link
Returns
int|string

Definition at line 129 of file class.ilDclFileuploadRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$value, ilObject2\_exists(), and ilObject2\_lookupType().

130  {
131  if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
132  return '';
133  }
134  $file_obj = new ilObjFile($value, false);
135  return $file_obj->getTitle();
136  }
static _lookupType($a_id, $a_reference=false)
static _exists($a_id, $a_reference=false, $a_type=null)
+ Here is the call graph for this function:

◆ parseValue()

ilDclFileuploadRecordFieldModel::parseValue (   $value)

Definition at line 16 of file class.ilDclFileuploadRecordFieldModel.php.

References $_GET, $_POST, $DIC, $file, ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), ilMimeTypeUtil\getMimeType(), ilDclBaseRecordFieldModel\getRecord(), ilDclPropertyFormGUI\getTempFilename(), and ilDclBaseRecordFieldModel\getValue().

Referenced by setValue().

17  {
18  global $DIC;
19  if ($value == -1) { //marked for deletion.
20  return 0;
21  }
22 
23  $file = $value;
24 
25  $has_save_confirmation = ($this->getRecord()->getTable()->getSaveConfirmation() && !isset($_GET['record_id']));
26  $is_confirmed = (bool) (isset($_POST['save_confirmed']));
27 
28  if (is_array($file) && $file['tmp_name'] != "" && (!$has_save_confirmation || $is_confirmed)) {
29  $file_obj = new ilObjFile();
30  $file_obj->setType("file");
31  $file_obj->setTitle($file["name"]);
32  $file_obj->setFileName($file["name"]);
33  $file_obj->setFileType(ilMimeTypeUtil::getMimeType("", $file["name"], $file["type"]));
34  $file_obj->setFileSize($file["size"]);
35  $file_obj->setMode("object");
36  $file_obj->create();
37 
38  if ($has_save_confirmation) {
39  $move_file = ilDclPropertyFormGUI::getTempFilename($_POST['ilfilehash'], 'field_' . $this->getField()->getId(), $file["name"], $file["type"]);
40  $file_obj->storeUnzipedFile($move_file, $file["name"]);
41  } else {
42  $move_file = $file['tmp_name'];
43  $file_obj->getUploadFile($move_file, $file["name"]);
44  }
45 
46  $file_obj->update();
47 
48  $file_id = $file_obj->getId();
49  $return = $file_id;
50  // handover for save-confirmation
51  } elseif (is_array($file) && isset($file['tmp_name']) && $file['tmp_name'] != "") {
52  $return = $file;
53  } else {
54  $return = $this->getValue();
55  }
56 
57  return $return;
58  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static getMimeType($a_file='', $a_filename='', $a_mime='')
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
$_POST["username"]
static getTempFilename($a_hash, $a_field, $a_name, $a_type, $a_index=null, $a_sub_index=null)
return temp-filename
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValue()

ilDclFileuploadRecordFieldModel::setValue (   $value,
  $omit_parsing = false 
)

Set value for record field.

Parameters
mixed$value
bool$omit_parsingIf true, does not parse the value and stores it in the given format

Definition at line 79 of file class.ilDclFileuploadRecordFieldModel.php.

References $old, ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getRecord(), ilDclBaseRecordFieldModel\loadValue(), and parseValue().

Referenced by afterClone(), and setValueFromForm().

80  {
81  $this->loadValue();
82 
83  if (!$omit_parsing) {
84  $tmp = $this->parseValue($value, $this);
86  //if parse value fails keep the old value
87  if ($tmp !== false) {
88  $this->value = $tmp;
89  //delete old file from filesystem
90  if ($old && $old != $tmp) {
91  $this->getRecord()->deleteFile($old);
92  }
93  }
94  } else {
95  $this->value = $value;
96  }
97  }
$old
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValueFromForm()

ilDclFileuploadRecordFieldModel::setValueFromForm (   $form)

Definition at line 141 of file class.ilDclFileuploadRecordFieldModel.php.

References $form, ilDclBaseRecordFieldModel\$value, ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), and setValue().

142  {
143  $value = $form->getInput("field_" . $this->getField()->getId());
144  if ($form->getItemByPostVar("field_" . $this->getField()->getId())->getDeletionFlag()) {
145  $value = -1;
146  }
147  $this->setValue($value);
148  }
setValue($value, $omit_parsing=false)
Set value for record field.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

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