ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilFileVersionsUploadHandlerGUI.php
Go to the documentation of this file.
1<?php
2
24
33{
34 public const MODE_APPEND = 'append';
35 public const MODE_REPLACE = 'replace';
36 public const P_UPLOAD_MODE = 'upload_mode';
37 protected ilObjFile $file;
38 protected bool $append;
39 protected string $upload_mode = self::MODE_APPEND;
40
41 public function __construct(ilObjFile $existing_file, string $upload_mode = self::MODE_APPEND)
42 {
43 global $DIC;
44 parent::__construct(new ilObjFileStakeholder($DIC->user()->getId()));
45 $this->file = $existing_file;
46 $this->upload_mode = $this->http->wrapper()->query()->has(self::P_UPLOAD_MODE)
47 ? $this->http->wrapper()->query()->retrieve(self::P_UPLOAD_MODE, $DIC->refinery()->kindlyTo()->string())
49
50 $this->ctrl->setParameter($this, self::P_UPLOAD_MODE, $this->upload_mode);
51 }
52
53 protected function getUploadResult(): HandlerResult
54 {
55 $this->upload->register(new ilCountPDFPagesPreProcessors());
56 $this->upload->process();
57 $upload_mode =
58
59 $result_array = $this->upload->getResults();
60 $result = end($result_array);
61
62 if ($result instanceof UploadResult && $result->isOK()) {
63 if ($this->upload_mode === self::MODE_REPLACE) {
64 $identifier = (string) $this->file->replaceWithUpload($result, $result->getName());
65 } else {
66 $identifier = (string) $this->file->appendUpload($result, $result->getName());
67 }
68 $status = HandlerResult::STATUS_OK;
69 $message = "file upload OK";
70 } else {
71 $identifier = '';
72 $status = HandlerResult::STATUS_FAILED;
73 $message = $result->getStatus()->getMessage();
74 }
75
76 return new BasicHandlerResult(
78 $status,
79 $identifier,
81 );
82 }
83}
Class ilCountPDFPagesPreProcessors.
Class ilCtrlAwareStorageUploadHandler.
Class ilFileVersionsUploadHandlerGUI.
__construct(ilObjFile $existing_file, string $upload_mode=self::MODE_APPEND)
Class ilObjFileStakeholder.
Class ilObjFile.
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$message
Definition: xapiexit.php:32