ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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  {
122  return $this->getWebDavPathToLanguageTemplate($language) . '?' . $this->mount_instructions_query;
123  }
124 }
getWebDavPathToLanguageTemplate(string $language)
__construct(\Psr\Http\Message\RequestInterface $a_request)
getWebDavDefaultUri(int $a_ref_id)
getWebDavNautilusUri(int $a_ref_id)
changePathToWebDavScript(string $a_original_path)
getUriToMountInstructionModalByLanguage(string $language)
getUriToMountInstructionModalByRef(int $a_ref_id)
getWebDavUriByPlaceholderName(string $placeholder_name, int $a_ref_id)
getWebDavKonquerorUri(int $a_ref_id)