ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilFilePreviewRenderer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Preview/classes/class.ilPreviewRenderer.php");
5 
15 {
21  public final function getSupportedRepositoryTypes()
22  {
23  return array("file");
24  }
25 
32  public function supports($preview)
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  }
59 
68  public function prepareFileForExec($filepath)
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  }
85 
91  public abstract function getSupportedFileFormats();
92 }
93 ?>
prepareFileForExec($filepath)
Checks whether the specified file path can be used with exec() commands.
Abstract parent class for all file preview renderer classes.
$preview
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
Abstract parent class for all preview renderer classes.
getSupportedFileFormats()
Gets an array containing the file formats that are supported by the renderer.
static _lookupFileName($a_id)
supports($preview)
Determines whether the specified preview object is supported by the renderer.
getSupportedRepositoryTypes()
Gets an array containing the repository types (e.g.
Create styles array
The data for the language used.
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.