ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilMediaCreationGUI::applyFilter ( )
protected

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

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

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

◆ cancel()

ilMediaCreationGUI::cancel ( )
protected

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

References $ctrl, and ilCtrl\returnToParent().

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

◆ cancelCreate()

ilMediaCreationGUI::cancelCreate ( )
protected

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

References $ctrl, and ilCtrl\returnToParent().

570  : void
571  {
572  $ctrl = $this->ctrl;
573  $ctrl->returnToParent($this);
574  }
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 ILIAS\UICore\GlobalTemplate\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, "components/ILIAS/ILIASObject");
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 475 of file class.ilMediaCreationGUI.php.

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

475  : void
476  {
477  $ctrl = $this->ctrl;
478  $lng = $this->lng;
479 
480  $ctrl->saveParameter($this, "mep_hash");
481 
483 
484  $media_items = ilMediaItem::getMediaItemsForUploadHash($this->request->getUploadHash());
485 
486  $tb = new ilToolbarGUI();
487  $tb->setFormAction($ctrl->getFormAction($this));
488  $tb->addFormButton($lng->txt("save"), "saveTitlesAndDescriptions");
489  $tb->setOpenFormTag(true);
490  $tb->setCloseFormTag(false);
491  $tb->setId("tb_top");
492 
493  if (count($media_items) == 1 && $this->finish_single_upload) {
494  $mi = current($media_items);
495  ($this->finish_single_upload)($mi["mob_id"]);
496  return;
497  }
498 
499  $html = $tb->getHTML();
500  foreach ($media_items as $mi) {
501  $acc = new ilAccordionGUI();
502  $acc->setBehaviour(ilAccordionGUI::ALL_CLOSED);
503  $acc->setId("acc_" . $mi["mob_id"]);
504 
505  $mob = new ilObjMediaObject($mi["mob_id"]);
506  $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
507  $acc->addItem($mob->getTitle(), $form->getHTML());
508 
509  $html .= $acc->getHTML();
510  }
511 
512  $html .= $tb->getHTML();
513  $tb->setOpenFormTag(false);
514  $tb->setCloseFormTag(true);
515  $tb->setId("tb_bottom");
516 
517  $main_tpl->setContent($html);
518  }
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
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)
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 722 of file class.ilMediaCreationGUI.php.

References ilMediaPoolTableGUI\IL_MEP_SELECT.

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

723  {
724  $pool = new ilObjMediaPool($this->requested_mep);
725  $mpool_table = new ilMediaPoolTableGUI(
726  $this,
727  "listPoolItems",
728  $pool,
729  "mep_folder",
731  $this->pool_view == self::POOL_VIEW_ALL
732  );
733  $mpool_table->setFilterCommand("applyFilter");
734  $mpool_table->setResetCommand("resetFilter");
735  $mpool_table->setInsertCommand("insertFromPool");
736  return $mpool_table;
737  }
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, and ILIAS\FileUpload\DTO\UploadResult\getName().

401  $title = $result->getName();
402 
403  $mob = new ilObjMediaObject();
404  $mob->setTitle($title);
405  $mob->setDescription("");
406  $mob->create();
407 
408  $media_item = $mob->addMediaItemFromUpload(
409  "Standard",
410  $result,
411  $this->request->getUploadHash()
412  );
413 
414  /*
415  $mob->createDirectory();
416  $media_item = new ilMediaItem();
417  $mob->addMediaItem($media_item);
418  $media_item->setPurpose("Standard");
419 
420  $mob_dir = ilObjMediaObject::_getRelativeDirectory($mob->getId());
421  $file_name = ilObjMediaObject::fixFilename($title);
422  $file = $mob_dir . "/" . $file_name;
423 
424  $upload->moveOneFileTo(
425  $result,
426  $mob_dir,
427  Location::WEB,
428  $file_name,
429  true
430  );
431 
432  // get mime type
433  $format = ilObjMediaObject::getMimeType($file);
434  $location = $file_name;
435 
436  // set real meta and object data
437  $media_item->setFormat($format);
438  $media_item->setLocation($location);
439  $media_item->setLocationType("LocalFile");
440  $media_item->setUploadHash($this->request->getUploadHash());*/
441  $mob->update();
442  $item_ids[] = $mob->getId();
443 
444  // duration
445  $med_item = $mob->getMediaItem("Standard");
446  $med_item->determineDuration();
447  $med_item->update();
448 
449  ($this->after_upload)([$mob->getId()]);
450 
451  return new BasicHandlerResult(
452  "mep_id",
453  HandlerResult::STATUS_OK,
454  $med_item->getId(),
455  ''
456  );
457  }
+ Here is the call graph for this function:

◆ initMediaBulkForm()

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

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

References $lng, and ilLanguage\txt().

