3declare(strict_types=1);
33 $this->webDirectory =
$DIC->filesystem()->web();
34 $this->
logger = $DIC->logger()->otpl();
43 $this->
logger->warning(
'File upload already processed: ' . $e->getMessage());
47 $result = $upload->
getResults()[$tmpname] ??
false;
48 if ($result instanceof
UploadResult && $result->
isOK() && $result->getSize()) {
65 $this->webDirectory->write(
66 self::WEBDIR_PREFIX .
'/' . $this->
settings->getId() .
'.svg',
71 }
catch (Exception
$e) {
72 $this->
logger->warning(
'Error writing svg image from xml: ' . $e->getMessage());
78 if ($this->webDirectory->has(self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg')) {
89 $this->webDirectory->copy(
91 self::WEBDIR_PREFIX .
'/' . $this->settings->getId() .
'.svg'
93 }
catch (Exception
$e) {
94 $this->
logger->warning(
'Copying icon failed with message: ' . $e->getMessage());
98 $this->
settings->setIconIdentifier(
"0");
103 public function delete():
void
105 if ($this->webDirectory->has(self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg')) {
107 $this->webDirectory->delete(self::WEBDIR_PREFIX .
'/' . $this->
settings->getIconIdentifier() .
'.svg');
108 $this->
settings->setIconIdentifier(
'');
110 }
catch (Exception
$e) {
111 $this->
logger->warning(
'Deleting icon dfailed with message: ' . $e->getMessage());
118 if (!$this->webDirectory->has(self::WEBDIR_PREFIX)) {
120 $this->webDirectory->createDir(self::WEBDIR_PREFIX);
122 $this->
logger->error(
'Creating icon directory failed with message: ' . $e->getMessage());
124 $this->
logger->warning(
'Creating icon directory failed with message: ' . $e->getMessage());
131 if ($this->
settings->getIconIdentifier()) {
133 if ($this->webDirectory->has(self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg')) {
134 $writer->
xmlElement(
'icon', [], $this->webDirectory->read(
135 self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg'
138 }
catch (Exception
$e) {
139 $this->
logger->warning(
'Export xml failed with message: ' . $e->getMessage());
Class IllegalStateException.
Icon handler for didactic template custom icons.
handleUpload(FileUpload $upload, string $tmpname)
toXml(ilXmlWriter $writer)
__construct(ilDidacticTemplateSetting $setting)
copy(ilDidacticTemplateSetting $original)
ilDidacticTemplateSetting $settings
static getWebspaceDir(string $mode="filesystem")
get webspace directory
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
getResults()
Returns the results of the processing and moving operation of the uploaded files.
hasUploads()
Return (bool)true if one ore more file-uploads are in the current request, (bool)false if not.
moveOneFileTo(UploadResult $uploadResult, string $destination, int $location=Location::STORAGE, string $file_name='', bool $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
process()
Invokes all preprocessors for each uploaded file in the sequence they got registered.
hasBeenProcessed()
Return (bool)true if the current upload has already been processed.
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...