19declare(strict_types=1);
30use InvalidArgumentException;
44 $apply = fn($proc) => fn(array $args) => $proc(...$args);
45 $translate = fn(
string $txt, ...$args) => [$txt, ...$args];
47 $id = substr(md5($table->name()), 0, 30);
49 $this->columns = array_map($apply($translate), $table->columns());
52 $table->config($config);
55 $this->
setFormAction($this->
ctrl->getFormAction($this->getParentObject(), $command));
56 $this->
setRowTemplate(
'legacy-table-row.html',
'components/ILIAS/LegalDocuments');
62 $DIC->ui()->mainTemplate()->addJavaScript(
'assets/js/Form.js');
64 $this->
setData($table->rows($this));
70 parent::setMaxCount($a_max_count);
75 $this->sel = array_merge($this->sel, $names);
80 return array_flip($this->sel);
85 return array_map(fn($x) => [
'txt' => $x[0]], array_intersect_key(
93 return array_column(array_map(
114 $restore_key_order = fn($array) => array_intersect_key($this->columns, $array);
117 return $restore_key_order(array_merge(
$base, array_intersect_key($this->columns, $this->
getSelectedColumns())));
125 $this->
applyParamters(array_map(
static fn():
string =>
'', $parameters));
133 foreach ($parameters as $key => $value) {
138 protected function fillRow(array $a_set): void
140 $this->
requireKeys(array_keys($this->columns), $a_set);
142 $this->tpl->setVariable(
'VALUE', join(
'', array_map($this->
tableCellOfField(...), $set)));
147 return sprintf(
'<td>%s</td>', $this->
asString($x));
155 $is_component = fn($x):
bool => $x instanceof
Component;
157 if ($is_component($x) || (is_array($x) && array_filter($x, fn($x) => !$is_component($x)) === [])) {
160 } elseif ($x instanceof Closure) {
162 } elseif (is_string($x)) {
163 return htmlentities($x);
166 throw new InvalidArgumentException(
'Value must be either: Component|list<Component>|Closure|string. Given: ' . var_export($x,
true));
169 protected function txt(
string $key): string
171 return $key ===
'' ?
'' : $this->
lng->txt($key);
180 $given = array_keys($given);
181 $missing = $this->
intersect($required, $this->
diff($required, $given));
182 if ([] !== $missing) {
183 throw new InvalidArgumentException(
'Missing keys: ' . join(
', ', $missing));
189 return array_filter(
$a, fn($x) => !$this->
has($x,
$b));
194 return array_filter(
$a, fn($x) => $this->
has($x,
$b));
197 private function has($x, array $array): bool
199 return in_array($x, $array,
true);
205 ...$this->getFilterItems(),
206 ...$this->getFilterItems(
true),
217 if ($DIC->ctrl()->getCmd() === $reset_command) {
219 } elseif (strtoupper(
$DIC->http()->request()->getMethod()) ===
'POST') {
232 return $DIC->ui()->renderer()->render($this->
flatMap(
240 return array_filter($this->
asArray($x), fn($x) => !$this->
isModal($x));
243 private function flatMap(callable $proc, array
$a): array
245 return array_merge(...array_values(array_map($proc,
$a)));
250 return is_array($x) ? $x : [$x];
255 return $x instanceof
Modal;
requireKeys(array $required, array $given)
__construct(?object $gui, string $command, TableInterface $table)
resetParameters(array $parameters)
setMaxCount(int $a_max_count)
getSelectableColumns()
Get selectable columns.
isColumnVisible(int $index)
setupFilter(string $reset_command)
flatMap(callable $proc, array $a)
intersect(array $a, array $b)
applyParamters(array $parameters)
fillRow(array $a_set)
Standard Version of Fill Row.
setSelectableColumns(string ... $names)
This class takes care of the order in which the methods must be called.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isFilterSelected(string $a_col)
Is given filter selected?
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setFilterCommand(string $a_val, string $a_caption="")
determineOffsetAndOrder(bool $a_omit_offset=false)
setExternalSegmentation(bool $a_val)
setFormName(string $a_name="")
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)
getFilterItems(bool $a_optionals=false)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setResetCommand(string $a_val, string $a_caption="")
setData(array $a_data)
Set table data.
determineSelectedFilters()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
A component is the most general form of an entity in the UI.
This describes commonalities between the different modals.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples