ILIAS  release_8 Revision v8.24
ilObjFileInfoRepository Class Reference
+ Collaboration diagram for ilObjFileInfoRepository:

Public Member Functions

 __construct (bool $with_cleared_cache=false)
 
 getByRefId (int $ref_id)
 
 preloadData (array $object_ids)
 
 getByObjectId (int $object_id)
 

Private Member Functions

 initInlineSuffixes ()
 

Private Attributes

ILIAS ResourceStorage Services $irss
 
ilDBInterface $db
 
array $inline_suffixes = []
 

Static Private Attributes

static array $cache = []
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s
    Use this class to get common information about a file object. if you need infos for multiple files, use the
    preloadData method to load all data at once.

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

Constructor & Destructor Documentation

◆ __construct()

ilObjFileInfoRepository::__construct ( bool  $with_cleared_cache = false)

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

43 {
44 global $DIC;
45 if ($with_cleared_cache) {
46 self::$cache = [];
47 }
48 $this->irss = $DIC->resourceStorage();
49 $this->db = $DIC->database();
50 $this->inline_suffixes = $this->initInlineSuffixes();
51 }
global $DIC
Definition: feed.php:28

References $DIC, and initInlineSuffixes().

+ Here is the call graph for this function:

Member Function Documentation

◆ getByObjectId()

ilObjFileInfoRepository::getByObjectId ( int  $object_id)

Definition at line 113 of file class.ilObjFileInfoRepository.php.

114 {
115 $this->preloadData([$object_id]);
116 return self::$cache[$object_id] ?? new ilObjFileInfo(
117 'Unknown',
118 'Unknown',
119 '',
120 false,
121 false,
122 0,
123 new DateTimeImmutable(),
124 false,
125 '',
126 new DataSize(0, DataSize::Byte),
127 null
128 );
129 }
This class provides the data size with additional information to remove the work to calculate the siz...
Definition: DataSize.php:31

References preloadData().

Referenced by getByRefId().

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

◆ getByRefId()

ilObjFileInfoRepository::getByRefId ( int  $ref_id)

Definition at line 53 of file class.ilObjFileInfoRepository.php.

54 {
56
57 return $this->getByObjectId($object_id);
58 }
static _lookupObjectId(int $ref_id)
$ref_id
Definition: ltiauth.php:67

References $ref_id, ilObject\_lookupObjectId(), and getByObjectId().

+ Here is the call graph for this function:

◆ initInlineSuffixes()

ilObjFileInfoRepository::initInlineSuffixes ( )
private

Definition at line 60 of file class.ilObjFileInfoRepository.php.

60 : array
61 {
62 $settings = new ilSetting('file_access');
63 return array_map('strtolower', explode(" ", $settings->get('inline_file_extensions')));
64 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

References ILIAS\LTI\ToolProvider\$settings.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ preloadData()

ilObjFileInfoRepository::preloadData ( array  $object_ids)

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

66 : void
67 {
68 $res = $this->db->query(
69 "SELECT title, rid, file_id, page_count FROM file_data JOIN object_data ON object_data.obj_id = file_data.file_id WHERE rid IS NOT NULL AND " . $this->db->in(
70 'file_id',
71 $object_ids,
72 false,
73 'integer'
74 )
75 );
76 $rids = [];
77 $page_counts = [];
78 $object_titles = [];
79
80 while ($row = $this->db->fetchObject($res)) {
81 $rids[(int) $row->file_id] = $row->rid;
82 $page_counts[(int) $row->file_id] = $row->page_count;
83 $object_titles[(int) $row->file_id] = $row->title;
84 }
85 $this->irss->preload($rids);
86
87 foreach ($rids as $file_id => $rid) {
88 if ($id = $this->irss->manage()->find($rid)) {
89 $max = $this->irss->manage()->getResource($id)->getCurrentRevision();
90
91 $info = new ilObjFileInfo(
92 $object_titles[$file_id] ?? $max->getTitle(),
93 $max->getInformation()->getTitle(),
94 $max->getInformation()->getSuffix(),
95 in_array(strtolower($max->getInformation()->getSuffix()), $this->inline_suffixes, true),
96 true,
97 $max->getVersionNumber(),
98 $max->getInformation()->getCreationDate(),
99 in_array(strtolower($max->getInformation()->getMimeType()), [
100 MimeType::APPLICATION__ZIP,
101 MimeType::APPLICATION__X_ZIP_COMPRESSED
102 ], true),
103 $max->getInformation()->getMimeType(),
104 new DataSize($max->getInformation()->getSize() ?? 0, DataSize::Byte),
105 $page_counts[$file_id] === null ? null : (int) $page_counts[$file_id]
106 );
107
108 self::$cache[$file_id] = $info;
109 }
110 }
111 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$res
Definition: ltiservices.php:69

References $id, $res, and ILIAS\Repository\int().

Referenced by getByObjectId().

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

Field Documentation

◆ $cache

array ilObjFileInfoRepository::$cache = []
staticprivate

Definition at line 37 of file class.ilObjFileInfoRepository.php.

◆ $db

ilDBInterface ilObjFileInfoRepository::$db
private

Definition at line 39 of file class.ilObjFileInfoRepository.php.

◆ $inline_suffixes

array ilObjFileInfoRepository::$inline_suffixes = []
private

Definition at line 40 of file class.ilObjFileInfoRepository.php.

◆ $irss

ILIAS ResourceStorage Services ilObjFileInfoRepository::$irss
private

Definition at line 38 of file class.ilObjFileInfoRepository.php.


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