19declare(strict_types=1);
43 protected \ILIAS\Data\Factory
$df;
45 protected \ilLanguage
$lng;
48 protected \ilCtrlInterface
$ctrl;
49 protected \ILIAS\DI\UIServices
$ui;
57 protected string $title,
59 protected object $parent_gui,
60 protected string $parent_cmd =
"tableCommand",
62 protected string $ordering_cmd =
"",
63 protected ?\Closure $active_action_closure =
null,
64 protected ?\Closure $row_transformer =
null,
65 protected bool $numeric_ids =
true
68 $this->
ui = $DIC->ui();
69 $this->
ctrl = $DIC->ctrl();
70 $this->
http = $DIC->http();
71 $this->
lng = $DIC->language();
73 $this->
user = $DIC->user();
74 $this->df = new \ILIAS\Data\Factory();
77 $this->
namespace = $id;
79 $this->order_cmd = $ordering_cmd;
81 $form_action = $this->df->uri(
82 ILIAS_HTTP_PATH .
'/' .
83 $this->
ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
85 $this->url_builder =
new URLBuilder($form_action);
87 $this->url_builder->acquireParameters(
98 bool $sortable =
false
100 $column = $this->
ui->
factory()->table()->column()->text($title)->withIsSortable($sortable);
108 bool $sortable =
false
110 $column = $this->
ui->
factory()->table()->column()->statusIcon($title)->withIsSortable($sortable);
111 $this->addColumn($key, $column);
118 bool $sortable =
false
120 $column = $this->
ui->
factory()->table()->column()->date($title, $this->
user->getDateTimeFormat())->withIsSortable($sortable);
121 $this->addColumn($key, $column);
128 bool $sortable =
false
130 $column = $this->
ui->
factory()->table()->column()->
link($title)->withIsSortable($sortable);
131 $this->addColumn($key, $column);
138 bool $sortable =
false
140 $column = $this->
ui->
factory()->table()->column()->linkListing($title)->withIsSortable($sortable);
141 $this->addColumn($key, $column);
150 $this->addAction(self::SINGLE, $action, $title, $async);
159 string $id_param =
"",
162 $this->addAction(self::SINGLE, $action, $title, $async);
163 $act = $this->actions[$this->last_action_key] ??
false;
164 if ($act && $act[
"type"] === self::SINGLE) {
165 $act[
"redirect_class_path"] = $class_path;
166 $act[
"redirect_cmd"] = $cmd;
167 $act[
"redirect_id_param"] = $id_param;
168 $this->actions[$this->last_action_key] = $act;
177 $this->addAction(self::STANDARD, $action, $title);
186 $this->addAction(self::MULTI, $action, $title, $async);
195 $this->filter_data = $filter_data;
199 protected function addAction(
int $type,
string $action,
string $title,
bool $async =
false): void
201 $this->actions[$action] = [
207 $this->last_action_key = $action;
213 throw new \ilException(
"Missing Input Key: " . $key);
215 if (isset($this->columns[$key])) {
216 throw new \ilException(
"Duplicate Input Key: " . $key);
218 $this->columns[$key] = $column;
219 $this->last_key = $key;
224 if (!isset($this->columns[$key])) {
225 throw new \ilException(
"Unknown Key: " . $key);
227 return $this->columns[$key];
232 return $this->columns[$this->last_key] ??
null;
237 if ($this->last_key !==
"") {
238 $this->columns[$this->last_key] = $column;
244 if ($this->numeric_ids) {
245 $ids = $this->
intArray($this->row_id_token->getName());
247 $ids = $this->
strArray($this->row_id_token->getName());
249 if (count($ids) > 0) {
252 if ($this->numeric_ids) {
253 $ids = $this->
intArray(
"interruptive_items");
255 $ids = $this->
strArray(
"interruptive_items");
257 if (count($ids) > 0) {
265 $action = $this->
str($this->action_parameter_token->getName());
266 if ($action !==
"") {
267 if ($this->actions[$action][
"type"] === self::SINGLE) {
268 $id = $this->getItemIds()[0];
269 if ($this->actions[$action][
"redirect_class_path"] ??
false) {
270 $path = $this->actions[$action][
"redirect_class_path"];
271 if ($this->actions[$action][
"redirect_id_param"] ??
false) {
272 $this->
ctrl->setParameterByClass(
274 $this->actions[$action][
"redirect_id_param"],
278 $cmd = $this->actions[$action][
"redirect_cmd"] ?? $action;
279 $this->
ctrl->redirectByClass($this->actions[$action][
"redirect_class_path"], $cmd);
281 $this->parent_gui->$action(
$id);
284 $this->parent_gui->$action($this->getItemIds());
293 $a = $this->
ui->factory()->table()->action();
295 if (is_null($this->table)) {
297 foreach ($this->columns as $key => $column) {
298 $columns[$key] = $column;
301 foreach ($this->actions as $act) {
302 switch ($act[
"type"]) {
304 $actions[$act[
"action"]] =
$a->single(
306 $this->url_builder->withParameter($this->action_parameter_token, $act[
"action"]),
311 $actions[$act[
"action"]] =
$a->standard(
313 $this->url_builder->withParameter($this->action_parameter_token, $act[
"action"]),
318 $actions[$act[
"action"]] =
$a->multi(
320 $this->url_builder->withParameter($this->action_parameter_token, $act[
"action"]),
326 $actions[$act[
"action"]] = $actions[$act[
"action"]]->withAsync(
true);
329 if ($this->order_cmd !==
"") {
330 $uri = $this->df->uri(
331 ILIAS_HTTP_PATH .
'/' .
332 $this->
ctrl->getLinkTarget($this->parent_gui, $this->order_cmd)
336 array_keys($actions),
337 $this->active_action_closure,
338 $this->row_transformer
344 ->ordering($table_retrieval, $uri, $this->title, $columns)
346 ->withActions($actions)
347 ->withRequest($this->
http->request());
351 array_keys($actions),
352 $this->active_action_closure,
353 $this->row_transformer
359 ->data($table_retrieval, $this->title, $columns)
361 ->withActions($actions)
362 ->withRequest($this->
http->request())
363 ->withFilter($this->filter_data);
371 return $this->getTable()->getData();
376 $html = $this->
ui->renderer()->render($this->getTable());
382 string $modal_message,
387 $r = $this->
ui->renderer();
389 foreach ($items as
$id => $title) {
390 if (is_array($title)) {
391 $key = $title[0] ??
"";
392 $val = $title[1] ??
"";
397 $del_items[] =
$f->modal()->interruptiveItem()->keyValue((
string)
$id, $key, $val);
399 $action = $this->
ctrl->getLinkTarget($this->parent_gui, $delete_cmd);
401 echo($r->renderAsync([
402 $f->modal()->interruptive(
406 )->withAffectedItems($del_items)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
URLBuilderToken $action_parameter_token
textColumn(string $key, string $title, bool $sortable=false)
singleAction(string $action, string $title, bool $async=false)
filterData(array $filter_data)
Not applied if the table supports ordering.
renderDeletionConfirmation(string $modal_title, string $modal_message, string $delete_cmd, array $items)
dateColumn(string $key, string $title, bool $sortable=false)
addAction(int $type, string $action, string $title, bool $async=false)
standardAction(string $action, string $title)
__construct(protected string $id, protected string $title, protected RetrievalInterface $retrieval, protected object $parent_gui, protected string $parent_cmd="tableCommand", protected string $namespace="", protected string $ordering_cmd="", protected ?\Closure $active_action_closure=null, protected ?\Closure $row_transformer=null, protected bool $numeric_ids=true)
singleRedirectAction(string $action, string $title, array $class_path, string $cmd="", string $id_param="", bool $async=false)
getColumnForKey(string $key)
replaceLastColumn(Column $column)
multiAction(string $action, string $title, bool $async=false)
URLBuilderToken $row_id_token
linkListingColumn(string $key, string $title, bool $sortable=false)
addColumn(string $key, Column $column)
linkColumn(string $key, string $title, bool $sortable=false)
iconColumn(string $key, string $title, bool $sortable=false)
trait BaseGUIRequest
Base gui request wrapper.
if($err=$client->getError()) $namespace
A Column describes the form of presentation for a certain aspect of data, i.e.
static http()
Fetches the global http state from ILIAS.
initRequest(HTTP\Services $http, Refinery\Factory $refinery, ?array $passed_query_params=null, ?array $passed_post_data=null)
Query params and post data parameters are used for testing.
link(string $caption, string $href, bool $new_viewport=false)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples