48 string $formAction =
'',
49 string $saveCommand =
'saveDocument',
50 string $cancelCommand =
'showDocuments',
51 bool $isEditable =
false 70 $this->check_input_called = $status;
75 if ($this->document->getId() > 0) {
76 $this->
setTitle($this->
lng->txt(
'acc_form_edit_doc_head'));
78 $this->
setTitle($this->
lng->txt(
'acc_form_new_doc_head'));
84 $title->setInfo($this->
lng->txt(
'acc_form_document_title_info'));
86 $title->setDisabled(!$this->isEditable);
87 $title->setValue($this->document->getTitle());
91 $documentLabel = $this->
lng->txt(
'acc_form_document');
92 $documentByline = $this->
lng->txt(
'acc_form_document_info');
93 if ($this->document->getId() > 0) {
94 $documentLabel = $this->
lng->txt(
'acc_form_document_new');
95 $documentByline = $this->
lng->txt(
'acc_form_document_new_info');
99 $document->setInfo($documentByline);
100 if (!$this->document->getId()) {
101 $document->setRequired(
true);
103 $document->setDisabled(!$this->isEditable);
104 $document->setSuffixes([
'html',
'txt']);
107 if ($this->isEditable) {
116 return strlen($this->translatedError) > 0;
126 return strlen($this->translatedInfo) > 0;
136 if (!$this->fillObject()) {
141 $this->document->save();
146 protected function fillObject():
bool 152 if ($this->fileUpload->hasUploads() && !$this->fileUpload->hasBeenProcessed()) {
153 $this->fileUpload->process();
156 if ($this->fileUpload->hasUploads()) {
159 $uploadResult = array_values($this->fileUpload->getResults())[0];
160 if (!$uploadResult) {
165 if (!$this->document->getId() || $uploadResult->getName() !==
'') {
166 if (!$uploadResult->isOK()) {
167 $this->
getItemByPostVar(
'document')->setAlert($uploadResult->getStatus()->getMessage());
171 $this->fileUpload->moveOneFileTo(
179 $pathToFile =
'/agreements/' . $uploadResult->getName();
180 if (!$this->tmpFileSystem->has($pathToFile)) {
185 $originalContent = $content = $this->tmpFileSystem->read($pathToFile);
187 $purifiedHtmlContent = $this->documentPurifier->purify($content);
190 if (!$htmlValidator->isValid()) {
191 $purifiedHtmlContent = nl2br($purifiedHtmlContent);
194 if (trim($purifiedHtmlContent) !== trim($originalContent)) {
195 $this->translatedInfo = $this->
lng->txt(
'acc_form_document_content_changed');
198 $this->document->setText($purifiedHtmlContent);
199 $this->tmpFileSystem->delete($pathToFile);
202 $this->translatedError = $e->getMessage();
207 $this->document->setTitle($this->
getInput(
'title'));
209 if ($this->document->getId() > 0) {
210 $this->document->setLastModifiedUsrId($this->actor->getId());
212 $this->document->setOwnerUsrId($this->actor->getId());
216 $this->document->setSorting((
int) $documentWithMaxSorting->getSorting() + 1);
218 $this->document->setSorting(1);
static orderBy($orderBy, string $orderDirection='ASC')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface for html sanitizing functionality.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
Class FlySystemFileAccessTest disabled disabled disabled.