ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjFileBasedLMGUI.php
Go to the documentation of this file.
1 <?php
2 
25 
35 {
36  private const PARAM_PATH = "path";
37  public const CMD_LIST_FILES = "listFiles";
38  public const CMD_IMPORT_FROM_UPLOAD_DIR = 'importFromUploadDir';
39  private \ILIAS\ResourceStorage\Services $irss;
40  private \ILIAS\HTTP\Services $http;
41  protected \ILIAS\HTMLLearningModule\InternalGUIService $gui;
44  protected ilTabsGUI $tabs;
45  protected ilHelpGUI $help;
46  public bool $output_prepared;
47 
48  public function __construct(
49  $a_data,
50  int $a_id = 0,
51  bool $a_call_by_reference = true,
52  bool $a_prepare_output = true
53  ) {
54  global $DIC;
55 
56  $this->irss = $DIC->resourceStorage();
57  $this->lng = $DIC->language();
58  $this->user = $DIC->user();
59  $this->locator = $DIC["ilLocator"];
60  $this->tabs = $DIC->tabs();
61  $this->tree = $DIC->repositoryTree();
62  $this->tpl = $DIC["tpl"];
63  $this->access = $DIC->access();
64  $this->toolbar = $DIC->toolbar();
65  $this->help = $DIC["ilHelp"];
66  $this->http = $DIC->http();
67  $lng = $DIC->language();
68  $ilCtrl = $DIC->ctrl();
69 
70  $this->ctrl = $ilCtrl;
71  $this->ctrl->saveParameter($this, array("ref_id"));
72 
73  $this->lm_request = $DIC->htmlLearningModule()
74  ->internal()
75  ->gui()
76  ->standardRequest();
77 
78  $this->type = "htlm";
79  $lng->loadLanguageModule("content");
80  $lng->loadLanguageModule("obj");
81  $lng->loadLanguageModule("htlm");
82 
83  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
84  $this->output_prepared = $a_prepare_output;
85  $this->gui = $DIC->htmlLearningModule()->internal()->gui();
86  }
87 
88  public function executeCommand(): void
89  {
90  $next_class = $this->ctrl->getNextClass($this);
91  $cmd = $this->ctrl->getCmd();
92 
93  if (
94  $this->getCreationMode() === true ||
95  strtolower($this->lm_request->getBaseClass()) === "iladministrationgui"
96  ) {
97  $this->prepareOutput();
98  } elseif (!in_array($cmd, array("", "framset")) || $next_class != "") {
99  $this->tpl->loadStandardTemplate();
100  $this->setLocator();
101  $this->setTabs();
102  }
103 
104  switch ($next_class) {
105  case strtolower(ilContainerResourceGUI::class):
106  $this->tabs->activateTab('id_list_files');
107  // Check wite access to determine upload and manage capabilities
108  $check_access = $this->access->checkAccess('write', '', $this->object->getRefId());
109 
110  // Build the view configuration
111  $view_configuration = new Configuration(
112  $this->object->getResource(),
113  new ilHTLMStakeholder(),
114  $this->lng->txt('files'),
116  250,
117  $check_access,
118  $check_access
119  );
120 
121  // Add a single action for text-files to set as startfile
122  $view_configuration = $view_configuration->withExternalAction(
123  $this->lng->txt('cont_set_start_file'),
124  self::class,
125  'setStartFile',
126  'lm',
127  self::PARAM_PATH,
128  false,
129  ['text/*']
130  );
131 
132  if ($this->getUploadDirectory()) {
133  foreach ($this->getUploadFiles() as $file) {
134  $options[$file] = $file;
135  }
136 
137  $modal = $this->ui_factory->modal()->roundtrip(
138  $this->lng->txt('import_from_upload_dir'),
139  [],
140  [
141  $this->ui_factory->input()->field()->select(
142  $this->lng->txt('import_from_upload_dir_file_name'),
143  $options,
144  $this->lng->txt('import_from_upload_dir_info'),
145  )->withRequired(true)
146  ],
147  $this->ctrl->getFormActionByClass(
148  \ilObjFileBasedLMGUI::class,
150  )
151  );
152 
153  $top_action = new TopAction(
154  $this->lng->txt('import_from_upload_dir'),
155  $modal->getShowSignal()
156  );
157  $view_configuration = $view_configuration->withExternalTopAction(
158  'import_from_upload_dir',
159  $top_action,
160  $modal
161  );
162  }
163  // build the collection GUI
164  $container_gui = new ilContainerResourceGUI(
165  $view_configuration
166  );
167 
168  // forward the command
169  $this->ctrl->forwardCommand($container_gui);
170  break;
171  case 'ilobjectmetadatagui':
172  $this->checkPermission("write");
173  $this->tabs->activateTab('id_meta_data');
174  $md_gui = new ilObjectMetaDataGUI($this->object);
175  $this->ctrl->forwardCommand($md_gui);
176  break;
177 
178  case "ilinfoscreengui":
179  $this->showInfoScreen();
180  break;
181 
182  case "illearningprogressgui":
183  $this->tabs->activateTab('id_learning_progress');
184  $user_id = ($this->lm_request->getUserId() > 0)
185  ? $this->lm_request->getUserId()
186  : $this->user->getId();
187  $new_gui = new ilLearningProgressGUI(
189  $this->object->getRefId(),
190  $user_id
191  );
192  $this->ctrl->forwardCommand($new_gui);
193  break;
194 
195  case 'ilpermissiongui':
196  $this->tabs->activateTab('id_permissions');
197  $perm_gui = new ilPermissionGUI($this);
198  $ret = $this->ctrl->forwardCommand($perm_gui);
199  break;
200 
201  case "ilexportgui":
202  $this->tabs->activateTab("export");
203  $exp_gui = new ilExportGUI($this);
204  $ret = $this->ctrl->forwardCommand($exp_gui);
205  break;
206 
207  case "ilcommonactiondispatchergui":
209  $this->ctrl->forwardCommand($gui);
210  break;
211 
212  default:
213  $cmd = $this->ctrl->getCmd(self::CMD_LIST_FILES);
214  if (
215  $this->getCreationMode() === true ||
216  strtolower($this->lm_request->getBaseClass()) === "iladministrationgui"
217  ) {
218  $cmd .= "Object";
219  }
220  $ret = $this->$cmd();
221  break;
222  }
223 
224  $this->addHeaderAction();
225  }
226 
227  final public function cancelCreationObject(): void
228  {
229  $this->ctrl->redirectByClass("ilrepositorygui", "frameset");
230  }
231 
232  public function properties(): void
233  {
234  if (!$this->checkPermissionBool("write")) {
235  $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
236  }
237  $this->tabs->activateTab("id_settings");
238 
239  $this->initSettingsForm();
240  $this->getSettingsFormValues();
241  $this->tpl->setContent($this->form->getHTML());
242  }
243 
244  public function initSettingsForm(): void
245  {
246  $obj_service = $this->getObjectService();
247 
248  $this->form = new ilPropertyFormGUI();
249 
250  // title
251  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
252  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
253  $ti->setMaxLength(ilObject::TITLE_LENGTH);
254  $ti->setRequired(true);
255  $this->form->addItem($ti);
256 
257  // description
258  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
259  $ta->setCols(40);
260  $ta->setRows(2);
261  $this->form->addItem($ta);
262 
263  // online
264  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
265  $cb->setOptionTitle($this->lng->txt(""));
266  $cb->setValue("y");
267  $this->form->addItem($cb);
268 
269  // startfile
270  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
271 
272  $ne = new ilNonEditableValueGUI($this->lng->txt("cont_startfile"), "");
273  if ($startfile !== "") {
274  $ne->setValue(basename($startfile));
275  } else {
276  $ne->setValue(basename($this->lng->txt("no_start_file")));
277  }
278  $this->form->addItem($ne);
279 
280  $pres = new ilFormSectionHeaderGUI();
281  $pres->setTitle($this->lng->txt('obj_presentation'));
282  $this->form->addItem($pres);
283 
284  // tile image
285  $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage();
286 
287  $this->form->addCommandButton("saveProperties", $this->lng->txt("save"));
288  $this->form->addCommandButton("toFilesystem", $this->lng->txt("cont_set_start_file"));
289 
290  $this->form->setTitle($this->lng->txt("cont_lm_properties"));
291  $this->form->setFormAction($this->ctrl->getFormAction($this, "saveProperties"));
292 
293  // additional features
294  $section = new ilFormSectionHeaderGUI();
295  $section->setTitle($this->lng->txt('obj_features'));
296  $this->form->addItem($section);
297 
299  $this->object->getId(),
300  $this->form,
301  [
303  ]
304  );
305  }
306 
307  public function getSettingsFormValues(): void
308  {
309  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
310 
311  $values = array();
312  $values['cobj_online'] = !$this->object->getOfflineStatus();
313  if ($startfile !== "") {
314  $startfile = basename($startfile);
315  } else {
316  $startfile = $this->lng->txt("no_start_file");
317  }
318 
319  $values["startfile"] = $startfile;
320  $values["title"] = $this->object->getTitle();
321  $values["desc"] = $this->object->getLongDescription();
322  $values["cont_show_info_tab"] = $this->object->isInfoEnabled();
323 
324  $this->form->setValuesByArray($values);
325  }
326 
327  public function toFilesystem(): void
328  {
329  // If we already have a RID, we can redirect to Container GUI
330  // otherwise we display an message which informs the user that the resource is not yet available
331  if ($this->object->getRID() != "") {
332  $this->ctrl->redirectByClass(ilContainerResourceGUI::class);
333  } else {
334  $this->ctrl->redirectByClass(static::class, "properties");
335  }
336  }
337 
338  public function saveProperties(): void
339  {
340  if (!$this->checkPermissionBool("write")) {
341  $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
342  }
343 
344  $obj_service = $this->getObjectService();
345 
346  $this->initSettingsForm();
347  if ($this->form->checkInput()) {
348  $this->object->setTitle($this->form->getInput("title"));
349  $this->object->setDescription($this->form->getInput("desc"));
350  $this->object->setOfflineStatus(!(bool) $this->form->getInput("cobj_online"));
351 
352  $this->object->update();
353 
354  // tile image
355  $obj_service->commonSettings()->legacyForm($this->form, $this->object)->saveTileImage();
356 
357  // services
359  $this->object->getId(),
360  $this->form,
361  array(
363  )
364  );
365 
366  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
367  $this->ctrl->redirect($this, "properties");
368  }
369 
370  $this->tabs->activateTab("id_settings");
371  $this->form->setValuesByPost();
372  $this->tpl->setContent($this->form->getHTML());
373  }
374 
375  public function editObject(): void
376  {
377  if (!$this->rbac_system->checkAccess("visible,write", $this->object->getRefId())) {
378  throw new ilPermissionException($this->lng->txt("permission_denied"));
379  }
380  }
381 
382  public function edit(): void
383  {
384  $this->prepareOutput();
385  $this->editObject();
386  }
387 
388  public function cancel(): void
389  {
390  $this->cancelObject();
391  }
392 
393  protected function afterSave(ilObject $new_object): void
394  {
395  if (!$new_object->getStartFile()) {
396  $new_object->maybeDetermineStartFile();
397  }
398 
399  // always send a message
400  $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
401  $this->object = $new_object;
402  $this->redirectAfterCreation();
403  }
404 
405  public function update(): void
406  {
407  $this->updateObject();
408  }
409 
410  public function setStartFile(): void
411  {
412  if (!$this->checkPermissionBool("write")) {
413  $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
414  }
415 
416  // try to determine start file from request
417  $start_file = $this->http->wrapper()->query()->has('lm_path')
418  ? $start_file = $this->http->wrapper()->query()->retrieve(
419  'lm_path',
420  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
421  )[0] ?? ''
422  : '';
423  // the ContainerResourceGUI uses e bin2hex/hex2bin serialization of pathes. Due to the internals of
424  // UI\Table\Data it's not possible to have a different handling for the parameter in case of external actions...
425  try {
426  $start_file = hex2bin($start_file);
427  } catch (Throwable $e) {
428  $start_file = '';
429  }
430 
431  if ($start_file === '') {
432  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('cont_no_start_file'), true);
433  } else {
434  $this->object->setStartFile($start_file);
435  $this->object->update();
436  $this->tpl->setOnScreenMessage('success', $this->lng->txt('cont_start_file_set'), true);
437  }
438 
439  $this->ctrl->redirectByClass(ilContainerResourceGUI::class);
440  }
441 
442  public function showLearningModule(): void
443  {
444  // #9483
445  if ($this->user->getId() !== ANONYMOUS_USER_ID) {
447  $this->user->getId(),
448  $this->object->getId(),
449  $this->object->getRefId(),
450  "htlm"
451  );
452 
453  ilLPStatusWrapper::_updateStatus($this->object->getId(), $this->user->getId());
454  }
455 
457  $resource = $this->object->getResource();
458 
459  if ($resource !== null) {
460  $startfile = $this->object->getStartFile() ?? 'index.html';
461  $uri = $this->irss->consume()->containerURI(
462  $resource->getIdentification(),
463  $startfile,
464  8 * 60
465  )->getURI();
466 
467  ilUtil::redirect((string) $uri);
468  } else {
469  // This is a legacy learning module which has not yet been migrated to the new resource storage
470  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
471 
473  if ($startfile !== "") {
474  ilUtil::redirect($startfile);
475  }
476  }
477  }
478 
482  public function infoScreen(): void
483  {
484  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
485  }
486 
487  public function showInfoScreen(): void
488  {
489  $this->tabs->activateTab('id_info');
490 
491  $this->lng->loadLanguageModule("meta");
492 
493  $info = new ilInfoScreenGUI($this);
494  $info->enablePrivateNotes();
495  $info->enableLearningProgress();
496 
497  $info->enableNews();
498  if ($this->access->checkAccess("write", "", $this->requested_ref_id)) {
499  $info->enableNewsEditing();
500 
501  $news_set = new ilSetting("news");
502  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
503  if ($enable_internal_rss) {
504  $info->setBlockProperty("news", "settings", true);
505  }
506  }
507 
508  // add read / back button
509  if ($this->access->checkAccess("read", "", $this->requested_ref_id)) {
510  // #15127
511  $this->gui->link(
512  $this->lng->txt("view"),
513  "ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=" . $this->object->getRefId(),
514  true
515  )->primary()->toToolbar();
516  }
517 
518  // show standard meta data section
519  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
520 
521  // forward the command
522  $this->ctrl->forwardCommand($info);
523  }
524 
525  protected function setTabs(): void
526  {
527  $this->getTabs();
528  $this->setTitleAndDescription();
529  }
530 
531  protected function getTabs(): void
532  {
533  $lng = $this->lng;
534  $ilHelp = $this->help;
535 
536  $ilHelp->setScreenIdComponent("htlm");
537 
538  if ($this->access->checkAccess('write', '', $this->ref_id)) {
539  // Depending on whether the module has already been migrated to the IRSS, we add a tab to
540  // ilContainerResourceGUI or internally. internally, it is only indicated that the files cannot be edited.
541  $this->tabs->addTab(
542  "id_list_files",
543  $lng->txt("cont_list_files"),
544  $this->ctrl->getLinkTarget($this, self::CMD_LIST_FILES)
545  );
546  }
547 
548  if ($this->access->checkAccess('visible', '', $this->ref_id) && $this->object->isInfoEnabled()) {
549  $this->tabs->addTab(
550  "id_info",
551  $lng->txt("info_short"),
552  $this->ctrl->getLinkTargetByClass([self::class, ilInfoScreenGUI::class], "showSummary")
553  );
554  }
555 
556  if ($this->access->checkAccess('write', '', $this->ref_id)) {
557  $this->tabs->addTab(
558  "id_settings",
559  $lng->txt("settings"),
560  $this->ctrl->getLinkTarget($this, "properties")
561  );
562  }
563 
564  if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
565  $this->tabs->addTab(
566  "id_learning_progress",
567  $lng->txt("learning_progress"),
568  $this->ctrl->getLinkTargetByClass([self::class, ilLearningProgressGUI::class], '')
569  );
570  }
571 
572  if ($this->access->checkAccess('write', '', $this->ref_id)) {
573  $mdgui = new ilObjectMetaDataGUI($this->object);
574  $mdtab = $mdgui->getTab();
575  if ($mdtab) {
576  $this->tabs->addTab(
577  "id_meta_data",
578  $lng->txt("meta_data"),
579  $mdtab
580  );
581  }
582  }
583 
584  // export
585  if ($this->access->checkAccess("write", "", $this->object->getRefId())) {
586  $this->tabs->addTab(
587  "export",
588  $lng->txt("export"),
589  $this->ctrl->getLinkTargetByClass(ilExportGUI::class, "")
590  );
591  }
592 
593  if ($this->access->checkAccess('edit_permission', '', $this->object->getRefId())) {
594  $this->tabs->addTab(
595  "id_permissions",
596  $lng->txt("perm_settings"),
597  $this->ctrl->getLinkTargetByClass([self::class, ilPermissionGUI::class], "perm")
598  );
599  }
600 
601  $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId());
602  if ($startfile !== "" && $this->access->checkAccess('read', '', $this->ref_id)) {
603  $this->tabs->addNonTabbedLink(
604  "presentation_view",
605  $this->lng->txt("glo_presentation_view"),
606  "ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=" . $this->object->getRefId(),
607  "_blank"
608  );
609  }
610  }
611 
612  public static function _goto(string $a_target): void
613  {
614  global $DIC;
615  $main_tpl = $DIC->ui()->mainTemplate();
616 
617  $lng = $DIC->language();
618  $access = $DIC->access();
619 
620  if ($access->checkAccess("read", "", $a_target) ||
621  $access->checkAccess("visible", "", $a_target)) {
622  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
623  } elseif ($access->checkAccess("read", "", ROOT_FOLDER_ID)) {
624  $main_tpl->setOnScreenMessage(
625  'failure',
626  sprintf(
627  $lng->txt("msg_no_perm_read_item"),
629  ),
630  true
631  );
633  }
634 
635  throw new ilPermissionException($lng->txt("msg_no_perm_read_lm"));
636  }
637 
638  protected function addLocatorItems(): void
639  {
640  $ilLocator = $this->locator;
641 
642  if (is_object($this->object)) {
643  $ilLocator->addItem(
644  $this->object->getTitle(),
645  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"),
646  "",
648  );
649  }
650  }
651 
652  private function listFiles(): void
653  {
654  if ($this->object->getResource() !== null) {
655  $this->ctrl->redirectByClass(ilContainerResourceGUI::class);
656  return;
657  }
658  $this->tabs->activateTab("id_list_files");
659 
660  $message_box = $this->gui->ui()->factory()->messageBox()->info(
661  $this->lng->txt("infobox_files_not_migrated")
662  );
663 
664  $this->tpl->setContent(
665  $this->gui->ui()->renderer()->render([$message_box])
666  );
667  }
668 
669  protected function importFileObject(int $parent_id = null): void
670  {
671  try {
672  parent::importFileObject();
674  // since there is no manifest xml we assume that this is an HTML export file
675  $this->createFromDirectory($e->getTmpDir());
676  }
677  }
678 
679  protected function afterImport(ilObject $new_object): void
680  {
681  $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId());
682  $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
683  $this->ctrl->redirect($this, "properties");
684  }
685 
686  public function createFromDirectory(string $a_dir): void
687  {
688  if ($a_dir === "" || !$this->checkPermissionBool("create", "", "htlm")) {
689  throw new ilPermissionException($this->lng->txt("no_create_permission"));
690  }
691 
692  // create instance
693  $newObj = new ilObjFileBasedLM();
694  $filename = ilUtil::stripSlashes($_FILES["importfile"]["name"]);
695  $newObj->setTitle($filename);
696  $newObj->setDescription("");
697  $newObj->create();
698  $newObj->populateByDirectoy($a_dir, $filename);
699  $this->putObjectInTree($newObj);
700 
701  $this->afterSave($newObj);
702  }
703 
704 
708 
709  public function exportHTML(): void
710  {
712  $this->object->getId(),
713  "html",
714  $this->object->getType()
715  );
716  $export_dir = ilExport::_getExportDirectory(
717  $this->object->getId(),
718  "html",
719  $this->object->getType()
720  );
721 
722  $subdir = $this->object->getType() . "_" . $this->object->getId();
723 
724  $target_dir = $export_dir . "/" . $subdir;
725 
726  ilFileUtils::delDir($target_dir);
727  ilFileUtils::makeDir($target_dir);
728 
729  $source_dir = $this->object->getDataDirectory();
730 
731  ilFileUtils::rCopy($source_dir, $target_dir);
732 
733  // zip it all
734  $date = time();
735  $zip_file = $export_dir . "/" . $date . "__" . IL_INST_ID . "__" .
736  $this->object->getType() . "_" . $this->object->getId() . ".zip";
737  ilFileUtils::zip($target_dir, $zip_file);
738 
739  ilFileUtils::delDir($target_dir);
740  }
741 
742  public function redirectAfterCreation(): void
743  {
744  $ctrl = $this->ctrl;
745  $ctrl->setParameterByClass("ilObjFileBasedLMGUI", "ref_id", $this->object->getRefId());
746  $ctrl->redirectByClass(["ilrepositorygui", "ilObjFileBasedLMGUI"], "properties");
747  }
748 
749  public function learningProgress(): void
750  {
751  $this->ctrl->redirectByClass("illearningprogressgui", "");
752  }
753 
754  public function redrawHeaderAction(): void
755  {
756  $this->redrawHeaderActionObject();
757  }
758 
759  public function importFromUploadDir(): void
760  {
761  global $DIC;
762  if (!$this->checkPermissionBool("write", "", "htlm")) {
763  $main_tpl = $DIC->ui()->mainTemplate();
764 
765  $main_tpl->setOnScreenMessage(
766  'failure',
767  sprintf(
768  $this->lng->txt("msg_no_perm_write"),
769  ),
770  true
771  );
773  }
774 
775  $file = $this->lm_request->getString('form/input_0');
776  $path = $this->getUploadDirectory() . DIRECTORY_SEPARATOR . $file;
777  if ($file === '') {
778  $DIC->ui()->mainTemplate()->setOnScreenMessage(
779  'failure',
780  $this->lng->txt('import_from_upload_dir_info'),
781  true
782  );
783  } elseif (str_starts_with(realpath($path), $this->getUploadDirectory())) {
784  $this->irss->manageContainer()->addStreamToContainer(
785  $this->object->getResource()->getIdentification(),
786  Streams::ofResource(fopen($path, 'rb')),
787  $file
788  );
789  $DIC->ui()->mainTemplate()->setOnScreenMessage(
790  'success',
791  $this->lng->txt('file_imported_from_upload_dir'),
792  true
793  );
794  } else {
795  $DIC->ui()->mainTemplate()->setOnScreenMessage(
796  'failure',
797  $this->lng->txt('file_import_from_upload_dir_failed'),
798  true
799  );
800  }
801 
802  $this->ctrl->setParameterByClass("ilObjFileBasedLMGUI", "ref_id", $this->object->getRefId());
803  $this->ctrl->redirectByClass(["ilrepositorygui", "ilObjFileBasedLMGUI", "ilContainerResourceGUI"]);
804  }
805 
806  public function getUploadDirectory(): string
807  {
808  $lm_set = new ilSetting("lm");
809  $upload_dir = $lm_set->get("cont_upload_dir");
810 
811  $import_file_factory = new ilImportDirectoryFactory();
812  try {
813  $import_directory = $import_file_factory->getInstanceForComponent(ilImportDirectoryFactory::TYPE_SAHS);
814  } catch (InvalidArgumentException $e) {
815  return '';
816  }
817  return $import_directory->getAbsolutePath();
818  }
819 
820  public function getUploadFiles(): array
821  {
822  if (!$upload_dir = $this->getUploadDirectory()) {
823  return array();
824  }
825 
826  // get the sorted content of the upload directory
827  $handle = opendir($upload_dir);
828  $files = array();
829  while (false !== ($file = readdir($handle))) {
830  $full_path = $upload_dir . "/" . $file;
831  if (is_file($full_path) and is_readable($full_path)) {
832  $files[] = $file;
833  }
834  }
835  closedir($handle);
836  sort($files);
837 
838  return $files;
839  }
840 
841 }
redrawHeaderActionObject()
Ajax call: redraw action header only.
Class ilObjectMetaDataGUI.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
__construct( $a_data, int $a_id=0, bool $a_call_by_reference=true, bool $a_prepare_output=true)
const IL_INST_ID
Definition: constants.php:40
const ANONYMOUS_USER_ID
Definition: constants.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
cancelObject()
cancel action and go back to previous page
const ROOT_FOLDER_ID
Definition: constants.php:32
static _goto(string $a_target)
const TITLE_LENGTH
prepareOutput(bool $show_sub_objects=true)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
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) ...
Help GUI class.
File Based Learning Module (HTML) object.
static _gotoRepositoryNode(int $ref_id, string $cmd="")
setParameterByClass(string $a_class, string $a_parameter, $a_value)
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
loadLanguageModule(string $a_module)
Load language module.
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:25
$path
Definition: ltiservices.php:30
infoScreen()
this one is called from the info button in the repository
static _lookupObjId(int $ref_id)
afterSave(ilObject $new_object)
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
withExternalAction(string $label, string $target_gui, string $target_cmd, string $parameter_namespace, string $path_parameter='path', bool $supports_directories=false, array $supported_mime_types=[' *'])
StandardGUIRequest $lm_request
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS HTMLLearningModule InternalGUIService $gui
if($request_wrapper->has('ui_mainbar')) getURI()
Definition: ui_mainbar.php:285
afterImport(ilObject $new_object)
static http()
Fetches the global http state from ILIAS.
static _lookupTitle(int $obj_id)
static signFolderOfStartFile(string $start_file_path)
ILIAS ResourceStorage Services $irss
setScreenIdComponent(string $a_comp)
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
Class ilObjectGUI Basic methods of all Output classes.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
global $DIC
Definition: shib_login.php:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
$filename
Definition: buildRTE.php:78
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static redirect(string $a_script)
putObjectInTree(ilObject $obj, int $parent_node_id=null)
Add object to tree at given position.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
form( $class_path, string $cmd, string $submit_caption="")
$lm_set
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
ilAccessHandler $access
static zip(string $a_dir, string $a_file, bool $compress_content=false)
User Interface class for file based learning modules (HTML)
updateObject()
updates object entry in object_data
importFileObject(int $parent_id=null)
addHeaderAction()
Add header action menu.
ilLocatorGUI $locator
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)