ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Repository\Table\TableAdapterGUI Class Reference
+ Collaboration diagram for ILIAS\Repository\Table\TableAdapterGUI:

Public Member Functions

 __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)
 
 textColumn (string $key, string $title, bool $sortable=false)
 
 iconColumn (string $key, string $title, bool $sortable=false)
 
 dateColumn (string $key, string $title, bool $sortable=false)
 
 linkColumn (string $key, string $title, bool $sortable=false)
 
 linkListingColumn (string $key, string $title, bool $sortable=false)
 
 singleAction (string $action, string $title, bool $async=false)
 
 singleRedirectAction (string $action, string $title, array $class_path, string $cmd="", string $id_param="", bool $async=false)
 
 standardAction (string $action, string $title)
 
 multiAction (string $action, string $title)
 
 filterData (array $filter_data)
 Not applied if the table supports ordering. More...
 
 handleCommand ()
 
 getData ()
 
 render ()
 
 renderDeletionConfirmation (string $modal_title, string $modal_message, string $delete_cmd, array $items)
 

Protected Member Functions

 addAction (int $type, string $action, string $title, bool $async=false)
 
 addColumn (string $key, Column $column)
 
 getColumnForKey (string $key)
 
 getLastColumn ()
 
 replaceLastColumn (Column $column)
 
 getItemIds ()
 
 getTable ()
 

Protected Attributes

const int STANDARD = 0
 
const int SINGLE = 1
 
const int MULTI = 2
 
string $order_cmd = ""
 
string $last_action_key
 
URLBuilderToken $row_id_token
 
URLBuilderToken $action_parameter_token
 
URLBuilder $url_builder
 
ILIAS Data Factory $df
 
ilLanguage $lng
 
Table $table = null
 
string $last_key
 
ilCtrlInterface $ctrl
 
ILIAS DI UIServices $ui
 
ilObjUser $user
 
array $columns = []
 
array $actions = []
 
array $filter_data = []
 

Detailed Description

Definition at line 31 of file TableAdapterGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Repository\Table\TableAdapterGUI::__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 
)

Definition at line 55 of file TableAdapterGUI.php.

