ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilRendererFactory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Services/Preview/classes/class.ilPreview.php");
5 
14 final class ilRendererFactory
15 {
20  private static $renderers = null;
21 
27  public static function getRenderers()
28  {
29  self::loadAvailableRenderers();
30  return self::$renderers;
31  }
32 
39  public static function getRenderer($preview)
40  {
41  $renderers = self::getRenderers();
42 
43  // check each renderer if it supports that preview object
44  foreach ($renderers as $renderer)
45  {
46  if ($renderer->supports($preview))
47  {
48  return $renderer;
49  }
50  }
51 
52  // no matching renderer was found
53  return null;
54  }
55 
61  private static function loadAvailableRenderers()
62  {
63  // already loaded?
64  if (self::$renderers != null)
65  return;
66 
67  $r = array();
68 
69  // get registered and active plugins
70  global $ilPluginAdmin;
71  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Preview", "pvre");
72  foreach ($pl_names as $pl)
73  {
74  $plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "Preview", "pvre", $pl);
75  $r[] = $plugin->getRendererClassInstance();
76  }
77 
78  // add default renderers
79  include_once("./Services/Preview/classes/class.ilImageMagickRenderer.php");
80  $r[] = new ilImageMagickRenderer();
81 
82  include_once("./Services/Preview/classes/class.ilGhostscriptRenderer.php");
84  $r[] = new ilGhostscriptRenderer();
85 
86  self::$renderers = $r;
87  }
88 }
89 ?>
Preview renderer class that is able to create previews from images by using ImageMagick.
Factory that provides access to all available preview renderers.
static getRenderers()
Gets an array containing all available preview renderers.
static isGhostscriptInstalled()
Determines whether Ghostscript is installed.
$preview
static getRenderer($preview)
Gets the renderer that is able to create a preview for the specified preview object.
$r
Definition: example_031.php:79
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
Create styles array
The data for the language used.
static loadAvailableRenderers()
Loads the available preview renderers.
const IL_COMP_SERVICE
Preview renderer class that is able to create previews from PDF, PS and EPS by using GhostScript...