ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilFilePreviewRenderer Class Reference

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

+ Inheritance diagram for ilFilePreviewRenderer:
+ Collaboration diagram for ilFilePreviewRenderer:

Public Member Functions

 getSupportedRepositoryTypes ()
 Gets an array containing the repository types (e.g. More...
 
 supports ($preview)
 Determines whether the specified preview object is supported by the renderer. More...
 
 prepareFileForExec ($filepath)
 Checks whether the specified file path can be used with exec() commands. More...
 
 getSupportedFileFormats ()
 Gets an array containing the file formats that are supported by the renderer. More...
 
- Public Member Functions inherited from ilPreviewRenderer
 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 ($preview)
 Determines whether the specified preview object is supported by the renderer. More...
 
 render ($preview, $obj, $async)
 Creates the preview of the specified preview object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ilPreviewRenderer
 renderImages ($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...
 

Detailed Description

Abstract parent class for all file 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.ilFilePreviewRenderer.php.

Member Function Documentation

◆ getSupportedFileFormats()

ilFilePreviewRenderer::getSupportedFileFormats ( )
abstract

Gets an array containing the file formats that are supported by the renderer.

Returns
array An array containing the supported file formats.

Referenced by prepareFileForExec(), and supports().

+ Here is the caller graph for this function:

◆ getSupportedRepositoryTypes()

ilFilePreviewRenderer::getSupportedRepositoryTypes ( )
final

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.

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

22  {
23  return array("file");
24  }

◆ prepareFileForExec()

ilFilePreviewRenderer::prepareFileForExec (   $filepath)

Checks whether the specified file path can be used with exec() commands.

If the file name is not conform with exec() commands, a temporary file is created and the path to that file is returned.

Parameters
string$filepathThe path of the file to check.
Returns
string The specified file path if conform with exec(); otherwise, the path to a temporary copy of the file.

Definition at line 64 of file class.ilFilePreviewRenderer.php.

References $name, and getSupportedFileFormats().

Referenced by ilGhostscriptRenderer\renderImages(), and ilImageMagickRenderer\renderImages().

65  {
66  $pos = strrpos($filepath, "/");
67  $name = $pos !== false ? substr($filepath, $pos + 1) : $filepath;
68 
69  // if the file path contains any characters that could cause problems
70  // we copy the file to a temporary file
71  // $normName = preg_replace("/[^A-Za-z0-9.\- +_&]/", "", $name);
72  // if ($normName != $name)
73  // {
74  // $tempPath = ilUtil::ilTempnam();
75  // if (copy($filepath, $tempPath))
76  // return $tempPath;
77  // }
78  //
79  return $filepath;
80  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supports()

ilFilePreviewRenderer::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.

Definition at line 32 of file class.ilFilePreviewRenderer.php.

References $filename, $preview, ilObjFileAccess\_getFileExtension(), ilObjFile\_lookupFileName(), and getSupportedFileFormats().

33  {
34  // let parent check first
35  if (!parent::supports($preview)) {
36  return false;
37  }
38 
39  // get file extension
40  require_once("./Modules/File/classes/class.ilObjFile.php");
41  include_once './Modules/File/classes/class.ilObjFileAccess.php';
42  // bugfix mantis 23293
43  if (isset($_FILES['file']['name'])) {
44  $filename = $_FILES['file']['name'];
45  } elseif (isset($_FILES['upload_files']['name'])) {
46  $filename = $_FILES['upload_files']['name'];
47  } else {
49  }
51 
52  // contains that extension?
53  return in_array($ext, $this->getSupportedFileFormats());
54  }
$preview
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
getSupportedFileFormats()
Gets an array containing the file formats that are supported by the renderer.
static _lookupFileName($a_id)
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

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