ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
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, bool $async=false)
 
 filterData (array $filter_data)
 Not applied if the table supports ordering. More...
 
 getItemIds ()
 
 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)
 
 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 199 of file TableAdapterGUI.php.

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

◆ addColumn()

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

Definition at line 210 of file TableAdapterGUI.php.

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

◆ 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 193 of file TableAdapterGUI.php.

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

◆ getColumnForKey()

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

Definition at line 222 of file TableAdapterGUI.php.

222 : Column
223 {
224 if (!isset($this->columns[$key])) {
225 throw new \ilException("Unknown Key: " . $key);
226 }
227 return $this->columns[$key];
228 }
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 369 of file TableAdapterGUI.php.

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

◆ getItemIds()

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

Definition at line 242 of file TableAdapterGUI.php.

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

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 230 of file TableAdapterGUI.php.

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

◆ getTable()

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

Definition at line 291 of file TableAdapterGUI.php.

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

263 : bool
264 {
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(
273 $path[count($path) - 1],
274 $this->actions[$action]["redirect_id_param"],
275 $id
276 );
277 }
278 $cmd = $this->actions[$action]["redirect_cmd"] ?? $action;
279 $this->ctrl->redirectByClass($this->actions[$action]["redirect_class_path"], $cmd);
280 }
281 $this->parent_gui->$action($id);
282 return true;
283 } else {
284 $this->parent_gui->$action($this->getItemIds());
285 return true;
286 }
287 }
288 return false;
289 }
$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\COPage\Layout\PageLayoutTableBuilder\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 }

Referenced by ILIAS\COPage\History\HistoryTableBuilder\build().

+ Here is the caller graph for this function:

◆ 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,
bool  $async = false 
)

Definition at line 181 of file TableAdapterGUI.php.

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

Referenced by ILIAS\Blog\Contributor\ContributorTableBuilder\build(), ILIAS\Catgory\AssignRoleTableBuilder\build(), and ILIAS\COPage\PC\FileList\FileListTableBuilder\build().

+ Here is the caller graph for this function:

◆ render()

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

Definition at line 374 of file TableAdapterGUI.php.

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

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 380 of file TableAdapterGUI.php.

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

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

◆ replaceLastColumn()

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

Definition at line 235 of file TableAdapterGUI.php.

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

◆ singleAction()

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

◆ 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()

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: