19declare(strict_types=1);
43 private int $ttl = 3600 * 8;
48 self::SUB_EMBED => false
56 protected URI $back_target,
57 protected bool $inline =
false,
58 ?
string $ui_language =
null
62 $data_signer =
$DIC[
'file_delivery.data_signer'];
63 $this->ilias_base_url =
new URI(ILIAS_HTTP_PATH);
64 $editable = $this->action?->getName() === ActionTarget::EDIT->value;
67 'resource_id' => $this->identification->serialize(),
68 'user_id' =>
$DIC->user()->getId(),
69 'stakeholder' => $this->stakeholder::class,
70 'editable' => $editable
73 $ui_language ??=
'en_US';
74 $this->substitutions[
'lang'] = $ui_language;
75 $this->substitutions[
'rs'] = $ui_language;
76 $this->substitutions[
'ui'] = $ui_language;
78 $this->token = $data_signer->sign(
$payload,
'wopi',
new \DateTimeImmutable(
"now + $this->ttl seconds"));
93 return $this->back_target;
103 if ($this->action ===
null) {
109 $url = rtrim((
string) $this->action->getLauncherUrl(),
'/?#')
114 rtrim((
string) $this->ilias_base_url,
'/')
118 . $this->identification->serialize()
121 if ($appendices !== []) {
122 $url .=
'&' . implode(
'&', $appendices);
134 $appendix = $this->action->getUrlAppendix();
137 if ($appendix !==
null) {
138 preg_match_all(
'/([^<]*)=([^>&]*)/m', $appendix, $appendices, PREG_SET_ORDER, 0);
140 $appendices = array_filter($appendices,
static fn(array $appendix):
bool => isset($appendix[1], $appendix[2]));
143 $appendices = array_filter($appendices,
static fn(array $appendix):
bool => strtolower($appendix[1]) !==
'wopisrc');
146 $appendices = array_map(
function (array $appendix): array {
147 $key = strtolower($appendix[1]);
148 if (isset($this->substitutions[$key])) {
149 $appendix[2] = (string) $this->substitutions[$key];
155 $appendices = array_filter($appendices,
static fn(array $appendix):
bool => $appendix[0] !== $appendix[1] .
'=' . $appendix[2]);
159 $appendices = array_map(
static fn(array $appendix):
string => $appendix[1] .
'=' . $appendix[2], $appendices);
161 }
catch (\Throwable $t) {
The scope of this class is split ilias-conform URI's into components.
Class ResourceIdentification.
__construct()
Constructor setup ILIAS global object @access public.
Interface ResourceStakeholder.
if(count($parts) !=3) $payload
ActionTarget
Officialy supported action targets, see https://learn.microsoft.com/en-us/openspecs/office_protocols/...