ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilGuidedTourAdminGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28
32class ilGuidedTourAdminGUI // implements ilCtrlBaseClassInterface
33{
34 private \ILIAS\Help\GuidedTour\Step\StepManager $step_manager;
35 protected \ILIAS\Help\GuidedTour\UserFinished\UserFinishedManager $finish_manager;
36 protected \ILIAS\Help\GuidedTour\Tour\TourManager $tm;
37
38 public function __construct(
39 protected \ILIAS\Help\GuidedTour\InternalDataService $data,
40 protected \ILIAS\Help\GuidedTour\InternalDomainService $domain,
41 protected \ILIAS\Help\GuidedTour\InternalGUIService $gui
42 ) {
43 $ctrl = $this->gui->ctrl();
44 $this->tm = $domain->tour();
45 $ctrl->saveParameterByClass(self::class, "tour_id");
46 $this->step_manager = $domain->step();
47 $this->finish_manager = $domain->userFinished();
48 }
49
50 public function executeCommand(): void
51 {
52 $ctrl = $this->gui->ctrl();
53 $mt = $this->gui->ui()->mainTemplate();
54
55 $next_class = $ctrl->getNextClass($this);
56 $cmd = $ctrl->getCmd("listTours");
57
58 switch ($next_class) {
59 case strtolower(ilExportGUI::class):
60 $this->setStepsHeader();
61 $this->setSettingsTabs("export");
62 $tour_id = $this->gui->standardRequest()->getTourId();
63 $exp_gui = new ilExportGUI($this->gui->objectGUI($tour_id));
64 $exp_gui->addFormat("xml");
65 $ctrl->forwardCommand($exp_gui);
66 break;
67
68 case strtolower(ilGuidedTourPageGUI::class):
69 $mt = $this->gui->mainTemplate();
70 $lng = $this->domain->lng();
71 $this->setStepsHeader();
72 $mt->setOnScreenMessage("info", $lng->txt("gdtr_edit_page_info"));
73 $ctrl->setReturnByClass(self::class, "listSteps");
74 $ctrl->saveParameterByClass(self::class, "step_id");
75 $ret = $this->forwardToPageObject();
76 $mt->setContent($ret);
77 break;
78
79 case strtolower(ilRepoStandardUploadHandlerGUI::class):
80 $form = $this->getImportForm();
81 $gui = $form->getRepoStandardUploadHandlerGUI("import");
82 $ctrl->forwardCommand($gui);
83 break;
84
85 default:
86 if (in_array($cmd, [
87 "listTours",
88 "addTour",
89 "saveTour",
90 "deleteTour",
91 "listSteps",
92 "addStep",
93 "saveStep",
94 "tableCommand",
95 "editStep",
96 "editPage",
97 "editSettings",
98 "saveSettings",
99 "idSettings",
100 "saveIdSettings",
101 "saveOrder",
102 "confirmStepDeletion",
103 "deleteStep",
104 "resetTour",
105 "importTourForm",
106 "importTour"
107 ])) {
108 $this->$cmd();
109 }
110 }
111 }
112
113 protected function setSettingsTabs(string $active): void
114 {
115 $tabs = $this->gui->tabs();
116 $lng = $this->domain->lng();
117 $ctrl = $this->gui->ctrl();
118 $tabs->clearTargets();
119 $this->gui->help()->setScreenIdComponent("hlps_gdtr");
120 $tabs->setBackTarget(
121 $lng->txt("gdtr_guided_tours"),
122 $ctrl->getLinkTargetByClass(self::class, "listTours")
123 );
124 $ctrl->saveParameterByClass(self::class, "tour_id");
125 $tabs->addTab(
126 "steps",
127 $lng->txt("gdtr_tour_steps"),
128 $ctrl->getLinkTargetByClass(self::class, "listSteps")
129 );
130 $tabs->addTab(
131 "settings",
132 $lng->txt("settings"),
133 $ctrl->getLinkTargetByClass(self::class, "editSettings")
134 );
135 $tabs->addTab(
136 "export",
137 $lng->txt("export"),
138 $ctrl->getLinkTargetByClass(ilexportGUI::class, "export", ""),
139 );
140 $tabs->activateTab($active);
141 }
142
143 public function forwardToPageObject(): string
144 {
145 $tabs = $this->gui->tabs();
146 $lng = $this->domain->lng();
147 $ctrl = $this->gui->ctrl();
148 $step_id = $this->gui->standardRequest()->getStepId();
149 $tour_id = $this->gui->standardRequest()->getTourId();
150
151 $tabs->clearTargets();
152
153 $tabs->setBackTarget(
154 $lng->txt("back"),
155 $ctrl->getLinkTargetByClass(ilGuidedTourPageGUI::class, "edit")
156 );
157
159 "gdtr",
160 $step_id
161 )) {
162 $new_page_object = new ilGuidedTourPage();
163 $new_page_object->setParentId($tour_id);
164 $new_page_object->setId($step_id);
165 $new_page_object->createFromXML();
166 }
167
168 // get page object
169 $page_gui = new ilGuidedTourPageGUI($step_id);
170 /*$page_gui->setStyleId(
171 $style->getEffectiveStyleId()
172 );*/
173 $page_gui->setTemplateTargetVar("ADM_CONTENT");
174 $page_gui->setFileDownloadLink("");
175 $page_gui->setPresentationTitle("");
176 $page_gui->setTemplateOutput(false);
177
178 // style tab
179 //$page_gui->setTabHook($this, "addPageTabs");
180
181 return $ctrl->forwardCommand($page_gui);
182 }
183
184
185 protected function listTours(): void
186 {
187 $mt = $this->gui->ui()->mainTemplate();
188 $f = $this->gui->ui()->factory();
189 $r = $this->gui->ui()->renderer();
190 $this->setSubTabs("tours");
191 $ctrl = $this->gui->ctrl();
192 $lng = $this->domain->lng();
193
194 $mt->setOnScreenMessage("info", $lng->txt("gdtr_list_tours_mess"));
195
196 $b = $f->button()->standard(
197 $lng->txt("gdtr_add_tour"),
198 $ctrl->getLinkTarget($this, "addTour")
199 );
200 $this->gui->toolbar()->addComponent($b);
201 $b = $f->button()->standard(
202 $lng->txt("gdtr_import_tour"),
203 $ctrl->getLinkTarget($this, "importTourForm")
204 );
205 $this->gui->toolbar()->addComponent($b);
206
207 $items = [];
208 $ui_items = [];
209 foreach ($this->tm->getAll() as $tour) {
210 $ctrl->setParameterByClass(self::class, "tour_id", $tour->getId());
211 $actions = [];
212 $actions[] = $f->link()->standard(
213 $lng->txt("gdtr_edit_steps"),
214 $ctrl->getLinkTargetByClass(self::class, "listSteps")
215 );
216 $actions[] = $f->link()->standard(
217 $lng->txt("gdtr_tour_settings"),
218 $ctrl->getLinkTargetByClass(self::class, "editSettings")
219 );
220 $reset_modal = $this->getResetTourModal($tour->getId());
221 $actions[] = $f->button()->shy(
222 $lng->txt("gdtr_reset_tour"),
223 "#"
224 )->withOnClick($reset_modal->getShowSignal());
225 $ui_items[] = $reset_modal;
226 $delete_modal = $this->getDeleteTourModal($tour->getId());
227 $actions[] = $f->button()->shy(
228 $lng->txt("gdtr_delete_tour"),
229 "#"
230 )->withOnClick($delete_modal->getShowSignal());
231 $ui_items[] = $delete_modal;
232 $properties = [];
233 $settings = $this->domain->tourSettings()->getByObjId($tour->getId());
234 $properties[$lng->txt("active")] = $settings?->isActive()
235 ? $lng->txt("yes")
236 : $lng->txt("no");
237 $items[] = $f->item()->standard($tour->getTitle())
238 ->withActions($f->dropdown()->standard($actions))
239 ->withProperties($properties);
240 }
241 if (count($items) > 0) {
242 $grp = $f->item()->group("", $items);
243 $panel = $f->panel()->listing()->standard(
244 $lng->txt("gdtr_guided_tours"),
245 [$grp]
246 );
247 $ui_items[] = $panel;
248 $mt->setContent($r->render($ui_items));
249 }
250 }
251
252 protected function getResetTourModal(int $tour_id): \ILIAS\UI\Component\Modal\Interruptive
253 {
254 $tour = $this->tm->getByObjId($tour_id);
255 $f = $this->gui->ui()->factory();
256 $r = $this->gui->ui()->renderer();
257 $lng = $this->domain->lng();
258 $ctrl = $this->gui->ctrl();
259 $res_items = [];
260 $res_items[] = $f->modal()->interruptiveItem()->keyValue(
261 (string) $tour_id,
262 $tour->getTitle(),
263 ""
264 );
265 $ctrl->setParameterByClass(self::class, "tour_id", $tour_id);
266 $action = $ctrl->getLinkTargetByClass(self::class, "resetTour");
267
268 return $f->modal()->interruptive(
269 $lng->txt("gdtr_reset_tour"),
270 $lng->txt("gdtr_reset_tour_mess"),
271 $action
272 )->withAffectedItems($res_items)
273 ->withActionButtonLabel($lng->txt("gdtr_reset_tour"));
274 }
275
276 protected function resetTour(): void
277 {
278 $mt = $this->gui->ui()->mainTemplate();
279 $lng = $this->domain->lng();
280 $ctrl = $this->gui->ctrl();
281 $tour_id = $this->gui->standardRequest()->getTourId();
282 $this->finish_manager->resetTour($tour_id);
283 $mt->setOnScreenMessage("success", $lng->txt("gdtr_tour_has_been_reset"), true);
284 $ctrl->redirectByClass(self::class, "listTours");
285 }
286
287 protected function getDeleteTourModal(int $tour_id): \ILIAS\UI\Component\Modal\Interruptive
288 {
289 $tour = $this->tm->getByObjId($tour_id);
290 $f = $this->gui->ui()->factory();
291 $r = $this->gui->ui()->renderer();
292 $lng = $this->domain->lng();
293 $ctrl = $this->gui->ctrl();
294 $del_items = [];
295 $del_items[] = $f->modal()->interruptiveItem()->keyValue(
296 (string) $tour_id,
297 $tour->getTitle(),
298 ""
299 );
300 $ctrl->setParameterByClass(self::class, "tour_id", $tour_id);
301 $action = $ctrl->getLinkTargetByClass(self::class, "deleteTour");
302
303 return $f->modal()->interruptive(
304 $lng->txt("gdtr_delete_tour"),
305 $lng->txt("gdtr_delete_tour_mess"),
306 $action
307 )->withAffectedItems($del_items);
308 }
309
310 protected function deleteTour(): void
311 {
312 $mt = $this->gui->ui()->mainTemplate();
313 $lng = $this->domain->lng();
314 $ctrl = $this->gui->ctrl();
315 $tour_id = $this->gui->standardRequest()->getTourId();
316 $this->tm->deleteTour($tour_id);
317 $mt->setOnScreenMessage("success", $lng->txt("gdtr_deleted_tour"), true);
318 $ctrl->redirectByClass(self::class, "listTours");
319 }
320
321 protected function getCreateForm(): FormAdapterGUI
322 {
323 $lng = $this->domain->lng();
324 return $this->gui->form([self::class], "saveTour")
325 ->section("sec", $lng->txt("gdtr_add_tour"))
326 ->addStdTitleAndDescription(0, "gdtr");
327 }
328
329 protected function addTour(): void
330 {
331 $mt = $this->gui->ui()->mainTemplate();
332 $mt->setContent($this->getCreateForm()->render());
333 }
334
335 public function saveTour(): void
336 {
337 $mt = $this->gui->ui()->mainTemplate();
338 $lng = $this->domain->lng();
339 $ctrl = $this->gui->ctrl();
340 $form = $this->getCreateForm();
341 if ($form->isValid()) {
342 $obj_id = $this->tm->createTour("dummy", "");
343 $form->saveStdTitleAndDescription($obj_id, "gdtr");
344 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
345 $ctrl->redirectByClass(self::class, "listTours");
346 } else {
347 $mt->setContent($form->render());
348 }
349 }
350
351 protected function editSettings(): void
352 {
353 $this->setStepsHeader();
354 $this->setSettingsTabs("settings");
355 $mt = $this->gui->ui()->mainTemplate();
356 $mt->setContent($this->getSettingsForm()->render());
357 }
358
359 protected function getSettingsForm(): FormAdapterGUI
360 {
361 $tour_id = $this->gui->standardRequest()->getTourId();
362 $lng = $this->domain->lng();
363 $settings = $this->domain->tourSettings()->getByObjId($tour_id);
364 $perm_val = (string) $settings?->getPermission()->value;
365 if ($perm_val === "0") {
366 $perm_val = "";
367 }
368 $lang_val = (string) $settings?->getLanguage();
369 $lang_vals = $this->domain->tourSettings()->getLangOptions($lang_val);
370 if ($perm_val === "0") {
371 $perm_val = "";
372 }
373 return $this
374 ->gui
375 ->form([self::class], "saveSettings")
376 ->section("sec", $lng->txt("settings"))
377 ->addStdTitleAndDescription($tour_id, "gdtr")
378 ->checkbox(
379 "active",
380 $lng->txt("gdtr_active"),
381 "",
382 $settings?->isActive()
383 )
384 ->section("sec2", $lng->txt("gdtr_presentation_limitation"))
385 ->text(
386 "screen_ids",
387 $lng->txt("gdtr_screen_ids"),
388 $lng->txt("gdtr_screen_ids_info"),
389 $settings?->getScreenIds()
390 )
391 ->select(
392 "permission",
393 $lng->txt("gdtr_permission"),
394 [
395 (string) PermissionType::Read->value => $lng->txt("read"),
396 (string) PermissionType::Write->value => $lng->txt("write"),
397 (string) PermissionType::Create->value => $lng->txt("create"),
398 ],
399 $lng->txt("gdtr_permission_info"),
400 $perm_val
401 )
402 ->select(
403 "lang",
404 $lng->txt("gdtr_language"),
405 $lang_vals,
406 $lng->txt("gdtr_language_info"),
407 $lang_val
408 );
409
410 }
411
412 public function saveSettings(): void
413 {
414 $mt = $this->gui->ui()->mainTemplate();
415 $form = $this->getSettingsForm();
416 $tour_id = $this->gui->standardRequest()->getTourId();
417 $lng = $this->domain->lng();
418 $ctrl = $this->gui->ctrl();
419
420 $tour_settings = $this->domain->tourSettings();
421 if ($form->isValid()) {
422 $form->saveStdTitleAndDescription($tour_id, "gdtr");
423 $tour_settings->save($this->data->settings(
424 $tour_id,
425 (bool) $form->getData("active"),
426 $form->getData("screen_ids"),
427 PermissionType::from((int) $form->getData("permission")),
428 $form->getData("lang")
429 ));
430 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
431 $ctrl->redirectByClass(self::class, "editSettings");
432 } else {
433 $mt->setContent($form->render());
434 }
435 }
436
437
438 protected function setStepsHeader(): void
439 {
440 $tabs = $this->gui->tabs();
441 $lng = $this->domain->lng();
442 $mt = $this->gui->ui()->mainTemplate();
443 $ctrl = $this->gui->ctrl();
444 $tour = $this->tm->getByObjId($this->gui->standardRequest()->getTourId());
445 $mt->setTitle($lng->txt("guided_tour") . ": " . $tour?->getTitle());
446 $mt->setDescription($tour?->getDescription());
447 $tabs->clearTargets();
448 $tabs->setBackTarget(
449 $lng->txt("back"),
450 $ctrl->getLinkTargetByClass(self::class, "listTours")
451 );
452 }
453
454 protected function setSingleStepHeader(): void
455 {
456 $this->setStepsHeader();
457 $tabs = $this->gui->tabs();
458 $lng = $this->domain->lng();
459 $ctrl = $this->gui->ctrl();
460 $tabs->setBackTarget(
461 $lng->txt("back"),
462 $ctrl->getLinkTargetByClass(self::class, "listSteps")
463 );
464 }
465
466 protected function listSteps(): void
467 {
468 $mt = $this->gui->ui()->mainTemplate();
469 $f = $this->gui->ui()->factory();
470 $ctrl = $this->gui->ctrl();
471 $lng = $this->domain->lng();
472
473 $table = $this->getStepTable();
474 if ($table->handleCommand()) {
475 return;
476 }
477
478 $this->setStepsHeader();
479 $this->setSettingsTabs("steps");
480
481 $b = $f->button()->standard(
482 $lng->txt("gdtr_add_step"),
483 $ctrl->getLinkTarget($this, "addStep")
484 );
485 $this->gui->toolbar()->addComponent($b);
486
487 $mt->setContent($table->render());
488 }
489
490 protected function getStepTable(): \ILIAS\Repository\Table\TableAdapterGUI
491 {
492 return $this->gui->stepTableGUI(
493 $this->gui->standardRequest()->getTourId(),
494 $this,
495 "listSteps"
496 );
497 }
498
499 /*
500 public function tableCommand(): void
501 {
502 $table = $this->getStepTable();
503 $table->handleCommand();
504 }*/
505
506 protected function addStep(): void
507 {
508 $this->setSingleStepHeader();
509 $mt = $this->gui->ui()->mainTemplate();
510 $lng = $this->domain->lng();
511 $mt->setOnScreenMessage("info", $lng->txt("gdtr_edit_step_info"));
512 $mt->setContent($this->getStepForm()->render());
513 }
514
515 protected function getStepForm(?Step $step = null): FormAdapterGUI
516 {
517 $lng = $this->domain->lng();
518 $type_val = (string) $step?->getType()->value;
519 $mb_element_id = $step?->getType()->value === StepType::Mainbar->value
520 ? $step?->getElementId()
521 : null;
522 $mt_element_id = $step?->getType()->value === StepType::Metabar->value
523 ? $step?->getElementId()
524 : null;
525 $tab_element_id = $step?->getType()->value === StepType::Tab->value
526 ? $step?->getElementId()
527 : null;
528 return $this->gui->form([self::class], "saveStep")
529 ->section("sec", $lng->txt("gdtr_step"))
530 ->switch("type", $lng->txt("gdtr_step_type"), "", $type_val)
531 ->group((string) StepType::Mainbar->value, $lng->txt("gdtr_mainbar"), $lng->txt("gdtr_mainbar_info"))
532 ->text("mb_element_id", $lng->txt("gdtr_element_id"), "", $mb_element_id)
533 ->group((string) StepType::Metabar->value, $lng->txt("gdtr_metabar"), $lng->txt("gdtr_metabar_info"))
534 ->text("mt_element_id", $lng->txt("gdtr_element_id"), "", $mt_element_id)
535 ->group((string) StepType::Tab->value, $lng->txt("gdtr_tabs"), $lng->txt("gdtr_tabs_info"))
536 ->text("tab_element_id", $lng->txt("gdtr_element_id"), "", $tab_element_id)
537 ->group((string) StepType::Form->value, $lng->txt("gdtr_form"), $lng->txt("gdtr_form_info"))
538 ->group((string) StepType::Table->value, $lng->txt("gdtr_table"), $lng->txt("gdtr_table_info"))
539 ->group((string) StepType::Toolbar->value, $lng->txt("gdtr_toolbar"), $lng->txt("gdtr_toolbar_info"))
540 ->group((string) StepType::PrimaryButton->value, $lng->txt("gdtr_primary_button"), $lng->txt("gdtr_primary_button_info"))
541 ->end();
542 }
543
544 public function saveStep(): void
545 {
546 $ctrl = $this->gui->ctrl();
547 $mt = $this->gui->ui()->mainTemplate();
548 $oder_nr = 0;
549 if (($step_id = $this->gui->standardRequest()->getStepId()) > 0) {
550 $step = $this->step_manager->getById($step_id);
551 $oder_nr = $step->getOrderNr();
552 }
553 $form = $this->getStepForm();
554 if ($form->isValid()) {
555 $element_id = match ((int) $form->getData("type")) {
556 StepType::Mainbar->value => $form->getData("mb_element_id"),
557 StepType::Metabar->value => $form->getData("mt_element_id"),
558 StepType::Tab->value => $form->getData("tab_element_id"),
559 default => ''
560 };
561 $step = $this->data->step(
562 $step_id,
563 $this->gui->standardRequest()->getTourId(),
564 $oder_nr,
565 StepType::from((int) $form->getData("type")),
566 $element_id
567 );
568 if ($step_id > 0) {
569 $this->step_manager->update($step);
570 $ctrl->redirectByClass(self::class, "listSteps");
571 } else {
572 $new_id = $this->step_manager->create($step);
573 $ctrl->setParameterByClass(self::class, "step_id", $new_id);
574 $ctrl->redirectByClass(ilGuidedTourPageGUI::class, "edit");
575 }
576 } else {
577 $mt->setContent($form->render());
578 }
579 }
580
581 public function editStep(int $step_id): void
582 {
583 $mt = $this->gui->mainTemplate();
584 $lng = $this->domain->lng();
585 $this->setSingleStepHeader();
586 $mt->setOnScreenMessage("info", $lng->txt("gdtr_edit_step_info"));
587 $ctrl = $this->gui->ctrl();
588 $ctrl->setParameterByClass(self::class, "step_id", $step_id);
589 $step = $this->step_manager->getById($step_id);
590 $form = $this->getStepForm($step);
591 $mt->setContent($form->render());
592 }
593
594 public function editPage(int $step_id): void
595 {
596 $ctrl = $this->gui->ctrl();
597 $ctrl->setParameterByClass(self::class, "step_id", $step_id);
598 $ctrl->redirectByClass(ilGuidedTourPageGUI::class, "edit");
599 }
600
601 protected function setSubTabs(string $active): void
602 {
603 $tabs = $this->gui->tabs();
604 $lng = $this->domain->lng();
605 $ctrl = $this->gui->ctrl();
606 $tabs->addSubTab(
607 "tours",
608 $lng->txt("gdtr_tours"),
609 $ctrl->getLinkTargetByClass(self::class, "listTours")
610 );
611 $tabs->addSubTab(
612 "id_settings",
613 $lng->txt("gdtr_id_settings"),
614 $ctrl->getLinkTargetByClass(self::class, "idSettings")
615 );
616 $tabs->activateSubTab($active);
617 }
618
619 protected function idSettings(): void
620 {
621 $this->setSubTabs("id_settings");
622 $mt = $this->gui->ui()->mainTemplate();
623 $mt->setContent($this->getIdForm()->render());
624 }
625
626 protected function getIdForm(): FormAdapterGUI
627 {
628 $lng = $this->domain->lng();
629 $id_pres = $this->domain->idPresentation();
630 return $this
631 ->gui
632 ->form([self::class], "saveIdSettings")
633 ->section("sec", $lng->txt("gdtr_id_settings"))
634 ->text(
635 "users",
636 $lng->txt("gdtr_id_pres_users"),
637 $lng->txt("gdtr_id_pres_users_info"),
638 $id_pres->getIdPresentationUsers()
639 );
640 }
641
642 protected function saveIdSettings(): void
643 {
644 $mt = $this->gui->ui()->mainTemplate();
645 $lng = $this->domain->lng();
646 $ctrl = $this->gui->ctrl();
647 $form = $this->getIdForm();
648 $id_pres = $this->domain->idPresentation();
649 $id_pres->saveIdPresentationUsers($form->getData("users"));
650 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
651 $ctrl->redirectByClass(self::class, "idSettings");
652 }
653
654 protected function saveOrder(): void
655 {
656 $ctrl = $this->gui->ctrl();
657 $mt = $this->gui->ui()->mainTemplate();
658 $lng = $this->domain->lng();
659 $ctrl->saveParameterByClass(self::class, "tour_id");
660
661 $table = $this->getStepTable();
662 $data = $table->getData();
663 if (is_array($data)) {
664 $this->step_manager->saveOrder(
665 $this->gui->standardRequest()->getTourId(),
666 $data
667 );
668 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
669 }
670 $ctrl->redirectByClass(self::class, "listSteps");
671 }
672
673 public function confirmStepDeletion(int $step_id): void
674 {
675 $lng = $this->domain->lng();
676 $ctrl = $this->gui->ctrl();
677 $table = $this->getStepTable();
678 $step = $this->step_manager->getById($step_id);
679 $ctrl->setParameterByClass(self::class, "step_id", $step_id);
680 $title = $this->step_manager->getStepName($step->getType());
681 if ($step->getElementId() !== "") {
682 $title .= " (" . $step->getElementId() . ")";
683 }
684 $table->renderDeletionConfirmation(
685 $lng->txt("gdtr_delete_step"),
686 $lng->txt("gdtr_delete_step_mess"),
687 "deleteStep",
688 [
689 $step_id => $title
690 ]
691 );
692 }
693
694 public function deleteStep(): void
695 {
696 $ctrl = $this->gui->ctrl();
697 $mt = $this->gui->ui()->mainTemplate();
698 $lng = $this->domain->lng();
699 $tour_id = $this->gui->standardRequest()->getTourId();
700 $step_id = $this->gui->standardRequest()->getStepId();
701
702 $this->step_manager->delete($tour_id, $step_id);
703 $mt->setOnScreenMessage("success", $lng->txt("gdtr_deleted_step"), true);
704 $ctrl->redirectByClass(self::class, "listSteps");
705 }
706
707 protected function importTourForm(): void
708 {
709 $mt = $this->gui->ui()->mainTemplate();
710 $mt->setContent($this->getImportForm()->render());
711 }
712
713 protected function getImportForm(): FormAdapterGUI
714 {
715 $lng = $this->domain->lng();
716 return $this->gui->form([self::class], "importTour")
717 ->section("sec", $lng->txt("gdtr_import_tour"))
718 ->file(
719 "import",
720 $lng->txt("import_file"),
721 $this->handleImportUpload(...),
722 "id",
723 "",
724 1,
725 ["application/zip"]
726 );
727 }
728
729 protected function handleImportUpload(
730 FileUpload $upload,
731 UploadResult $result
733 $new_id = $this->importTourFile($result->getName(), $result->getPath());
734 return new BasicHandlerResult(
735 '',
736 \ILIAS\FileUpload\Handler\HandlerResult::STATUS_OK,
737 (string) $new_id,
738 ''
739 );
740 }
741
742
743 protected function importTourFile(
744 string $filename,
745 string $path
746 ): int {
747 $new_id = 0;
748 $fname = explode("_", $filename);
749 if ($fname[4] == "gdtr") {
750 $imp = new ilImport();
751 $new_id = $imp->importObject(
752 null,
753 $path,
754 $filename,
755 "gdtr",
756 "",
757 true
758 );
759 }
760 return $new_id;
761 }
762
763 protected function importTour(): void
764 {
765 $ctrl = $this->gui->ctrl();
766 $ctrl->redirectByClass(self::class, "listTours");
767 }
768}
$filename
Definition: buildRTE.php:78
Export User Interface Class.
@ilCtrl_Calls ilGuidedTourAdminGUI: ilGuidedTourPageGUI, ilExportGUI, ilRepoStandardUploadHandlerGUI
ILIAS Help GuidedTour Step StepManager $step_manager
importTourFile(string $filename, string $path)
ILIAS Help GuidedTour UserFinished UserFinishedManager $finish_manager
__construct(protected \ILIAS\Help\GuidedTour\InternalDataService $data, protected \ILIAS\Help\GuidedTour\InternalDomainService $domain, protected \ILIAS\Help\GuidedTour\InternalGUIService $gui)
ILIAS Help GuidedTour Tour TourManager $tm
handleImportUpload(FileUpload $upload, UploadResult $result)
@ilCtrl_Calls ilGuidedTourPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI @ilCtrl_Calls i...
Import class.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
$path
Definition: ltiservices.php:30
addStdTitleAndDescription(int $obj_id, string $type)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31
getLanguage()