ILIAS  release_8 Revision v8.24
ilPreviewRenderer Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilPreviewRenderer:
+ Collaboration diagram for ilPreviewRenderer:

Public Member Functions

 getName ()
 Gets the name of the renderer. More...
 
 isPlugin ()
 Determines whether the renderer is a plugin or a built in one. More...
 
 getSupportedRepositoryTypes ()
 Gets an array containing the repository types (e.g. More...
 
 supports (\ilPreview $preview)
 Determines whether the specified preview object is supported by the renderer. More...
 
 render (\ilPreview $preview, \ilObject $obj, bool $async)
 Creates the preview of the specified preview object. More...
 

Protected Member Functions

 renderImages (\ilObject $obj)
 Renders the specified object into images. More...
 
 getImageSize ()
 Gets the size of the preview images in pixels. More...
 
 getImageQuality ()
 Gets the quality (compression) of the preview images (1-100). More...
 
 getMaximumNumberOfPreviews ()
 Gets the maximum number of preview pictures per object. More...
 

Private Member Functions

 createPreviewImage (string $src_img_path, string $dest_img_path)
 Creates a preview image path from the specified source image. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Abstract parent class for all preview renderer classes.

Author
Stefan Born stefa.nosp@m.n.bo.nosp@m.rn@ph.nosp@m.zh.c.nosp@m.h
Version
$Id$

Definition at line 26 of file class.ilPreviewRenderer.php.

Member Function Documentation

◆ createPreviewImage()

ilPreviewRenderer::createPreviewImage ( string  $src_img_path,
string  $dest_img_path 
)
private

Creates a preview image path from the specified source image.

Parameters
string$src_img_pathThe source image path.
string$dest_img_pathThe destination image path.
Returns
bool true, if the preview was created; otherwise, false.

Definition at line 125 of file class.ilPreviewRenderer.php.

125 : bool
126 {
127 // create resize argument
128 $imgSize = $this->getImageSize();
129 $resizeArg = $imgSize . "x" . $imgSize . (ilUtil::isWindows() ? "^" : "\\") . ">";
130
131 // cmd: convert $src_img_path -background white -flatten -resize 280x280 -quality 85 -sharpen 0x0.5 $dest_img_path
132 $args = sprintf(
133 "%s -background white -flatten -resize %s -quality %d -sharpen 0x0.5 %s",
134 ilShellUtil::escapeShellArg($src_img_path),
135 $resizeArg,
136 $this->getImageQuality(),
137 ilShellUtil::escapeShellArg($dest_img_path)
138 );
139
140 ilShellUtil::execQuoted(PATH_TO_CONVERT, $args);
141
142 return is_file($dest_img_path);
143 }
getImageQuality()
Gets the quality (compression) of the preview images (1-100).
getImageSize()
Gets the size of the preview images in pixels.
static escapeShellArg(string $a_arg)
static execQuoted(string $cmd, ?string $args=null)
static isWindows()

References ilShellUtil\escapeShellArg(), ilShellUtil\execQuoted(), getImageQuality(), getImageSize(), and ilUtil\isWindows().

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageQuality()

ilPreviewRenderer::getImageQuality ( )
finalprotected

Gets the quality (compression) of the preview images (1-100).

Returns
int The current value

Definition at line 169 of file class.ilPreviewRenderer.php.

169 : int
170 {
172 }
static getImageQuality()
Gets the quality (compression) of the preview images (1-100).

References ilPreviewSettings\getImageQuality().

Referenced by createPreviewImage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageSize()

ilPreviewRenderer::getImageSize ( )
finalprotected

Gets the size of the preview images in pixels.

Returns
int The current value

Definition at line 159 of file class.ilPreviewRenderer.php.

159 : int
160 {
162 }
static getImageSize()
Gets the size of the preview images in pixels.

References ilPreviewSettings\getImageSize().

Referenced by createPreviewImage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaximumNumberOfPreviews()

ilPreviewRenderer::getMaximumNumberOfPreviews ( )
finalprotected

Gets the maximum number of preview pictures per object.

Returns
int The current value

Definition at line 179 of file class.ilPreviewRenderer.php.

179 : int
180 {
182 }
static getMaximumPreviews()
Gets the maximum number of preview pictures per object.

References ilPreviewSettings\getMaximumPreviews().

Referenced by ilGhostscriptRenderer\renderImages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getName()

ilPreviewRenderer::getName ( )

Gets the name of the renderer.

Returns
string The name of the renderer.

Definition at line 33 of file class.ilPreviewRenderer.php.

33 : string
34 {
35 $name = get_class($this);
36
37 if (strpos($name, "il") === 0) {
38 $name = substr($name, 2);
39 }
40
41 if (strpos($name, "Renderer") === (strlen($name) - 8)) {
42 $name = substr($name, 0, -8) . " Renderer";
43 }
44
45 return $name;
46 }
if($format !==null) $name
Definition: metadata.php:247

References $name.

Referenced by ilObjFileAccessSettingsGUI\showPreviewRenderers().

+ Here is the caller graph for this function:

◆ getSupportedRepositoryTypes()

ilPreviewRenderer::getSupportedRepositoryTypes ( )
abstract

Gets an array containing the repository types (e.g.

'file' or 'crs') that are supported by the renderer.

Returns
array An array containing the supported repository types.

Reimplemented in ilFilePreviewRenderer.

◆ isPlugin()

ilPreviewRenderer::isPlugin ( )
final

Determines whether the renderer is a plugin or a built in one.

Returns
bool true, if the renderer is a plugin; otherwise, false.

Definition at line 53 of file class.ilPreviewRenderer.php.

53 : bool
54 {
55 return !is_file("./Services/Preview/classes/class." . get_class($this) . ".php");
56 }

Referenced by ilObjFileAccessSettingsGUI\showPreviewRenderers().

+ Here is the caller graph for this function:

◆ render()

ilPreviewRenderer::render ( \ilPreview  $preview,
\ilObject  $obj,
bool  $async 
)
final

Creates the preview of the specified preview object.

Parameters
ilPreview$previewThe preview object.
ilObject$objThe object to create a preview for.
bool$asynctrue, if the rendering should be done asynchronously; otherwise, false.
Returns
bool true, if the preview was successfully rendered; otherwise, false.

Definition at line 85 of file class.ilPreviewRenderer.php.

85 : ?bool
86 {
87 $preview->setRenderDate(ilUtil::now());
89 $preview->save();
90 $images = $this->renderImages($obj);
91
92 // process each image
93 if (is_array($images) && count($images) > 0) {
94 $success = false;
95 foreach ($images as $idx => $image) {
96 // create the ending preview image
97 $success |= $this->createPreviewImage(
98 $image->getImagePath(),
99 sprintf($preview->getFilePathFormat(), $idx + 1)
100 );
101
102 // if the image is temporary we can delete it
103 if ($image->isTemporary()) {
104 $image->delete();
105 }
106 }
107
108 $preview->setRenderDate(ilUtil::now());
110 return $success;
111 }
112
113 $preview->setRenderDate(ilUtil::now());
115 return false;
116 }
renderImages(\ilObject $obj)
Renders the specified object into images.
createPreviewImage(string $src_img_path, string $dest_img_path)
Creates a preview image path from the specified source image.
const RENDER_STATUS_FAILED
const RENDER_STATUS_CREATED
const RENDER_STATUS_PENDING
static now()
Return current timestamp in Y-m-d H:i:s format.
$preview
Definition: imgupload.php:81

References $preview, createPreviewImage(), ilUtil\now(), ilPreview\RENDER_STATUS_CREATED, ilPreview\RENDER_STATUS_FAILED, ilPreview\RENDER_STATUS_PENDING, and renderImages().

+ Here is the call graph for this function:

◆ renderImages()

ilPreviewRenderer::renderImages ( \ilObject  $obj)
abstractprotected

Renders the specified object into images.

The images do not need to be of the preview image size.

Parameters
ilObject$objThe object to create images from.
Returns
array An array of ilRenderedImage containing the absolute file paths to the images.

Reimplemented in ilGhostscriptRenderer, and ilImageMagickRenderer.

Referenced by render().

+ Here is the caller graph for this function:

◆ supports()

ilPreviewRenderer::supports ( \ilPreview  $preview)

Determines whether the specified preview object is supported by the renderer.

Parameters
ilPreview$previewThe preview object to check.
Returns
bool true, if the renderer supports the specified preview object; otherwise, false.

Reimplemented in ilFilePreviewRenderer.

Definition at line 71 of file class.ilPreviewRenderer.php.

71 : bool
72 {
73 // contains type?
74 return in_array($preview->getObjType(), $this->getSupportedRepositoryTypes());
75 }

References $preview.


The documentation for this class was generated from the following file: