ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilFilePreviewRenderer 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 ilFilePreviewRenderer:
+ Collaboration diagram for ilFilePreviewRenderer:

Public Member Functions

 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...
 
 prepareFileForExec (string $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 (\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...
 

Additional Inherited Members

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

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 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 26 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(), ilObjFileAccessSettingsGUI\showPreviewRenderers(), 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 33 of file class.ilFilePreviewRenderer.php.

Referenced by ilObjFileAccessSettingsGUI\showPreviewRenderers().

33  : array
34  {
35  return ["file"];
36  }
+ Here is the caller graph for this function:

◆ prepareFileForExec()

ilFilePreviewRenderer::prepareFileForExec ( string  $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 89 of file class.ilFilePreviewRenderer.php.

References $name, getSupportedFileFormats(), and ilFileUtils\getValidFilename().

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

89  : string
90  {
91  $filepath = ilFileUtils::getValidFilename($filepath);
92 
93  $pos = strrpos($filepath, "/");
94  $name = $pos !== false ? substr($filepath, $pos + 1) : $filepath;
95 
96  // if the file path contains any characters that could cause problems
97  // we copy the file to a temporary file
98  // $normName = preg_replace("/[^A-Za-z0-9.\- +_&]/", "", $name);
99  // if ($normName != $name)
100  // {
101  // $tempPath = ilUtil::ilTempnam();
102  // if (copy($filepath, $tempPath))
103  // return $tempPath;
104  // }
105  //
106  return $filepath;
107  }
static getValidFilename(string $a_filename)
if($format !==null) $name
Definition: metadata.php:247
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supports()

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

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

References Vendor\Package\$e, $filename, ilObjFileAccess\_getFileExtension(), ilPreview\getObjId(), and getSupportedFileFormats().

44  : bool
45  {
46  // let parent check first
47  if (!parent::supports($preview)) {
48  return false;
49  }
50 
51  // legacy
52  if (null === $preview->getObjId()) {
53  // bugfix mantis 23293
54  if (isset($_FILES['file']['name'])) {
55  $filename = $_FILES['file']['name'];
56  } elseif (isset($_FILES['upload_files']['name'])) {
57  $filename = $_FILES['upload_files']['name'];
58  }
59  if (empty($filename)) {
60  return false;
61  }
62 
63  // contains that extension?
65  return in_array($ext, $this->getSupportedFileFormats(), true);
66  }
67 
68  try {
69  $obj = new ilObjFile($preview->getObjId(), false);
70  } catch (Exception $e) {
71  return false;
72  }
73 
74  if (empty($obj->getResourceId())) {
75  return false;
76  }
77 
78  return in_array($obj->getFileExtension(), $this->getSupportedFileFormats(), true);
79  }
getSupportedFileFormats()
Gets an array containing the file formats that are supported by the renderer.
$preview
Definition: imgupload.php:81
Class ilObjFile.
$filename
Definition: buildRTE.php:78
static _getFileExtension(string $a_file_name)
Gets the file extension of the specified file name.
+ Here is the call graph for this function:

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