24 include_once(
"classes/class.ilObjectAccess.php");
62 $commands[] = array(
"permission" =>
"read",
"cmd" =>
"sendfile",
"lang_var" =>
"download",
"default" =>
true);
63 $commands[] = array(
"permission" =>
"write",
"cmd" =>
"edit",
"lang_var" =>
"edit");
64 $commands[] = array(
"permission" =>
"write",
"cmd" =>
"versions",
"lang_var" =>
"versions");
76 $t_arr = explode(
"_", $a_target);
78 if ($t_arr[0] !=
"file" || ((
int) $t_arr[1]) <= 0)
83 if ($ilAccess->checkAccess(
"visible",
"", $t_arr[1]))
98 $q =
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
99 $r = $ilDB->query($q);
112 $q =
"SELECT version FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
113 $r = $ilDB->query($q);
127 $q =
"SELECT file_size FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
128 $r = $ilDB->query($q);
131 $size =
$row->file_size;
146 $q =
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
147 $r = $ilDB->query($q);
150 require_once(
'Modules/File/classes/class.ilFSStorageFile.php');
152 $file = $fss->getAbsolutePath().
'/'.
$row->file_name;
154 if (@!is_file(
$file))
157 $file = $fss->getAbsolutePath().
'/'.$version_subdir.
'/'.
$row->file_name;
162 $size = filesize(
$file);
178 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
183 $q =
"SELECT * FROM object_data WHERE obj_id = ".$ilDB->quote($a_id ,
'integer');
184 $r = $ilDB->query($q);
186 require_once
'Modules/File/classes/class.ilObjFile.php';
198 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
200 $dir = $fileStorage->getAbsolutePath();
210 if (self::$_inlineFileExtensionsArray === null)
212 require_once
'Services/Administration/classes/class.ilSetting.php';
213 $settings =
new ilSetting(
'file_access');
214 self::$_inlineFileExtensionsArray = preg_split(
'/ /', $settings->get(
'inline_file_extensions'), -1, PREG_SPLIT_NO_EMPTY);
217 return in_array($extension, self::$_inlineFileExtensionsArray);
233 if (preg_match(
'/\.([a-z0-9]+)\z/i',$a_file_name,$matches) == 1)
235 return strtolower($matches[1]);
254 return substr($a_file_name,0,1) ==
'.' ||
255 substr($a_file_name,-1,1) ==
'~' ||
256 substr($a_file_name,0,2) ==
'~$' ||
257 $a_file_name ==
'Thumbs.db';
294 if (strlen($extension) > 0)
296 $extension =
'.'.$extension;
297 $filenameWithoutExtension= substr($a_file_name, 0, -strlen($extension));
301 $filenameWithoutExtension= $a_file_name;
308 $nthCopyRegex = preg_replace(
'/([\^$.\[\]|()?*+{}])/',
'\\\\${1}',
' '.$lng->txt(
'copy_n_of_suffix'));
309 $nthCopyRegex =
'/'.preg_replace(
'/%1\\\\\$s/',
'([0-9]+)', $nthCopyRegex).
'$/';
313 if (preg_match($nthCopyRegex, $filenameWithoutExtension, $matches))
316 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen($matches[0]));
317 if ($nth_copy == null)
319 $nth_copy = $matches[1]+1;
322 else if (substr($filenameWithoutExtension,-strlen(
' '.$lng->txt(
'copy_of_suffix'))) ==
' '.$lng->txt(
'copy_of_suffix'))
325 $filenameWithoutCopy = substr($filenameWithoutExtension, 0, -strlen(
' '.$lng->txt(
'copy_of_suffix')));
326 if ($nth_copy == null)
334 $filenameWithoutCopy = $filenameWithoutExtension;
335 if ($nth_copy == null)
346 $newFilename = $filenameWithoutCopy.sprintf(
' '.$lng->txt(
'copy_n_of_suffix'), $nth_copy).$extension;
351 $newFilename = $filenameWithoutCopy.
' '.$lng->txt(
'copy_of_suffix').$extension;