ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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...
 
 updateCopyright ()
 
 getPathToSize ()
 
 getPathToFirstFormat ()
 
 getPathToVersion ()
 

Variables

trait ilObjFileMetadata
 Trait ilObjFileMetadata. More...
 

Function Documentation

◆ beforeCreateMetaData()

beforeCreateMetaData ( )
protected

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

81 : bool
82 {
83 return !(bool) $this->no_meta_data_creation;
84 }

◆ beforeMDUpdateListener()

beforeMDUpdateListener ( string  $a_element)
protected

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

109 : bool
110 {
111 global $DIC;
112
113 // Check file extension
114 // Removing the file extension is not allowed
115 if ($a_element !== 'General') {
116 return true;
117 }
118
119 $paths = $DIC->learningObjectMetadata()->paths();
120
121 $title = $DIC->learningObjectMetadata()->read(
122 $this->getId(),
123 0,
124 $this->getType(),
125 $paths->title()
126 )->firstData($paths->title())->value();
127
128 $title = $this->appendSuffixToTitle($title, $this->getFileName());
129
130 $DIC->learningObjectMetadata()->manipulate($this->getId(), 0, $this->getType())
131 ->prepareCreateOrUpdate($paths->title(), $title)
132 ->execute();
133
134 return true;
135 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

◆ beforeUpdateMetaData()

beforeUpdateMetaData ( )
protected

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

86 : bool
87 {
88 return !(bool) $this->no_meta_data_creation;
89 }

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

57 : void
58 {
59 global $DIC;
60
61 // New Item
62 if (isset($this->ref_id)) {
63 $default_visibility = ilNewsItem::_getDefaultVisibilityForRefId($this->ref_id);
64 if ($default_visibility === "public") {
65 ilBlockSetting::_write("news", "public_notifications", 1, 0, $this->getId());
66 }
67 }
68 $this->updateFileData();
69
70 // no meta data handling for file list files
71 if ($this->getMode() !== self::MODE_FILELIST) {
72 $this->createMetaData();
73 }
74 }
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.

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

94 : void
95 {
96 global $DIC;
97
98 // add file size and format to LOM
99 $manipulator = $DIC->learningObjectMetadata()
100 ->manipulate($this->getId(), 0, $this->getType())
101 ->prepareCreateOrUpdate($this->getPathToSize(), (string) $this->getFileSize())
102 ->prepareCreateOrUpdate($this->getPathToVersion(), (string) $this->getVersion());
103 if ($this->getFileType() !== '') {
104 $manipulator = $manipulator->prepareCreateOrUpdate($this->getPathToFirstFormat(), $this->getFileType());
105 }
106 $manipulator->execute();
107 }
getPathToFirstFormat()

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

+ Here is the call graph for this function:

◆ doMDUpdateListener()

doMDUpdateListener ( string  $a_element)
protected

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

137 : void
138 {
139 global $DIC;
140
141 // handling for technical section
142 if ($a_element !== 'Technical') {
143 return;
144 }
145
146 $first_format = $DIC->learningObjectMetadata()->read(
147 $this->getId(),
148 0,
149 $this->getType(),
150 $this->getPathToFirstFormat()
151 )->firstData($this->getPathToFirstFormat())->value();
152
153 $this->setFileType($first_format);
154 }

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

+ Here is the call graph for this function:

◆ doUpdateMetaData()

doUpdateMetaData ( )
protected

update meta data

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

159 : void
160 {
161 global $DIC;
162
163 $manipulator = $DIC->learningObjectMetadata()
164 ->manipulate($this->getId(), 0, $this->getType())
165 ->prepareCreateOrUpdate($this->getPathToSize(), (string) $this->getFileSize())
166 ->prepareCreateOrUpdate($this->getPathToVersion(), (string) $this->getVersion());
167 if ($this->getFileType() !== '') {
168 $manipulator = $manipulator->prepareCreateOrUpdate($this->getPathToFirstFormat(), $this->getFileType());
169 }
170 $manipulator->execute();
171 }

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

+ Here is the call graph for this function:

◆ getPathToFirstFormat()

getPathToFirstFormat ( )
protected

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

202 : Path
203 {
204 global $DIC;
205
206 return $DIC->learningObjectMetadata()
207 ->paths()
208 ->custom()
209 ->withNextStep('technical')
210 ->withNextStep('format')
211 ->withAdditionalFilterAtCurrentStep(FilterType::INDEX, '0')
212 ->get();
213 }

References $DIC.

Referenced by doCreateMetaData(), doMDUpdateListener(), and doUpdateMetaData().

+ Here is the caller graph for this function:

◆ getPathToSize()

getPathToSize ( )
protected

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

190 : Path
191 {
192 global $DIC;
193
194 return $DIC->learningObjectMetadata()
195 ->paths()
196 ->custom()
197 ->withNextStep('technical')
198 ->withNextStep('size')
199 ->get();
200 }

References $DIC.

Referenced by doCreateMetaData(), and doUpdateMetaData().

+ Here is the caller graph for this function:

◆ getPathToVersion()

getPathToVersion ( )
protected

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

215 : Path
216 {
217 global $DIC;
218
219 return $DIC->learningObjectMetadata()
220 ->paths()
221 ->custom()
222 ->withNextStep('lifeCycle')
223 ->withNextStep('version')
224 ->withNextStep('string')
225 ->get();
226 }

References $DIC.

Referenced by doCreateMetaData(), and doUpdateMetaData().

+ Here is the caller graph for this function:

◆ setNoMetaDataCreation()

setNoMetaDataCreation ( bool  $a_status)

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

76 : void
77 {
78 $this->no_meta_data_creation = $a_status;
79 }

◆ updateCopyright()

updateCopyright ( )
protected

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

173 : void
174 {
175 global $DIC;
176
177 $lom_services = $DIC->learningObjectMetadata();
178
179 $copyright_id = $this->getCopyrightID();
180 if (!$lom_services->copyrightHelper()->isCopyrightSelectionActive() || $copyright_id === null) {
181 return;
182 }
183
184 $lom_services->copyrightHelper()->prepareCreateOrUpdateOfCopyrightFromPreset(
185 $lom_services->manipulate($this->getId(), 0, $this->getType()),
186 $copyright_id
187 )->execute();
188 }

References $DIC.

Referenced by ilObjFile\beforeUpdate(), and ilObjFile\doCreate().

+ Here is the caller graph for this function:

◆ updateFileData()

updateFileData ( )
protected

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

31 : void
32 {
33 global $DIC;
34 $check_existing = $DIC->database()->queryF(
35 'SELECT file_id FROM file_data WHERE file_id = %s',
36 ['integer'],
37 [$this->getId()]
38 );
39 if ($check_existing->numRows() === 0) {
40 $DIC->database()->insert('file_data', $this->getArrayForDatabase());
41 } else {
42 $DIC->database()->update(
43 'file_data',
44 $this->getArrayForDatabase(),
45 ['file_id' => ['integer', $this->getId()]]
46 );
47 }
48 }

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