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) {
164 return (
string) $capability->getURI();
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
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(
static _getInstanceByObjectType(string $a_type)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static _getCommands()
get commands this method returns an array of all possible commands/permission combinations example: $...
static _shouldDownloadDirectly(int $obj_id)
getCommandLink(string $cmd)
Get command link url.
insertCommands()
@description This methods seems to be called by ItemRenderer
Context $capability_context
stripTitleOfFileExtension(string $a_title)
checkCommandAccess(string $permission, string $cmd, int $ref_id, string $type, ?int $obj_id=null)
getProperties()
Get item properties.
getTitle()
getTitle overwritten in class.ilObjLinkResourceList.php
getCommandFrame(string $cmd)
Get command target frame.
ilObjFileInfoRepository $file_info
getCommandImage($a_cmd)
Get command icon image.
CapabilityCollection $capabilities
IconDatabaseRepository $icon_repo
getIconImageType()
Returns the icon image type.
getCommands()
get all current commands for a specific ref id (in the permission context of the current user)
__construct(int $context=self::CONTEXT_REPOSITORY)
CapabilityBuilder $capability_builder
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
trait ilObjFileSecureString
Trait ilObjFileSecureString.