ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ProblemInfoFile.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\WebDAV\Entity;
22
23use Sabre\DAV\IFile;
24use Sabre\DAV\Exception\Forbidden;
25use ilLanguage;
26
34final class ProblemInfoFile implements IFile
35{
36 public const string FILE_NAME = '#!_WEBDAV_INFORMATION.txt';
37
38 public function __construct(
40 private array $duplicate_titles,
42 private array $forbidden_titles,
43 private bool $info_name_collision,
44 private ilLanguage $lang
45 ) {
46 }
47
48 public function hasProblems(): bool
49 {
50 return $this->info_name_collision
51 || $this->duplicate_titles !== []
52 || $this->forbidden_titles !== [];
53 }
54
55 public function getName(): string
56 {
57 return self::FILE_NAME;
58 }
59
60 public function setName($name): void
61 {
62 throw new Forbidden('The error info file cannot be renamed');
63 }
64
65 public function getLastModified(): int
66 {
67 return time();
68 }
69
70 public function put($data): void
71 {
72 throw new Forbidden('The error info file is virtual and cannot be overwritten');
73 }
74
75 public function get(): string
76 {
77 $message = '';
78
79 if ($this->info_name_collision) {
80 $message .= '# ' . $this->lang->txt('webdav_problem_info_duplicate') . "\n\n";
81 }
82
83 if ($this->duplicate_titles !== []) {
84 $message .= '# ' . $this->lang->txt('webdav_duplicate_detected_title') . "\n";
85 foreach ($this->duplicate_titles as $title) {
86 $message .= $title . "\n";
87 }
88 $message .= "\n";
89 }
90
91 if ($this->forbidden_titles !== []) {
92 $message .= '# ' . $this->lang->txt('webdav_forbidden_chars_title') . "\n";
93 foreach ($this->forbidden_titles as $title) {
94 $message .= $title . "\n";
95 }
96 $message .= "\n";
97 }
98
99 if ($message === '') {
100 return $this->lang->txt('webdav_problem_free_container');
101 }
102
103 return $message;
104 }
105
106 public function getSize(): int
107 {
108 return strlen($this->get());
109 }
110
111 public function getContentType(): string
112 {
113 return 'text/plain';
114 }
115
116 public function getETag(): ?string
117 {
118 return null;
119 }
120
121 public function delete(): void
122 {
123 throw new Forbidden('The error info file cannot be deleted');
124 }
125}
Virtual text file shown in every container that lists ILIAS objects which cannot be exposed via WebDA...
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76
language handling