75 public function __construct(
int $a_obj_id,
string $a_type =
"")
77 $this->obj_id = $a_obj_id;
78 $this->obj_type = $a_type;
93 return $preview->create($a_obj, $a_force);
113 public static function copyPreviews(
int $a_src_id,
int $a_dest_id): void
121 $status = $src->getRenderStatus();
124 if ($status === self::RENDER_STATUS_CREATED) {
127 $dest->setRenderDate($src->getRenderDate());
128 $dest->setRenderStatus($src->getRenderStatus());
131 $dest->getStorage()->create();
148 public static function hasPreview(
int $a_obj_id,
string $a_type =
""): bool
160 return $renderer !==
null;
201 if ($renderer ===
null) {
225 $renderer->render($this, $a_obj,
true);
236 public function delete():
void
246 $this->render_date =
null;
264 while (
false !== ($file = readdir($handle))) {
265 $filepath =
$path .
"/" . $file;
266 if (!is_file($filepath)) {
270 if ($file !==
'.' && $file !==
'..' && strpos($file,
"preview_") === 0) {
275 $size = @getimagesize($filepath);
276 if ($size !==
false) {
277 $image[
"width"] = $size[0];
278 $image[
"height"] = $size[1];
281 $images[$file] = $image;
316 "obj_id" => array(
"integer", $this->
getObjId()),
332 $set =
$ilDB->queryF(
333 "SELECT * FROM preview_data WHERE obj_id=%s",
338 while ($rec =
$ilDB->fetchAssoc($set)) {
359 array(
"obj_id" => array(
"integer", $this->
getObjId()))
372 "DELETE FROM preview_data WHERE obj_id=%s",
396 if (empty($this->obj_type)) {
442 $this->render_date = $a_date;
462 $this->render_status = $a_status;
472 if ($this->storage ===
null) {
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static removeTrailingPathSeparators(string $path)
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
getLastUpdateDate()
Get last update date in YYYY-MM-DD HH-MM-SS format.
static isPreviewEnabled()
Gets whether the preview functionality is enabled.
getFilePathFormat()
Gets the absolute file path for preview images that contains a placeholder in the file name ('%02d') ...
setRenderDate(string $a_date)
doUpdate()
Update data in database.
init()
Initializes the preview object.
ilRendererFactory $factory
bool $exists
Defines whether the preview exists.
ilFSStoragePreview $storage
The file storage instance.
static lookupRenderStatus(int $a_obj_id)
Gets the render status for the object with the specified id.
__construct(int $a_obj_id, string $a_type="")
Creates a new ilPreview.
create(\ilObject $a_obj, bool $a_force=false)
Creates the preview.
doRead()
Read data from database.
static hasPreview(int $a_obj_id, string $a_type="")
Determines whether the object with the specified reference id has a preview.
setRenderStatus(string $a_status)
Sets the status of the rendering process.
static deletePreview(int $a_obj_id)
Deletes the preview for the object with the specified id.
getAbsoluteStoragePath()
Gets the absolute path where the previews are stored.
save()
Saves the preview data to the database.
exists()
Determines whether the preview exists or not.
getStorage()
Gets the storage object for the preview.
string $render_status
The status of the rendering process.
getRenderStatus()
Gets the status of the rendering process.
getImages()
Gets an array of preview images.
doDelete()
Delete data from database.
string $render_date
The timestamp when the preview was rendered.
const RENDER_STATUS_FAILED
const RENDER_STATUS_CREATED
int $obj_id
The object id.
string $obj_type
The type of the object.
static copyPreviews(int $a_src_id, int $a_dest_id)
Copies the preview images from one preview to a new preview object.
doCreate()
Create entry in database.
getStoragePath()
Gets the path where the previews are stored relative to the web directory.
getObjType()
Gets the type of the object the preview is for.
getObjId()
Gets the id of the object the preview is for.
static createPreview(\ilObject $a_obj, bool $a_force=false)
Creates the preview for the object with the specified id.
const RENDER_STATUS_PENDING
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRenderer(\ilPreview $preview)
Gets the renderer that is able to create a preview for the specified preview object.
static getHtmlPath(string $relative_path)
get url of path