19declare(strict_types=1);
32 public function getFileInfoForUsers(): array
35 $page_count = $this->
getFileObj()->getPageCount();
36 $page_count = ($page_count !== 0) ? $page_count :
null;
40 if ($preview_renderer->has() && !$this->getCtrl()->isAsynch()) {
41 $preview = $preview_renderer->getRenderedTriggerComponents(
true);
52 $this->
getLanguage()->txt(
"size") => (string) $data_size,
53 $this->
getLanguage()->txt(
"page_count") => $page_count,
64 public function getFileInfoForAll(): array
67 $version_nr = $this->
getFileObj()->getVersion();
76 $version_uploader =
$version[
"user_id"] ?? -1;
78 $download_link_tpl =
null;
79 if ($this->getAccessHandler()->checkAccessOfUser(
85 $download_link_tpl =
new ilTemplate(
"tpl.download_link.html",
true,
true,
"components/ILIAS/File");
90 $this->
getLanguage()->txt(
"version") => $version_nr,
91 $this->
getLanguage()->txt(
"version_uploaded") => $version_date,
93 $this->
getLanguage()->txt(
"download_link") => $download_link_tpl->get(),
94 $this->
getLanguage()->txt(
"download_link") => $download_link_tpl->get(),
101 public function getFileInfoForAuthorsAndAdmins(): array
103 $amount_of_downloads =
null;
107 $this->
getLanguage()->txt(
"amount_of_downloads_since"),
118 $this->
getLanguage()->txt(
"amount_of_downloads") => $amount_of_downloads
128 public function getAllFileInfoForCurrentUser(): array
131 $access_handler = $this->getAccessHandler();
137 if ($access_handler->checkAccessOfUser(
138 $this->getUser()->getId(),
141 $this->getFileObj()->getRefId()
143 $file_info[
'for_users'] = $this->getFileInfoForUsers();
144 $file_info[
'for_all'] = $this->getFileInfoForAll();
146 if ($access_handler->checkAccessOfUser(
147 $this->getUser()->getId(),
150 $this->getFileObj()->getRefId()
152 $file_info[
'for_authors_and_admins'] = $this->getFileInfoForAuthorsAndAdmins();
158 abstract protected function getAccessHandler();
177 private function safeSprintf(
string $format, mixed ...$args): string
180 return sprintf($format, ...$args);
181 }
catch (\ValueError
$e) {
182 $fixed = preg_replace(
'/%(?!([0-9]+\$)?[bcdeEfFgGosuxX%])/',
'%%', $format);
184 return sprintf($fixed, ...$args);
185 }
catch (\ValueError $e2) {
This class provides the data size with additional information to remove the work to calculate the siz...
Class ilCtrl provides processing control methods.
@classDescription Date and time handling
static _getPermanentDownloadLink(int $ref_id)
Gets the permanent download link for the file.
Class ilObjFileStakeholder.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
safeSprintf(string $format, mixed ... $args)
Robust sprintf: tolerates broken translation placeholders.
trait ilObjFileInfoProvider