Public Member Functions | Data Fields | Private Attributes

ilObjFile Class Reference
[Modules/File]

Class ilObjFile. More...

Inheritance diagram for ilObjFile:
Collaboration diagram for ilObjFile:

Public Member Functions

 ilObjFile ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 create ($a_upload=false)
 create object
 createMetaData ()
 create file object meta data
 MDUpdateListener ($a_element)
 Meta data update listener.
 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
 updateMetaData ()
 update meta data
 setFileName ($a_name)
 set filename
 getFileName ()
 setFileType ($a_type)
 getFileType ()
 setFileSize ($a_size)
 getFileSize ()
 setVersion ($a_version)
 getVersion ()
 setMode ($a_mode)
 mode is object or filelist
 getMode ()
 mode is object or filelist
 _writeFileType ($a_id, $a_format)
 _lookupFileName ($a_id)
 _lookupFileSize ($a_id, $a_as_string=false)
 _lookupVersion ($a_id)
 lookup version
 determineFileSize ()
 Determine File Size.
 sendFile ($a_hist_entry_id=null)
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone.
 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 ()
 addNewsNotification ($a_lang_var)
 initFileStorage ()
 init file storage object
 storeUnzipedFile ($a_upload_file, $a_filename)
 storeUnzipedFile

Data Fields

 $filename
 $filetype
 $filemaxsize = "20000000"
 $raise_upload_error
 $mode = "object"

Private Attributes

 $file_storage = null

Detailed Description

Class ilObjFile.

Author:
Sascha Hofmann <shofmann@databay.de>
Version:
Id:
class.ilObjFile.php 15121 2007-10-29 16:30:14Z akill

Definition at line 38 of file class.ilObjFile.php.


Member Function Documentation

ilObjFile::_deleteAllUsages ( a_type,
a_id 
)

static delete all usages of

Definition at line 644 of file class.ilObjFile.php.

Referenced by ilPageObject::delete(), and ilPageObject::saveFileUsage().

        {
                global $ilDB;
                
                $q = "DELETE FROM file_usage WHERE usage_type=".$ilDB->quote($a_type)." AND usage_id=".$ilDB->quote($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

Parameters:
string $a_type object type (e.g. "lm:pg")
int $a_id object id
Returns:
array array of file ids

Definition at line 692 of file class.ilObjFile.php.

References $ret.

Referenced by ilObjContentObject::exportHTMLGlossaryTerms(), ilObjGlossary::exportHTMLGlossaryTerms(), ilObjContentObject::exportHTMLPages(), and ilPageObject::update().

        {
                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 405 of file class.ilObjFile.php.

References ilUtil::stripSlashes().

        {
                global $ilDB;

                $q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($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 417 of file class.ilObjFile.php.

Referenced by ilPageObject::addFileSizes(), and ilObjFileGUI::infoScreen().

        {
                global $ilDB;

                $q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id);
                $r = $ilDB->query($q);
                $row = $r->fetchRow(DB_FETCHMODE_OBJECT);

                $size = $row->file_size;
                if ($a_as_string)
                {
                        if ($size > 1000000)
                        {
                                return round($size/1000000,1)." MB";
                        }
                        else if ($size > 1000)
                        {
                                return round($size/1000,1)." KB";
                        }
                        else
                        {
                                return $size." Bytes";
                        }
                        
                }
                return $size;
        }

Here is the caller graph for this function:

ilObjFile::_lookupVersion ( a_id  ) 

lookup version

Definition at line 448 of file class.ilObjFile.php.

        {
                include_once("./Modules/File/classes/class.ilObjFileAccess.php");
                return ilObjFileAccess::_lookupVersion($a_id);
        }

ilObjFile::_saveUsage ( a_mob_id,
a_type,
a_id 
)

save usage

Definition at line 655 of file class.ilObjFile.php.

Referenced by ilPageObject::saveFileUsage().

        {
                global $ilDB;
                
                $q = "REPLACE INTO file_usage (id, usage_type, usage_id) VALUES".
                        " (".$ilDB->quote($a_mob_id).",".$ilDB->quote($a_type).",".$ilDB->quote($a_id).")";
                $this->ilias->db->query($q);
        }

Here is the caller graph for this function:

ilObjFile::_writeFileType ( a_id,
a_format 
)

Definition at line 394 of file class.ilObjFile.php.

Referenced by MDUpdateListener().

        {
                global $ilDB;
                
                $q = "UPDATE file_data SET ".
                        " file_type = ".$ilDB->quote($a_format).
                        " WHERE file_id = ".$ilDB->quote($a_id);
                $ilDB->query($q);
                
        }

Here is the caller graph for this function:

ilObjFile::addNewsNotification ( a_lang_var  ) 

Definition at line 722 of file class.ilObjFile.php.

References ilObject::getDescription(), ilObject::getId(), and ilObject::getType().

Referenced by create(), and replaceFile().

        {
                global $ilUser;
                
                // Add Notification to news
                include_once("./Services/News/classes/class.ilNewsItem.php");
                include_once("./Modules/File/classes/class.ilObjFileAccess.php");
                $news_item = new ilNewsItem();
                $news_item->setContext($this->getId(), $this->getType());
                $news_item->setPriority(NEWS_NOTICE);
                $news_item->setTitle($a_lang_var);
                $news_item->setContentIsLangVar(true);
                if ($this->getDescription() != "")
                {
                        $news_item->setContent(
                                "<p>".
                                $this->getDescription()."</p>");
                }
                $news_item->setUserId($ilUser->getId());
                $news_item->setVisibility(NEWS_USERS);
                $news_item->create();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjFile::clearDataDirectory (  ) 

clear data directory

Definition at line 246 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::cloneObject ( a_target_id,
a_copy_id = 0 
)

Clone.

public

Parameters:
int target id
int copy id

Reimplemented from ilObject.

Definition at line 540 of file class.ilObjFile.php.

References ilHistory::_copyEntriesForObject(), ilObject::cloneMetaData(), getDirectory(), ilObject::getId(), and ilUtil::rCopy().

        {
                global $ilDB;
                
                $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
                $new_obj->createDirectory();
                $this->cloneMetaData($new_obj);
                
                // Copy all file versions
                ilUtil::rCopy($this->getDirectory(),$new_obj->getDirectory());
                
                // object created now copy other settings
                $query = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,mode) VALUES (".
                                $ilDB->quote($new_obj->getId()).",".
                                $ilDB->quote($this->getFileName()).",".
                                $ilDB->quote($this->getFileType()).",".
                                $ilDB->quote($this->getFileSize()).", ".
                                $ilDB->quote($this->getVersion()).", ".
                                $ilDB->quote($this->getMode()).")";
                $ilDB->query($query);

                // copy history entries
                require_once("classes/class.ilHistory.php");
                ilHistory::_copyEntriesForObject($this->getId(),$new_obj->getId());
                
                // add news notification
                $new_obj->addNewsNotification("file_created");

                return $new_obj;
        }

Here is the call graph for this function:

ilObjFile::copy ( a_source,
a_destination 
)

copy file

Definition at line 238 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 ( a_upload = false  ) 

create object

Parameters:
bool upload mode (if enabled no entries in file_data will be done)

Definition at line 72 of file class.ilObjFile.php.

References $_GET, ilHistory::_createEntry(), ilNewsItem::_getDefaultVisibilityForRefId(), ilBlockSetting::_write(), addNewsNotification(), ilObject::create(), createMetaData(), getFileName(), getFileSize(), getFileType(), ilObject::getId(), getMode(), and initFileStorage().

        {
                global $ilDB;
                
                $new_id = parent::create();
                // Create file directory
                $this->initFileStorage();
                $this->file_storage->create();
                
                if($a_upload)
                {
                        return $new_id;
                }
                
                // not upload mode
                require_once("classes/class.ilHistory.php");
                ilHistory::_createEntry($this->getId(), "create", $this->getFileName().",1");
                $this->addNewsNotification("file_created");
                $default_visibility =
                        ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]);
                if ($default_visibility == "public")
                {
                        ilBlockSetting::_write("news", "public_notifications",
                                1, 0, $this->getId());
                }

                $q = "INSERT INTO file_data (file_id,file_name,file_type,file_size,version,mode) "
                        ."VALUES (".$ilDB->quote($this->getId()).","
                        .$ilDB->quote($this->getFileName()).","
                        .$ilDB->quote($this->getFileType()).","
                        .$ilDB->quote($this->getFileSize()).","
                        .$ilDB->quote("1").",".$ilDB->quote($this->getMode()).")";
                $this->ilias->db->query($q);
                
                // no meta data handling for file list files
                if ($this->getMode() != "filelist")
                {
                        $this->createMetaData();
                }
                return $new_id;         
        }

Here is the call graph for this function:

ilObjFile::createDirectory (  ) 

Definition at line 195 of file class.ilObjFile.php.

References getDirectory(), and ilUtil::makeDirParents().

Referenced by clearDataDirectory().

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjFile::createMetaData (  ) 

create file object meta data

Reimplemented from ilObject.

Definition at line 117 of file class.ilObjFile.php.

References getFileSize(), getFileType(), ilObject::getId(), and ilObject::getType().

Referenced by create().

        {
                parent::createMetaData();
                
                // add technical section with file size and format
                $md_obj =& new ilMD($this->getId(),0,$this->getType());
                $technical = $md_obj->addTechnical();
                $technical->setSize($this->getFileSize());
                $technical->save();
                $format = $technical->addFormat();
                $format->setFormat($this->getFileType());
                $format->save();
                $technical->update();
        }

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

Returns:
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 578 of file class.ilObjFile.php.

References ilHistory::_removeEntriesForObject(), ilUtil::delDir(), ilObject::deleteMetaData(), getDirectory(), ilObject::getId(), getMode(), and getUsages().

        {
                global $ilDB;
                
                // 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 = ".$ilDB->quote($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());
                        }
                        
                        // delete meta data
                        if ($this->getMode() != "filelist")
                        {
                                $this->deleteMetaData();
                        }

                        return true;
                }

                return false;
        }

Here is the call graph for this function:

ilObjFile::determineFileSize (  ) 

Determine File Size.

Definition at line 457 of file class.ilObjFile.php.

References $file, getDirectory(), getFileName(), and getVersion().

        {
                $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();
                }
                
                $size = @filesize($file);
                if ($size > 0)
                {
                        $this->setFilesize($size);
                }
                
                return $size;
        }

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

