ILIAS  release_8 Revision v8.24
trait.ilObjFileMetadata.php File Reference

Go to the source code of this file.

Functions

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

Variables

trait ilObjFileMetadata
 Trait ilObjFileMetadata. More...
 

Function Documentation

◆ beforeCreateMetaData()

beforeCreateMetaData ( )
protected

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

62 : bool
63 {
64 return !(bool) $this->no_meta_data_creation;
65 }

◆ beforeMDUpdateListener()

beforeMDUpdateListener ( string  $a_element)
protected

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

88 : bool
89 {
90 // Check file extension
91 // Removing the file extension is not allowed
92 $md = new ilMD($this->getId(), 0, $this->getType());
93 if (!is_object($md_gen = $md->getGeneral())) {
94 return false;
95 }
96 $title = $this->appendSuffixToTitle($md_gen->getTitle(), $this->getFileName());
97 $md_gen->setTitle($title);
98 $md_gen->update();
99
100 return true;
101 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ beforeUpdateMetaData()

beforeUpdateMetaData ( )
protected

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

67 : bool
68 {
69 return !(bool) $this->no_meta_data_creation;
70 }

◆ createProperties()

createProperties ( bool  $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 38 of file trait.ilObjFileMetadata.php.

38 : void
39 {
40 global $DIC;
41
42 // New Item
43 if (isset($this->ref_id)) {
44 $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($this->ref_id);
45 if ($default_visibility === "public") {
46 ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
47 }
48 }
49 $this->updateFileData();
50
51 // no meta data handling for file list files
52 if ($this->getMode() !== self::MODE_FILELIST) {
53 $this->createMetaData();
54 }
55 }
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
static _getDefaultVisibilityForRefId(int $a_ref_id)
Get default visibility for reference id.
global $DIC
Definition: feed.php:28

References $DIC, ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_write(), ILIAS\Survey\Mode\getId(), and updateFileData().

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 75 of file trait.ilObjFileMetadata.php.

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

References $format, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ doMDUpdateListener()

doMDUpdateListener ( string  $a_element)
protected

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

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

References $id, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ doUpdateMetaData()

doUpdateMetaData ( )
protected

update meta data

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

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

References $format, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ setNoMetaDataCreation()

setNoMetaDataCreation ( bool  $a_status)

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

58 {
59 $this->no_meta_data_creation = $a_status;
60 }

◆ updateFileData()

updateFileData ( )
protected

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

12 : void
13 {
14 global $DIC;
15 $check_existing = $DIC->database()->queryF(
16 'SELECT file_id FROM file_data WHERE file_id = %s',
17 ['integer'],
18 [$this->getId()]
19 );
20 if ($check_existing->numRows() === 0) {
21 $DIC->database()->insert('file_data', $this->getArrayForDatabase());
22 } else {
23 $DIC->database()->update(
24 'file_data',
25 $this->getArrayForDatabase(),
26 ['file_id' => ['integer', $this->getId()]]
27 );
28 }
29 }

References $DIC, and ILIAS\Survey\Mode\getId().

Referenced by createProperties().

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

Variable Documentation

◆ ilObjFileMetadata

trait ilObjFileMetadata
Initial value:
{
protected ?bool $no_meta_data_creation = null

Trait ilObjFileMetadata.

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

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