ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDclMobRecordFieldModel Class Reference

Class ilDclMobRecordFieldModel. More...

+ Inheritance diagram for ilDclMobRecordFieldModel:
+ Collaboration diagram for ilDclMobRecordFieldModel:

Public Member Functions

 parseValue ($value)
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 addHiddenItemsToConfirmation (ilConfirmationGUI &$confirmation)
 
 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()

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

Definition at line 127 of file class.ilDclMobRecordFieldModel.php.

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

127  {
128  if (is_array($this->getValue())) {
129  foreach($this->getValue() as $key=>$value) {
130  $confirmation->addHiddenItem('field_'.$this->field->getId().'['.$key.']', $value);
131  }
132  }
133  }
addHiddenItem($a_post_var, $a_value)
Add hidden item.
+ Here is the call graph for this function:

◆ afterClone()

ilDclMobRecordFieldModel::afterClone ( )

Definition at line 163 of file class.ilDclMobRecordFieldModel.php.

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

163  {
167 
168  if (!$record_field || !$record_field->getValue()) {
169  return;
170  }
171 
172  $mob_old = new ilObjMediaObject($record_field->getValue());
173  $mob_new = $mob_old->duplicate();
174 
175  $this->setValue($mob_new->getId(), true);
176  $this->doUpdate();
177  }
static getCloneOf($id, $type)
setValue($value, $omit_parsing=false)
Set value for record field.
doUpdate()
Update object in database.
Class ilObjMediaObject.
static getRecordFieldCache($record, $field)
duplicate()
Duplicate media object, return new media object.
+ Here is the call graph for this function:

◆ parseExportValue()

ilDclMobRecordFieldModel::parseExportValue (   $value)

Function to parse incoming data from form input value $value.

returns the strin/number/etc. to store in the database.

Parameters
mixed$value
Returns
mixed

Definition at line 113 of file class.ilDclMobRecordFieldModel.php.

References $file, and ilDclBaseRecordFieldModel\$value.

113  {
114  $file = $value;
115  if (is_numeric($file)) {
116  $mob = new ilObjMediaObject($file, false);
117  $mob_name = $mob->getTitle();
118 
119  return $mob_name;
120  }
121  return $file;
122  }
Class ilObjMediaObject.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ parseSortingValue()

ilDclMobRecordFieldModel::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 145 of file class.ilDclMobRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$value.

145  {
146  $mob = new ilObjMediaObject($value, false);
147  return $mob->getTitle();
148  }
Class ilObjMediaObject.

◆ parseValue()

ilDclMobRecordFieldModel::parseValue (   $value)

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

References $_GET, $_POST, ilDclBaseRecordFieldModel\$field, $file, $location, $title, ilDclBaseRecordFieldModel\$value, ilObjMediaObject\_determineWidthHeight(), ilObjMediaObject\_getDirectory(), ilObjMediaObject\_resizeImage(), ilObjMediaObject\_saveUsage(), ilFFmpeg\enabled(), ilFFmpeg\extractImage(), ilUtil\getASCIIFilename(), ilDclBaseRecordFieldModel\getField(), ilDclBaseRecordFieldModel\getId(), ilObjMediaObject\getMimeType(), ilDclBaseRecordFieldModel\getRecord(), ilDclPropertyFormGUI\getTempFilename(), ilDclBaseRecordFieldModel\getValue(), ilUtil\moveUploadedFile(), ilDclBaseFieldModel\PROP_HEIGHT, ilDclBaseFieldModel\PROP_WIDTH, ilUtil\renameExecutables(), ilUtil\sendFailure(), and ilFFmpeg\supportsImageExtraction().

