19 declare(strict_types=1);
42 protected \ILIAS\Data\Factory
$df;
44 protected \ilLanguage
$lng;
47 protected \ilCtrlInterface
$ctrl;
48 protected \ILIAS\DI\UIServices
$ui;
54 protected string $title,
56 protected object $parent_gui,
57 protected string $parent_cmd =
"tableCommand",
59 protected string $ordering_cmd =
"",
62 protected bool $numeric_ids =
true 65 $this->
ui = $DIC->ui();
66 $this->
ctrl = $DIC->ctrl();
67 $this->
http = $DIC->http();
68 $this->
lng = $DIC->language();
70 $this->df = new \ILIAS\Data\Factory();
73 $this->
namespace = $id;
75 $this->order_cmd = $ordering_cmd;
77 $form_action = $this->df->uri(
78 ILIAS_HTTP_PATH .
'/' .
79 $this->
ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
81 $this->url_builder =
new URLBuilder($form_action);
83 $this->url_builder->acquireParameters(
94 bool $sortable =
false 96 $column = $this->
ui->factory()->table()->column()->text($title)->withIsSortable($sortable);
104 bool $sortable =
false 106 $column = $this->
ui->factory()->table()->column()->statusIcon($title)->withIsSortable($sortable);
116 $this->
addAction(self::SINGLE, $action, $title, $async);
125 string $id_param =
"" 127 $this->
addAction(self::SINGLE, $action, $title);
129 if ($act && $act[
"type"] === self::SINGLE) {
130 $act[
"redirect_class_path"] = $class_path;
131 $act[
"redirect_cmd"] = $cmd;
132 $act[
"redirect_id_param"] = $id_param;
142 $this->
addAction(self::STANDARD, $action, $title);
150 $this->
addAction(self::MULTI, $action, $title);
154 protected function addAction(
int $type,
string $action,
string $title,
bool $async =
false): void
156 $this->actions[$action] = [
162 $this->last_action_key = $action;
168 throw new \ilException(
"Missing Input Key: " . $key);
170 if (isset($this->columns[$key])) {
171 throw new \ilException(
"Duplicate Input Key: " . $key);
173 $this->columns[$key] = $column;
174 $this->last_key = $key;
179 if (!isset($this->columns[$key])) {
180 throw new \ilException(
"Unknown Key: " . $key);
182 return $this->columns[$key];
192 if ($this->last_key !==
"") {
199 if ($this->numeric_ids) {
200 $ids = $this->
intArray($this->row_id_token->getName());
202 $ids = $this->
strArray($this->row_id_token->getName());
204 if (count($ids) > 0) {
207 if ($this->numeric_ids) {
208 $ids = $this->
intArray(
"interruptive_items");
210 $ids = $this->
strArray(
"interruptive_items");
212 if (count($ids) > 0) {
220 $action = $this->
str($this->action_parameter_token->getName());
221 if ($action !==
"") {
222 if ($this->actions[$action][
"type"] === self::SINGLE) {
224 if ($this->actions[$action][
"redirect_class_path"] ??
false) {
225 $path = $this->actions[$action][
"redirect_class_path"];
226 if ($this->actions[$action][
"redirect_id_param"] ??
false) {
227 $this->
ctrl->setParameterByClass(
229 $this->actions[$action][
"redirect_id_param"],
233 $cmd = $this->actions[$action][
"redirect_cmd"] ?? $action;
234 $this->
ctrl->redirectByClass($this->actions[$action][
"redirect_class_path"], $cmd);
236 $this->parent_gui->$action(
$id);
239 $this->parent_gui->$action($this->
getItemIds());
248 $a = $this->
ui->factory()->table()->action();
250 if (is_null($this->table)) {
252 foreach ($this->columns as $key => $column) {
253 $columns[$key] = $column;
256 foreach ($this->actions as $act) {
257 switch ($act[
"type"]) {
259 $actions[$act[
"action"]] =
$a->single(
261 $this->url_builder->withParameter($this->action_parameter_token, $act[
"action"]),
266 $actions[$act[
"action"]] =
$a->standard(
268 $this->url_builder->withParameter($this->action_parameter_token, $act[
"action"]),
273 $actions[$act[
"action"]] =
$a->multi(
275 $this->url_builder->withParameter($this->action_parameter_token, $act[
"action"]),
281 $actions[$act[
"action"]] = $actions[$act[
"action"]]->withAsync(
true);
284 if ($this->order_cmd !==
"") {
285 $uri = $this->df->uri(
286 ILIAS_HTTP_PATH .
'/' .
287 $this->
ctrl->getLinkTarget($this->parent_gui, $this->order_cmd)
291 array_keys($actions),
292 $this->active_action_closure,
293 $this->row_transformer
299 ->ordering($table_retrieval, $uri, $this->title, $columns)
301 ->withActions($actions)
302 ->withRequest($this->
http->request());
306 array_keys($actions),
307 $this->active_action_closure,
308 $this->row_transformer
314 ->data($table_retrieval, $this->title, $columns)
316 ->withActions($actions)
317 ->withRequest($this->
http->request());
325 return $this->
getTable()->getData();
330 $html = $this->
ui->renderer()->render($this->
getTable());
if($err=$client->getError()) $namespace
URLBuilderToken $action_parameter_token
singleRedirectAction(string $action, string $title, array $class_path, string $cmd="", string $id_param="")
__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)
addColumn(string $key, Column $column)
replaceLastColumn(Column $column)
textColumn(string $key, string $title, bool $sortable=false)
trait BaseGUIRequest
Base gui request wrapper.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.
addAction(int $type, string $action, string $title, bool $async=false)
URLBuilderToken $row_id_token
iconColumn(string $key, string $title, bool $sortable=false)
multiAction(string $action, string $title)
standardAction(string $action, string $title)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
getColumnForKey(string $key)
singleAction(string $action, string $title, bool $async=false)
A Column describes the form of presentation for a certain aspect of data, i.e.