19declare(strict_types=1);
37 protected \ILIAS\Filesystem\Filesystem
$fs;
64 public function __construct(
string $a_tex,
string $a_type,
int $a_dpi)
68 $this->fs =
$DIC->filesystem()->web();
73 $this->suffix =
'.png';
76 $this->suffix =
'.svg';
82 $this->salt =
'#' . $a_dpi;
90 $hash = md5($this->tex . $this->salt);
91 return $this->basepath
92 .
'/' . substr($hash, 0, 4)
93 .
'/' . substr($hash, 4, 4)
110 return $this->fs->has($this->
filepath());
118 return $this->fs->read($this->
filepath());
125 public function write(
string $a_content): void
127 $this->fs->put($this->
filepath(), $a_content);
136 if ($this->fs->hasDir($this->basepath)) {
137 foreach ($this->fs->finder()->in([$this->basepath])->files() as $meta) {
138 $size += $this->fs->getSize($meta->getPath(), 1)->inBytes();
142 $type = array(
"K",
"M",
"G",
"T",
"P",
"E",
"Z",
"Y");
145 while ($size >= 1000) {
150 return (round($size, 1) .
" " .
$type[$counter] .
"B");
158 $this->fs->deleteDir($this->basepath);
Customizing of pimple-DIC for ILIAS.
Rendered MathJax image Supports image types SVG or PNG Files are stored in the web file system of ili...
ILIAS Filesystem Filesystem $fs
read()
Read the content of a cached image.
absolutePath()
Get the absolute path of the image.
write(string $a_content)
Save the content of a cached image.
__construct(string $a_tex, string $a_type, int $a_dpi)
exists()
Check if an image is cached.
clearCache()
Delete all files from the cache.
getCacheSize()
Get the total size of the cache with an appropriate unit for display.
filepath()
Create the relative file path of the image.