Inheritance diagram for ilObjFile:
Collaboration diagram for ilObjFile:Public Member Functions | |
| ilObjFile ($a_id=0, $a_call_by_reference=true) | |
| Constructor public. | |
| create () | |
| create | |
| getDirectory ($a_version=0) | |
| createDirectory () | |
| raiseUploadError ($a_raise=true) | |
| getUploadFile ($a_upload_file, $a_filename) | |
| replaceFile ($a_upload_file, $a_filename) | |
| replace file with new file | |
| copy ($a_source, $a_destination) | |
| copy file | |
| clearDataDirectory () | |
| clear data directory | |
| read () | |
| read file properties | |
| update () | |
| update file | |
| setFileName ($a_name) | |
| getFileName () | |
| setFileType ($a_type) | |
| getFileType () | |
| setVersion ($a_version) | |
| getVersion () | |
| _lookupFileName ($a_id) | |
| _lookupFileSize ($a_id, $a_as_string=false) | |
| _lookupVersion ($a_id) | |
| lookup version | |
| sendFile ($a_hist_entry_id=null) | |
| ilClone ($a_parent_ref) | |
| ilClone object into tree basic clone function. | |
| delete () | |
| delete file and all related data | |
| export ($a_target_dir) | |
| export files of object to target directory note: target directory must be the export target directory, "/objects/il_<inst>_file_<file_id>/..." will be appended to this directory | |
| _deleteAllUsages ($a_type, $a_id) | |
| static delete all usages of | |
| _saveUsage ($a_mob_id, $a_type, $a_id) | |
| save usage | |
| getUsages () | |
| get all usages of file object | |
| _getFilesOfObject ($a_type, $a_id) | |
| get all files of an object | |
| getXMLZip () | |
Data Fields | |
| $filename | |
| $filetype | |
| $filemaxsize = "20000000" | |
| $raise_upload_error | |
Definition at line 37 of file class.ilObjFile.php.
| ilObjFile::_deleteAllUsages | ( | $ | a_type, | |
| $ | a_id | |||
| ) |
static delete all usages of
Definition at line 423 of file class.ilObjFile.php.
References $q.
Referenced by ilPageObject::delete(), and ilPageObject::saveFileUsage().
{
$q = "DELETE FROM file_usage WHERE usage_type='$a_type' AND usage_id='$a_id'";
$this->ilias->db->query($q);
}
Here is the caller graph for this function:| ilObjFile::_getFilesOfObject | ( | $ | a_type, | |
| $ | a_id | |||
| ) |
get all files of an object
| string | $a_type object type (e.g. "lm:pg") | |
| int | $a_id object id |
Definition at line 467 of file class.ilObjFile.php.
References $q.
Referenced by ilObjGlossary::exportHTMLGlossaryTerms(), ilObjContentObject::exportHTMLGlossaryTerms(), and ilObjContentObject::exportHTMLPages().
{
global $ilDB;
// get usages in learning modules
$q = "SELECT * FROM file_usage WHERE usage_id = ".$ilDB->quote($a_id).
" AND usage_type = ".$ilDB->quote($a_type);
$file_set = $ilDB->query($q);
$ret = array();
while($file_rec = $file_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$ret[$file_rec["id"]] = $file_rec["id"];
}
return $ret;
}
Here is the caller graph for this function:| ilObjFile::_lookupFileName | ( | $ | a_id | ) |
Definition at line 202 of file class.ilObjFile.php.
References $q, $row, and ilUtil::stripSlashes().
{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = '".$a_id."'";
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
return ilUtil::stripSlashes($row->file_name);
}
Here is the call graph for this function:| ilObjFile::_lookupFileSize | ( | $ | a_id, | |
| $ | a_as_string = false | |||
| ) |
Definition at line 214 of file class.ilObjFile.php.
References $file, $q, $row, $size, _lookupVersion(), and ilUtil::getDataDir().
Referenced by ilPageObject::addFileSizes(), and ilObjFileListGUI::getProperties().
{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = '".$a_id."'";
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
$file = ilUtil::getDataDir()."/files/file_".$a_id."/".$row->file_name;
if (@!is_file($file))
{
$version_subdir = "/".sprintf("%03d", ilObjFile::_lookupVersion($a_id));
$file = ilUtil::getDataDir()."/files/file_".$a_id.$version_subdir."/".$row->file_name;
}
if (is_file($file))
{
$size = filesize($file);
}
else
{
$size = 0;
}
if ($a_as_string)
{
if ($size > 1000000)
{
return round($size/1000000,2)." MB";
}
else if ($size > 1000)
{
return round($size/1000,2)." KBytes";
}
else
{
return $size." Bytes";
}
}
return $size;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjFile::_lookupVersion | ( | $ | a_id | ) |
lookup version
Definition at line 262 of file class.ilObjFile.php.
References $q, $row, and ilUtil::stripSlashes().
Referenced by _lookupFileSize(), and ilObjFileListGUI::getProperties().
{
global $ilDB;
$q = "SELECT * FROM file_data WHERE file_id = '".$a_id."'";
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
return ilUtil::stripSlashes($row->version);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjFile::_saveUsage | ( | $ | a_mob_id, | |
| $ | a_type, | |||
| $ | a_id | |||
| ) |
save usage
Definition at line 432 of file class.ilObjFile.php.
References $q.
Referenced by ilPageObject::saveFileUsage().
{
$q = "REPLACE INTO file_usage (id, usage_type, usage_id) VALUES".
" ('$a_mob_id', '$a_type', '$a_id')";
$this->ilias->db->query($q);
}
Here is the caller graph for this function:| ilObjFile::clearDataDirectory | ( | ) |
clear data directory
Definition at line 134 of file class.ilObjFile.php.
References createDirectory(), ilUtil::delDir(), and getDirectory().
{
ilUtil::delDir($this->getDirectory());
$this->createDirectory();
}
Here is the call graph for this function:| ilObjFile::copy | ( | $ | a_source, | |
| $ | a_destination | |||
| ) |
copy file
Definition at line 126 of file class.ilObjFile.php.
References getDirectory().
{
return copy($a_source,$this->getDirectory()."/".$a_destination);
}
Here is the call graph for this function:| ilObjFile::create | ( | ) |
create
note: title, description and type should be set when this function is called
public
Reimplemented from ilObject.
Definition at line 58 of file class.ilObjFile.php.
References $q, ilHistory::_createEntry(), getFileName(), and ilObject::getId().
{
parent::create();
require_once("classes/class.ilHistory.php");
ilHistory::_createEntry($this->getId(), "create", $this->getFileName().",1");
$q = "INSERT INTO file_data (file_id,file_name,file_type,version) "
."VALUES ('".$this->getId()."','"
.ilUtil::prepareDBString($this->getFileName())."','"
.$this->getFileType()."','"
."1"."')";
$this->ilias->db->query($q);
}
Here is the call graph for this function:| ilObjFile::createDirectory | ( | ) |
Definition at line 85 of file class.ilObjFile.php.
References getDirectory(), and ilUtil::makeDir().
Referenced by clearDataDirectory().
{
ilUtil::makeDir($this->getDirectory());
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjFile::delete | ( | ) |
delete file and all related data
public
Reimplemented from ilObject.
Definition at line 365 of file class.ilObjFile.php.
References $q, ilHistory::_removeEntriesForObject(), ilUtil::delDir(), getDirectory(), ilObject::getId(), and getUsages().
{
// check, if file is used somewhere
$usages = $this->getUsages();
if (count($usages) == 0)
{
// always call parent delete function first!!
if (!parent::delete())
{
return false;
}
// delete file data entry
$q = "DELETE FROM file_data WHERE file_id = '".$this->getId()."'";
$this->ilias->db->query($q);
// delete history entries
require_once("classes/class.ilHistory.php");
ilHistory::_removeEntriesForObject($this->getId());
// delete entire directory and its content
if (@is_dir($this->getDirectory()))
{
ilUtil::delDir($this->getDirectory());
}
return true;
}
return false;
}
Here is the call graph for this function:| ilObjFile::export | ( | $ | a_target_dir | ) |
export files of object to target directory note: target directory must be the export target directory, "/objects/il_<inst>_file_<file_id>/..." will be appended to this directory
| string | $a_target_dir target directory |
Definition at line 405 of file class.ilObjFile.php.
References getDirectory(), ilObject::getId(), getVersion(), ilUtil::makeDir(), and ilUtil::rCopy().
{
$subdir = "il_".IL_INST_ID."_file_".$this->getId();
ilUtil::makeDir($a_target_dir."/objects/".$subdir);
$filedir = $this->getDirectory($this->getVersion());
if (@!is_dir($filedir))
{
$filedir = $this->getDirectory();
}
ilUtil::rCopy($filedir, $a_target_dir."/objects/".$subdir);
}
Here is the call graph for this function:| ilObjFile::getDirectory | ( | $ | a_version = 0 |
) |
Definition at line 73 of file class.ilObjFile.php.
References ilUtil::getDataDir(), and ilObject::getId().
Referenced by clearDataDirectory(), copy(), createDirectory(), delete(), export(), getUploadFile(), getXMLZip(), ilClone(), and sendFile().
{
$version_subdir = "";
if ($a_version)
{
$version_subdir = "/".sprintf("%03d", $a_version);
}
return ilUtil::getDataDir()."/files/file_".$this->getId().$version_subdir;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjFile::getFileName | ( | ) |
Definition at line 177 of file class.ilObjFile.php.
Referenced by create(), getXMLZip(), ilClone(), sendFile(), and update().
{
return $this->filename;
}
Here is the caller graph for this function:| ilObjFile::getFileType | ( | ) |
Definition at line 187 of file class.ilObjFile.php.
{
return $this->filetype;
}
| ilObjFile::getUploadFile | ( | $ | a_upload_file, | |
| $ | a_filename | |||
| ) |
Definition at line 95 of file class.ilObjFile.php.
References $file, getDirectory(), getVersion(), ilUtil::makeDir(), ilUtil::moveUploadedFile(), and setVersion().
Referenced by replaceFile().
{
$this->setVersion($this->getVersion() + 1);
if (@!is_dir($this->getDirectory($this->getVersion())))
{
ilUtil::makeDir($this->getDirectory($this->getVersion()));
}
$file = $this->getDirectory($this->getVersion())."/".$a_filename;
//move_uploaded_file($a_upload_file, $file);
ilUtil::moveUploadedFile($a_upload_file, $a_filename, $file, $this->raise_upload_error);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjFile::getUsages | ( | ) |
get all usages of file object
Definition at line 442 of file class.ilObjFile.php.
References $q.
Referenced by delete().
{
global $ilDB;
// get usages in learning modules
$q = "SELECT * FROM file_usage WHERE id = '".$this->getId()."'";
$us_set = $ilDB->query($q);
$ret = array();
while($us_rec = $us_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$ret[] = array("type" => $us_rec["usage_type"],
"id" => $us_rec["usage_id"]);
}
return $ret;
}
Here is the caller graph for this function:| ilObjFile::getVersion | ( | ) |
Definition at line 197 of file class.ilObjFile.php.
Referenced by export(), getUploadFile(), ilClone(), and sendFile().
{
return $this->version;
}
Here is the caller graph for this function:| ilObjFile::getXMLZip | ( | ) |
Reimplemented from ilObject.
Definition at line 485 of file class.ilObjFile.php.
References ilObject::$ilias, ilUtil::escapeShellArg(), getDirectory(), and getFileName().
{
global $ilias;
$zip = PATH_TO_ZIP;
exec($zip.' '.ilUtil::escapeShellArg($this->getDirectory().'/'.$this->getFileName())." ".
ilUtil::escapeShellArg($this->getDirectory().'/'.'1.zip'));
return $this->getDirectory().'/1.zip';
}
Here is the call graph for this function:| ilObjFile::ilClone | ( | $ | a_parent_ref | ) |
ilClone object into tree basic clone function.
Register new object in object_data, creates reference and insert reference ID in tree. All object specific data must be copied in the ilClone function of the appropriate object class. Look in ilObjForum::ilClone() for example code
public
| integer | $a_parent_ref ref id of parent object |
Reimplemented from ilObject.
Definition at line 328 of file class.ilObjFile.php.
References $q, ilHistory::_copyEntriesForObject(), getDirectory(), getFileName(), ilObject::getId(), getVersion(), and ilUtil::rCopy().
{
// always call parent clone function first!!
$new_ref_id = parent::ilClone($a_parent_ref);
$fileObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);
$fileObj->createDirectory();
// copy all versions of file
ilUtil::rCopy($this->getDirectory(),$fileObj->getDirectory());
//copy($this->getDirectory()."/".$this->getFileName(),$fileObj->getDirectory()."/".$this->getFileName());
$q = "INSERT INTO file_data (file_id,file_name,file_type,version) VALUES ('"
.$fileObj->getId()."','"
.ilUtil::prepareDBString($this->getFileName())."','"
.$this->getFileType()."','".$this->getVersion()
."')";
$this->ilias->db->query($q);
// copy history entries
require_once("classes/class.ilHistory.php");
ilHistory::_copyEntriesForObject($this->getId(),$fileObj->getId());
// dump object
unset($fileObj);
// ... and finally always return new reference ID!!
return $new_ref_id;
}
Here is the call graph for this function:| ilObjFile::ilObjFile | ( | $ | a_id = 0, |
|
| $ | a_call_by_reference = true | |||
| ) |
Constructor public.
| integer | reference_id or object_id | |
| boolean | treat the id as reference_id (true) or object_id (false) |
Definition at line 50 of file class.ilObjFile.php.
References ilObject::ilObject().
{
$this->version = 0;
$this->type = "file";
$this->raise_upload_error = true;
$this->ilObject($a_id,$a_call_by_reference);
}
Here is the call graph for this function:| ilObjFile::raiseUploadError | ( | $ | a_raise = true |
) |
Definition at line 90 of file class.ilObjFile.php.
{
$this->raise_upload_error = $a_raise;
}
| ilObjFile::read | ( | ) |
read file properties
Definition at line 143 of file class.ilObjFile.php.
References $q, $row, setFileName(), setFileType(), and setVersion().
{
parent::read();
$q = "SELECT * FROM file_data WHERE file_id = '".$this->getId()."'";
$r = $this->ilias->db->query($q);
$row = $r->fetchRow(DB_FETCHMODE_OBJECT);
$this->setFileName($row->file_name);
$this->setFileType($row->file_type);
$this->setVersion($row->version);
}
Here is the call graph for this function:| ilObjFile::replaceFile | ( | $ | a_upload_file, | |
| $ | a_filename | |||
| ) |
replace file with new file
Definition at line 112 of file class.ilObjFile.php.
References ilHistory::_createEntry(), ilObject::getId(), and getUploadFile().
{
//$this->clearDataDirectory(); // ! This has to be changed, if multiple versions should be supported
$this->getUploadFile($a_upload_file, $a_filename);
require_once("classes/class.ilHistory.php");
ilHistory::_createEntry($this->getId(), "replace",
$a_filename.",".$this->getVersion());
}
Here is the call graph for this function:| ilObjFile::sendFile | ( | $ | a_hist_entry_id = null |
) |
Definition at line 273 of file class.ilObjFile.php.
References $data, $file, ilHistory::_getEntryByHistoryID(), ilUtil::deliverFile(), getDirectory(), getFileName(), and getVersion().
{
if (is_null($a_hist_entry_id))
{
$file = $this->getDirectory($this->getVersion())."/".$this->getFileName();
// if not found lookup for file in file object's main directory for downward c ompability
if (@!is_file($file))
{
$file = $this->getDirectory()."/".$this->getFileName();
}
}
else
{
require_once("classes/class.ilHistory.php");
$entry = ilHistory::_getEntryByHistoryID($a_hist_entry_id);
if ($entry === false)
{
echo "3";return false;
}
$data = explode(",",$entry["info_params"]);
// bugfix: first created file had no version number
// this is a workaround for all files created before the bug was fixed
if (empty($data[1]))
{
$data[1] = "1";
}
$file = $this->getDirectory($data[1])."/".$data[0];
// if not found lookup for file in file object's main directory for downward compability
if (@!is_file($file))
{
$file = $this->getDirectory()."/".$data[0];
}
if (@is_file($file))
{
ilUtil::deliverFile($file, $data[0]);
return true;
}
}
if (@is_file($file))
{
ilUtil::deliverFile($file, $this->getFileName());
return true;
}
return false;
}
Here is the call graph for this function:| ilObjFile::setFileName | ( | $ | a_name | ) |
Definition at line 172 of file class.ilObjFile.php.
Referenced by read().
{
$this->filename = $a_name;
}
Here is the caller graph for this function:| ilObjFile::setFileType | ( | $ | a_type | ) |
Definition at line 182 of file class.ilObjFile.php.
Referenced by read().
{
$this->filetype = $a_type;
}
Here is the caller graph for this function:| ilObjFile::setVersion | ( | $ | a_version | ) |
Definition at line 192 of file class.ilObjFile.php.
Referenced by getUploadFile(), and read().
{
$this->version = $a_version;
}
Here is the caller graph for this function:| ilObjFile::update | ( | ) |
update file
Reimplemented from ilObject.
Definition at line 159 of file class.ilObjFile.php.
References $q, and getFileName().
{
parent::update();
$q = "UPDATE file_data SET file_name = '".ilUtil::prepareDBString($this->getFileName()).
"', file_type = '".$this->getFiletype()."' ".
", version = '".$this->getVersion()."' ".
"WHERE file_id = '".$this->getId()."'";
$this->ilias->db->query($q);
return true;
}
Here is the call graph for this function:| ilObjFile::$filemaxsize = "20000000" |
Definition at line 41 of file class.ilObjFile.php.
| ilObjFile::$filename |
Definition at line 39 of file class.ilObjFile.php.
| ilObjFile::$filetype |
Definition at line 40 of file class.ilObjFile.php.
| ilObjFile::$raise_upload_error |
Definition at line 42 of file class.ilObjFile.php.
1.7.1