ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilWebLinkItemInternal.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28{
29 public function isInternal(): bool
30 {
31 return true;
32 }
33
37 public function getResolvedLink(bool $with_parameters = true): string
38 {
39 $parts = explode("|", $this->getTarget());
40 $type = (string) ($parts[0] ?? '');
41 $ref_id = (int) ($parts[1] ?? 0);
42
43 switch ($type) {
44 case 'wpage':
45 $link = $this->getStaticLink(0, 'wiki');
46 $link = $this->appendParameter($link, 'target', 'wiki_wpage_' . $ref_id);
47 break;
48
49 case 'term':
50 // #16894
51 $link = $this->getStaticLink(0, "git");
52 $link = $this->appendParameter($link, 'target', 'git_' . $ref_id);
53 break;
54
55 case 'page':
56 $type = "pg";
57 $link = $this->getStaticLink($ref_id, $type);
58 break;
59
60 default:
61 $link = $this->getStaticLink($ref_id, $type);
62 }
63
64 if (!$with_parameters) {
65 return $link;
66 }
67
68 foreach ($this->getParameters() as $parameter) {
69 $link = $parameter->appendToLink($link);
70 }
71
72 return $link;
73 }
74
75 protected function getStaticLink(int $ref_id, string $type): string
76 {
77 return ilLink::_getStaticLink($ref_id, $type);
78 }
79
80 protected function appendParameter(string $link, string $key, string $value): string
81 {
82 $uri = new URI($link);
83 return (string) $uri->withParameter($key, $value);
84 }
85}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Immutable class for internal Web Link items.
getStaticLink(int $ref_id, string $type)
appendParameter(string $link, string $key, string $value)
getResolvedLink(bool $with_parameters=true)
TODO: should be refactored to use URI data object everywhere.
Immutable class for Web Link items.
$ref_id
Definition: ltiauth.php:66
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61