ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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="")
 
 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 197 of file TableAdapterGUI.php.

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

◆ addColumn()

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

Definition at line 208 of file TableAdapterGUI.php.

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

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

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

◆ getColumnForKey()

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

Definition at line 220 of file TableAdapterGUI.php.

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

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

◆ getItemIds()

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

Definition at line 240 of file TableAdapterGUI.php.

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

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

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

◆ getTable()

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

Definition at line 289 of file TableAdapterGUI.php.

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

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

183 : self {
184 $this->addAction(self::MULTI, $action, $title);
185 return $this;
186 }
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 372 of file TableAdapterGUI.php.

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

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

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

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

◆ replaceLastColumn()

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

Definition at line 233 of file TableAdapterGUI.php.

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

◆ 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(), 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 = "" 
)

Definition at line 154 of file TableAdapterGUI.php.

160 : self {
161 $this->addAction(self::SINGLE, $action, $title);
162 $act = $this->actions[$this->last_action_key] ?? false;
163 if ($act && $act["type"] === self::SINGLE) {
164 $act["redirect_class_path"] = $class_path;
165 $act["redirect_cmd"] = $cmd;
166 $act["redirect_id_param"] = $id_param;
167 $this->actions[$this->last_action_key] = $act;
168 }
169 return $this;
170 }

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

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

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: