4 require_once(
"./Services/Preview/classes/class.ilPreviewSettings.php");
5 require_once(
"./Services/Preview/classes/class.ilFSStoragePreview.php");
71 $this->obj_id = $a_obj_id;
87 return $preview->create($a_obj, $a_force);
115 $status = $src->getRenderStatus();
118 if ($status == self::RENDER_STATUS_CREATED) {
121 $dest->setRenderDate($src->getRenderDate());
122 $dest->setRenderStatus($src->getRenderStatus());
125 $dest->getStorage()->create();
128 ilUtil::rCopy($src->getStoragePath(), $dest->getStoragePath());
159 require_once(
"./Services/Preview/classes/class.ilRendererFactory.php");
161 return $renderer != null;
193 public function create($a_obj, $a_force =
false)
200 require_once(
"./Services/Preview/classes/class.ilRendererFactory.php");
204 if ($renderer == null) {
216 if ($this->
getRenderStatus() == self::RENDER_STATUS_CREATED && !$a_force) {
228 $renderer->render($this, $a_obj,
true);
239 public function delete()
249 $this->render_date =
false;
250 $this->render_status = self::RENDER_STATUS_NONE;
267 if ($handle = @opendir(
$path)) {
268 while (
false !== ($file = readdir($handle))) {
269 $filepath =
$path .
"/" . $file;
270 if (!is_file($filepath)) {
274 if ($file !=
'.' && $file !=
'..' && strpos($file,
"preview_") === 0) {
279 $size = @getimagesize($filepath);
280 if (
$size !==
false) {
281 $image[
"width"] =
$size[0];
282 $image[
"height"] =
$size[1];
285 $images[$file] = $image;
316 $ilDB = $DIC[
'ilDB'];
321 "obj_id" => array(
"integer", $this->
getObjId()),
335 $ilDB = $DIC[
'ilDB'];
337 $set =
$ilDB->queryF(
338 "SELECT * FROM preview_data WHERE obj_id=%s",
343 while ($rec =
$ilDB->fetchAssoc($set)) {
356 $ilDB = $DIC[
'ilDB'];
364 array(
"obj_id" => array(
"integer", $this->
getObjId()))
374 $ilDB = $DIC[
'ilDB'];
377 "DELETE FROM preview_data WHERE obj_id=%s",
401 if (empty($this->obj_type)) {
425 return ILIAS_ABSOLUTE_PATH . substr($this->
getStorage()->getPath(), 1);
437 return $path .
"/" . self::FILENAME_FORMAT;
457 $this->render_date = $a_date;
477 $this->render_status = $a_status;
487 if ($this->storage == null) {
__construct($a_obj_id, $a_type="")
Creates a new ilPreview.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
const RENDER_STATUS_FAILED
getObjType()
Gets the type of the object the preview is for.
exists()
Determines whether the preview exists or not.
getAbsoluteStoragePath()
Gets the absolute path where the previews are stored.
const RENDER_STATUS_PENDING
getFilePathFormat()
Gets the absolute file path for preview images that contains a placeholder in the file name ('%02d') ...
doCreate()
Create entry in database.
static lookupRenderStatus($a_obj_id)
Gets the render status for the object with the specified id.
init()
Initializes the preview object.
static getRenderer($preview)
Gets the renderer that is able to create a preview for the specified preview object.
static hasPreview($a_obj_id, $a_type="")
Determines whether the object with the specified reference id has a preview.
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.
static removeTrailingPathSeparators($path)
getRenderStatus()
Gets the status of the rendering process.
static getHtmlPath($relative_path)
get url of path
static isPreviewEnabled()
Gets whether the preview functionality is enabled.
static _lookupType($a_id, $a_reference=false)
lookup object type
const RENDER_STATUS_CREATED
doRead()
Read data from database.
getObjId()
Gets the id of the object the preview is for.
static copyPreviews($a_src_id, $a_dest_id)
Copies the preview images from one preview to a new preview object.
doDelete()
Delete data from database.
doUpdate()
Update data in database.
setRenderStatus($a_status)
Sets the status of the rendering process.
getRenderDate()
Gets the date when the preview was rendered.
getStoragePath()
Gets the path where the previews are stored relative to the web directory.
static deletePreview($a_obj_id)
Deletes the preview for the object with the specified id.
setRenderDate($a_date)
Sets the date when the preview was rendered.
save()
Saves the preview data to the database.
getImages()
Gets an array of preview images.
getStorage()
Gets the storage object for the preview.
create($a_obj, $a_force=false)
Creates the preview.