82 parent::__construct();
92 $this->check_input_called = $status;
100 if ($this->document->getId() > 0) {
101 $this->
setTitle($this->lng->txt(
'tos_form_edit_doc_head'));
103 $this->
setTitle($this->lng->txt(
'tos_form_new_doc_head'));
108 $title = new \ilTextInputGUI($this->lng->txt(
'tos_form_document_title'),
'title');
109 $title->setInfo($this->lng->txt(
'tos_form_document_title_info'));
110 $title->setRequired(
true);
111 $title->setDisabled(!$this->isEditable);
112 $title->setValue($this->document->getTitle());
113 $title->setMaxLength(255);
116 $documentLabel = $this->lng->txt(
'tos_form_document');
117 $documentByline = $this->lng->txt(
'tos_form_document_info');
118 if ($this->document->getId() > 0) {
119 $documentLabel = $this->lng->txt(
'tos_form_document_new');
120 $documentByline = $this->lng->txt(
'tos_form_document_new_info');
125 if (!$this->document->getId()) {
128 $document->setDisabled(!$this->isEditable);
132 if ($this->isEditable) {
144 return strlen($this->translatedError);
160 return strlen($this->translatedInfo);
176 if (!$this->fillObject()) {
181 $this->document->save();
189 protected function fillObject() :
bool 195 if ($this->fileUpload->hasUploads() && !$this->fileUpload->hasBeenProcessed()) {
197 $this->fileUpload->process();
200 $uploadResult = array_values($this->fileUpload->getResults())[0];
201 if (!$uploadResult) {
202 $this->
getItemByPostVar(
'document')->setAlert($this->lng->txt(
'form_msg_file_no_upload'));
203 throw new \ilException($this->lng->txt(
'form_input_not_valid'));
206 if (!$this->document->getId() || $uploadResult->getName() !==
'') {
207 if ($uploadResult->getStatus()->getCode() != ProcessingStatus::OK) {
208 $this->
getItemByPostVar(
'document')->setAlert($uploadResult->getStatus()->getMessage());
209 throw new \ilException($this->lng->txt(
'form_input_not_valid'));
212 $this->fileUpload->moveOneFileTo(
220 $pathToFile =
'/agreements/' . $uploadResult->getName();
221 if (!$this->tmpFileSystem->has($pathToFile)) {
222 $this->
getItemByPostVar(
'document')->setAlert($this->lng->txt(
'form_msg_file_no_upload'));
223 throw new \ilException($this->lng->txt(
'form_input_not_valid'));
226 $originalContent = $content = $this->tmpFileSystem->read($pathToFile);
228 $purifiedHtmlContent = $this->documentPurifier->purify($content);
231 if (!$htmlValidator->isValid()) {
232 $purifiedHtmlContent = nl2br($purifiedHtmlContent);
235 if (trim($purifiedHtmlContent) !== trim($originalContent)) {
236 $this->translatedInfo = $this->lng->txt(
'tos_form_document_content_changed');
239 $this->document->setText($purifiedHtmlContent);
240 $this->tmpFileSystem->delete($pathToFile);
243 $this->translatedError = $e->getMessage();
248 $this->document->setTitle($this->
getInput(
'title'));
250 if ($this->document->getId() > 0) {
251 $this->document->setLastModifiedUsrId($this->actor->getId());
253 $this->document->setOwnerUsrId($this->actor->getId());
257 $this->document->setSorting((
int) $documentWithMaxSorting->getSorting() + 1);
259 $this->document->setSorting(1);
Class ilTermsOfServiceDocumentsContainsHtmlValidator.
Interface for html sanitizing functionality.
Class ilTermsOfServiceDocument.
static orderBy($orderBy, $orderDirection='ASC')
Class FlySystemFileAccessTest.