4declare(strict_types=1);
50 $this->webDirectory =
$DIC->filesystem()->web();
51 $this->logger =
$DIC->logger()->otpl();
63 $this->logger->warning(
'File upload already processed: ' .
$e->getMessage());
88 $this->webDirectory->write(
89 self::WEBDIR_PREFIX .
'/' . $this->
settings->getId() .
'.svg',
94 }
catch (Exception
$e) {
95 $this->logger->warning(
'Error writing svg image from xml: ' .
$e->getMessage());
104 if ($this->webDirectory->has(self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg')) {
118 $this->webDirectory->copy(
120 self::WEBDIR_PREFIX .
'/' . $this->settings->getId() .
'.svg'
122 }
catch (Exception
$e) {
123 $this->logger->warning(
'Copying icon failed with message: ' .
$e->getMessage());
128 $this->
settings->setIconIdentifier((
string) 0 );
136 public function delete()
138 if ($this->webDirectory->has(self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg')) {
140 $this->webDirectory->delete(self::WEBDIR_PREFIX .
'/' . $this->
settings->getIconIdentifier() .
'.svg');
141 $this->
settings->setIconIdentifier(
'');
143 }
catch (Exception
$e) {
144 $this->logger->warning(
'Deleting icon dfailed with message: ' .
$e->getMessage());
154 if (!$this->webDirectory->has(self::WEBDIR_PREFIX)) {
156 $this->webDirectory->createDir(self::WEBDIR_PREFIX);
158 $this->logger->error(
'Creating icon directory failed with message: ' .
$e->getMessage());
160 $this->logger->warning(
'Creating icon directory failed with message: ' .
$e->getMessage());
171 if ($this->
settings->getIconIdentifier()) {
173 if ($this->webDirectory->has(self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg')) {
174 $writer->
xmlElement(
'icon', [], $this->webDirectory->read(
175 self::WEBDIR_PREFIX .
'/' . $this->settings->getIconIdentifier() .
'.svg'
178 }
catch (Exception
$e) {
179 $this->logger->warning(
'Export xml failed with message: ' .
$e->getMessage());
An exception for terminatinating execution or to throw for unit testing.
Class IOException Indicates general problems with the input or output operations.
Class IllegalStateException The IllegalStateException indicates a wrong state of the object.
Icon handler for didactic template custom icons.
handleUpload(FileUpload $upload, string $tmpname)
initWebDir()
Init web directory.
toXml(ilXmlWriter $writer)
__construct(ilDidacticTemplateSetting $setting)
ilDidacticTemplateIconHandler constructor.
copy(ilDidacticTemplateSetting $original)
static getWebspaceDir($mode="filesystem")
get webspace directory
xmlElement($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.
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.
moveOneFileTo(UploadResult $UploadResult, $destination, $location=Location::STORAGE, $file_name='', $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
Interface Filesystem The filesystem interface provides the public interface for the Filesystem servic...