16  {
17  if ($value == -1) //marked for deletion.
18  {
19  return 0;
20  }
21 
22  $media = $value;
23  $has_save_confirmation = ($this->getRecord()->getTable()->getSaveConfirmation() && !isset($_GET['record_id']));
24  $is_confirmed = (bool) (isset($_POST['save_confirmed']));
25 
26  if (is_array($media) && $media['tmp_name'] != "" && (!$has_save_confirmation || $is_confirmed)) {
27  $mob = new ilObjMediaObject();
28  $mob->setTitle($media['name']);
29  $mob->create();
30  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
31  if (!is_dir($mob_dir)) {
32  $mob->createDirectory();
33  }
34  $media_item = new ilMediaItem();
35  $mob->addMediaItem($media_item);
36  $media_item->setPurpose("Standard");
37  $file_name = ilUtil::getASCIIFilename($media['name']);
38  $file_name = str_replace(" ", "_", $file_name);
39  $file = $mob_dir . "/" . $file_name;
40  $title = $file_name;
41  $location = $file_name;
42  if($has_save_confirmation) {
43  $move_file = ilDclPropertyFormGUI::getTempFilename($_POST['ilfilehash'], 'field_'.$this->getField()->getId(), $media["name"], $media["type"]);
44  ilUtil::moveUploadedFile($move_file, $file_name, $file, true, "rename");
45  } else {
46  ilUtil::moveUploadedFile($media['tmp_name'], $file_name, $file);
47  }
48 
49  ilUtil::renameExecutables($mob_dir);
50  // Check image/video
52 
53  if ($format == 'image/jpeg') {
54  list($width, $height, $type, $attr) = getimagesize($file);
55  $field = $this->getField();
56  $new_width = $field->getProperty(ilDclBaseFieldModel::PROP_WIDTH);
57  $new_height = $field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT);
58  if ($new_width || $new_height) {
59  //only resize if it is bigger, not if it is smaller
60  if ($new_height < $height && $new_width < $width) {
61  //resize proportional
62  if (!$new_height || !$new_width) {
64  $wh = ilObjMediaObject::_determineWidthHeight($format, "File", $file, "", true, false, $field->getProperty(ilDclBaseFieldModel::PROP_WIDTH), (int)$field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT));
65  } else {
66  $wh['width'] = (int)$field->getProperty(ilDclBaseFieldModel::PROP_WIDTH);
67  $wh['height'] = (int)$field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT);
68  }
69 
70  $location = ilObjMediaObject::_resizeImage($file, $wh['width'], $wh['height'], false);
71  }
72  }
73  }
74 
75  ilObjMediaObject::_saveUsage($mob->getId(), "dcl:html", $this->getRecord()->getTable()->getCollectionObject()->getId());
76  $media_item->setFormat($format);
77  $media_item->setLocation($location);
78  $media_item->setLocationType("LocalFile");
79 
80  // FSX MediaPreview
81  include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
83  $med = $mob->getMediaItem("Standard");
84  $mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $med->getLocation();
85  $a_target_dir = ilObjMediaObject::_getDirectory($mob->getId());
86  try {
87  $new_file = ilFFmpeg::extractImage($mob_file, "mob_vpreview.png", $a_target_dir, 1);
88  } catch (Exception $e) {
89  ilUtil::sendFailure($e->getMessage(), true);
90  }
91  }
92 
93  $mob->update();
94  $return = $mob->getId();
95  // handover for save-confirmation
96  } else if(is_array($media) && isset($media['tmp_name']) && $media['tmp_name'] != '') {
97  $return = $media;
98  }else {
99  $return = $this->getValue();
100  }
101 
102  return $return;
103  }
static _resizeImage($a_file, $a_width, $a_height, $a_constrain_prop=false)
resize image and return new image file ("_width_height" string appended)
$_GET["client_id"]
$location
Definition: buildRTE.php:44
static extractImage($a_file, $a_target_filename, $a_target_dir="", $a_sec=1)
Extract image from video file.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static _getDirectory($a_mob_id)
get directory for files of media object (static)
static _determineWidthHeight($a_format, $a_type, $a_file, $a_reference, $a_constrain_proportions, $a_use_original, $a_user_width, $a_user_height)
Determine width and height.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
Class ilMediaItem.
Class ilObjMediaObject.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getMimeType($a_file, $a_external=false)
get mime type for file
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static enabled()
Checks, whether FFmpeg support is enabled (path is set in the setup)
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
$_POST["username"]
static supportsImageExtraction($a_mime)
Check if mime type supports image extraction.
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:

◆ setValueFromForm()

ilDclMobRecordFieldModel::setValueFromForm (   $form)

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

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

154  {
155  $value = $form->getInput("field_" . $this->getField()->getId());
156  if ($form->getItemByPostVar("field_" . $this->getField()->getId())->getDeletionFlag()) {
157  $value = - 1;
158  }
159  $this->setValue($value);
160  }
setValue($value, $omit_parsing=false)
Set value for record field.
+ Here is the call graph for this function:

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