ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
4include_once("./Services/Preview/classes/class.ilPreviewRenderer.php");
5
15{
21 final public 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
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 }
55
64 public function prepareFileForExec($filepath)
65 {
66 $filepath = ilFileUtils::getValidFilename($filepath);
67
68 $pos = strrpos($filepath, "/");
69 $name = $pos !== false ? substr($filepath, $pos + 1) : $filepath;
70
71 // if the file path contains any characters that could cause problems
72 // we copy the file to a temporary file
73 // $normName = preg_replace("/[^A-Za-z0-9.\- +_&]/", "", $name);
74 // if ($normName != $name)
75 // {
76 // $tempPath = ilUtil::ilTempnam();
77 // if (copy($filepath, $tempPath))
78 // return $tempPath;
79 // }
80 //
81 return $filepath;
82 }
83
89 abstract public function getSupportedFileFormats();
90}
$filename
Definition: buildRTE.php:89
An exception for terminatinating execution or to throw for unit testing.
Abstract parent class for all file preview renderer classes.
supports($preview)
Determines whether the specified preview object is supported by the renderer.
getSupportedRepositoryTypes()
Gets an array containing the repository types (e.g.
prepareFileForExec($filepath)
Checks whether the specified file path can be used with exec() commands.
getSupportedFileFormats()
Gets an array containing the file formats that are supported by the renderer.
static getValidFilename($a_filename)
Get valid filename.
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static _lookupFileName($a_id)
Abstract parent class for all preview renderer classes.
if($format !==null) $name
Definition: metadata.php:230
$preview