ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 
 getFormulaValue ()
 
 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 132 of file class.ilDclMobRecordFieldModel.php.

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

133  {
134  if (is_array($this->getValue())) {
135  foreach ($this->getValue() as $key => $value) {
136  $confirmation->addHiddenItem('field_' . $this->field->getId() . '[' . $key . ']', $value);
137  }
138  }
139  }
addHiddenItem($a_post_var, $a_value)
Add hidden item.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ afterClone()

ilDclMobRecordFieldModel::afterClone ( )

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

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

173  {
177 
178  if (!$record_field || !$record_field->getValue()) {
179  return;
180  }
181 
182  $mob_old = new ilObjMediaObject($record_field->getValue());
183  $mob_new = $mob_old->duplicate();
184 
185  $this->setValue($mob_new->getId(), true);
186  $this->doUpdate();
187  }
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 115 of file class.ilDclMobRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$value.

116  {
117  $file = $value;
118  if (is_numeric($file)) {
119  $mob = new ilObjMediaObject($file, false);
120  $mob_name = $mob->getTitle();
121 
122  return $mob_name;
123  }
124 
125  return $file;
126  }
Class ilObjMediaObject.

◆ 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 151 of file class.ilDclMobRecordFieldModel.php.

References ilDclBaseRecordFieldModel\$value.

152  {
153  $mob = new ilObjMediaObject($value, false);
154 
155  return $mob->getTitle();
156  }
Class ilObjMediaObject.

◆ parseValue()

ilDclMobRecordFieldModel::parseValue (   $value)

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

References $_GET, $_POST, ilDclBaseRecordFieldModel\$field, $format, $location, $title, $type, 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(), ilDclBaseFieldModel\PROP_HEIGHT, ilDclBaseFieldModel\PROP_WIDTH, ilUtil\renameExecutables(), ilUtil\sendFailure(), and ilFFmpeg\supportsImageExtraction().

16  {
17  if ($value == -1) { //marked for deletion.
18  return 0;
19  }
20 
21  $media = $value;
22  $has_save_confirmation = ($this->getRecord()->getTable()->getSaveConfirmation() && !isset($_GET['record_id']));
23  $is_confirmed = (bool) (isset($_POST['save_confirmed']));
24 
25  if (is_array($media) && $media['tmp_name'] != "" && (!$has_save_confirmation || $is_confirmed)) {
26  $mob = new ilObjMediaObject();
27  $mob->setTitle($media['name']);
28  $mob->create();
29  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
30  if (!is_dir($mob_dir)) {
31  $mob->createDirectory();
32  }
33  $media_item = new ilMediaItem();
34  $mob->addMediaItem($media_item);
35  $media_item->setPurpose("Standard");
36  $file_name = ilUtil::getASCIIFilename($media['name']);
37  $file_name = str_replace(" ", "_", $file_name);
38  $file = $mob_dir . "/" . $file_name;
39  $title = $file_name;
40  $location = $file_name;
41  if ($has_save_confirmation) {
42  $move_file = ilDclPropertyFormGUI::getTempFilename($_POST['ilfilehash'], 'field_' . $this->getField()->getId(), $media["name"], $media["type"]);
43  ilUtil::moveUploadedFile($move_file, $file_name, $file);
44  } else {
45  ilUtil::moveUploadedFile($media['tmp_name'], $file_name, $file);
46  }
47 
48  ilUtil::renameExecutables($mob_dir);
49  // Check image/video
51 
52  if ($format == 'image/jpeg') {
53  list($width, $height, $type, $attr) = getimagesize($file);
54  $field = $this->getField();
55  $new_width = $field->getProperty(ilDclBaseFieldModel::PROP_WIDTH);
56  $new_height = $field->getProperty(ilDclBaseFieldModel::PROP_HEIGHT);
57  if ($new_width || $new_height) {
58  //only resize if it is bigger, not if it is smaller
59  if ($new_height < $height && $new_width < $width) {
60  //resize proportional
61  if (!$new_height || !$new_width) {
63  $wh
64  = 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 {
97  if (is_array($media) && isset($media['tmp_name']) && $media['tmp_name'] != '') {
98  $return = $media;
99  } else {
100  $return = $this->getValue();
101  }
102  }
103 
104  return $return;
105  }
static getMimeType($a_file, $a_external=null)
get mime type for file
$format
Definition: metadata.php:141
$type
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 getASCIIFilename($a_filename)
convert utf8 to ascii filename
static _getDirectory($a_mob_id)
Get absolute directory.
static extractImage( $a_file, $a_target_filename, $a_target_dir="", $a_sec=1)
Extract image from video file.
Class ilMediaItem.
Class ilObjMediaObject.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static enabled()
Checks, whether FFmpeg support is enabled (path is set in the setup)
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 _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 162 of file class.ilDclMobRecordFieldModel.php.

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

163  {
164  $value = $form->getInput("field_" . $this->getField()->getId());
165  if ($form->getItemByPostVar("field_" . $this->getField()->getId())->getDeletionFlag()) {
166  $value = -1;
167  }
168  $this->setValue($value);
169  }
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: