49 $this->capability_context =
new Context(
53 self::CONTEXT_REPOSITORY => Context::CONTEXT_REPO,
54 self::CONTEXT_WORKSPACE => Context::CONTEXT_WORKSPACE,
55 self::CONTEXT_SEARCH => Context::CONTEXT_SEARCH,
56 default => Context::CONTEXT_REPO,
62 $DIC->language()->loadLanguageModule(
'wopi');
70 $DIC[
'static_url.uri_builder']
76 $this->capability_context = $this->capability_context
77 ->withCallingId($this->ref_id ?? 0)
78 ->withObjectId($this->obj_id ?? 0);
93 public function init(): void
95 $this->delete_enabled =
true;
96 $this->cut_enabled =
true;
97 $this->copy_enabled =
true;
98 $this->subscribe_enabled =
true;
99 $this->link_enabled =
true;
100 $this->info_screen_enabled =
false;
102 $this->gui_class_name = ilObjFileGUI::class;
106 if ($this->substitutions->isActive()) {
107 $this->substitutions_enabled =
true;
118 $this->capabilities = $this->capability_builder->get($this->capability_context);
120 $best = $this->capabilities->getBest();
124 foreach ($this->commands as $key => $command) {
125 if ($command[
'cmd'] === $best->getCapability()->value) {
127 $this->commands[$key][
'default'] =
true;
132 if ($default_key !==
null) {
133 $command_copy = $this->commands[$default_key];
134 $command_copy[
'default'] =
false;
138 foreach ($this->commands as $key => $command) {
139 if ($key === $default_key) {
147 return parent::getCommands();
154 $this->capabilities = $this->capability_builder->get($this->capability_context);
156 $needed_capability = Capabilities::fromCommand($cmd);
157 $capability = $this->capabilities->get($needed_capability);
158 if ($capability ===
false || !$capability->isUnlocked()) {
162 switch ($this->context) {
163 case self::CONTEXT_REPOSITORY:
164 return (
string) $capability->getURI();
165 case self::CONTEXT_WORKSPACE:
166 $this->
ctrl->setParameterByClass(ilObjFileGUI::class,
'wsp_id', $this->ref_id);
168 return $this->
ctrl->getLinkTargetByClass(
170 Capabilities::INFO_PAGE->value
176 return parent::getCommandLink($cmd);
184 return $this->file_info->getByObjectId($this->obj_id)->getListTitle();
189 return $this->secure(preg_replace(
'/\.[^.]*$/',
'', $a_title));
196 $info = $this->file_info->getByObjectId($this->obj_id);
198 if ($cmd === Capabilities::DOWNLOAD->value) {
199 return $info->shouldDeliverInline() ?
'_blank' :
'';
215 return $this->file_info->getByObjectId($this->obj_id)->shouldDeliverInline()
216 ? $this->type .
'_inline' 232 $this->capabilities = $this->capability_builder->get($this->capability_context);
234 $props = parent::getProperties();
236 $info = $this->file_info->getByObjectId($this->obj_id);
240 "property" => $DIC->language()->txt(
"type"),
241 "value" =>
$info->getSuffix(),
242 'propertyNameVisible' =>
false,
247 "property" => $DIC->language()->txt(
"size"),
248 "value" => (string)
$info->getFileSize(),
249 'propertyNameVisible' =>
false,
255 if ($this->capabilities->get(Capabilities::MANAGE_VERSIONS)->isUnlocked()) {
257 $value =
"<a href=\"$link\">" . $DIC->language()->txt(
"version") .
": $version</a>";
259 $value = $DIC->language()->txt(
"version") .
": $version";
263 "property" => $DIC->language()->txt(
"version"),
265 "propertyNameVisible" => false
271 "property" => $DIC->language()->txt(
"last_update"),
275 'propertyNameVisible' =>
false,
278 if (
$info->getPageCount() !==
null &&
$info->getPageCount() > 0) {
281 "property" => $DIC->language()->txt(
"page_count"),
282 "value" =>
$info->getPageCount(),
283 'propertyNameVisible' =>
true,
309 $this->capability_context = $this->capability_context
310 ->withCallingId($ref_id)
311 ->withObjectId(
$obj_id ?? $this->capability_context->getObjectId());
314 if ($this->context !== self::CONTEXT_REPOSITORY && $permission ===
"edit_learning_progress") {
318 $this->capabilities = $this->capability_builder->get($this->capability_context);
320 $capability = Capabilities::fromCommand($cmd);
321 $additional_check = $this->capabilities->get($capability)->isUnlocked();
323 return $additional_check && parent::checkCommandAccess(
getCommandLink(string $cmd)
getIconImageType()
Returns the icon image type.
static _getCommands()
get commands this method returns an array of all possible commands/permission combinations example: $...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
insertCommands()
This methods seems to be called by ItemRenderer
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _shouldDownloadDirectly(int $obj_id)
__construct(int $context=self::CONTEXT_REPOSITORY)
ilObjFileInfoRepository $file_info
CapabilityCollection $capabilities
CapabilityBuilder $capability_builder
trait ilObjFileSecureString
Trait ilObjFileSecureString.
getProperties()
Get item properties.
__construct(Container $dic, ilPlugin $plugin)
Context $capability_context
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
IconDatabaseRepository $icon_repo
getCommandFrame(string $cmd)
stripTitleOfFileExtension(string $a_title)
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
getCommandImage($a_cmd)
Get command icon image.
static _getInstanceByObjectType(string $a_type)