Referenced by editTitlesAndDescriptions(), and saveTitlesAndDescriptions().

521  {
522  $lng = $this->lng;
523 
524  $form = new ilPropertyFormGUI();
525  $form->setOpenTag(false);
526  $form->setCloseTag(false);
527 
528  // title
529  $ti = new ilTextInputGUI($lng->txt("title"), "title_" . $a_id);
530  $ti->setValue($a_title);
531  $form->addItem($ti);
532 
533  // description
534  $ti = new ilTextAreaInputGUI($lng->txt("description"), "description_" . $a_id);
535  $form->addItem($ti);
536 
537  return $form;
538  }
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, 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  }
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
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...
setRequired(bool $a_required)
+ 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  }
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
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...
+ 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 771 of file class.ilMediaCreationGUI.php.

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

771  : void
772  {
773  $ids = $this->request->getIds();
774  if (count($ids) == 0) {
775  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"));
776  $this->listPoolItems();
777  return;
778  }
779  $mob_ids = [];
780  foreach ($ids as $pool_entry_id) {
781  $id = ilMediaPoolItem::lookupForeignId($pool_entry_id);
782  $mob = new ilObjMediaObject((int) $id);
783  if (!in_array($mob->getMediaItem("Standard")->getFormat(), $this->getMimeTypes())) {
784  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("mob_mime_type_not_allowed") . ": " .
785  $mob->getMediaItem("Standard")->getFormat());
786  $this->listPoolItems();
787  return;
788  }
789  $mob_ids[] = $id;
790  }
791  ($this->after_pool_insert)($mob_ids);
792  }
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 655 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(), ILIAS\UICore\GlobalTemplate\setContent(), ilCtrl\setParameter(), and ilLanguage\txt().

Referenced by insertFromPool().

655  : void
656  {
657  $ctrl = $this->ctrl;
659  $lng = $this->lng;
660  $ui = $this->ui;
662 
663  $form = $this->initPoolSelection();
664  if ($this->requested_mep === 0) {
665  $this->main_tpl->setOnScreenMessage("failure", $this->lng->txt("mob_please_select_pool"));
666  $form->setValuesByPost();
667  $this->main_tpl->setContent($form->getHTML());
668  return;
669  }
670 
671  if ($this->requested_mep > 0 &&
672  $access->checkAccess("write", "", $this->requested_mep)
673  && ilObject::_lookupType(ilObject::_lookupObjId($this->requested_mep)) == "mep") {
674  $tb = new ilToolbarGUI();
675 
676  // button: select pool
677  $tb->addButton(
678  $lng->txt("cont_switch_to_media_pool"),
679  $ctrl->getLinkTarget($this, "poolSelection")
680  );
681 
682  // view mode: pool view (folders/all media objects)
683  $f = $ui->factory();
684  $lng->loadLanguageModule("mep");
685  $ctrl->setParameter($this, "pool_view", self::POOL_VIEW_FOLDER);
686  $actions[$lng->txt("folders")] = $ctrl->getLinkTarget($this, "listPoolItems");
687  $ctrl->setParameter($this, "pool_view", self::POOL_VIEW_ALL);
688  $actions[$lng->txt("mep_all_mobs")] = $ctrl->getLinkTarget($this, "listPoolItems");
689  $ctrl->setParameter($this, "pool_view", $this->pool_view);
690  $aria_label = $lng->txt("cont_change_pool_view");
691  $view_control = $f->viewControl()->mode($actions, $aria_label)->withActive(($this->pool_view == self::POOL_VIEW_FOLDER)
692  ? $lng->txt("folders") : $lng->txt("mep_all_mobs"));
693  $tb->addSeparator();
694  $tb->addComponent($view_control);
695 
696  $html = $tb->getHTML();
697 
698  $pool_table = $this->getPoolTable();
699 
700  $html .= $pool_table->getHTML();
701 
702  $main_tpl->setContent($html);
703  }
704  }
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) ...
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
setContent(string $a_html)
Sets content for standard template.
loadLanguageModule(string $a_module)
Load language module.
static _lookupObjId(int $ref_id)
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 462 of file class.ilMediaCreationGUI.php.

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

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

◆ poolSelection()

ilMediaCreationGUI::poolSelection ( )

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

References $main_tpl, null, and ILIAS\UICore\GlobalTemplate\setContent().

750  : void
751  {
753  $exp = new ilPoolSelectorGUI(
754  $this,
755  "poolSelection",
756  null,
757  "selectPool",
758  "",
759  "mep_ref_id"
760  );
761  $exp->setTypeWhiteList(array("root", "cat", "grp", "fold", "crs", "mep"));
762  $exp->setClickableTypes(array('mep'));
763  if (!$exp->handleCommand()) {
764  $main_tpl->setContent($exp->getHTML());
765  }
766  }
ilGlobalTemplateInterface $main_tpl
setContent(string $a_html)
Sets content for standard template.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 714 of file class.ilMediaCreationGUI.php.

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

