19declare(strict_types=1);
44 private int $ttl = 3600 * 8;
49 self::SUB_EMBED => false
64 protected URI $back_target,
65 protected bool $inline =
false,
66 ?
string $ui_language =
null,
67 ?
bool $user_can_write =
null
71 $data_signer =
$DIC[
'file_delivery.data_signer'];
72 $this->ilias_base_url =
new URI(ILIAS_HTTP_PATH);
74 $this->action?->getName(),
75 [ActionTarget::EDIT->value, ActionTarget::EMBED_EDIT->value, ActionTarget::EDIT_NEW->value],
80 'resource_id' => $this->identification->serialize(),
81 'user_id' =>
$DIC->user()->getId(),
82 'stakeholder' => $this->stakeholder::class,
83 'editable' => $editable,
84 'user_can_write' => $user_can_write ?? $editable
87 $ui_language ??=
'en_US';
88 $this->substitutions[
'lang'] = $ui_language;
89 $this->substitutions[
'rs'] = $ui_language;
90 $this->substitutions[
'ui'] = $ui_language;
92 $this->token = $data_signer->sign($payload,
'wopi',
new \DateTimeImmutable(
"now + $this->ttl seconds"));
107 return $this->back_target;
112 return $this->inline;
118 if ($this->action ===
null || !
Crawler::isWebUrl($this->action->getLauncherUrl())) {
124 $url = rtrim((
string) $this->action->getLauncherUrl(),
'/?#')
129 rtrim((
string) $this->ilias_base_url,
'/')
133 . $this->identification->serialize()
136 if ($appendices !== []) {
137 $url .=
'&' . implode(
'&', $appendices);
140 return new URI($url);
149 $appendix = $this->action->getUrlAppendix();
152 if ($appendix !==
null) {
153 preg_match_all(
'/([^<]*)=([^>&]*)/m', $appendix, $appendices, PREG_SET_ORDER, 0);
155 $appendices = array_filter($appendices,
static fn(array $appendix):
bool => isset($appendix[1], $appendix[2]));
158 $appendices = array_filter($appendices,
static fn(array $appendix):
bool => strtolower((
string) $appendix[1]) !==
'wopisrc');
161 $appendices = array_map(
function (array $appendix): array {
162 $key = strtolower($appendix[1]);
163 if (isset($this->substitutions[$key])) {
164 $appendix[2] = (string) $this->substitutions[$key];
170 $appendices = array_filter($appendices,
static fn(array $appendix):
bool => $appendix[0] !== $appendix[1] .
'=' . $appendix[2]);
174 $appendices = array_map(
static fn(array $appendix):
string => $appendix[1] .
'=' . $appendix[2], $appendices);
176 }
catch (\Throwable $t) {
The scope of this class is split ilias-conform URI's into components.
Class ResourceIdentification.
static isWebUrl(URI $url)
Handles the requests of a WOPI client, see https://learn.microsoft.com/en-us/microsoft-365/cloud-stor...
__construct()
Constructor setup ILIAS global object @access public.
Interface ResourceStakeholder.
ActionTarget
Officialy supported action targets, see https://learn.microsoft.com/en-us/openspecs/office_protocols/...