ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilWebDAVUriBuilder.php
Go to the documentation of this file.
1<?php
2
3
5{
7 protected $request;
8
10 protected $schemas = array(
11 'default' => 'http',
12 'konqueror' => 'webdav',
13 'nautilus' => 'dav'
14 );
15
16 protected $mount_instructions_query = 'mount-instructions';
17
18 protected $webdav_script_name = 'webdav.php';
19
20 public function __construct(\Psr\Http\Message\RequestInterface $a_request)
21 {
22 $this->request = $a_request;
23
24 $this->uri = $a_request->getUri();
25 $this->host = $this->uri->getHost();
26
27 $this->client_id = CLIENT_ID;
28 $this->web_path_to_script = $this->changePathToWebDavScript($this->uri->getPath());
29 }
30
37 protected function changePathToWebDavScript(string $a_original_path)
38 {
39 $exploded_path = explode('/', $a_original_path);
40
41 if (in_array($this->webdav_script_name, $exploded_path)) {
42 return implode('/', array_splice($exploded_path, 0, -2));
43 }
44
45 return implode('/', array_splice($exploded_path, 0, -1)) . '/' . $this->webdav_script_name;
46 }
47
52 protected function getWebDavPathToRef(int $a_ref_id)
53 {
54 return "$this->web_path_to_script/$this->client_id/ref_$a_ref_id";
55 }
56
61 protected function getWebDavPathToLanguageTemplate(string $language)
62 {
63 return "$this->web_path_to_script/$this->client_id/$language";
64 }
65
71 protected function getWebDavUriByPlaceholderName(string $placeholder_name, int $a_ref_id)
72 {
73 $scheme = $this->schemas[$placeholder_name];
74 if ($this->uri->getScheme() == 'https') {
75 $scheme .= 's';
76 }
77 return $scheme . '://' . $this->host . $this->getWebDavPathToRef($a_ref_id);
78 }
79
84 public function getWebDavDefaultUri(int $a_ref_id)
85 {
86 return $this->getWebDavUriByPlaceholderName('default', $a_ref_id);
87 }
88
93 public function getWebDavNautilusUri(int $a_ref_id)
94 {
95 return $this->getWebDavUriByPlaceholderName('nautilus', $a_ref_id);
96 }
97
102 public function getWebDavKonquerorUri(int $a_ref_id)
103 {
104 return $this->getWebDavUriByPlaceholderName('konqueror', $a_ref_id);
105 }
106
111 public function getUriToMountInstructionModalByRef(int $a_ref_id)
112 {
113 return $this->getWebDavPathToRef($a_ref_id) . '?' . $this->mount_instructions_query;
114 }
115
120 public function getUriToMountInstructionModalByLanguage(string $language)
121 {
123 }
124}
An exception for terminatinating execution or to throw for unit testing.
getWebDavPathToLanguageTemplate(string $language)
__construct(\Psr\Http\Message\RequestInterface $a_request)
getWebDavNautilusUri(int $a_ref_id)
getWebDavDefaultUri(int $a_ref_id)
changePathToWebDavScript(string $a_original_path)
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:39