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,
63 $DIC->language()->loadLanguageModule(
'wopi');
78 $this->capability_context = $this->capability_context
79 ->withCallingId($this->ref_id ?? 0)
80 ->withObjectId($this->obj_id ?? 0);
86 public function init(): void
88 $this->delete_enabled =
true;
89 $this->cut_enabled =
true;
90 $this->copy_enabled =
true;
91 $this->subscribe_enabled =
true;
92 $this->link_enabled =
true;
93 $this->info_screen_enabled =
false;
95 $this->gui_class_name = ilObjFileGUI::class;
99 if ($this->substitutions->isActive()) {
100 $this->substitutions_enabled =
true;
110 $this->capabilities = $this->capability_builder->get($this->capability_context);
112 $best = $this->capabilities->getBest();
114 foreach ($this->commands as
$key => $command) {
115 if ($command[
'cmd'] === $best->getCapability()->value) {
117 $this->commands[
$key][
'default'] =
true;
121 return parent::getCommands();
127 $this->capabilities = $this->capability_builder->get($this->capability_context);
129 $needed_capability = Capabilities::fromCommand($cmd);
130 $capability = $this->capabilities->get($needed_capability);
131 if ($capability ===
false || !$capability->isUnlocked()) {
135 switch ($this->context) {
136 case self::CONTEXT_REPOSITORY:
137 return (
string) $capability->getURI();
138 case self::CONTEXT_WORKSPACE:
139 $this->
ctrl->setParameterByClass(ilObjFileGUI::class,
'wsp_id', $this->ref_id);
141 return $this->
ctrl->getLinkTargetByClass(
143 Capabilities::INFO_PAGE->value
150 return parent::getCommandLink($cmd);
157 return $this->file_info->getByObjectId($this->obj_id)->getListTitle();
162 return $this->secure(preg_replace(
'/\.[^.]*$/',
'', $a_title));
168 $info = $this->file_info->getByObjectId($this->obj_id);
170 if ($cmd === Capabilities::DOWNLOAD->value) {
171 return $info->shouldDeliverInline() ?
'_blank' :
'';
186 return $this->file_info->getByObjectId($this->obj_id)->shouldDeliverInline()
187 ? $this->type .
'_inline' 203 $this->capabilities = $this->capability_builder->get($this->capability_context);
205 $props = parent::getProperties();
207 $info = $this->file_info->getByObjectId($this->obj_id);
211 "property" => $DIC->language()->txt(
"type"),
212 "value" => $info->getSuffix(),
213 'propertyNameVisible' =>
false,
218 "property" => $DIC->language()->txt(
"size"),
219 "value" => (string) $info->getFileSize(),
220 'propertyNameVisible' =>
false,
227 if ($this->capabilities->get(Capabilities::MANAGE_VERSIONS)->isUnlocked()) {
229 $value =
"<a href=\"$link\">" . $DIC->language()->txt(
"version") .
": $version</a>";
231 $value = $DIC->language()->txt(
"version") .
": $version";
235 "property" => $DIC->language()->txt(
"version"),
237 "propertyNameVisible" => false
243 "property" => $DIC->language()->txt(
"last_update"),
247 'propertyNameVisible' =>
false,
250 if ($info->getPageCount() !== null && $info->getPageCount() > 0) {
253 "property" => $DIC->language()->txt(
"page_count"),
254 "value" => $info->getPageCount(),
255 'propertyNameVisible' =>
true,
279 $this->capability_context = $this->capability_context
280 ->withCallingId($ref_id)
281 ->withObjectId(
$obj_id ?? $this->capability_context->getObjectId());
284 if ($this->context !== self::CONTEXT_REPOSITORY && $permission ===
"edit_learning_progress") {
288 $this->capabilities = $this->capability_builder->get($this->capability_context);
290 $capability = Capabilities::fromCommand($cmd);
291 $additional_check = $this->capabilities->get($capability)->isUnlocked();
293 return $additional_check && parent::checkCommandAccess(
getCommandLink(string $cmd)
getIconImageType()
Returns the icon image type.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
static _getCommands()
get commands this method returns an array of all possible commands/permission combinations example: $...
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.
Context $capability_context
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)