ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

References array.

22  {
23  return array("file");
24  }
Create styles array
The data for the language used.

◆ 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 68 of file class.ilFilePreviewRenderer.php.

References getSupportedFileFormats(), and ilUtil\ilTempnam().

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

69  {
70  $pos = strrpos($filepath, "/");
71  $name = $pos !== false ? substr($filepath, $pos + 1) : $filepath;
72 
73  // if the file path contains any characters that could cause problems
74  // we copy the file to a temporary file
75  $normName = preg_replace("/[^A-Za-z0-9.\- +_&]/", "", $name);
76  if ($normName != $name)
77  {
78  $tempPath = ilUtil::ilTempnam();
79  if (copy($filepath, $tempPath))
80  return $tempPath;
81  }
82 
83  return $filepath;
84  }
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
+ 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  // get file extension
39  require_once("./Modules/File/classes/class.ilObjFile.php");
40  include_once './Modules/File/classes/class.ilObjFileAccess.php';
41  // bugfix mantis 23293
42  if (isset($_FILES['file']['name']))
43  {
44  $filename = $_FILES['file']['name'];
45  }
46  elseif (isset($_FILES['upload_files']['name']))
47  {
48  $filename = $_FILES['upload_files']['name'];
49  }
50  else
51  {
53  }
55 
56  // contains that extension?
57  return in_array($ext, $this->getSupportedFileFormats());
58  }
$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)
+ Here is the call graph for this function:

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