|
static | processZipFile ($a_directory, $a_file, $structure, $ref_id=null, $containerType=null, $tree=null, $access_handler=null) |
| unzips in given directory and processes uploaded zip for use as single files More...
|
|
static | recursive_dirscan ($dir, &$arr) |
| Recursively scans a given directory and writes path and filename into referenced array. More...
|
|
static | createObjects ($dir, $structure, $ref_id, $containerType, $tree=null, $access_handler=null) |
| Recursively scans a given directory and creates file and folder/category objects. More...
|
|
static | createContainer ($name, $ref_id, $containerType, $tree=null, $access_handler=null) |
| Creates and inserts container object (folder/category) into tree. More...
|
|
static | createFile ($filename, $path, $ref_id, $tree=null, $access_handler=null) |
| Creates and inserts file object into tree. More...
|
|
static | getNewObjects () |
|
static | utf8_encode ($string) |
| utf8-encodes string if it is not a valid utf8-string. More...
|
|
static | fastBase64Decode ($filein, $fileout) |
| decodes base encoded file row by row to prevent memory exhaust More...
|
|
static | lookupContentMimeType ($content) |
|
static | lookupFileMimeType ($a_file) |
|
static | _lookupMimeType ($a_file) |
|
static | getValidExtensions () |
| Valid extensions. More...
|
|
static | getDefaultValidExtensionWhiteList () |
| Valid extensions. More...
|
|
static | getValidFilename ($a_filename) |
| Get valid filename. More...
|
|
static | hasValidExtension ($a_filename) |
|
static | rename ($a_source, $a_target) |
| Rename a file. More...
|
|
Class ilFileUtils.
- Deprecated:
- All Methods are widely used and there is currently no other service providing all of them, but please do not implement new methods in this class.
- Author
- Jan Hippchen janhi.nosp@m.ppch.nosp@m.en@gm.nosp@m.x.de
Definition at line 38 of file class.ilFileUtils.php.
static ilFileUtils::createFile |
( |
|
$filename, |
|
|
|
$path, |
|
|
|
$ref_id, |
|
|
|
$tree = null , |
|
|
|
$access_handler = null |
|
) |
| |
|
static |
Creates and inserts file object into tree.
- Parameters
-
string | $filename | Name of the object |
string | $path | Path to file |
integer | $ref_id | ref_id of parent |
- Version
- 1.6.9.07
- Author
- Jan Hippchen
Definition at line 296 of file class.ilFileUtils.php.
References $DIC, $filename, $ilErr, $lng, $path, $tree, ilObjMediaObject\getMimeType(), ilUtil\stripSlashes(), and utf8_encode().
Referenced by createObjects().
300 $rbacsystem = $DIC->rbac()->system();
301 $lng = $DIC->language();
304 if (!$access_handler) {
305 $permission = $rbacsystem->checkAccess(
"create", $ref_id,
"file");
307 $permission = $access_handler->checkAccess(
"create",
"", $ref_id,
"file");
312 include_once(
"./Modules/File/classes/class.ilObjFile.php");
314 $fileObj->setType(
'file');
319 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
321 $fileObj->setFileSize(filesize(
$path .
"/" . $filename));
325 if (!$access_handler) {
326 $fileObj->createReference();
327 $fileObj->putInTree($ref_id);
328 $fileObj->setPermissions($ref_id);
330 self::$new_files[$ref_id][] = $fileObj;
332 $node_id =
$tree->insertObject($ref_id, $fileObj->getId());
333 $access_handler->setPermissions($ref_id, $node_id);
337 $fileObj->createDirectory();
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
static ilFileUtils::createObjects |
( |
|
$dir, |
|
|
|
$structure, |
|
|
|
$ref_id, |
|
|
|
$containerType, |
|
|
|
$tree = null , |
|
|
|
$access_handler = null |
|
) |
| |
|
static |
Recursively scans a given directory and creates file and folder/category objects.
Calls createContainer & createFile to store objects in tree
- Parameters
-
string | $dir | Directory to start from |
| boolean | structure True if archive structure is to be overtaken (otherwise flat inclusion) |
integer | $ref_id | ref_id of parent object, if null, files won�t be included in system (just checked) |
| string | containerType object type of created containerobjects (folder or category) |
- Returns
- integer errorcode
- Exceptions
-
- Author
- Jan Hippchen
- Version
- 1.6.9.07
Definition at line 198 of file class.ilFileUtils.php.
References ilFileUtilsException\$BROKEN_FILE, $lng, $tree, createContainer(), createFile(), and utf8_encode().
Referenced by processZipFile().
200 $dirlist = opendir($dir);
202 while (
false !== ($file = readdir($dirlist))) {
203 if (!is_file($dir .
"/" . $file) && !is_dir($dir .
"/" . $file)) {
206 if ($file !=
'.' && $file !=
'..') {
207 $newpath = $dir .
'/' . $file;
208 $level = explode(
'/', $newpath);
209 if (is_dir($newpath)) {
static createFile($filename, $path, $ref_id, $tree=null, $access_handler=null)
Creates and inserts file object into tree.
static createObjects($dir, $structure, $ref_id, $containerType, $tree=null, $access_handler=null)
Recursively scans a given directory and creates file and folder/category objects. ...
static createContainer($name, $ref_id, $containerType, $tree=null, $access_handler=null)
Creates and inserts container object (folder/category) into tree.
static utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
Class to report exception.
static ilFileUtils::processZipFile |
( |
|
$a_directory, |
|
|
|
$a_file, |
|
|
|
$structure, |
|
|
|
$ref_id = null , |
|
|
|
$containerType = null , |
|
|
|
$tree = null , |
|
|
|
$access_handler = null |
|
) |
| |
|
static |
unzips in given directory and processes uploaded zip for use as single files
- Parameters
-
string | $a_directory | Directory to unzip |
string | $a_file | Filename of archive |
| boolean | structure True if archive structure is to be overtaken |
integer | $ref_id | ref_id of parent object, if null, files wont be included in system (just checked) |
| string | containerType object type of created containerobjects (folder or category) |
- Exceptions
-
- Author
- Jan Hippchen
- Version
- 1.6.9.07
Definition at line 62 of file class.ilFileUtils.php.
References ilFileUtilsException\$BROKEN_FILE, $DIC, ilFileUtilsException\$DOUBLETTES_FOUND, ilFileUtilsException\$INFECTED_FILE, $key, $lng, $tree, createObjects(), ilUtil\delDir(), recursive_dirscan(), ilUtil\unzip(), utf8_encode(), and ilUtil\virusHandling().
Referenced by ilCloudPluginUploadGUI\handleFileUpload(), ilExSubmission\processUploadedZipFile(), ilObjFileGUI\saveUnzip(), and ilObjFileGUI\uploadFiles().
66 $lng = $DIC->language();
68 self::$new_files = array();
70 $pathinfo = pathinfo($a_file);
71 $file = $pathinfo[
"basename"];
74 if ($pathinfo[
"extension"] ==
"") {
81 ilUtil::moveUploadedFile($a_file, $file, $a_directory .
"/" . $file);
83 unlink($a_directory .
"/" . $file);
90 if (empty($filearray)) {
95 foreach ($filearray[
"file"] as
$key => $value) {
97 if (substr($value, 0, 1) ==
"." || stristr($filearray[
"path"][
$key],
"/__MACOSX/")) {
98 unlink($filearray[
"path"][
$key] . $value);
99 unset($filearray[
"path"][
$key]);
100 unset($filearray[
"file"][
$key]);
107 unlink($filearray[path][
$key]);
120 foreach (array_count_values($filearray[
"file"]) as
$key => $value) {
126 if (isset($doublettes)) {
128 $lng->txt(
"exc_upload_error") .
"<br />" .
$lng->txt(
"zip_structure_error") . $doublettes,
133 $mac_dir = $a_directory .
"/__MACOSX";
134 if (file_exists($mac_dir)) {
140 if ($ref_id != null) {
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static createObjects($dir, $structure, $ref_id, $containerType, $tree=null, $access_handler=null)
Recursively scans a given directory and creates file and folder/category objects. ...
static utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
Class to report exception.
static ilFileUtils::recursive_dirscan |
( |
|
$dir, |
|
|
& |
$arr |
|
) |
| |
|
static |
Recursively scans a given directory and writes path and filename into referenced array.
- Parameters
-
string | $dir | Directory to start from |
array | &$arr | Referenced array which is filled with Filename and path |
- Exceptions
-
- Version
- 1.6.9.07
- Author
- Jan Hippchen
Definition at line 156 of file class.ilFileUtils.php.
References ilFileUtilsException\$BROKEN_FILE, $DIC, and $lng.
Referenced by ilObjFileBasedLMGUI\afterSave(), ilSCORM13Package\dbImportSco(), ilSCORM2004Asset\exportPDF(), ilObjSCORM2004LearningModule\exportPDF(), ilObjTest\getCustomStyles(), ilExSubmission\processUploadedZipFile(), processZipFile(), ilUtil\unzip(), and ilFileSystemGUI\unzipFile().
160 $lng = $DIC->language();
162 $dirlist = opendir($dir);
163 while (
false !== ($file = readdir($dirlist))) {
164 if (!is_file($dir .
"/" . $file) && !is_dir($dir .
"/" . $file)) {
168 if ($file !=
'.' && $file !=
'..') {
169 $newpath = $dir .
'/' . $file;
170 $level = explode(
'/', $newpath);
171 if (is_dir($newpath)) {
174 $arr[
"path"][] = $dir .
"/";
175 $arr[
"file"][] = end($level);
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
Class to report exception.