714  : void
715  {
716  $mpool_table = $this->getPoolTable();
717  $mpool_table->resetOffset();
718  $mpool_table->resetFilter();
719  $this->ctrl->redirect($this, "listPoolItems");
720  }
+ Here is the call graph for this function:

◆ saveTitlesAndDescriptions()

ilMediaCreationGUI::saveTitlesAndDescriptions ( )
protected

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

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

540  : void
541  {
542  $lng = $this->lng;
543  $ctrl = $this->ctrl;
544 
545  $media_items = ilMediaItem::getMediaItemsForUploadHash($this->request->getUploadHash());
546 
547  foreach ($media_items as $mi) {
548  $mob = new ilObjMediaObject($mi["mob_id"]);
549  $form = $this->initMediaBulkForm($mi["mob_id"], $mob->getTitle());
550  $form->checkInput();
551  $title = $form->getInput("title_" . $mi["mob_id"]);
552  $desc = $form->getInput("description_" . $mi["mob_id"]);
553  if (trim($title) != "") {
554  $mob->setTitle($title);
555  }
556  $mob->setDescription($desc);
557  $mob->update();
558  ($this->on_mob_update)($mob->getId());
559  }
560  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
561  $ctrl->returnToParent($this);
562  }
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)
static getMediaItemsForUploadHash(string $a_hash)
Get media items for upload hash.
returnToParent(object $a_gui_obj, ?string $a_anchor=null)
+ Here is the call graph for this function:

◆ saveUrl()

ilMediaCreationGUI::saveUrl ( )
protected

Definition at line 576 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().

576  : void
577  {
578  $form = $this->initUrlForm();
579 
580  if (!$form->checkInput()) {
581  $form->setValuesByPost();
582  $this->main_tpl->setContent($form->getHTML());
583  } else {
584  $locationType = "Reference";
585  $url = $form->getInput("url");
586  $url_pi = pathinfo(basename($url));
587  $title = str_replace("_", " ", $url_pi["filename"]);
588 
589  /*
590  * Creating the MediaObject also creates a LOM set for it,
591  * and a LOM set can not be created without a title.
592  */
593  $mob = new ilObjMediaObject();
594  $mob->setTitle($title);
595  $mob->create();
596 
597  //handle standard purpose
598  $mediaItem = new ilMediaItem();
599  $mob->addMediaItem($mediaItem);
600  $mediaItem->setPurpose("Standard");
601 
602  // determine and create mob directory, move uploaded file to directory
603  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
604  if (!is_dir($mob_dir)) {
605  $mob->createDirectory();
606  }
607 
608  // get mime type, if not already set!
609  $format = ilObjMediaObject::getMimeType($url, true);
610  if (!in_array($format, $this->getMimeTypes())) {
611  $this->main_tpl->setOnScreenMessage(
612  "failure",
613  $this->lng->txt("mob_type_not_supported") . " " . $format
614  );
615  $form->setValuesByPost();
616  $this->main_tpl->setContent($form->getHTML());
617  return;
618  }
619  // set real meta and object data
620  $mediaItem->setFormat($format);
621  $mediaItem->setLocation($url);
622  $mediaItem->setLocationType("Reference");
623  $mediaItem->setHAlign("Left");
624  try {
625  $mob->getExternalMetadata();
626  } catch (Exception $e) {
627  $this->main_tpl->setOnScreenMessage('failure', $e->getMessage(), true);
628  $form->setValuesByPost();
629  $this->main_tpl->setContent($form->getHTML());
630  return;
631  }
632 
633  $long_desc = $mob->getLongDescription();
634  $mob->update();
635 
636  $mob = new ilObjMediaObject($mob->getId());
637  $mob->generatePreviewPic(320, 240);
638 
639  // duration
640  $med_item = $mob->getMediaItem("Standard");
641  $med_item->determineDuration();
642  $med_item->update();
643 
644  //
645  // @todo: save usage
646  //
647 
648  ($this->after_url_saving)($mob->getId(), $long_desc);
649  }
650  }
$url
Definition: shib_logout.php:66
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
Class ilMediaItem Media Item, component of a media object (file or reference)
+ Here is the call graph for this function:

◆ selectPool()

ilMediaCreationGUI::selectPool ( )

Select concrete pool.

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

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

742  : void
743  {
744  $ctrl = $this->ctrl;
745 
746  $ctrl->setParameter($this, "mep", $this->request->getSelectedMediaPoolRefId());
747  $ctrl->redirect($this, "listPoolItems");
748  }
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: