ILIAS  release_7 Revision v7.30-3-g800a261c036
trait.ilObjFileMetadata.php File Reference

Go to the source code of this file.

Functions

 createProperties ($a_upload=false)
 The basic properties of a file object are stored in table object_data. More...
 
 setNoMetaDataCreation ($a_status)
 
 beforeCreateMetaData ()
 
 beforeUpdateMetaData ()
 
 doCreateMetaData ()
 create file object meta data More...
 
 beforeMDUpdateListener ($a_element)
 
 doMDUpdateListener ($a_element)
 
 doUpdateMetaData ()
 update meta data More...
 

Variables

trait ilObjFileMetadata
 Trait ilObjFileMetadata. More...
 

Function Documentation

◆ beforeCreateMetaData()

beforeCreateMetaData ( )
protected

Definition at line 58 of file trait.ilObjFileMetadata.php.

59 {
60 return !(bool) $this->no_meta_data_creation;
61 }

◆ beforeMDUpdateListener()

beforeMDUpdateListener (   $a_element)
protected

Definition at line 84 of file trait.ilObjFileMetadata.php.

85 {
86 // Check file extension
87 // Removing the file extension is not allowed
88 include_once 'Services/MetaData/classes/class.ilMD.php';
89 $md = new ilMD($this->getId(), 0, $this->getType());
90 if (!is_object($md_gen = $md->getGeneral())) {
91 return false;
92 }
93 $title = $this->checkFileExtension($this->getFileName(), $md_gen->getTitle());
94 $md_gen->setTitle($title);
95 $md_gen->update();
96
97 return true;
98 }

◆ beforeUpdateMetaData()

beforeUpdateMetaData ( )
protected

Definition at line 63 of file trait.ilObjFileMetadata.php.

64 {
65 return !(bool) $this->no_meta_data_creation;
66 }

◆ createProperties()

createProperties (   $a_upload = false)

The basic properties of a file object are stored in table object_data.

This is not sufficient for a file object. Therefore we create additional properties in table file_data. This method has been put into a separate operation, to allow a WebDAV Null resource (class.ilObjNull.php) to become a file object.

Definition at line 21 of file trait.ilObjFileMetadata.php.

22 {
23 global $DIC;
24
25 if ($a_upload) {
26 return true;
27 }
28
29 // New Item
30 $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($_GET['ref_id']);
31 if ($default_visibility === "public") {
32 ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
33 }
34
35 // log creation
36 $this->log->debug("ilObjFile::createProperties, ID: " . $this->getId() . ", Name: "
37 . $this->getFileName() . ", Type: " . $this->getFileType() . ", Size: "
38 . $this->getFileSize() . ", Mode: " . $this->getMode() . ", Name(Bytes): "
39 . implode(":", ilStr::getBytesForString($this->getFileName())));
40 $this->log->logStack(ilLogLevel::DEBUG);
41
42 $DIC->database()->insert('file_data', $this->getArrayForDatabase());
43
44 // no meta data handling for file list files
45 if ($this->getMode() != self::MODE_FILELIST) {
46 $this->createMetaData();
47 }
48 }
$_GET["client_id"]
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
static getBytesForString($a_str)
Return string as byte array Note: Use this for debugging purposes only.
global $DIC
Definition: goto.php:24

References $_GET, $DIC, ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_write(), ilLogLevel\DEBUG, and ilStr\getBytesForString().

Referenced by ilObjFile\doCreate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doCreateMetaData()

doCreateMetaData ( )
protected

create file object meta data

Definition at line 71 of file trait.ilObjFileMetadata.php.

72 {
73 // add technical section with file size and format
74 $md_obj = new ilMD($this->getId(), 0, $this->getType());
75 $technical = $md_obj->addTechnical();
76 $technical->setSize($this->getFileSize());
77 $technical->save();
78 $format = $technical->addFormat();
79 $format->setFormat($this->getFileType());
80 $format->save();
81 $technical->update();
82 }
$format
Definition: metadata.php:218

References $format.

◆ doMDUpdateListener()

doMDUpdateListener (   $a_element)
protected

Definition at line 100 of file trait.ilObjFileMetadata.php.

101 {
102 // handling for technical section
103 include_once 'Services/MetaData/classes/class.ilMD.php';
104
105 switch ($a_element) {
106 case 'Technical':
107
108 // Update Format (size is not stored in db)
109 $md = new ilMD($this->getId(), 0, $this->getType());
110 if (!is_object($md_technical = $md->getTechnical())) {
111 return false;
112 }
113
114 foreach ($md_technical->getFormatIds() as $id) {
115 $md_format = $md_technical->getFormat($id);
116 $this->setFileType($md_format->getFormat());
117 break;
118 }
119
120 break;
121 }
122
123 return true;
124 }

◆ doUpdateMetaData()

doUpdateMetaData ( )
protected

update meta data

Definition at line 129 of file trait.ilObjFileMetadata.php.

130 {
131 // add technical section with file size and format
132 $md_obj = new ilMD($this->getId(), 0, $this->getType());
133 if (!is_object($technical = $md_obj->getTechnical())) {
134 $technical = $md_obj->addTechnical();
135 $technical->save();
136 }
137 $technical->setSize($this->getFileSize());
138
139 $format_ids = $technical->getFormatIds();
140 if (count($format_ids) > 0) {
141 $format = $technical->getFormat($format_ids[0]);
142 $format->setFormat($this->getFileType());
143 $format->update();
144 } else {
145 $format = $technical->addFormat();
146 $format->setFormat($this->getFileType());
147 $format->save();
148 }
149 $technical->update();
150 }

References $format.

◆ setNoMetaDataCreation()

setNoMetaDataCreation (   $a_status)
Parameters
bool$a_status

Definition at line 53 of file trait.ilObjFileMetadata.php.

54 {
55 $this->no_meta_data_creation = (bool) $a_status;
56 }

Variable Documentation

◆ ilObjFileMetadata

trait ilObjFileMetadata
Initial value:
{
protected $no_meta_data_creation

Trait ilObjFileMetadata.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 7 of file trait.ilObjFileMetadata.php.