ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjFileImplementationStorage Class Reference

Class ilObjFileImplementationStorage. More...

+ Inheritance diagram for ilObjFileImplementationStorage:
+ Collaboration diagram for ilObjFileImplementationStorage:

Public Member Functions

 handleChangedObjectTitle (string $new_title)
 
 getFile ($a_hist_entry_id=null)
 
 getFileType ()
 
 getDirectory ($a_version=0)
 
 sendFile ($a_hist_entry_id=null)
 
 deleteVersions ($a_hist_entry_ids=null)
 
 getFileExtension ()
 
 getVersions ($version_ids=null)
 
 export (string $target_dir)
 
 getStorageID ()
 
- Public Member Functions inherited from ilObjFileImplementationAbstract
 createDirectory ()
 
 replaceFile ($a_upload_file, $a_filename)
 
 addFileVersion ($a_upload_file, $a_filename)
 
 clearDataDirectory ()
 
 setFileType ($a_type)
 
 setFileSize ($a_size)
 
 getFileSize ()
 
 setVersion ($a_version)
 
 getVersion ()
 
 setMaxVersion ($a_max_version)
 
 getMaxVersion ()
 
 storeUnzipedFile ($a_upload_file, $a_filename)
 
 getSpecificVersion ($version_id)
 

Protected Attributes

 $resource
 
 $storage
 
 $download_with_uploaded_filename
 
 $obj_id
 

Private Member Functions

 debug ()
 
 isInline ($a_hist_entry_id=null)
 

Detailed Description

Member Function Documentation

◆ debug()

ilObjFileImplementationStorage::debug ( )
private

Definition at line 51 of file class.ilObjFileImplementationStorage.php.

References $container, and ilUtil\sendInfo().

51  : void
52  {
53  // debug
54  $stream = $this->storage->consume()->stream($this->resource->getIdentification())->getStream();
55  $container = dirname($stream->getMetadata('uri'), 2);
56 
57  $dir_reader = function (string $path) {
58  $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
59 
60  $files = array();
61  foreach ($rii as $file) {
62  if (!$file->isDir()) {
63  $files[] = $file->getPathname();
64  }
65  }
66 
67  return $files;
68  };
69 
70  ilUtil::sendInfo('<pre>' . print_r($dir_reader($container), true) . '</pre>');
71  }
$container
Definition: wac.php:13
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

◆ deleteVersions()

ilObjFileImplementationStorage::deleteVersions (   $a_hist_entry_ids = null)

Implements ilObjFileImplementationInterface.

Definition at line 161 of file class.ilObjFileImplementationStorage.php.

162  {
163  if (is_array($a_hist_entry_ids)) {
164  foreach ($a_hist_entry_ids as $id) {
165  $this->storage->manage()->removeRevision($this->resource->getIdentification(), $id);
166  }
167  }
168  }

◆ export()

ilObjFileImplementationStorage::export ( string  $target_dir)

Implements ilObjFileImplementationInterface.

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

References $DIC, $obj_id, and IL_INST_ID.

205  : void
206  {
207  global $DIC;
208  $relative_dir = LegacyPathHelper::createRelativePath($target_dir);
209  $filesystem = LegacyPathHelper::deriveFilesystemFrom($target_dir);
210 
211  if ($filesystem->has($target_dir)) {
212  $directory = $relative_dir . '/objects/il_' . IL_INST_ID . "_file_" . $this->obj_id;
213  $filesystem->createDir($directory);
214  $stream = $DIC->resourceStorage()->consume()->stream($this->resource->getIdentification())->getStream();
215  $filesystem->writeStream(
216  $directory . '/' . $this->resource->getCurrentRevision()->getInformation()->getTitle(),
217  $stream
218  );
219  }
220  }
const IL_INST_ID
Definition: constants.php:38
global $DIC
Definition: goto.php:24

◆ getDirectory()

ilObjFileImplementationStorage::getDirectory (   $a_version = 0)

Implements ilObjFileImplementationInterface.

Definition at line 103 of file class.ilObjFileImplementationStorage.php.

104  {
105  $consumer = $this->storage->consume()->stream($this->resource->getIdentification());
106  if ($a_version) {
107  $consumer->setRevisionNumber($a_version);
108  }
109  $stream = $consumer->getStream();
110 
111  return dirname($stream->getMetadata('uri'));
112  }

◆ getFile()

ilObjFileImplementationStorage::getFile (   $a_hist_entry_id = null)

Implements ilObjFileImplementationInterface.

Definition at line 83 of file class.ilObjFileImplementationStorage.php.

84  {
85  $stream = $this->storage->consume()->stream($this->resource->getIdentification());
86  if ($a_hist_entry_id) {
87  $stream = $stream->setRevisionNumber($a_hist_entry_id);
88  }
89  return $stream->getStream()->getMetadata('uri');
90  }

◆ getFileExtension()

ilObjFileImplementationStorage::getFileExtension ( )

Implements ilObjFileImplementationInterface.

Definition at line 173 of file class.ilObjFileImplementationStorage.php.

174  {
175  return $this->resource->getCurrentRevision()->getInformation()->getSuffix();
176  }

◆ getFileType()

ilObjFileImplementationStorage::getFileType ( )

Implements ilObjFileImplementationInterface.

Definition at line 95 of file class.ilObjFileImplementationStorage.php.

96  {
97  return $this->resource->getCurrentRevision()->getInformation()->getMimeType();
98  }

◆ getStorageID()

ilObjFileImplementationStorage::getStorageID ( )

Implements ilObjFileImplementationInterface.

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

222  : ?string
223  {
224  return $this->resource->getStorageID();
225  }

◆ getVersions()

ilObjFileImplementationStorage::getVersions (   $version_ids = null)

Implements ilObjFileImplementationInterface.

Definition at line 181 of file class.ilObjFileImplementationStorage.php.

181  : array
182  {
183  $versions = [];
184  foreach ($this->resource->getAllRevisions() as $revision) {
185  if (is_array($version_ids) && !in_array($revision->getVersionNumber(), $version_ids)) {
186  continue;
187  }
188  $information = $revision->getInformation();
189  $v = new ilObjFileVersion();
190  $v->setVersion($revision->getVersionNumber());
191  $v->setHistEntryId($revision->getVersionNumber());
192  $v->setFilename($information->getTitle());
193  $v->setAction($revision->getVersionNumber() === 1 ? 'create' : 'new_version');
194  $v->setTitle($revision->getTitle());
195  $v->setDate($information->getCreationDate()->format(DATE_ATOM));
196  $v->setUserId($revision->getOwnerId() !== 0 ? $revision->getOwnerId() : 6);
197  $v->setSize($information->getSize());
198 
199  $versions[] = $v;
200  }
201 
202  return $versions;
203  }
Class ilObjFileVersion.

◆ handleChangedObjectTitle()

ilObjFileImplementationStorage::handleChangedObjectTitle ( string  $new_title)

Implements ilObjFileImplementationInterface.

Definition at line 73 of file class.ilObjFileImplementationStorage.php.

74  {
75  $current_revision = $this->resource->getCurrentRevision();
76  $current_revision->setTitle($new_title);
77  $this->storage->manage()->updateRevision($current_revision);
78  }

◆ isInline()

ilObjFileImplementationStorage::isInline (   $a_hist_entry_id = null)
private
Parameters
null$a_hist_entry_id
Returns
bool

Definition at line 146 of file class.ilObjFileImplementationStorage.php.

References Vendor\Package\$e.

Referenced by sendFile().

147  {
148  try {
149  $revision = $a_hist_entry_id ?
150  $this->resource->getSpecificRevision($a_hist_entry_id) :
151  $this->resource->getCurrentRevision();
152  return \ilObjFileAccess::_isFileInline($revision->getTitle());
153  } catch (Exception $e) {
154  return false;
155  }
156  }
+ Here is the caller graph for this function:

◆ sendFile()

ilObjFileImplementationStorage::sendFile (   $a_hist_entry_id = null)

Implements ilObjFileImplementationInterface.

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

References isInline().

118  {
119  if ($this->isInline($a_hist_entry_id)) {
120  $consumer = $this->storage->consume()->inline($this->resource->getIdentification());
121  } else {
122  $consumer = $this->storage->consume()->download($this->resource->getIdentification());
123  }
124 
125 
126  if ($a_hist_entry_id) {
127  $revision = $this->resource->getSpecificRevision($a_hist_entry_id);
128  $consumer->setRevisionNumber($a_hist_entry_id);
129  } else {
130  $revision = $this->resource->getCurrentRevision();
131  }
132 
133  if ($this->download_with_uploaded_filename) {
134  $consumer->overrideFileName($revision->getInformation()->getTitle());
135  } else {
136  $consumer->overrideFileName($revision->getTitle());
137  }
138 
139  $consumer->run();
140  }
+ Here is the call graph for this function:

Field Documentation

◆ $download_with_uploaded_filename

ilObjFileImplementationStorage::$download_with_uploaded_filename
protected

Definition at line 27 of file class.ilObjFileImplementationStorage.php.

◆ $obj_id

ilObjFileImplementationStorage::$obj_id
protected

Definition at line 31 of file class.ilObjFileImplementationStorage.php.

Referenced by export().

◆ $resource

ilObjFileImplementationStorage::$resource
protected

Definition at line 19 of file class.ilObjFileImplementationStorage.php.

◆ $storage

ilObjFileImplementationStorage::$storage
protected

Definition at line 23 of file class.ilObjFileImplementationStorage.php.


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