19 declare(strict_types=1);
47 $apply = fn($proc) => fn(array $args) => $proc(...$args);
48 $translate = fn(
string $txt, ...$args) => [
$txt, ...$args];
50 $id = substr(md5($table->name()), 0, 30);
52 $this->columns = array_map($apply($translate), $table->columns());
55 $table->config($config);
58 $this->
setFormAction($this->
ctrl->getFormAction($this->getParentObject(), $command));
59 $this->
setRowTemplate(
'legacy-table-row.html',
'Services/LegalDocuments');
67 $DIC->ui()->mainTemplate()->addJavaScript(
'./Services/Form/js/Form.js');
69 $this->
setData($table->rows($this));
75 parent::setMaxCount($a_max_count);
80 $this->sel = array_merge($this->sel, $names);
85 return array_flip($this->sel);
90 return array_map(fn($x) => [
'txt' => $x[0]], array_intersect_key(
98 return array_column(array_map(
100 $input->getPostVar(),
119 $restore_key_order = fn($array) => array_intersect_key($this->columns, $array);
122 return $restore_key_order(array_merge(
$base, array_intersect_key($this->columns, $this->
getSelectedColumns())));
130 $this->
applyParamters(array_map(
static fn():
string =>
'', $parameters));
138 foreach ($parameters as
$key => $value) {
143 protected function fillRow(array $a_set): void
145 $this->
requireKeys(array_keys($this->columns), $a_set);
147 $this->tpl->setVariable(
'VALUE', join(
'', array_map($this->
tableCellOfField(...), $set)));
152 return sprintf(
'<td>%s</td>', $this->
asString($x));
160 $is_component = fn($x):
bool => $x instanceof
Component;
162 if ($is_component($x) || (is_array($x) && array_filter($x, fn($x) => !$is_component($x)) === [])) {
164 return $DIC->ui()->renderer()->render($this->
removeModals($x));
165 } elseif ($x instanceof
Closure) {
167 } elseif (is_string($x)) {
168 return htmlentities($x);
171 throw new InvalidArgumentException(
'Value must be either: Component|list<Component>|Closure|string. Given: ' . var_export($x,
true));
176 return $key ===
'' ?
'' : $this->
lng->txt($key);
185 $given = array_keys($given);
186 $missing = $this->
intersect($required, $this->
diff($required, $given));
187 if ([] !== $missing) {
194 return array_filter($a, fn($x) => !$this->
has($x, $b));
199 return array_filter($a, fn($x) => $this->
has($x, $b));
202 private function has($x, array $array): bool
204 return in_array($x, $array,
true);
210 ...$this->getFilterItems(),
211 ...$this->getFilterItems(
true),
222 if ($DIC->ctrl()->getCmd() === $reset_command) {
224 } elseif (strtoupper($DIC->http()->request()->getMethod()) ===
'POST') {
237 return $DIC->ui()->renderer()->render($this->
flatMap(
245 return array_filter($this->
asArray($x), fn($x) => !$this->
isModal($x));
248 private function flatMap(callable $proc, array
$a): array
250 return array_merge(...array_values(array_map($proc, $a)));
255 return is_array($x) ? $x : [$x];
260 return $x instanceof
Modal;
This describes commonalities between the different modals.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
intersect(array $a, array $b)
This class takes care of the order in which the methods must be called.
setFormAction(string $a_form_action, bool $a_multipart=false)
setResetCommand(string $a_val, string $a_caption="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
requireKeys(array $required, array $given)
isColumnVisible(int $index)
flatMap(callable $proc, array $a)
setFormName(string $a_name="")
setSelectableColumns(... $names)
applyParamters(array $parameters)
resetParameters(array $parameters)
__construct(?object $gui, string $command, TableInterface $table)
isFilterSelected(string $a_col)
Is given filter selected?
setupFilter(string $reset_command)
setExternalSorting(bool $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
determineSelectedFilters()
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
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)
getFilterItems(bool $a_optionals=false)
setMaxCount(int $a_max_count)
determineOffsetAndOrder(bool $a_omit_offset=false)
static initPanel(bool $a_resize=false, ?ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel used in Modules/Test, Services/TermsOfService (Jan 2022)
static initOverlay(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Overlay module used in Modules/Test, Services/TermsOfService, Services/Tracking, Services/UIComponent.
setExternalSegmentation(bool $a_val)