ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 ()
 update copyright meta data More...
 
 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.

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

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:25
+ 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.

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

Referenced by ilObjFile\doCreate().

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 _getDefaultVisibilityForRefId(int $a_ref_id)
Get default visibility for reference id.
global $DIC
Definition: shib_login.php:25
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
+ 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.

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

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()
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

◆ doMDUpdateListener()

doMDUpdateListener ( string  $a_element)
protected

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

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

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  }
getPathToFirstFormat()
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

◆ doUpdateMetaData()

doUpdateMetaData ( )
protected

update meta data

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

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

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  }
getPathToFirstFormat()
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

◆ getPathToFirstFormat()

getPathToFirstFormat ( )
protected

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

References $DIC.

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

205  : Path
206  {
207  global $DIC;
208 
209  return $DIC->learningObjectMetadata()
210  ->paths()
211  ->custom()
212  ->withNextStep('technical')
213  ->withNextStep('format')
214  ->withAdditionalFilterAtCurrentStep(FilterType::INDEX, '0')
215  ->get();
216  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ getPathToSize()

getPathToSize ( )
protected

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

References $DIC.

Referenced by doCreateMetaData(), and doUpdateMetaData().

193  : Path
194  {
195  global $DIC;
196 
197  return $DIC->learningObjectMetadata()
198  ->paths()
199  ->custom()
200  ->withNextStep('technical')
201  ->withNextStep('size')
202  ->get();
203  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ getPathToVersion()

getPathToVersion ( )
protected

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

References $DIC.

Referenced by doCreateMetaData(), and doUpdateMetaData().

218  : Path
219  {
220  global $DIC;
221 
222  return $DIC->learningObjectMetadata()
223  ->paths()
224  ->custom()
225  ->withNextStep('lifeCycle')
226  ->withNextStep('version')
227  ->withNextStep('string')
228  ->get();
229  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ setNoMetaDataCreation()

setNoMetaDataCreation ( bool  $a_status)

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

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

◆ updateCopyright()

updateCopyright ( )
protected

update copyright meta data

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

References $DIC.

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

176  : void
177  {
178  global $DIC;
179 
180  $lom_services = $DIC->learningObjectMetadata();
181 
182  $copyright_id = $this->getCopyrightID();
183  if (!$lom_services->copyrightHelper()->isCopyrightSelectionActive() || $copyright_id === null) {
184  return;
185  }
186 
187  $lom_services->copyrightHelper()->prepareCreateOrUpdateOfCopyrightFromPreset(
188  $lom_services->manipulate($this->getId(), 0, $this->getType()),
189  $copyright_id
190  )->execute();
191  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ updateFileData()

updateFileData ( )
protected

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

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

Referenced by createProperties().

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  }
global $DIC
Definition: shib_login.php:25
+ 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 28 of file trait.ilObjFileMetadata.php.