Parameters:
string $a_target_dir target directory

Definition at line 626 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 178 of file class.ilObjFile.php.

References initFileStorage().

Referenced by clearDataDirectory(), cloneObject(), copy(), createDirectory(), delete(), determineFileSize(), export(), getUploadFile(), getXMLZip(), sendFile(), and storeUnzipedFile().

        {
                $version_subdir = "";

                if ($a_version)
                {
                        $version_subdir = "/".sprintf("%03d", $a_version);
                }
                
                if(!is_object($this->file_storage))
                {
                        $this->initFileStorage();
                }
                
                return $this->file_storage->getAbsolutePath().'/'.$version_subdir;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjFile::getFileName (  ) 

Definition at line 339 of file class.ilObjFile.php.

Referenced by create(), determineFileSize(), getXMLZip(), sendFile(), and update().

        {
                return $this->filename;
        }

Here is the caller graph for this function:

ilObjFile::getFileSize (  ) 

Definition at line 359 of file class.ilObjFile.php.

Referenced by create(), createMetaData(), update(), and updateMetaData().

        {
                return $this->filesize;
        }

Here is the caller graph for this function:

ilObjFile::getFileType (  ) 

Definition at line 349 of file class.ilObjFile.php.

Referenced by create(), createMetaData(), and updateMetaData().

        {
                return $this->filetype;
        }

Here is the caller graph for this function:

ilObjFile::getMode (  ) 

mode is object or filelist

Returns:
string mode

Definition at line 389 of file class.ilObjFile.php.

Referenced by create(), delete(), and update().

        {
                return $this->mode;
        }

Here is the caller graph for this function:

ilObjFile::getUploadFile ( a_upload_file,
a_filename 
)

Definition at line 205 of file class.ilObjFile.php.

References $file, getDirectory(), getVersion(), ilUtil::makeDirParents(), ilUtil::moveUploadedFile(), and setVersion().

Referenced by replaceFile().

        {
                $this->setVersion($this->getVersion() + 1);

                if (@!is_dir($this->getDirectory($this->getVersion())))
                {
                        ilUtil::makeDirParents($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 667 of file class.ilObjFile.php.

References $ret, and ilObject::getId().

Referenced by delete().

        {
                global $ilDB;

                // get usages in learning modules
                $q = "SELECT * FROM file_usage WHERE id = ".$ilDB->quote($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 call graph for this function:

Here is the caller graph for this function:

ilObjFile::getVersion (  ) 

Definition at line 369 of file class.ilObjFile.php.

Referenced by determineFileSize(), export(), getUploadFile(), sendFile(), storeUnzipedFile(), and update().

        {
                return $this->version;
        }

Here is the caller graph for this function:

ilObjFile::getXMLZip (  ) 

Reimplemented from ilObject.

Definition at line 710 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::ilObjFile ( a_id = 0,
a_call_by_reference = true 
)

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

Definition at line 54 of file class.ilObjFile.php.

References ilObject::getId(), ilObject::ilObject(), and initFileStorage().

        {
                $this->version = 0;
                $this->type = "file";
                $this->raise_upload_error = true;
                $this->ilObject($a_id,$a_call_by_reference);
                
                if($this->getId())
                {
                        $this->initFileStorage();
                }
        }

Here is the call graph for this function:

ilObjFile::initFileStorage (  ) 

init file storage object

public

Definition at line 751 of file class.ilObjFile.php.

References ilObject::getId().

Referenced by create(), getDirectory(), ilObjFile(), and read().

        {
                $this->file_storage = new ilFSStorageFile($this->getId());
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjFile::MDUpdateListener ( a_element  ) 

Meta data update listener.

Important note: Do never call create() or update() method of ilObject here. It would result in an endless loop: update object -> update meta -> update object -> ... Use static _writeTitle() ... methods instead.

Parameters:
string $a_element

Reimplemented from ilObject.

Definition at line 143 of file class.ilObjFile.php.

References ilObject::$id, _writeFileType(), ilObject::getId(), ilObject::getType(), and setFileType().

        {
                // handling for general section
                parent::MDUpdateListener($a_element);
                
                // handling for technical section 
                include_once 'Services/MetaData/classes/class.ilMD.php';
//echo "-".$a_element."-";
                switch($a_element)
                {
                        case 'Technical':

                                // Update Format (size is not stored in db)
                                $md = new ilMD($this->getId(),0, $this->getType());
                                if(!is_object($md_technical = $md->getTechnical()))
                                {
                                        return false;
                                }

                                foreach($md_technical->getFormatIds() as $id)
                                {
                                        $md_format = $md_technical->getFormat($id);
                                        ilObjFile::_writeFileType($this->getId(),$md_format->getFormat());
                                        $this->setFileType($md_format->getFormat());
                                        break;
                                }

                                break;

                        default:
                }
                return true;
        }

Here is the call graph for this function:

ilObjFile::raiseUploadError ( a_raise = true  ) 

Definition at line 200 of file class.ilObjFile.php.

        {
                $this->raise_upload_error = $a_raise;
        }

ilObjFile::read (  ) 

read file properties

Definition at line 255 of file class.ilObjFile.php.

References ilObject::getId(), initFileStorage(), setFileName(), setFileSize(), setFileType(), setMode(), and setVersion().

        {
                global $ilDB;
                
                parent::read();

                $q = "SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($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->setFileSize($row->file_size);
                $this->setVersion($row->version);
                $this->setMode($row->mode);
                
                $this->initFileStorage();
        }

Here is the call graph for this function:

ilObjFile::replaceFile ( a_upload_file,
a_filename 
)

replace file with new file

Definition at line 222 of file class.ilObjFile.php.

References ilHistory::_createEntry(), addNewsNotification(), 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());
                $this->setFilename($a_filename);
                $this->addNewsNotification("file_updated");
        }

Here is the call graph for this function:

ilObjFile::sendFile ( a_hist_entry_id = null  ) 

Definition at line 476 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  ) 

set filename

Definition at line 334 of file class.ilObjFile.php.

Referenced by read().

        {
                $this->filename = $a_name;
        }

Here is the caller graph for this function:

ilObjFile::setFileSize ( a_size  ) 

Definition at line 354 of file class.ilObjFile.php.

Referenced by read().

        {
                $this->filesize = $a_size;
        }

Here is the caller graph for this function:

ilObjFile::setFileType ( a_type  ) 

Definition at line 344 of file class.ilObjFile.php.

Referenced by MDUpdateListener(), and read().

        {
                $this->filetype = $a_type;
        }

Here is the caller graph for this function:

ilObjFile::setMode ( a_mode  ) 

mode is object or filelist

Parameters:
string $a_mode mode

Definition at line 379 of file class.ilObjFile.php.

Referenced by read().

        {
                $this->mode = $a_mode;
        }

Here is the caller graph for this function:

ilObjFile::setVersion ( a_version  ) 

Definition at line 364 of file class.ilObjFile.php.

Referenced by getUploadFile(), read(), and storeUnzipedFile().

        {
                $this->version = $a_version;
        }

Here is the caller graph for this function:

ilObjFile::storeUnzipedFile ( a_upload_file,
a_filename 
)

storeUnzipedFile

Stores Files unzipped from uploaded archive in filesystem

Parameters:
string $a_upload_file
string $a_filename

Definition at line 765 of file class.ilObjFile.php.

References $file, getDirectory(), getVersion(), ilUtil::makeDir(), and setVersion().

                {
                        $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);
                        rename($a_upload_file,  $file);
        }

Here is the call graph for this function:

ilObjFile::update (  ) 

update file

Reimplemented from ilObject.

Definition at line 277 of file class.ilObjFile.php.

References getFileName(), getFileSize(), ilObject::getId(), getMode(), getVersion(), and updateMetaData().

        {
                global $ilDB;
                
                // no meta data handling for file list files
                if ($this->getMode() != "filelist")
                {
                        $this->updateMetaData();
                }
                parent::update();
                
                $q = "UPDATE file_data SET file_name = ".$ilDB->quote($this->getFileName()).
                        ", file_type = ".$ilDB->quote($this->getFiletype())." ".
                        ", file_size = ".$ilDB->quote($this->getFileSize())." ".
                        ", version = ".$ilDB->quote($this->getVersion())." ".
                        ", mode = ".$ilDB->quote($this->getMode())." ".
                        "WHERE file_id = ".$ilDB->quote($this->getId());
                $this->ilias->db->query($q);
                
                return true;
        }

Here is the call graph for this function:

ilObjFile::updateMetaData (  ) 

update meta data

Reimplemented from ilObject.

Definition at line 302 of file class.ilObjFile.php.

References getFileSize(), getFileType(), ilObject::getId(), and ilObject::getType().

Referenced by update().

        {
                parent::updateMetaData();
                
                // add technical section with file size and format
                $md_obj =& new ilMD($this->getId(),0,$this->getType());
                if(!is_object($technical = $md_obj->getTechnical()))
                {
                        $technical = $md_obj->addTechnical();
                        $technical->save();
                }
                $technical->setSize($this->getFileSize());
                
                $format_ids = $technical->getFormatIds();
                if (count($format_ids) > 0)
                {
                        $format = $technical->getFormat($format_ids[0]);
                        $format->setFormat($this->getFileType());
                        $format->update();
                }
                else
                {
                        $format = $technical->addFormat();
                        $format->setFormat($this->getFileType());
                        $format->save();
                }
                $technical->update();
        }

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

ilObjFile::$file_storage = null [private]

Definition at line 46 of file class.ilObjFile.php.

ilObjFile::$filemaxsize = "20000000"

Definition at line 42 of file class.ilObjFile.php.

ilObjFile::$filename

Definition at line 40 of file class.ilObjFile.php.

ilObjFile::$filetype

Definition at line 41 of file class.ilObjFile.php.

ilObjFile::$mode = "object"

Definition at line 44 of file class.ilObjFile.php.

ilObjFile::$raise_upload_error

Definition at line 43 of file class.ilObjFile.php.


The documentation for this class was generated from the following file: