ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMediaCreationGUI Class Reference
+ Collaboration diagram for ilMediaCreationGUI:

Public Member Functions

 __construct (array $accept_types, Closure $after_upload, Closure $after_url_saving, Closure $after_pool_insert, Closure $finish_single_upload=null, Closure $on_mob_update=null)
 
 setAllSuffixes (array $a_val)
 
 getAllSuffixes ()
 
 setAllMimeTypes (array $a_val)
 
 getAllMimeTypes ()
 
 executeCommand ()
 
 getUploadForm ()
 
 initUrlForm ()
 
 initPoolSelection ()
 
 performBulkUpload ()
 Save bulk upload form. More...
 
 initMediaBulkForm (string $a_id, string $a_title)
 
 listPoolItems ()
 Insert media object from pool. More...
 
 selectPool ()
 Select concrete pool. More...
 
 poolSelection ()
 

Data Fields

const TYPE_VIDEO = 1
 
const TYPE_AUDIO = 2
 
const TYPE_IMAGE = 3
 
const TYPE_OTHER = 4
 
const TYPE_ALL = 5
 
const POOL_VIEW_FOLDER = "fold"
 
const POOL_VIEW_ALL = "all"
 

Protected Member Functions

 getSuffixes ()
 
 getMimeTypes ($local_only=false)
 
 creationSelection ()
 
 handleUploadResult (FileUpload $upload, UploadResult $result)
 
 editTitlesAndDescriptions ()
 
 saveTitlesAndDescriptions ()
 
 cancel ()
 
 cancelCreate ()
 
 saveUrl ()
 
 applyFilter ()
 
 resetFilter ()
 
 getPoolTable ()
 
 insertFromPool ()
 Insert media from pool. More...
 

Protected Attributes

ILIAS MediaObjects MediaType MediaTypeManager $type_manager
 
InternalGUIService $gui
 
FormAdapterGUI $bulk_upload_form = null
 
CreationGUIRequest $request
 
array $accept_types = [1,2,3,4]
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $main_tpl
 
Closure $after_upload
 
Closure $after_url_saving
 
Closure $after_pool_insert
 
Closure $finish_single_upload
 
Closure $on_mob_update
 
ilAccessHandler $access
 
array $all_suffixes = []
 
array $all_mime_types = []
 
ILIAS DI UIServices $ui
 
int $requested_mep
 
string $pool_view = self::POOL_VIEW_FOLDER
 
ILIAS FileUpload FileUpload $upload
 
ilLogger $mob_log
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMediaCreationGUI::__construct ( array  $accept_types,
Closure  $after_upload,
Closure  $after_url_saving,
Closure  $after_pool_insert,
Closure  $finish_single_upload = null,
Closure  $on_mob_update = null 
)

Definition at line 71 of file class.ilMediaCreationGUI.php.

References $accept_types, $after_pool_insert, $after_upload, $after_url_saving, $DIC, $finish_single_upload, $on_mob_update, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\ui(), and ILIAS\Repository\upload().

78  {
79  global $DIC;
80 
81  $this->lng = $DIC->language();
82  $this->lng->loadLanguageModule("mob");
83  $this->lng->loadLanguageModule("content");
84  $this->access = $DIC->access();
85 
86  $this->ctrl = $DIC->ctrl();
87  $this->main_tpl = $DIC->ui()->mainTemplate();
88  $this->ui = $DIC->ui();
89  $this->upload = $DIC->upload();
90  $this->mob_log = $DIC->logger()->mob();
91 
92  $this->accept_types = $accept_types;
93  $this->after_upload = $after_upload;
94  $this->after_url_saving = $after_url_saving;
95  $this->after_pool_insert = $after_pool_insert;
96  $this->finish_single_upload = $finish_single_upload;
97  $this->on_mob_update = $on_mob_update;
98  $this->type_manager = $DIC->mediaObjects()
99  ->internal()
100  ->domain()
101  ->mediaType();
102 
103  $this->ctrl->saveParameter($this, ["mep", "pool_view"]);
104 
105  $this->request = $DIC->mediaObjects()
106  ->internal()
107  ->gui()
108  ->creation()
109  ->request();
110 
111  $this->requested_mep = $this->request->getMediaPoolId();
112  $this->ctrl->setParameter($this, "mep", $this->requested_mep);
113 
114  $pv = $this->request->getPoolView();
115  $this->pool_view = (in_array($pv, [self::POOL_VIEW_FOLDER, self::POOL_VIEW_ALL]))
116  ? $pv
117  : self::POOL_VIEW_FOLDER;
118  $this->gui = $DIC->mediaObjects()->internal()->gui();
119  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilMediaCreationGUI::applyFilter ( )
protected

Definition at line 697 of file class.ilMediaCreationGUI.php.

References ILIAS\Repository\ctrl(), and getPoolTable().

697  : void
698  {
699  $mpool_table = $this->getPoolTable();
700  $mpool_table->resetOffset();
701  $mpool_table->writeFilterToSession();
702  $this->ctrl->redirect($this, "listPoolItems");
703  }
+ Here is the call graph for this function:

◆ cancel()

ilMediaCreationGUI::cancel ( )
protected

Definition at line 560 of file class.ilMediaCreationGUI.php.

References $ctrl, and ilCtrl\returnToParent().

560  : void
561  {
562  $ctrl = $this->ctrl;
563  $ctrl->returnToParent($this);
564  }
returnToParent(object $a_gui_obj, string $a_anchor=null)
+ Here is the call graph for this function:

◆ cancelCreate()

ilMediaCreationGUI::cancelCreate ( )
protected

Definition at line 566 of file class.ilMediaCreationGUI.php.

References $ctrl, and ilCtrl\returnToParent().

566  : void
567  {
568  $ctrl = $this->ctrl;
569  $ctrl->returnToParent($this);
570  }
returnToParent(object $a_gui_obj, string $a_anchor=null)
+ Here is the call graph for this function:

◆ creationSelection()

ilMediaCreationGUI::creationSelection ( )
protected

Definition at line 216 of file class.ilMediaCreationGUI.php.

References $main_tpl, ilAccordionGUI\FIRST_OPEN, getUploadForm(), initPoolSelection(), initUrlForm(), ILIAS\Repository\lng(), and ilGlobalTemplateInterface\setContent().

216  : void
217  {
219 
220  $acc = new \ilAccordionGUI();
221  $acc->setBehaviour(\ilAccordionGUI::FIRST_OPEN);
222  $cnt = 1;
223  $forms = [
224  $this->getUploadForm(),
225  $this->initUrlForm(),
226  $this->initPoolSelection()
227  ];
228  foreach ($forms as $form_type => $cf) {
229  $htpl = new \ilTemplate("tpl.creation_acc_head.html", true, true, "Services/Object");
230 
231  // using custom form titles (used for repository plugins)
232  $form_title = "";
233  if (method_exists($this, "getCreationFormTitle")) {
234  $form_title = $this->getCreationFormTitle($form_type);
235  }
236  if (!$form_title) {
237  $form_title = $cf->getTitle();
238  }
239 
240  // move title from form to accordion
241  $htpl->setVariable("TITLE", $this->lng->txt("option") . " " . $cnt . ": " .
242  $form_title);
243  if (!($cf instanceof FormAdapterGUI)) {
244  $cf->setTitle("");
245  $cf->setTitleIcon("");
246  $cf->setTableWidth("100%");
247 
248  $acc->addItem($htpl->get(), $cf->getHTML());
249  } else {
250  $acc->addItem($htpl->get(), $cf->render());
251  }
252 
253  $cnt++;
254  }
255  $main_tpl->setContent($acc->getHTML());
256  }
ilGlobalTemplateInterface $main_tpl
setContent(string $a_html)
Sets content for standard template.
+ Here is the call graph for this function:

◆ editTitlesAndDescriptions()

ilMediaCreationGUI::editTitlesAndDescriptions ( )
protected

Definition at line 471 of file class.ilMediaCreationGUI.php.

References $ctrl, $finish_single_upload, $lng, $main_tpl, ilAccordionGUI\ALL_CLOSED, ilCtrl\getFormAction(), ilMediaItem\getMediaItemsForUploadHash(), initMediaBulkForm(), ilCtrl\saveParameter(), ilGlobalTemplateInterface\setContent(), and ilLanguage\txt().

471  : void
472  {
473  $ctrl = $this->ctrl;
474  $lng = $this->lng;
475 
476  $ctrl->saveParameter($this, "mep_hash");
477 
479 
480  $media_items = ilMediaItem::getMediaItemsForUploadHash($this->request->getUploadHash());
481 
482  $tb = new ilToolbarGUI();
483  $tb->setFormAction($ctrl->getFormAction($this));
484  $tb->addFormButton($lng->txt("save"), "saveTitlesAndDescriptions");
485  $tb->setOpenFormTag(true);
486  $tb->setCloseFormTag(false);
487  $tb->setId("tb_top");
488 
489  if (count($media_items) == 1 && $this->finish_single_upload) {
490  $mi = current($media_items);
491  ($this->finish_single_upload)($mi["mob_id"]);
492  return;
493  }
494 
495  $html = $tb->getHTML();
496  foreach ($media_items as $mi) {
497  $acc = new ilAccordionGUI();
498  $acc->setBehaviour(ilAccordionGUI::ALL_CLOSED);
499  $acc->setId("acc_" . $mi["mob_id"]);
500 
501  $mob = new ilObjMediaObject($mi["mob_id"]);
502  $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
503  $acc->addItem($mob->getTitle(), $form->getHTML());
504 
505  $html .= $acc->getHTML();
506  }
507 
508  $html .= $tb->getHTML();
509  $tb->setOpenFormTag(false);
510  $tb->setCloseFormTag(true);
511  $tb->setId("tb_bottom");
512 
513  $main_tpl->setContent($html);
514  }
ilGlobalTemplateInterface $main_tpl
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
initMediaBulkForm(string $a_id, string $a_title)
setContent(string $a_html)
Sets content for standard template.
static getMediaItemsForUploadHash(string $a_hash)
Get media items for upload hash.
saveParameter(object $a_gui_obj, $a_parameter)
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ executeCommand()

ilMediaCreationGUI::executeCommand ( )

Definition at line 188 of file class.ilMediaCreationGUI.php.

References $ctrl, ILIAS\Repository\ctrl(), ilCtrl\forwardCommand(), ilCtrl\getCmd(), ilCtrl\getNextClass(), getUploadForm(), and initPoolSelection().

188  : void
189  {
190  $ctrl = $this->ctrl;
191 
192  $next_class = $ctrl->getNextClass($this);
193  $cmd = $ctrl->getCmd("creationSelection");
194 
195  switch ($next_class) {
196  case "ilpropertyformgui":
197  $form = $this->initPoolSelection();
198  $ctrl->forwardCommand($form);
199  break;
200 
201  case strtolower(ilRepoStandardUploadHandlerGUI::class):
202  $form = $this->getUploadForm();
203  $gui = $form->getRepoStandardUploadHandlerGUI("media_files");
204  $this->ctrl->forwardCommand($gui);
205  break;
206 
207  default:
208  if (in_array($cmd, ["creationSelection", "uploadFile", "saveUrl", "cancel", "cancelCreate", "listPoolItems",
209  "insertFromPool", "poolSelection", "selectPool", "applyFilter", "resetFilter", "performBulkUpload",
210  "editTitlesAndDescriptions", "saveTitlesAndDescriptions"])) {
211  $this->$cmd();
212  }
213  }
214  }
getCmd(string $fallback_command=null)
forwardCommand(object $a_gui_object)
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ getAllMimeTypes()

ilMediaCreationGUI::getAllMimeTypes ( )
Returns
string[]

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

References $all_mime_types.

141  : array
142  {
143  return $this->all_mime_types;
144  }

◆ getAllSuffixes()

ilMediaCreationGUI::getAllSuffixes ( )

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

References $all_suffixes.

127  : array
128  {
129  return $this->all_suffixes;
130  }

◆ getMimeTypes()

ilMediaCreationGUI::getMimeTypes (   $local_only = false)
protected
Returns
string[]

Definition at line 170 of file class.ilMediaCreationGUI.php.

Referenced by getUploadForm(), insertFromPool(), and saveUrl().

170  : array
171  {
172  $mimes = [];
173  if (in_array(self::TYPE_ALL, $this->accept_types)) {
174  $mimes = iterator_to_array($this->type_manager->getAllowedMimeTypes());
175  }
176  if (in_array(self::TYPE_VIDEO, $this->accept_types)) {
177  $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedVideoMimeTypes($local_only)));
178  }
179  if (in_array(self::TYPE_AUDIO, $this->accept_types)) {
180  $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedAudioMimeTypes()));
181  }
182  if (in_array(self::TYPE_IMAGE, $this->accept_types)) {
183  $mimes = array_merge($mimes, iterator_to_array($this->type_manager->getAllowedImageMimeTypes()));
184  }
185  return $mimes;
186  }
+ Here is the caller graph for this function:

