ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilWOPIEmbeddedApplicationGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
26 
31 {
32  public const CMD_EDIT = 'edit';
33  public const CMD_VIEW = 'view';
34  public const CMD_RETURN = 'return';
35  public const P_RETURN_TO = 'return_to';
43  private ilTabsGUI $tabs;
55  private \ILIAS\UI\Renderer $ui_renderer;
63  private Factory $refinery;
71  private ilLanguage $lng;
72 
73  public function __construct(
74  private EmbeddedApplication $application,
75  ) {
76  global $DIC;
77  $this->main_tpl = $DIC->ui()->mainTemplate();
78  $this->tabs = $DIC->tabs();
79  $this->global_screen = $DIC->globalScreen();
80  $this->global_screen->layout()->meta()->addJs('./assets/js/wopi.min.js');
81  $this->global_screen->layout()->meta()->addOnloadCode('il.WOPI.init();');
82  $this->renderer = new Renderer($this->application);
83  $this->ui_renderer = $DIC->ui()->renderer();
84  $this->http = $DIC->http()->wrapper()->query();
85  $this->refinery = $DIC->refinery();
86  $this->ctrl = $DIC->ctrl();
87  $this->lng = $DIC->language();
88  $this->lng->loadLanguageModule('wopi');
89  }
90 
91  public function executeCommand(): void
92  {
93  if (!$this->application->isInline()) {
94  $this->tabs->clearTargets();
95  }
96  $this->global_screen->tool()->context()->current()->addAdditionalData(
97  EmbeddedApplicationGSProvider::EMBEDDED_APPLICATION,
98  $this->application
99  );
100  $a_value = bin2hex((string) $this->application->getBackTarget());
101  $this->ctrl->setParameter($this, self::P_RETURN_TO, $a_value);
102 
103  match ($this->ctrl->getCmd()) {
104  default => $this->edit(),
105  self::CMD_EDIT => $this->edit(),
106  self::CMD_VIEW => $this->view(),
107  self::CMD_RETURN => $this->return(),
108  };
109  }
110 
111  private function view(): void
112  {
113  $this->main_tpl->setContent(
114  $this->ui_renderer->render($this->renderer->getComponent())
115  );
116  }
117 
118  private function edit(): void
119  {
120  $this->main_tpl->setContent(
121  $this->ui_renderer->render($this->renderer->getComponent())
122  );
123  }
124 
125  private function return(): void
126  {
127  $return_to = $this->http->has(self::P_RETURN_TO)
128  ? hex2bin((string) $this->http->retrieve(self::P_RETURN_TO, $this->refinery->kindlyTo()->string()))
129  : null;
130 
131  if ($return_to === null) {
132  $return_to = (string) $this->application->getBackTarget();
133  }
134 
135  $this->main_tpl->setOnScreenMessage(
136  'info',
137  $this->lng->txt('close_wopi_editor_info'),
138  true
139  );
140 
141  $this->ctrl->redirectToURL($return_to);
142  }
143 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderer()
__construct(private EmbeddedApplication $application,)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...