ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjFileImplementationStorage Class Reference

Class ilObjFileImplementationStorage. More...

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

Public Member Functions

 __construct (protected StorableResource $resource)
 ilObjFileImplementationStorage constructor. More...
 
 handleChangedObjectTitle (string $new_title)
 
 getFile (?int $a_hist_entry_id=null)
 
 getFileName ()
 
 getFileSize ()
 
 getFileType ()
 
 getDirectory (int $a_version=0)
 
 sendFile (?int $a_hist_entry_id=null, bool $inline=true)
 
 deleteVersions (?array $a_hist_entry_ids=null)
 Deletes the specified history entries or all entries if no ids are specified. More...
 
 getFileExtension ()
 Returns the extension of the file name converted to lower-case. More...
 
 getVersions (?array $version_ids=null)
 
 getStorageID ()
 
 getVersion (bool $inclduing_drafts=false)
 
 getMaxVersion ()
 

Protected Attributes

Services $storage
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjFileImplementationStorage::__construct ( protected StorableResource  $resource)

ilObjFileImplementationStorage constructor.

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

References $DIC.

36  {
37  global $DIC;
38  $settings = new General();
39  $this->storage = $DIC->resourceStorage();
40  }
global $DIC
Definition: shib_login.php:22

Member Function Documentation

◆ deleteVersions()

ilObjFileImplementationStorage::deleteVersions ( ?array  $a_hist_entry_ids = null)

Deletes the specified history entries or all entries if no ids are specified.

Parameters
array | null$a_hist_entry_idsThe ids of the entries to delete or null to delete all entries
Deprecated:

Implements ilObjFileImplementationInterface.

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

References $id.

109  : void
110  {
111  if (is_array($a_hist_entry_ids)) {
112  foreach ($a_hist_entry_ids as $id) {
113  $this->storage->manage()->removeRevision($this->resource->getIdentification(), $id);
114  }
115  }
116  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ getDirectory()

ilObjFileImplementationStorage::getDirectory ( int  $a_version = 0)
Deprecated:

Implements ilObjFileImplementationInterface.

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

79  : string
80  {
81  $consumer = $this->storage->consume()->stream($this->resource->getIdentification());
82  if ($a_version !== 0) {
83  $consumer->setRevisionNumber($a_version);
84  }
85  $stream = $consumer->getStream();
86 
87  return dirname((string) $stream->getMetadata('uri'));
88  }

◆ getFile()

ilObjFileImplementationStorage::getFile ( ?int  $a_hist_entry_id = null)

Implements ilObjFileImplementationInterface.

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

52  : string
53  {
54  $stream = $this->storage->consume()->stream($this->resource->getIdentification());
55  if ($a_hist_entry_id) {
56  $stream = $stream->setRevisionNumber($a_hist_entry_id);
57  }
58  return $stream->getStream()->getMetadata('uri');
59  }

◆ getFileExtension()

ilObjFileImplementationStorage::getFileExtension ( )

Returns the extension of the file name converted to lower-case.

e.g. returns 'pdf' for 'document.pdf'.

Implements ilObjFileImplementationInterface.

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

118  : string
119  {
120  return $this->resource->getCurrentRevision()->getInformation()->getSuffix();
121  }

◆ getFileName()

ilObjFileImplementationStorage::getFileName ( )

Implements ilObjFileImplementationInterface.

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

61  : string
62  {
63  return $this->resource->getCurrentRevision()->getInformation()->getTitle();
64  }

◆ getFileSize()

ilObjFileImplementationStorage::getFileSize ( )

Implements ilObjFileImplementationInterface.

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

66  : int
67  {
68  return $this->resource->getCurrentRevision()->getInformation()->getSize() ?: 0;
69  }

◆ getFileType()

ilObjFileImplementationStorage::getFileType ( )

Implements ilObjFileImplementationInterface.

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

74  : string
75  {
76  return $this->resource->getCurrentRevision()->getInformation()->getMimeType();
77  }

◆ getMaxVersion()

ilObjFileImplementationStorage::getMaxVersion ( )

Implements ilObjFileImplementationInterface.

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

177  : int
178  {
179  return $this->resource->getMaxRevision(false);
180  }

◆ getStorageID()

ilObjFileImplementationStorage::getStorageID ( )

Implements ilObjFileImplementationInterface.

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

160  : ?string
161  {
162  return $this->resource->getStorageID();
163  }

◆ getVersion()

ilObjFileImplementationStorage::getVersion ( bool  $inclduing_drafts = false)

Implements ilObjFileImplementationInterface.

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

165  : int
166  {
167  try {
168  if ($inclduing_drafts) {
169  return $this->resource->getCurrentRevisionIncludingDraft()->getVersionNumber();
170  }
171  return $this->resource->getCurrentRevision()->getVersionNumber();
172  } catch (Throwable) {
173  return 0;
174  }
175  }

◆ getVersions()

ilObjFileImplementationStorage::getVersions ( ?array  $version_ids = null)
Returns
[]

Implements ilObjFileImplementationInterface.

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

References ILIAS\ResourceStorage\Revision\DRAFT.

126  : array
127  {
128  $versions = [];
129  $current_revision = $this->resource->getCurrentRevisionIncludingDraft();
130  foreach ($this->resource->getAllRevisionsIncludingDraft() as $revision) {
131  if (is_array($version_ids) && !in_array($revision->getVersionNumber(), $version_ids)) {
132  continue;
133  }
134  $information = $revision->getInformation();
135  $v = new ilObjFileVersion();
136  $v->setVersion($revision->getVersionNumber());
137  $v->setHistEntryId($revision->getVersionNumber());
138  $v->setFilename($information->getTitle());
139  if ($revision->getStatus() === RevisionStatus::DRAFT) {
140  $v->setAction('draft');
141  } else {
142  $version_number = $revision->getVersionNumber();
143  match ($version_number) {
144  1 => $v->setAction('create'),
145  $current_revision->getVersionNumber() => $v->setAction('published_version'),
146  default => $v->setAction('intermediate_version'),
147  };
148  }
149  $v->setTitle($revision->getTitle());
150  $v->setDate($information->getCreationDate()->format(DATE_ATOM));
151  $v->setUserId($revision->getOwnerId() !== 0 ? $revision->getOwnerId() : 6);
152  $v->setSize($information->getSize());
153 
154  $versions[] = $v;
155  }
156 
157  return $versions;
158  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ handleChangedObjectTitle()

ilObjFileImplementationStorage::handleChangedObjectTitle ( string  $new_title)

Implements ilObjFileImplementationInterface.

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

42  : void
43  {
44  $current_revision = $this->resource->getCurrentRevision();
45  $current_revision->setTitle($new_title);
46  $this->storage->manage()->updateRevision($current_revision);
47  }

◆ sendFile()

ilObjFileImplementationStorage::sendFile ( ?int  $a_hist_entry_id = null,
bool  $inline = true 
)
Parameters
bool$inline
Deprecated:

Implements ilObjFileImplementationInterface.

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

90  : void
91  {
92  if ($inline) {
93  $consumer = $this->storage->consume()->inline($this->resource->getIdentification());
94  } else {
95  $consumer = $this->storage->consume()->download($this->resource->getIdentification());
96  }
97 
98  if ($a_hist_entry_id) {
99  $revision = $this->resource->getSpecificRevision($a_hist_entry_id);
100  $consumer->setRevisionNumber($a_hist_entry_id);
101  } else {
102  $revision = $this->resource->getCurrentRevision();
103  }
104  $consumer->overrideFileName($revision->getTitle());
105 
106  $consumer->run();
107  }

Field Documentation

◆ $storage

Services ilObjFileImplementationStorage::$storage
protected

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


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