◆ getPoolTable()

ilMediaCreationGUI::getPoolTable ( )
protected

Definition at line 713 of file class.ilMediaCreationGUI.php.

References ilMediaPoolTableGUI\IL_MEP_SELECT.

Referenced by applyFilter(), listPoolItems(), and resetFilter().

714  {
715  $pool = new ilObjMediaPool($this->requested_mep);
716  $mpool_table = new ilMediaPoolTableGUI(
717  $this,
718  "listPoolItems",
719  $pool,
720  "mep_folder",
722  $this->pool_view == self::POOL_VIEW_ALL
723  );
724  $mpool_table->setFilterCommand("applyFilter");
725  $mpool_table->setResetCommand("resetFilter");
726  $mpool_table->setInsertCommand("insertFromPool");
727  return $mpool_table;
728  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
TableGUI class for recent changes in wiki.
+ Here is the caller graph for this function:

◆ getSuffixes()

ilMediaCreationGUI::getSuffixes ( )
protected
Returns
string[]

Definition at line 149 of file class.ilMediaCreationGUI.php.

Referenced by initUrlForm().

149  : array
150  {
151  $suffixes = [];
152  if (in_array(self::TYPE_ALL, $this->accept_types, true)) {
153  $suffixes = iterator_to_array($this->type_manager->getAllowedSuffixes());
154  }
155  if (in_array(self::TYPE_VIDEO, $this->accept_types, true)) {
156  $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedVideoSuffixes()));
157  }
158  if (in_array(self::TYPE_AUDIO, $this->accept_types, true)) {
159  $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedAudioSuffixes()));
160  }
161  if (in_array(self::TYPE_IMAGE, $this->accept_types, true)) {
162  $suffixes = array_merge($suffixes, iterator_to_array($this->type_manager->getAllowedImageSuffixes()));
163  }
164  return $suffixes;
165  }
+ Here is the caller graph for this function:

◆ getUploadForm()

ilMediaCreationGUI::getUploadForm ( )

Definition at line 258 of file class.ilMediaCreationGUI.php.

References $bulk_upload_form, ILIAS\Repository\ctrl(), getMimeTypes(), and ILIAS\Repository\lng().

Referenced by creationSelection(), executeCommand(), and performBulkUpload().

259  {
260  // $item->setSuffixes($this->getSuffixes());
261  if (is_null($this->bulk_upload_form)) {
262  $mep_hash = uniqid();
263  $this->ctrl->setParameter($this, "mep_hash", $mep_hash);
264  $this->bulk_upload_form = $this->gui
265  ->form(self::class, 'performBulkUpload')
266  ->section("props", $this->lng->txt('mob_upload_file'))
267  ->file(
268  "media_files",
269  $this->lng->txt("files"),
270  \Closure::fromCallable([$this, 'handleUploadResult']),
271  "mep_id",
272  "",
273  20,
274  $this->getMimeTypes(true)
275  )->required();
276  // ->meta()->text()->meta()->textarea()
277  }
279  }
getMimeTypes($local_only=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleUploadResult()

ilMediaCreationGUI::handleUploadResult ( FileUpload  $upload,
UploadResult  $result 
)
protected

Definition at line 397 of file class.ilMediaCreationGUI.php.

References $after_upload, $location, ilObjMediaObject\_getRelativeDirectory(), ilObjMediaObject\fixFilename(), ilObjMediaObject\getMediaItem(), ilObjMediaObject\getMimeType(), ILIAS\FileUpload\DTO\UploadResult\getName(), and ILIAS\FileUpload\FileUpload\moveOneFileTo().

401  $title = $result->getName();
402 
403  $mob = new ilObjMediaObject();
404  $mob->setTitle($title);
405  $mob->setDescription("");
406  $mob->create();
407 
408  $mob->createDirectory();
409  $media_item = new ilMediaItem();
410  $mob->addMediaItem($media_item);
411  $media_item->setPurpose("Standard");
412 
413  $mob_dir = ilObjMediaObject::_getRelativeDirectory($mob->getId());
414  $file_name = ilObjMediaObject::fixFilename($title);
415  $file = $mob_dir . "/" . $file_name;
416 
417  $upload->moveOneFileTo(
418  $result,
419  $mob_dir,
420  Location::WEB,
421  $file_name,
422  true
423  );
424 
425  // get mime type
426  $format = ilObjMediaObject::getMimeType($file);
427  $location = $file_name;
428 
429  // set real meta and object data
430  $media_item->setFormat($format);
431  $media_item->setLocation($location);
432  $media_item->setLocationType("LocalFile");
433  $media_item->setUploadHash($this->request->getUploadHash());
434  $mob->update();
435  $item_ids[] = $mob->getId();
436 
437  $mob = new ilObjMediaObject($mob->getId());
438  $mob->generatePreviewPic(320, 240);
439 
440  // duration
441  $med_item = $mob->getMediaItem("Standard");
442  $med_item->determineDuration();
443  $med_item->update();
444 
445  ($this->after_upload)([$mob->getId()]);
446 
447  return new BasicHandlerResult(
448  "mep_id",
449  HandlerResult::STATUS_OK,
450  $med_item->getId(),
451  ''
452  );
453  }
static _getRelativeDirectory(int $a_mob_id)
Get relative (to webspace dir) directory.
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
moveOneFileTo(UploadResult $uploadResult, string $destination, int $location=Location::STORAGE, string $file_name='', bool $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
getMediaItem(string $a_purpose)
get item for media purpose
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static fixFilename(string $a_name)
Fix filename of uploaded file.
+ Here is the call graph for this function:

◆ initMediaBulkForm()

ilMediaCreationGUI::initMediaBulkForm ( string  $a_id,
string  $a_title 
)

Definition at line 516 of file class.ilMediaCreationGUI.php.

References $lng, and ilLanguage\txt().

Referenced by editTitlesAndDescriptions(), and saveTitlesAndDescriptions().

517  {
518  $lng = $this->lng;
519 
520  $form = new ilPropertyFormGUI();
521  $form->setOpenTag(false);
522  $form->setCloseTag(false);
523 
524  // title
525  $ti = new ilTextInputGUI($lng->txt("title"), "title_" . $a_id);
526  $ti->setValue($a_title);
527  $form->addItem($ti);
528 
529  // description
530  $ti = new ilTextAreaInputGUI($lng->txt("description"), "description_" . $a_id);
531  $form->addItem($ti);
532 
533  return $form;
534  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPoolSelection()

ilMediaCreationGUI::initPoolSelection ( )

Definition at line 307 of file class.ilMediaCreationGUI.php.

References $ctrl, $lng, ilRepositorySelector2InputGUI\getExplorerGUI(), ilCtrl\getFormAction(), ilFormPropertyGUI\setRequired(), and ilLanguage\txt().

Referenced by creationSelection(), executeCommand(), and listPoolItems().

308  {
309  $ctrl = $this->ctrl;
310  $lng = $this->lng;
311 
312  $form = new \ilPropertyFormGUI();
313 
314  $mcst = new ilRepositorySelector2InputGUI(
315  $lng->txt("obj_mep"),
316  "mep",
317  false,
318  $form
319  );
320  $exp = $mcst->getExplorerGUI();
321  $exp->setSelectableTypes(["mep"]);
322  $exp->setTypeWhiteList(["root", "mep", "cat", "crs", "grp", "fold"]);
323  $mcst->setRequired(true);
324  $form->addItem($mcst);
325 
326  $form->addCommandButton("listPoolItems", $lng->txt("continue"));
327  $form->addCommandButton("cancel", $lng->txt("cancel"));
328 
329  $form->setTitle($lng->txt("mob_choose_from_pool"));
330  $form->setFormAction($ctrl->getFormAction($this));
331 
332  return $form;
333  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRequired(bool $a_required)
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initUrlForm()

ilMediaCreationGUI::initUrlForm ( )

Definition at line 281 of file class.ilMediaCreationGUI.php.

References $ctrl, $lng, ilCtrl\getFormAction(), getSuffixes(), and ilLanguage\txt().

Referenced by creationSelection(), and saveUrl().

282  {
283  $ctrl = $this->ctrl;
284  $lng = $this->lng;
285 
286  $form = new \ilPropertyFormGUI();
287 
288  //
289  $ti = new \ilTextInputGUI($lng->txt("mob_url"), "url");
290  $info = $lng->txt("mob_url_info1") . " " . implode(", ", $this->getSuffixes()) . ".";
291  if (in_array(self::TYPE_VIDEO, $this->accept_types)) {
292  $info .= " " . $lng->txt("mob_url_info_video");
293  }
294  $ti->setInfo($info);
295  $ti->setRequired(true);
296  $form->addItem($ti);
297 
298  $form->addCommandButton("saveUrl", $lng->txt("save"));
299  $form->addCommandButton("cancel", $lng->txt("cancel"));
300 
301  $form->setTitle($lng->txt("mob_external_url"));
302  $form->setFormAction($ctrl->getFormAction($this));
303 
304  return $form;
305  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertFromPool()

ilMediaCreationGUI::insertFromPool ( )
protected

Insert media from pool.

Definition at line 762 of file class.ilMediaCreationGUI.php.

References $after_pool_insert, $id, getMimeTypes(), listPoolItems(), ILIAS\Repository\lng(), and ilMediaPoolItem\lookupForeignId().

762  : void
763  {
764  $ids = $this->request->getIds();
765  if (count($ids) == 0) {
766  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
767  $this->listPoolItems();
768  return;
769  }
770  $mob_ids = [];
771  foreach ($ids as $pool_entry_id) {
772  $id = ilMediaPoolItem::lookupForeignId($pool_entry_id);
773  $mob = new ilObjMediaObject((int) $id);
774  if (!in_array($mob->getMediaItem("Standard")->getFormat(), $this->getMimeTypes())) {
775  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("mob_mime_type_not_allowed") . ": " .
776  $mob->getMediaItem("Standard")->getFormat());
777  $this->listPoolItems();
778  return;
779  }
780  $mob_ids[] = $id;
781  }
782  ($this->after_pool_insert)($mob_ids);
783  }
static lookupForeignId(int $a_id)
getMimeTypes($local_only=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
listPoolItems()
Insert media object from pool.
+ Here is the call graph for this function:

◆ listPoolItems()

ilMediaCreationGUI::listPoolItems ( )

Insert media object from pool.

Definition at line 646 of file class.ilMediaCreationGUI.php.

References $access, $ctrl, Vendor\Package\$f, $lng, $main_tpl, $ui, ilObject\_lookupObjId(), ilObject\_lookupType(), ilRBACAccessHandler\checkAccess(), ilCtrl\getLinkTarget(), getPoolTable(), initPoolSelection(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), ilGlobalTemplateInterface\setContent(), ilCtrl\setParameter(), and ilLanguage\txt().

Referenced by insertFromPool().

646  : void
647  {
648  $ctrl = $this->ctrl;
650  $lng = $this->lng;
651  $ui = $this->ui;
653 
654  $form = $this->initPoolSelection();
655  if ($this->requested_mep === 0) {
656  $this->main_tpl->setOnScreenMessage("failure", $this->lng->txt("mob_please_select_pool"));
657  $form->setValuesByPost();
658  $this->main_tpl->setContent($form->getHTML());
659  return;
660  }
661 
662  if ($this->requested_mep > 0 &&
663  $access->checkAccess("write", "", $this->requested_mep)
664  && ilObject::_lookupType(ilObject::_lookupObjId($this->requested_mep)) == "mep") {
665  $tb = new ilToolbarGUI();
666 
667  // button: select pool
668  $tb->addButton(
669  $lng->txt("cont_switch_to_media_pool"),
670  $ctrl->getLinkTarget($this, "poolSelection")
671  );
672 
673  // view mode: pool view (folders/all media objects)
674  $f = $ui->factory();
675  $lng->loadLanguageModule("mep");
676  $ctrl->setParameter($this, "pool_view", self::POOL_VIEW_FOLDER);
677  $actions[$lng->txt("folders")] = $ctrl->getLinkTarget($this, "listPoolItems");
678  $ctrl->setParameter($this, "pool_view", self::POOL_VIEW_ALL);
679  $actions[$lng->txt("mep_all_mobs")] = $ctrl->getLinkTarget($this, "listPoolItems");
680  $ctrl->setParameter($this, "pool_view", $this->pool_view);
681  $aria_label = $lng->txt("cont_change_pool_view");
682  $view_control = $f->viewControl()->mode($actions, $aria_label)->withActive(($this->pool_view == self::POOL_VIEW_FOLDER)
683  ? $lng->txt("folders") : $lng->txt("mep_all_mobs"));
684  $tb->addSeparator();
685  $tb->addComponent($view_control);
686 
687  $html = $tb->getHTML();
688 
689  $pool_table = $this->getPoolTable();
690 
691  $html .= $pool_table->getHTML();
692 
693  $main_tpl->setContent($html);
694  }
695  }
ilGlobalTemplateInterface $main_tpl
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
loadLanguageModule(string $a_module)
Load language module.
static _lookupObjId(int $ref_id)
setContent(string $a_html)
Sets content for standard template.
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performBulkUpload()

ilMediaCreationGUI::performBulkUpload ( )

Save bulk upload form.

Definition at line 458 of file class.ilMediaCreationGUI.php.

References ILIAS\Repository\ctrl(), and getUploadForm().

458  : void
459  {
460  $form = $this->getUploadForm();
461  if (!$form->isValid()) {
462  $this->main_tpl->setContent($form->render());
463  return;
464  }
465 
466  $this->ctrl->setParameter($this, "mep_hash", $this->request->getUploadHash());
467  $this->ctrl->redirect($this, "editTitlesAndDescriptions");
468  }
+ Here is the call graph for this function:

◆ poolSelection()

ilMediaCreationGUI::poolSelection ( )

Definition at line 741 of file class.ilMediaCreationGUI.php.

References $main_tpl, and ilGlobalTemplateInterface\setContent().

741  : void
742  {
744  $exp = new ilPoolSelectorGUI(
745  $this,
746  "poolSelection",
747  null,
748  "selectPool",
749  "",
750  "mep_ref_id"
751  );
752  $exp->setTypeWhiteList(array("root", "cat", "grp", "fold", "crs", "mep"));
753  $exp->setClickableTypes(array('mep'));
754  if (!$exp->handleCommand()) {
755  $main_tpl->setContent($exp->getHTML());
756  }
757  }
ilGlobalTemplateInterface $main_tpl
setContent(string $a_html)
Sets content for standard template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ resetFilter()

ilMediaCreationGUI::resetFilter ( )
protected

Definition at line 705 of file class.ilMediaCreationGUI.php.

References ILIAS\Repository\ctrl(), and getPoolTable().

705  : void
706  {
707  $mpool_table = $this->getPoolTable();
708  $mpool_table->resetOffset();
709  $mpool_table->resetFilter();
710  $this->ctrl->redirect($this, "listPoolItems");
711  }
+ Here is the call graph for this function:

◆ saveTitlesAndDescriptions()

ilMediaCreationGUI::saveTitlesAndDescriptions ( )
protected

Definition at line 536 of file class.ilMediaCreationGUI.php.

References $ctrl, $lng, $on_mob_update, ilMediaItem\getMediaItemsForUploadHash(), initMediaBulkForm(), ilCtrl\returnToParent(), and ilLanguage\txt().

536  : void
537  {
538  $lng = $this->lng;
539  $ctrl = $this->ctrl;
540 
541  $media_items = ilMediaItem::getMediaItemsForUploadHash($this->request->getUploadHash());
542 
543  foreach ($media_items as $mi) {
544  $mob = new ilObjMediaObject($mi["mob_id"]);
545  $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
546  $form->checkInput();
547  $title = $form->getInput("title_" . $mi["mob_id"]);
548  $desc = $form->getInput("description_" . $mi["mob_id"]);
549  if (trim($title) != "") {
550  $mob->setTitle($title);
551  }
552  $mob->setDescription($desc);
553  $mob->update();
554  ($this->on_mob_update)($mob->getId());
555  }
556  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
557  $ctrl->returnToParent($this);
558  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
initMediaBulkForm(string $a_id, string $a_title)
returnToParent(object $a_gui_obj, string $a_anchor=null)
static getMediaItemsForUploadHash(string $a_hash)
Get media items for upload hash.
+ Here is the call graph for this function:

◆ saveUrl()

ilMediaCreationGUI::saveUrl ( )
protected

Definition at line 572 of file class.ilMediaCreationGUI.php.

References $after_url_saving, Vendor\Package\$e, $url, ilObjMediaObject\_getDirectory(), ilObjMediaObject\getMediaItem(), ilObjMediaObject\getMimeType(), getMimeTypes(), initUrlForm(), and ILIAS\Repository\lng().

572  : void
573  {
574  $form = $this->initUrlForm();
575 
576  if (!$form->checkInput()) {
577  $form->setValuesByPost();
578  $this->main_tpl->setContent($form->getHTML());
579  } else {
580  $mob = new ilObjMediaObject();
581  $mob->create();
582 
583  //handle standard purpose
584  $mediaItem = new ilMediaItem();
585  $mob->addMediaItem($mediaItem);
586  $mediaItem->setPurpose("Standard");
587 
588  // determine and create mob directory, move uploaded file to directory
589  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
590  if (!is_dir($mob_dir)) {
591  $mob->createDirectory();
592  }
593  $locationType = "Reference";
594  $url = $form->getInput("url");
595  $url_pi = pathinfo(basename($url));
596  $title = str_replace("_", " ", $url_pi["filename"]);
597 
598  // get mime type, if not already set!
599  $format = ilObjMediaObject::getMimeType($url, true);
600  if (!in_array($format, $this->getMimeTypes())) {
601  $this->main_tpl->setOnScreenMessage(
602  "failure",
603  $this->lng->txt("mob_type_not_supported") . " " . $format
604  );
605  $form->setValuesByPost();
606  $this->main_tpl->setContent($form->getHTML());
607  return;
608  }
609  // set real meta and object data
610  $mediaItem->setFormat($format);
611  $mediaItem->setLocation($url);
612  $mediaItem->setLocationType("Reference");
613  $mediaItem->setHAlign("Left");
614  $mob->setTitle($title);
615  try {
616  $mob->getExternalMetadata();
617  } catch (Exception $e) {
618  $this->main_tpl->setOnScreenMessage('failure', $e->getMessage(), true);
619  $form->setValuesByPost();
620  $this->main_tpl->setContent($form->getHTML());
621  return;
622  }
623 
624  $long_desc = $mob->getLongDescription();
625  $mob->update();
626 
627  $mob = new ilObjMediaObject($mob->getId());
628  $mob->generatePreviewPic(320, 240);
629 
630  // duration
631  $med_item = $mob->getMediaItem("Standard");
632  $med_item->determineDuration();
633  $med_item->update();
634 
635  //
636  // @todo: save usage
637  //
638 
639  ($this->after_url_saving)($mob->getId(), $long_desc);
640  }
641  }
static _getDirectory(int $a_mob_id)
Get absolute directory.
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
getMimeTypes($local_only=false)
getMediaItem(string $a_purpose)
get item for media purpose
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$url
Definition: ltiregstart.php:35
+ Here is the call graph for this function:

◆ selectPool()

ilMediaCreationGUI::selectPool ( )

Select concrete pool.

Definition at line 733 of file class.ilMediaCreationGUI.php.

References $ctrl, ilCtrl\redirect(), and ilCtrl\setParameter().

733  : void
734  {
735  $ctrl = $this->ctrl;
736 
737  $ctrl->setParameter($this, "mep", $this->request->getSelectedMediaPoolRefId());
738  $ctrl->redirect($this, "listPoolItems");
739  }
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
+ Here is the call graph for this function:

◆ setAllMimeTypes()

ilMediaCreationGUI::setAllMimeTypes ( array  $a_val)

Definition at line 132 of file class.ilMediaCreationGUI.php.

134  : void {
135  $this->all_mime_types = $a_val;
136  }

◆ setAllSuffixes()

ilMediaCreationGUI::setAllSuffixes ( array  $a_val)

Definition at line 121 of file class.ilMediaCreationGUI.php.

123  : void {
124  $this->all_suffixes = $a_val;
125  }

Field Documentation

◆ $accept_types

array ilMediaCreationGUI::$accept_types = [1,2,3,4]
protected

Definition at line 47 of file class.ilMediaCreationGUI.php.

Referenced by __construct().

◆ $access

ilAccessHandler ilMediaCreationGUI::$access
protected

Definition at line 56 of file class.ilMediaCreationGUI.php.

Referenced by listPoolItems().

◆ $after_pool_insert

Closure ilMediaCreationGUI::$after_pool_insert
protected

Definition at line 53 of file class.ilMediaCreationGUI.php.

Referenced by __construct(), and insertFromPool().

◆ $after_upload

Closure ilMediaCreationGUI::$after_upload
protected

Definition at line 51 of file class.ilMediaCreationGUI.php.

Referenced by __construct(), and handleUploadResult().

◆ $after_url_saving

Closure ilMediaCreationGUI::$after_url_saving
protected

Definition at line 52 of file class.ilMediaCreationGUI.php.

Referenced by __construct(), and saveUrl().

◆ $all_mime_types

array ilMediaCreationGUI::$all_mime_types = []
protected

Definition at line 64 of file class.ilMediaCreationGUI.php.

Referenced by getAllMimeTypes().

◆ $all_suffixes

array ilMediaCreationGUI::$all_suffixes = []
protected

Definition at line 60 of file class.ilMediaCreationGUI.php.

Referenced by getAllSuffixes().

◆ $bulk_upload_form

FormAdapterGUI ilMediaCreationGUI::$bulk_upload_form = null
protected

Definition at line 44 of file class.ilMediaCreationGUI.php.

Referenced by getUploadForm().

◆ $ctrl

◆ $finish_single_upload

Closure ilMediaCreationGUI::$finish_single_upload
protected

Definition at line 54 of file class.ilMediaCreationGUI.php.

Referenced by __construct(), and editTitlesAndDescriptions().

◆ $gui

InternalGUIService ilMediaCreationGUI::$gui
protected

Definition at line 43 of file class.ilMediaCreationGUI.php.

◆ $lng

◆ $main_tpl

ilGlobalTemplateInterface ilMediaCreationGUI::$main_tpl
protected

◆ $mob_log

ilLogger ilMediaCreationGUI::$mob_log
protected

Definition at line 69 of file class.ilMediaCreationGUI.php.

◆ $on_mob_update

Closure ilMediaCreationGUI::$on_mob_update
protected

Definition at line 55 of file class.ilMediaCreationGUI.php.

Referenced by __construct(), and saveTitlesAndDescriptions().

◆ $pool_view

string ilMediaCreationGUI::$pool_view = self::POOL_VIEW_FOLDER
protected

Definition at line 67 of file class.ilMediaCreationGUI.php.

◆ $request

CreationGUIRequest ilMediaCreationGUI::$request
protected

Definition at line 45 of file class.ilMediaCreationGUI.php.

◆ $requested_mep

int ilMediaCreationGUI::$requested_mep
protected

Definition at line 66 of file class.ilMediaCreationGUI.php.

◆ $type_manager

ILIAS MediaObjects MediaType MediaTypeManager ilMediaCreationGUI::$type_manager
protected

Definition at line 42 of file class.ilMediaCreationGUI.php.

◆ $ui

ILIAS DI UIServices ilMediaCreationGUI::$ui
protected

Definition at line 65 of file class.ilMediaCreationGUI.php.

Referenced by listPoolItems().

◆ $upload

ILIAS FileUpload FileUpload ilMediaCreationGUI::$upload
protected

Definition at line 68 of file class.ilMediaCreationGUI.php.

◆ POOL_VIEW_ALL

const ilMediaCreationGUI::POOL_VIEW_ALL = "all"

Definition at line 41 of file class.ilMediaCreationGUI.php.

◆ POOL_VIEW_FOLDER

const ilMediaCreationGUI::POOL_VIEW_FOLDER = "fold"

Definition at line 40 of file class.ilMediaCreationGUI.php.

◆ TYPE_ALL

const ilMediaCreationGUI::TYPE_ALL = 5

Definition at line 39 of file class.ilMediaCreationGUI.php.

Referenced by ilObjMediaPoolGUI\executeCommand().

◆ TYPE_AUDIO

const ilMediaCreationGUI::TYPE_AUDIO = 2

Definition at line 36 of file class.ilMediaCreationGUI.php.

Referenced by ilObjMediaCastGUI\executeCommand().

◆ TYPE_IMAGE

const ilMediaCreationGUI::TYPE_IMAGE = 3

Definition at line 37 of file class.ilMediaCreationGUI.php.

Referenced by ilObjMediaCastGUI\executeCommand().

◆ TYPE_OTHER

const ilMediaCreationGUI::TYPE_OTHER = 4

Definition at line 38 of file class.ilMediaCreationGUI.php.

◆ TYPE_VIDEO

const ilMediaCreationGUI::TYPE_VIDEO = 1

Definition at line 35 of file class.ilMediaCreationGUI.php.

Referenced by ilObjMediaCastGUI\executeCommand().


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