ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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)
 
 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)
 
 handleCommand ()
 
 getData ()
 
 render ()
 

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 STANDARD = 0
 
const SINGLE = 1
 
const 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
 
array $columns = []
 
array $actions = []
 

Detailed Description

Definition at line 30 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 52 of file TableAdapterGUI.php.

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(), and ILIAS\Repository\ui().

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

Referenced by ILIAS\Repository\Table\TableAdapterGUI\multiAction(), ILIAS\Repository\Table\TableAdapterGUI\singleAction(), ILIAS\Repository\Table\TableAdapterGUI\singleRedirectAction(), and ILIAS\Repository\Table\TableAdapterGUI\standardAction().

154  : void
155  {
156  $this->actions[$action] = [
157  "type" => $type,
158  "action" => $action,
159  "title" => $title,
160  "async" => $async
161  ];
162  $this->last_action_key = $action;
163  }
+ Here is the caller graph for this function:

◆ addColumn()

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

Definition at line 165 of file TableAdapterGUI.php.

Referenced by ILIAS\Repository\Table\TableAdapterGUI\iconColumn(), and ILIAS\Repository\Table\TableAdapterGUI\textColumn().

165  : void
166  {
167  if ($key === "") {
168  throw new \ilException("Missing Input Key: " . $key);
169  }
170  if (isset($this->columns[$key])) {
171  throw new \ilException("Duplicate Input Key: " . $key);
172  }
173  $this->columns[$key] = $column;
174  $this->last_key = $key;
175  }
+ Here is the caller graph for this function:

◆ getColumnForKey()

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

Definition at line 177 of file TableAdapterGUI.php.

177  : Column
178  {
179  if (!isset($this->columns[$key])) {
180  throw new \ilException("Unknown Key: " . $key);
181  }
182  return $this->columns[$key];
183  }

◆ getData()

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

Definition at line 323 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\getTable().

323  : ?array
324  {
325  return $this->getTable()->getData();
326  }
+ Here is the call graph for this function:

◆ getItemIds()

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

Definition at line 197 of file TableAdapterGUI.php.

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

Referenced by ILIAS\Repository\Table\TableAdapterGUI\handleCommand().

197  : array
198  {
199  if ($this->numeric_ids) {
200  $ids = $this->intArray($this->row_id_token->getName());
201  } else {
202  $ids = $this->strArray($this->row_id_token->getName());
203  }
204  if (count($ids) > 0) {
205  return $ids; // from table multi action
206  }
207  if ($this->numeric_ids) {
208  $ids = $this->intArray("interruptive_items"); // from confirmation
209  } else {
210  $ids = $this->strArray("interruptive_items"); // from confirmation
211  }
212  if (count($ids) > 0) {
213  return $ids;
214  }
215  return [];
216  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastColumn()

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

Definition at line 185 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\$last_key, and null.

185  : ?Column
186  {
187  return $this->columns[$this->last_key] ?? null;
188  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getTable()

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

Definition at line 246 of file TableAdapterGUI.php.

References Vendor\Package\$a, ILIAS\Repository\Table\TableAdapterGUI\$row_id_token, ILIAS\Repository\Table\TableAdapterGUI\$table, ILIAS\Repository\ctrl(), ILIAS\Repository\http(), and ILIAS\Repository\ui().

Referenced by ILIAS\Repository\Table\TableAdapterGUI\getData(), ILIAS\LearningModule\Editing\EditSubObjectsGUI\getTable(), and ILIAS\Repository\Table\TableAdapterGUI\render().

246  : Table
247  {
248  $a = $this->ui->factory()->table()->action();
249 
250  if (is_null($this->table)) {
251  $columns = [];
252  foreach ($this->columns as $key => $column) {
253  $columns[$key] = $column;
254  }
255  $actions = [];
256  foreach ($this->actions as $act) {
257  switch ($act["type"]) {
258  case self::SINGLE:
259  $actions[$act["action"]] = $a->single(
260  $act["title"],
261  $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
263  );
264  break;
265  case self::STANDARD:
266  $actions[$act["action"]] = $a->standard(
267  $act["title"],
268  $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
270  );
271  break;
272  case self::MULTI:
273  $actions[$act["action"]] = $a->multi(
274  $act["title"],
275  $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
277  );
278  break;
279  }
280  if ($act["async"]) {
281  $actions[$act["action"]] = $actions[$act["action"]]->withAsync(true);
282  }
283  }
284  if ($this->order_cmd !== "") {
285  $uri = $this->df->uri(
286  ILIAS_HTTP_PATH . '/' .
287  $this->ctrl->getLinkTarget($this->parent_gui, $this->order_cmd)
288  );
289  $table_retrieval = new OrderingRetrieval(
290  $this->retrieval,
291  array_keys($actions),
292  $this->active_action_closure,
293  $this->row_transformer
294  );
295  $this->table = $this
296  ->ui
297  ->factory()
298  ->table()
299  ->ordering($table_retrieval, $uri, $this->title, $columns)
300  ->withId($this->id)
301  ->withActions($actions)
302  ->withRequest($this->http->request());
303  } else {
304  $table_retrieval = new TableRetrieval(
305  $this->retrieval,
306  array_keys($actions),
307  $this->active_action_closure,
308  $this->row_transformer
309  );
310  $this->table = $this
311  ->ui
312  ->factory()
313  ->table()
314  ->data($table_retrieval, $this->title, $columns)
315  ->withId($this->id)
316  ->withActions($actions)
317  ->withRequest($this->http->request());
318  }
319  }
320  return $this->table;
321  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ 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 218 of file TableAdapterGUI.php.

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

218  : bool
219  {
220  $action = $this->str($this->action_parameter_token->getName());
221  if ($action !== "") {
222  if ($this->actions[$action]["type"] === self::SINGLE) {
223  $id = $this->getItemIds()[0];
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(
228  $path[count($path) - 1],
229  $this->actions[$action]["redirect_id_param"],
230  $id
231  );
232  }
233  $cmd = $this->actions[$action]["redirect_cmd"] ?? $action;
234  $this->ctrl->redirectByClass($this->actions[$action]["redirect_class_path"], $cmd);
235  }
236  $this->parent_gui->$action($id);
237  return true;
238  } else {
239  $this->parent_gui->$action($this->getItemIds());
240  return true;
241  }
242  }
243  return false;
244  }
$path
Definition: ltiservices.php:29
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ iconColumn()

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

Definition at line 101 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\addColumn(), and ILIAS\Repository\ui().

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

105  : self {
106  $column = $this->ui->factory()->table()->column()->statusIcon($title)->withIsSortable($sortable);
107  $this->addColumn($key, $column);
108  return $this;
109  }
addColumn(string $key, Column $column)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ multiAction()

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

Definition at line 146 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\addAction().

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

149  : self {
150  $this->addAction(self::MULTI, $action, $title);
151  return $this;
152  }
addAction(int $type, string $action, string $title, bool $async=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

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

Definition at line 328 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\getTable(), and ILIAS\Repository\ui().

328  : string
329  {
330  $html = $this->ui->renderer()->render($this->getTable());
331  return $html;
332  }
+ Here is the call graph for this function:

◆ replaceLastColumn()

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

Definition at line 190 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\$last_key.

190  : void
191  {
192  if ($this->last_key !== "") {
193  $this->columns[$this->last_key] = $column;
194  }
195  }

◆ singleAction()

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

Definition at line 111 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\addAction().

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

115  : self {
116  $this->addAction(self::SINGLE, $action, $title, $async);
117  return $this;
118  }
addAction(int $type, string $action, string $title, bool $async=false)
+ Here is the call graph for this function:
+ 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 120 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\$last_action_key, and ILIAS\Repository\Table\TableAdapterGUI\addAction().

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

126  : self {
127  $this->addAction(self::SINGLE, $action, $title);
128  $act = $this->actions[$this->last_action_key] ?? false;
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;
133  $this->actions[$this->last_action_key] = $act;
134  }
135  return $this;
136  }
addAction(int $type, string $action, string $title, bool $async=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ standardAction()

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

Definition at line 138 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\addAction().

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

141  : self {
142  $this->addAction(self::STANDARD, $action, $title);
143  return $this;
144  }
addAction(int $type, string $action, string $title, bool $async=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ textColumn()

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

Definition at line 91 of file TableAdapterGUI.php.

References ILIAS\Repository\Table\TableAdapterGUI\addColumn(), and ILIAS\Repository\ui().

Referenced by ILIAS\Blog\Contributor\ContributorTableBuilder\build(), ILIAS\Catgory\AssignRoleTableBuilder\build(), ILIAS\Container\Skills\ContSkillTableBuilder\build(), ILIAS\Container\Skills\ContProfileTableBuilder\build(), ILIAS\LearningModule\Editing\SubObjectTableBuilder\build(), and ILIAS\Container\Skills\ContSkillMemberTableBuilder\build().

95  : self {
96  $column = $this->ui->factory()->table()->column()->text($title)->withIsSortable($sortable);
97  $this->addColumn($key, $column);
98  return $this;
99  }
addColumn(string $key, Column $column)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

◆ $columns

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

Definition at line 49 of file TableAdapterGUI.php.

◆ $ctrl

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

Definition at line 47 of file TableAdapterGUI.php.

◆ $df

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

Definition at line 42 of file TableAdapterGUI.php.

◆ $last_action_key

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

◆ $last_key

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

◆ $lng

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

Definition at line 44 of file TableAdapterGUI.php.

◆ $order_cmd

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

Definition at line 37 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 45 of file TableAdapterGUI.php.

Referenced by ILIAS\Repository\Table\TableAdapterGUI\getTable().

◆ $ui

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

Definition at line 48 of file TableAdapterGUI.php.

◆ $url_builder

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

◆ MULTI

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

Definition at line 36 of file TableAdapterGUI.php.

◆ SINGLE

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

Definition at line 35 of file TableAdapterGUI.php.

◆ STANDARD

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

Definition at line 34 of file TableAdapterGUI.php.


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