ILIAS  release_8 Revision v8.24
class.ilWebDAVUriBuilder.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use Psr\Http\Message\RequestInterface;
22use Psr\Http\Message\UriInterface;
23
25{
29 protected array $schemas = array(
30 'default' => 'http',
31 'konqueror' => 'webdav',
32 'nautilus' => 'dav'
33 );
34
35 protected string $mount_instructions_query = 'mount-instructions';
36 protected string $webdav_script_name = 'webdav.php';
37
38 protected RequestInterface $request;
39 protected UriInterface $uri;
40 protected string $host;
41 protected string $client_id;
42 protected string $web_path_to_script;
43
44 public function __construct(RequestInterface $request)
45 {
46 $this->request = $request;
47
48 $this->uri = $request->getUri();
49 $this->host = $this->uri->getHost();
50
51 $this->client_id = CLIENT_ID;
52 $this->web_path_to_script = $this->changePathToWebDavScript($this->uri->getPath());
53 }
54
55 protected function changePathToWebDavScript(string $a_original_path): string
56 {
57 $exploded_path = explode('/', $a_original_path);
58
59 if (in_array($this->webdav_script_name, $exploded_path)) {
60 return implode('/', array_splice($exploded_path, 0, -2));
61 }
62
63 return implode('/', array_splice($exploded_path, 0, -1)) . '/' . $this->webdav_script_name;
64 }
65
66 protected function getWebDavPathToRef(int $a_ref_id): string
67 {
68 return "$this->web_path_to_script/$this->client_id/ref_$a_ref_id";
69 }
70
71 protected function getWebDavPathToLanguageTemplate(string $language): string
72 {
73 return "$this->web_path_to_script/$this->client_id/$language";
74 }
75
76 protected function getWebDavUriByPlaceholderName(string $placeholder_name, int $a_ref_id): string
77 {
78 $scheme = $this->schemas[$placeholder_name];
79 if ($this->uri->getScheme() == 'https') {
80 $scheme .= 's';
81 }
82 return $scheme . '://' . $this->host . $this->getWebDavPathToRef($a_ref_id);
83 }
84
85 public function getWebDavDefaultUri(int $a_ref_id): string
86 {
87 return $this->getWebDavUriByPlaceholderName('default', $a_ref_id);
88 }
89
90 public function getWebDavNautilusUri(int $a_ref_id): string
91 {
92 return $this->getWebDavUriByPlaceholderName('nautilus', $a_ref_id);
93 }
94
95 public function getWebDavKonquerorUri(int $a_ref_id): string
96 {
97 return $this->getWebDavUriByPlaceholderName('konqueror', $a_ref_id);
98 }
99
100 public function getUriToMountInstructionModalByRef(int $a_ref_id): string
101 {
102 return $this->getWebDavPathToRef($a_ref_id) . '?' . $this->mount_instructions_query;
103 }
104
105 public function getUriToMountInstructionModalByLanguage(string $language): string
106 {
108 }
109}
getWebDavPathToLanguageTemplate(string $language)
getWebDavNautilusUri(int $a_ref_id)
getWebDavDefaultUri(int $a_ref_id)
changePathToWebDavScript(string $a_original_path)
__construct(RequestInterface $request)
getWebDavUriByPlaceholderName(string $placeholder_name, int $a_ref_id)
getUriToMountInstructionModalByRef(int $a_ref_id)
getWebDavKonquerorUri(int $a_ref_id)
getUriToMountInstructionModalByLanguage(string $language)
const CLIENT_ID
Definition: constants.php:41