66 {
67 global $DIC;
68 $this->ui = $DIC->ui();
69 $this->ctrl = $DIC->ctrl();
70 $this->http = $DIC->http();
71 $this->lng = $DIC->language();
72 $this->refinery = $DIC->refinery();
73 $this->user = $DIC->user();
74 $this->df = new \ILIAS\Data\Factory();
75 $this->initRequest($this->http, $this->refinery);
76 if ($namespace === "") {
77 $this->namespace = $id;
78 }
79 $this->order_cmd = $ordering_cmd;
80
81 $form_action = $this->df->uri(
82 ILIAS_HTTP_PATH . '/' .
83 $this->ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
84 );
85 $this->url_builder = new URLBuilder($form_action);
87 $this->url_builder->acquireParameters(
88 [$this->namespace], // namespace
89 "table_action", //this is the actions's parameter name
90 "ids" //this is the parameter name to be used for row-ids
91 );
92
93 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
if($err=$client->getError()) $namespace
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.
global $DIC
Definition: shib_login.php:26

References ILIAS\Repository\Table\TableAdapterGUI\$action_parameter_token, $DIC, $namespace, ILIAS\Repository\Table\TableAdapterGUI\$row_id_token, ILIAS\Repository\Table\TableAdapterGUI\$url_builder, ILIAS\Repository\ctrl(), ILIAS\Repository\http(), ILIAS\Repository\initRequest(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAction()

ILIAS\Repository\Table\TableAdapterGUI::addAction ( int  $type,
string  $action,
string  $title,
bool  $async = false 
)
protected

Definition at line 198 of file TableAdapterGUI.php.

198 : void
199 {
200 $this->actions[$action] = [
201 "type" => $type,
202 "action" => $action,
203 "title" => $title,
204 "async" => $async
205 ];
206 $this->last_action_key = $action;
207 }

◆ addColumn()

ILIAS\Repository\Table\TableAdapterGUI::addColumn ( string  $key,
Column  $column 
)
protected

Definition at line 209 of file TableAdapterGUI.php.

209 : void
210 {
211 if ($key === "") {
212 throw new \ilException("Missing Input Key: " . $key);
213 }
214 if (isset($this->columns[$key])) {
215 throw new \ilException("Duplicate Input Key: " . $key);
216 }
217 $this->columns[$key] = $column;
218 $this->last_key = $key;
219 }

◆ dateColumn()

ILIAS\Repository\Table\TableAdapterGUI::dateColumn ( string  $key,
string  $title,
bool  $sortable = false 
)

Definition at line 115 of file TableAdapterGUI.php.

119 : self {
120 $column = $this->ui->factory()->table()->column()->date($title, $this->user->getDateTimeFormat())->withIsSortable($sortable);
121 $this->addColumn($key, $column);
122 return $this;
123 }
addColumn(string $key, Column $column)

◆ filterData()

ILIAS\Repository\Table\TableAdapterGUI::filterData ( array  $filter_data)

Not applied if the table supports ordering.

Definition at line 192 of file TableAdapterGUI.php.

192 : self
193 {
194 $this->filter_data = $filter_data;
195 return $this;
196 }

◆ getColumnForKey()

ILIAS\Repository\Table\TableAdapterGUI::getColumnForKey ( string  $key)
protected

Definition at line 221 of file TableAdapterGUI.php.

221 : Column
222 {
223 if (!isset($this->columns[$key])) {
224 throw new \ilException("Unknown Key: " . $key);
225 }
226 return $this->columns[$key];
227 }
A Column describes the form of presentation for a certain aspect of data, i.e.
Definition: Column.php:28

◆ getData()

ILIAS\Repository\Table\TableAdapterGUI::getData ( )

Definition at line 368 of file TableAdapterGUI.php.

368 : ?array
369 {
370 return $this->getTable()->getData();
371 }

◆ getItemIds()

ILIAS\Repository\Table\TableAdapterGUI::getItemIds ( )
protected

Definition at line 241 of file TableAdapterGUI.php.

241 : array
242 {
243 if ($this->numeric_ids) {
244 $ids = $this->intArray($this->row_id_token->getName());
245 } else {
246 $ids = $this->strArray($this->row_id_token->getName());
247 }
248 if (count($ids) > 0) {
249 return $ids; // from table multi action
250 }
251 if ($this->numeric_ids) {
252 $ids = $this->intArray("interruptive_items"); // from confirmation
253 } else {
254 $ids = $this->strArray("interruptive_items"); // from confirmation
255 }
256 if (count($ids) > 0) {
257 return $ids;
258 }
259 return [];
260 }

References ILIAS\Repository\intArray(), and ILIAS\Repository\strArray().

+ Here is the call graph for this function:

◆ getLastColumn()

ILIAS\Repository\Table\TableAdapterGUI::getLastColumn ( )
protected

Definition at line 229 of file TableAdapterGUI.php.

229 : ?Column
230 {
231 return $this->columns[$this->last_key] ?? null;
232 }

◆ getTable()

ILIAS\Repository\Table\TableAdapterGUI::getTable ( )
protected

Definition at line 290 of file TableAdapterGUI.php.

290 : Table
291 {
292 $a = $this->ui->factory()->table()->action();
293
294 if (is_null($this->table)) {
295 $columns = [];
296 foreach ($this->columns as $key => $column) {
297 $columns[$key] = $column;
298 }
299 $actions = [];
300 foreach ($this->actions as $act) {
301 switch ($act["type"]) {
302 case self::SINGLE:
303 $actions[$act["action"]] = $a->single(
304 $act["title"],
305 $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
306 $this->row_id_token
307 );
308 break;
309 case self::STANDARD:
310 $actions[$act["action"]] = $a->standard(
311 $act["title"],
312 $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
313 $this->row_id_token
314 );
315 break;
316 case self::MULTI:
317 $actions[$act["action"]] = $a->multi(
318 $act["title"],
319 $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
320 $this->row_id_token
321 );
322 break;
323 }
324 if ($act["async"]) {
325 $actions[$act["action"]] = $actions[$act["action"]]->withAsync(true);
326 }
327 }
328 if ($this->order_cmd !== "") {
329 $uri = $this->df->uri(
330 ILIAS_HTTP_PATH . '/' .
331 $this->ctrl->getLinkTarget($this->parent_gui, $this->order_cmd)
332 );
333 $table_retrieval = new OrderingRetrieval(
334 $this->retrieval,
335 array_keys($actions),
336 $this->active_action_closure,
337 $this->row_transformer
338 );
339 $this->table = $this
340 ->ui
341 ->factory()
342 ->table()
343 ->ordering($table_retrieval, $uri, $this->title, $columns)
344 ->withId($this->id)
345 ->withActions($actions)
346 ->withRequest($this->http->request());
347 } else {
348 $table_retrieval = new TableRetrieval(
349 $this->retrieval,
350 array_keys($actions),
351 $this->active_action_closure,
352 $this->row_transformer
353 );
354 $this->table = $this
355 ->ui
356 ->factory()
357 ->table()
358 ->data($table_retrieval, $this->title, $columns)
359 ->withId($this->id)
360 ->withActions($actions)
361 ->withRequest($this->http->request())
362 ->withFilter($this->filter_data);
363 }
364 }
365 return $this->table;
366 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\Repository\ui().

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\getTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleCommand()

ILIAS\Repository\Table\TableAdapterGUI::handleCommand ( )

Definition at line 262 of file TableAdapterGUI.php.

262 : bool
263 {
264 $action = $this->str($this->action_parameter_token->getName());
265 if ($action !== "") {
266 if ($this->actions[$action]["type"] === self::SINGLE) {
267 $id = $this->getItemIds()[0];
268 if ($this->actions[$action]["redirect_class_path"] ?? false) {
269 $path = $this->actions[$action]["redirect_class_path"];
270 if ($this->actions[$action]["redirect_id_param"] ?? false) {
271 $this->ctrl->setParameterByClass(
272 $path[count($path) - 1],
273 $this->actions[$action]["redirect_id_param"],
274 $id
275 );
276 }
277 $cmd = $this->actions[$action]["redirect_cmd"] ?? $action;
278 $this->ctrl->redirectByClass($this->actions[$action]["redirect_class_path"], $cmd);
279 }
280 $this->parent_gui->$action($id);
281 return true;
282 } else {
283 $this->parent_gui->$action($this->getItemIds());
284 return true;
285 }
286 }
287 return false;
288 }
$path
Definition: ltiservices.php:30

References $id, $path, ILIAS\Repository\ctrl(), and ILIAS\Repository\str().

+ Here is the call graph for this function:

◆ iconColumn()

ILIAS\Repository\Table\TableAdapterGUI::iconColumn ( string  $key,
string  $title,
bool  $sortable = false 
)

Definition at line 105 of file TableAdapterGUI.php.

109 : self {
110 $column = $this->ui->factory()->table()->column()->statusIcon($title)->withIsSortable($sortable);
111 $this->addColumn($key, $column);
112 return $this;
113 }

Referenced by ILIAS\Container\StartObjects\Objects\Table\ObjectsBuilder\build(), ILIAS\Container\StartObjects\Objects\Table\PossibleObjectsBuilder\build(), ILIAS\LearningModule\Editing\SubObjectTableBuilder\build(), ILIAS\MediaObjects\OverviewGUI\Table\Builder\build(), and ILIAS\Repository\Ownership\OwnershipManagementTableBuilder\build().

+ Here is the caller graph for this function:

◆ linkColumn()

ILIAS\Repository\Table\TableAdapterGUI::linkColumn ( string  $key,
string  $title,
bool  $sortable = false 
)

Definition at line 125 of file TableAdapterGUI.php.

129 : self {
130 $column = $this->ui->factory()->table()->column()->link($title)->withIsSortable($sortable);
131 $this->addColumn($key, $column);
132 return $this;
133 }

◆ linkListingColumn()

ILIAS\Repository\Table\TableAdapterGUI::linkListingColumn ( string  $key,
string  $title,
bool  $sortable = false 
)

Definition at line 135 of file TableAdapterGUI.php.

139 : self {
140 $column = $this->ui->factory()->table()->column()->linkListing($title)->withIsSortable($sortable);
141 $this->addColumn($key, $column);
142 return $this;
143 }

Referenced by ILIAS\MediaObjects\OverviewGUI\Table\Builder\build().

+ Here is the caller graph for this function:

◆ multiAction()

ILIAS\Repository\Table\TableAdapterGUI::multiAction ( string  $action,
string  $title 
)

Definition at line 181 of file TableAdapterGUI.php.

184 : self {
185 $this->addAction(self::MULTI, $action, $title);
186 return $this;
187 }
addAction(int $type, string $action, string $title, bool $async=false)

Referenced by ILIAS\Blog\Contributor\ContributorTableBuilder\build(), and ILIAS\Catgory\AssignRoleTableBuilder\build().

+ Here is the caller graph for this function:

◆ render()

ILIAS\Repository\Table\TableAdapterGUI::render ( )

Definition at line 373 of file TableAdapterGUI.php.

373 : string
374 {
375 $html = $this->ui->renderer()->render($this->getTable());
376 return $html;
377 }

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ renderDeletionConfirmation()

ILIAS\Repository\Table\TableAdapterGUI::renderDeletionConfirmation ( string  $modal_title,
string  $modal_message,
string  $delete_cmd,
array  $items 
)

Definition at line 379 of file TableAdapterGUI.php.

384 : void {
385 $f = $this->ui->factory();
386 $r = $this->ui->renderer();
387 $del_items = [];
388 foreach ($items as $id => $title) {
389 if (is_array($title)) {
390 $key = $title[0] ?? "";
391 $val = $title[1] ?? "";
392 } else {
393 $key = $title;
394 $val = "";
395 }
396 $del_items[] = $f->modal()->interruptiveItem()->keyValue((string) $id, $key, $val);
397 }
398 $action = $this->ctrl->getLinkTarget($this->parent_gui, $delete_cmd);
399
400 echo($r->renderAsync([
401 $f->modal()->interruptive(
402 $modal_title,
403 $modal_message,
404 $action
405 )->withAffectedItems($del_items)
406 ]));
407 exit();
408 }
exit

References Vendor\Package\$f, and $id.

◆ replaceLastColumn()

ILIAS\Repository\Table\TableAdapterGUI::replaceLastColumn ( Column  $column)
protected

Definition at line 234 of file TableAdapterGUI.php.

234 : void
235 {
236 if ($this->last_key !== "") {
237 $this->columns[$this->last_key] = $column;
238 }
239 }

◆ singleAction()

ILIAS\Repository\Table\TableAdapterGUI::singleAction ( string  $action,
string  $title,
bool  $async = false 
)

Definition at line 145 of file TableAdapterGUI.php.

149 : self {
150 $this->addAction(self::SINGLE, $action, $title, $async);
151 return $this;
152 }

Referenced by ILIAS\Container\Skills\ContSkillMemberTableBuilder\build(), ILIAS\Container\Skills\ContSkillTableBuilder\build(), ILIAS\LearningModule\Editing\SubObjectTableBuilder\build(), and ILIAS\Repository\Ownership\OwnershipManagementTableBuilder\build().

+ Here is the caller graph for this function:

◆ singleRedirectAction()

ILIAS\Repository\Table\TableAdapterGUI::singleRedirectAction ( string  $action,
string  $title,
array  $class_path,
string  $cmd = "",
string  $id_param = "",
bool  $async = false 
)

Definition at line 154 of file TableAdapterGUI.php.

161 : self {
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;
169 }
170 return $this;
171 }

Referenced by ILIAS\Container\Skills\ContProfileTableBuilder\build(), and ILIAS\LearningModule\Editing\SubObjectTableBuilder\build().

+ Here is the caller graph for this function:

◆ standardAction()

ILIAS\Repository\Table\TableAdapterGUI::standardAction ( string  $action,
string  $title 
)

Definition at line 173 of file TableAdapterGUI.php.

176 : self {
177 $this->addAction(self::STANDARD, $action, $title);
178 return $this;
179 }

Referenced by ILIAS\Container\Skills\ContSkillMemberTableBuilder\build(), and ILIAS\LearningModule\Editing\SubObjectTableBuilder\build().

+ Here is the caller graph for this function:

◆ textColumn()

ILIAS\Repository\Table\TableAdapterGUI::textColumn ( string  $key,
string  $title,
bool  $sortable = false 
)

Field Documentation

◆ $action_parameter_token

URLBuilderToken ILIAS\Repository\Table\TableAdapterGUI::$action_parameter_token
protected

◆ $actions

array ILIAS\Repository\Table\TableAdapterGUI::$actions = []
protected

Definition at line 52 of file TableAdapterGUI.php.

◆ $columns

array ILIAS\Repository\Table\TableAdapterGUI::$columns = []
protected

Definition at line 51 of file TableAdapterGUI.php.

◆ $ctrl

ilCtrlInterface ILIAS\Repository\Table\TableAdapterGUI::$ctrl
protected

Definition at line 48 of file TableAdapterGUI.php.

◆ $df

ILIAS Data Factory ILIAS\Repository\Table\TableAdapterGUI::$df
protected

Definition at line 43 of file TableAdapterGUI.php.

◆ $filter_data

array ILIAS\Repository\Table\TableAdapterGUI::$filter_data = []
protected

Definition at line 53 of file TableAdapterGUI.php.

◆ $last_action_key

string ILIAS\Repository\Table\TableAdapterGUI::$last_action_key
protected

Definition at line 39 of file TableAdapterGUI.php.

◆ $last_key

string ILIAS\Repository\Table\TableAdapterGUI::$last_key
protected

Definition at line 47 of file TableAdapterGUI.php.

◆ $lng

ilLanguage ILIAS\Repository\Table\TableAdapterGUI::$lng
protected

Definition at line 45 of file TableAdapterGUI.php.

◆ $order_cmd

string ILIAS\Repository\Table\TableAdapterGUI::$order_cmd = ""
protected

Definition at line 38 of file TableAdapterGUI.php.

◆ $row_id_token

URLBuilderToken ILIAS\Repository\Table\TableAdapterGUI::$row_id_token
protected

◆ $table

Table ILIAS\Repository\Table\TableAdapterGUI::$table = null
protected

Definition at line 46 of file TableAdapterGUI.php.

◆ $ui

ILIAS DI UIServices ILIAS\Repository\Table\TableAdapterGUI::$ui
protected

Definition at line 49 of file TableAdapterGUI.php.

◆ $url_builder

URLBuilder ILIAS\Repository\Table\TableAdapterGUI::$url_builder
protected

◆ $user

ilObjUser ILIAS\Repository\Table\TableAdapterGUI::$user
protected

Definition at line 50 of file TableAdapterGUI.php.

◆ MULTI

const int ILIAS\Repository\Table\TableAdapterGUI::MULTI = 2
protected

Definition at line 37 of file TableAdapterGUI.php.

◆ SINGLE

const int ILIAS\Repository\Table\TableAdapterGUI::SINGLE = 1
protected

Definition at line 36 of file TableAdapterGUI.php.

◆ STANDARD

const int ILIAS\Repository\Table\TableAdapterGUI::STANDARD = 0
protected

Definition at line 35 of file TableAdapterGUI.php.


The documentation for this class was generated from the following file: