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);
92 public function init(): void
94 $this->delete_enabled =
true;
95 $this->cut_enabled =
true;
96 $this->copy_enabled =
true;
97 $this->subscribe_enabled =
true;
98 $this->link_enabled =
true;
99 $this->info_screen_enabled =
false;
101 $this->gui_class_name = ilObjFileGUI::class;
105 if ($this->substitutions->isActive()) {
106 $this->substitutions_enabled =
true;
116 $this->capabilities = $this->capability_builder->get($this->capability_context);
118 $best = $this->capabilities->getBest();
122 foreach ($this->commands as $key => $command) {
123 if ($command[
'cmd'] === $best->getCapability()->value) {
125 $this->commands[$key][
'default'] =
true;
130 if ($default_key !== null) {
131 $command_copy = $this->commands[$default_key];
132 $command_copy[
'default'] =
false;
136 foreach ($this->commands as $key => $command) {
137 if ($key === $default_key) {
145 return parent::getCommands();
151 $this->capabilities = $this->capability_builder->get($this->capability_context);
153 $needed_capability = Capabilities::fromCommand($cmd);
154 $capability = $this->capabilities->get($needed_capability);
155 if ($capability ===
false || !$capability->isUnlocked()) {
159 switch ($this->context) {
160 case self::CONTEXT_REPOSITORY:
161 return (
string) $capability->getURI();
162 case self::CONTEXT_WORKSPACE:
163 $this->
ctrl->setParameterByClass(ilObjFileGUI::class,
'wsp_id', $this->ref_id);
165 return $this->
ctrl->getLinkTargetByClass(
167 Capabilities::INFO_PAGE->value
173 return parent::getCommandLink($cmd);
178 return $this->file_info->getByObjectId($this->obj_id)->getListTitle();
183 return $this->secure(preg_replace(
'/\.[^.]*$/',
'', $a_title));
189 $info = $this->file_info->getByObjectId($this->obj_id);
191 if ($cmd === Capabilities::DOWNLOAD->value) {
192 return $info->shouldDeliverInline() ?
'_blank' :
'';
207 return $this->file_info->getByObjectId($this->obj_id)->shouldDeliverInline()
208 ? $this->type .
'_inline' 223 $this->capabilities = $this->capability_builder->get($this->capability_context);
225 $props = parent::getProperties();
227 $info = $this->file_info->getByObjectId($this->obj_id);
231 "property" => $DIC->language()->txt(
"type"),
232 "value" => $info->getSuffix(),
233 'propertyNameVisible' =>
false,
238 "property" => $DIC->language()->txt(
"size"),
239 "value" => (string) $info->getFileSize(),
240 'propertyNameVisible' =>
false,
246 if ($this->capabilities->get(Capabilities::MANAGE_VERSIONS)->isUnlocked()) {
248 $value =
"<a href=\"$link\">" . $DIC->language()->txt(
"version") .
": $version</a>";
250 $value = $DIC->language()->txt(
"version") .
": $version";
254 "property" => $DIC->language()->txt(
"version"),
256 "propertyNameVisible" => false
262 "property" => $DIC->language()->txt(
"last_update"),
266 'propertyNameVisible' =>
false,
269 if ($info->getPageCount() !== null && $info->getPageCount() > 0) {
272 "property" => $DIC->language()->txt(
"page_count"),
273 "value" => $info->getPageCount(),
274 'propertyNameVisible' =>
true,
298 $this->capability_context = $this->capability_context
299 ->withCallingId($ref_id)
300 ->withObjectId(
$obj_id ?? $this->capability_context->getObjectId());
303 if ($this->context !== self::CONTEXT_REPOSITORY && $permission ===
"edit_learning_progress") {
307 $this->capabilities = $this->capability_builder->get($this->capability_context);
309 $capability = Capabilities::fromCommand($cmd);
310 $additional_check = $this->capabilities->get($capability)->isUnlocked();
312 return $additional_check && parent::checkCommandAccess(
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ilObjUser $user=null,)
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: $...
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
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)