19 declare(strict_types=1);
45 $apply = fn($proc) => fn(array $args) => $proc(...$args);
46 $translate = fn(
string $txt, ...$args) => [
$txt, ...$args];
48 $id = substr(md5($table->name()), 0, 30);
50 $this->columns =
array_map($apply($translate), $table->columns());
53 $table->config($config);
56 $this->
setFormAction($this->
ctrl->getFormAction($this->getParentObject(), $command));
57 $this->
setRowTemplate(
'legacy-table-row.html',
'components/ILIAS/LegalDocuments');
65 $DIC->ui()->mainTemplate()->addJavaScript(
'assets/js/Form.js');
67 $this->
setData($table->rows($this));
73 parent::setMaxCount($a_max_count);
78 $this->sel = array_merge($this->sel, $names);
83 return array_flip($this->sel);
88 return array_map(fn($x) => [
'txt' => $x[0]], array_intersect_key(
117 $restore_key_order = fn($array) => array_intersect_key($this->columns, $array);
120 return $restore_key_order(array_merge(
$base, array_intersect_key($this->columns, $this->
getSelectedColumns())));
136 foreach ($parameters as $key => $value) {
141 protected function fillRow(array $a_set): void
143 $this->
requireKeys(array_keys($this->columns), $a_set);
150 return sprintf(
'<td>%s</td>', $this->
asString($x));
158 $is_component = fn($x):
bool => $x instanceof
Component;
160 if ($is_component($x) || (is_array($x) && array_filter($x, fn($x) => !$is_component($x)) === [])) {
162 return $DIC->ui()->renderer()->render($this->
removeModals($x));
163 } elseif ($x instanceof
Closure) {
165 } elseif (is_string($x)) {
166 return htmlentities($x);
169 throw new InvalidArgumentException(
'Value must be either: Component|list<Component>|Closure|string. Given: ' . var_export($x,
true));
172 protected function txt(
string $key): string
174 return $key ===
'' ?
'' : $this->
lng->txt($key);
183 $given = array_keys($given);
184 $missing = $this->
intersect($required, $this->
diff($required, $given));
185 if ([] !== $missing) {
192 return array_filter($a, fn($x) => !$this->
has($x, $b));
197 return array_filter($a, fn($x) => $this->
has($x, $b));
200 private function has($x, array $array): bool
202 return in_array($x, $array,
true);
208 ...$this->getFilterItems(),
209 ...$this->getFilterItems(
true),
220 if ($DIC->ctrl()->getCmd() === $reset_command) {
222 } elseif (strtoupper($DIC->http()->request()->getMethod()) ===
'POST') {
235 return $DIC->ui()->renderer()->render($this->
flatMap(
243 return array_filter($this->
asArray($x), fn($x) => !$this->
isModal($x));
246 private function flatMap(callable $proc, array
$a): array
248 return array_merge(...array_values(
array_map($proc, $a)));
253 return is_array($x) ? $x : [$x];
258 return $x instanceof
Modal;
This describes commonalities between the different modals.
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="")
requireKeys(array $required, array $given)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isColumnVisible(int $index)
flatMap(callable $proc, array $a)
setFormName(string $a_name="")
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.
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
setSelectableColumns(string ... $names)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
determineSelectedFilters()
__construct(Container $dic, ilPlugin $plugin)
$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)