24use ILIAS\ResourceStorage\Preloader\SecureString;
49 protected string $cur_subdir,
50 protected bool $label_enable,
51 protected array $file_labels = [],
52 protected string $label_header =
"",
53 ?array $a_commands = [],
54 protected ?
bool $post_dir_path =
false,
55 ?
string $a_table_id =
""
58 $this->
setId($a_table_id);
59 $this->
ctrl = $DIC->ctrl();
60 $this->
lng = $DIC->language();
61 if ($a_cur_dir ===
'' || $a_cur_dir !== realpath($a_cur_dir)) {
67 $a_cur_dir = $this->filesystem_gui->getMainAbsoluteDir();
68 $this->cur_subdir =
'';
70 $this->
filesystem = LegacyPathHelper::deriveFilesystemFrom($a_cur_dir);
71 $this->relative_cur_dir = LegacyPathHelper::createRelativePath($a_cur_dir);
72 $this->cur_dir = $a_cur_dir;
73 $this->ui_factory =
$DIC->ui()->factory();
74 $this->ui_renderer =
$DIC->ui()->renderer();
77 $this->
setTitle($this->
lng->txt(
"cont_files") .
" " . $this->cur_subdir);
79 $this->has_multi =
false;
81 foreach ((array) $a_commands as $i => $command) {
82 if (!($command[
"single"] ??
false)) {
85 $this->has_multi =
true;
87 $this->row_commands[] = [
88 "cmd" =>
"extCommand_" . $i,
89 "caption" => $command[
"name"],
90 "allow_dir" => $command[
"allow_dir"] ??
false,
91 "method" => $command[
"method"] ??
null,
103 "tpl.directory_row.html",
104 "components/ILIAS/Filesystem"
112 return $a_field ===
"size";
129 if ($this->cur_dir !==
'') {
141 $basename = basename($content->getPath());
142 $entries[$basename] = [
145 'entry' => $basename,
146 'type' => $content->isDir() ?
'dir' :
'file',
148 'size' => $content->isFile() ? $this->
filesystem->getSize($content->getPath(), 1)->inBytes() : 0
152 $entries = [[
"type" =>
"dir",
"entry" =>
".."]];
156 foreach ($entries as
$e) {
157 if (
$e[
"entry"] ===
".") {
160 if (
$e[
"entry"] ===
".." && empty($this->cur_subdir)) {
163 $cfile = (empty($this->cur_subdir))
165 : $this->cur_subdir .
"/" .
$e[
"entry"];
167 if ($this->label_enable) {
168 $label = (isset($this->file_labels[$cfile]) && is_array($this->file_labels[$cfile]))
169 ? implode(
", ", $this->file_labels[$cfile])
173 $pref = (
$e[
"type"] ===
"dir")
178 "entry" =>
$e[
"entry"],
179 "type" =>
$e[
"type"],
180 "label" => $label ??
'',
181 "size" =>
$e[
"size"] ??
'',
182 "name" => $pref .
$e[
"entry"]
190 if ($this->has_multi) {
196 $this->
addColumn($this->
lng->txt(
"cont_dir_file"),
"name");
199 if ($this->label_enable) {
200 $this->
addColumn($this->label_header,
"label");
203 if ($this->row_commands !== []) {
210 return $entry[
'entry'] ===
'..';
217 protected function fillRow(array $a_set): void
219 $hash = $this->post_dir_path
220 ? md5((
string) $a_set[
"file"])
221 : md5((
string) $a_set[
"entry"]);
223 if ($this->has_multi) {
225 $this->tpl->touchBlock(
'no_checkbox');
227 $this->tpl->setVariable(
"CHECKBOX_ID", $hash);
232 if ($this->label_enable) {
233 $this->tpl->setCurrentBlock(
"Label");
234 $this->tpl->setVariable(
"TXT_LABEL", $a_set[
"label"]);
235 $this->tpl->parseCurrentBlock();
238 $this->
ctrl->setParameter($this->parent_obj,
"cdir", $this->cur_subdir);
240 if ($a_set[
"type"] ==
"dir") {
241 $this->tpl->setCurrentBlock(
"FileLink");
242 $this->
ctrl->setParameter($this->parent_obj,
"newdir", $a_set[
"entry"]);
243 $this->
ctrl->setParameter($this->parent_obj,
"resetoffset", 1);
244 $this->tpl->setVariable(
246 $this->
ctrl->getLinkTarget($this->parent_obj,
"listFiles")
248 $this->
ctrl->setParameter($this->parent_obj,
"newdir",
"");
249 $this->tpl->setVariable(
"TXT_FILENAME", $a_set[
"entry"]);
250 $this->tpl->parseCurrentBlock();
252 $this->tpl->setVariable(
257 $this->
ctrl->setParameter($this->parent_obj,
"resetoffset",
"");
259 $this->tpl->setCurrentBlock(
"File");
260 $this->tpl->setVariable(
"TXT_FILENAME2", $this->secure($a_set[
"entry"]));
261 $this->tpl->parseCurrentBlock();
264 if ($a_set[
"type"] !=
"dir") {
269 if ($this->row_commands !== [] && !($a_set[
"type"] ===
"dir" && $a_set[
"entry"] ===
"..")) {
272 foreach ($this->row_commands as $rcom) {
273 if ($rcom[
"allow_dir"] || $a_set[
"type"] !==
"dir") {
274 $file_path = $this->cur_dir . $a_set[
'entry'];
279 $this->
ctrl->setParameter($this->parent_obj,
"fhsh", $hash);
280 $url = $this->
ctrl->getLinkTarget($this->parent_obj, $rcom[
"cmd"]);
281 $this->
ctrl->setParameter($this->parent_obj,
"fhsh",
"");
283 $actions[] = $this->ui_factory->link()->standard($rcom[
"caption"],
$url);
288 $dropdown = $this->ui_factory->dropdown()->standard($actions);
289 $this->tpl->setVariable(
"ACTIONS", $this->ui_renderer->render($dropdown));
Builds a Color from either hex- or rgb values.
The legacy path helper provides convenient functions for the integration of the filesystem service wi...
File System Explorer GUI class.
__construct(protected ilFileSystemGUI $filesystem_gui, string $a_parent_cmd, string $a_cur_dir, protected string $cur_subdir, protected bool $label_enable, protected array $file_labels=[], protected string $label_header="", ?array $a_commands=[], protected ?bool $post_dir_path=false, ?string $a_table_id="")
Constructor.
numericOrdering(string $a_field)
Should this field be sorted numeric?
isDoubleDotDirectory(array $entry)
fillRow(array $a_set)
Fill table row.
prepareOutput()
Anything that must be done before HTML is generated.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
determineOffsetAndOrder(bool $a_omit_offset=false)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static formatSize(int $size, string $a_mode='short', ?ilLanguage $a_lng=null)
Returns the specified file size value in a human friendly form.
The filesystem interface provides the public interface for the Filesystem service API consumer.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc