ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPreviewRenderer Class Reference

Abstract parent class for all preview renderer classes. More...

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

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

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

Detailed Description

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 14 of file class.ilPreviewRenderer.php.

Member Function Documentation

ilPreviewRenderer::createPreviewImage (   $src_img_path,
  $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 119 of file class.ilPreviewRenderer.php.

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

Referenced by render().

{
// create resize argument
$imgSize = $this->getImageSize();
$resizeArg = $imgSize . "x" . $imgSize . (ilUtil::isWindows() ? "^" : "\\") . ">";
// cmd: convert $src_img_path -background white -flatten -resize 280x280 -quality 85 -sharpen 0x0.5 $dest_img_path
$args = sprintf(
"%s -background white -flatten -resize %s -quality %d -sharpen 0x0.5 %s",
ilUtil::escapeShellArg($src_img_path),
$resizeArg,
$this->getImageQuality(),
ilUtil::escapeShellArg($dest_img_path));
return is_file($dest_img_path);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPreviewRenderer::getImageQuality ( )
finalprotected

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

Returns
int The current value

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

Referenced by createPreviewImage().

+ Here is the caller graph for this function:

ilPreviewRenderer::getImageSize ( )
finalprotected

Gets the size of the preview images in pixels.

Returns
int The current value

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

Referenced by createPreviewImage().

+ Here is the caller graph for this function:

ilPreviewRenderer::getMaximumNumberOfPreviews ( )
finalprotected

Gets the maximum number of preview pictures per object.

Returns
int The current value

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

References ilPreviewSettings\getMaximumPreviews().

Referenced by ilGhostscriptRenderer\renderImages().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPreviewRenderer::getName ( )

Gets the name of the renderer.

Returns
string The name of the renderer.

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

{
$name = get_class($this);
if (strpos($name, "il") === 0)
$name = substr($name, 2);
if (strpos($name, "Renderer") === (strlen($name) - 8))
$name = substr($name, 0, strlen($name) - 8) . " Renderer";
return $name;
}
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.

Referenced by supports().

+ Here is the caller graph for this function:

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 39 of file class.ilPreviewRenderer.php.

{
$filepath = "./Services/Preview/classes/class." . get_class($this) . ".php";
return !is_file($filepath);
}
ilPreviewRenderer::render (   $preview,
  $obj,
  $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 72 of file class.ilPreviewRenderer.php.

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

{
$preview->setRenderDate(ilUtil::now());
$preview->save();
// TODO: this should be done in background if $async is true
// the deriving renderer should deliver images
require_once("./Services/Preview/classes/class.ilRenderedImage.php");
$images = $this->renderImages($obj);
// process each image
if (is_array($images) && count($images) > 0)
{
$success = false;
foreach ($images as $idx => $image)
{
// create the ending preview image
$image->getImagePath(),
sprintf($preview->getFilePathFormat(), $idx + 1));
// if the image is temporary we can delete it
if($image->isTemporary())
$image->delete();
}
$preview->setRenderDate(ilUtil::now());
return $success;
}
else
{
$preview->setRenderDate(ilUtil::now());
return false;
}
}

+ Here is the call graph for this function:

ilPreviewRenderer::renderImages (   $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 ilImageMagickRenderer, and ilGhostscriptRenderer.

Referenced by render().

+ Here is the caller graph for this function:

ilPreviewRenderer::supports (   $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 58 of file class.ilPreviewRenderer.php.

References $preview, and getSupportedRepositoryTypes().

{
// contains type?
return in_array($preview->getObjType(), $this->getSupportedRepositoryTypes());
}

+ Here is the call graph for this function:


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