ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\LearningModule\Table\TableAdapterGUI Class Reference
+ Collaboration diagram for ILIAS\LearningModule\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="")
 
 ordering (string $order_cmd)
 
 textColumn (string $key, string $title, bool $sortable=false)
 
 iconColumn (string $key, string $title, bool $sortable=false)
 
 singleAction (string $action, string $title, bool $async=false)
 
 redirect (array $class_path, string $cmd="", string $id_param="")
 
 standardAction (string $action, string $title)
 
 multiAction (string $action, string $title)
 
 getItemIds ()
 
 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)
 
 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 29 of file class.TableAdapterGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LearningModule\Table\TableAdapterGUI::__construct ( protected string  $id,
protected string  $title,
protected RetrievalInterface  $retrieval,
protected object  $parent_gui,
protected string  $parent_cmd = "tableCommand",
protected string  $namespace = "" 
)

Definition at line 51 of file class.TableAdapterGUI.php.

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

58  {
59  global $DIC;
60  $this->ui = $DIC->ui();
61  $this->ctrl = $DIC->ctrl();
62  $this->http = $DIC->http();
63  $this->lng = $DIC->language();
64  $this->refinery = $DIC->refinery();
65  $this->df = new \ILIAS\Data\Factory();
66  $this->initRequest($this->http, $this->refinery);
67  if ($namespace === "") {
68  $this->namespace = $id;
69  }
70 
71  $form_action = $this->df->uri(
72  ILIAS_HTTP_PATH . '/' .
73  $this->ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
74  );
75  $this->url_builder = new URLBuilder($form_action);
77  $this->url_builder->acquireParameters(
78  [$this->namespace], // namespace
79  "table_action", //this is the actions's parameter name
80  "ids" //this is the parameter name to be used for row-ids
81  );
82 
83  }
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.
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Member Function Documentation

◆ addAction()

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

Definition at line 152 of file class.TableAdapterGUI.php.

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

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

◆ addColumn()

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

Definition at line 163 of file class.TableAdapterGUI.php.

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

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

◆ getColumnForKey()

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

Definition at line 175 of file class.TableAdapterGUI.php.

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

◆ getData()

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

Definition at line 300 of file class.TableAdapterGUI.php.

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

300  : ?array
301  {
302  return $this->getTable()->getData();
303  }
+ Here is the call graph for this function:

◆ getItemIds()

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

Definition at line 195 of file class.TableAdapterGUI.php.

References ILIAS\Repository\intArray().

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

195  : array
196  {
197  $ids = $this->intArray($this->row_id_token->getName());
198  if (count($ids) > 0) {
199  return $ids; // from table multi action
200  }
201  $ids = $this->intArray("interruptive_items"); // from confirmation
202  if (count($ids) > 0) {
203  return $ids;
204  }
205  return [];
206  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastColumn()

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

Definition at line 183 of file class.TableAdapterGUI.php.

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

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

◆ getTable()

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

Definition at line 233 of file class.TableAdapterGUI.php.

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

Referenced by ILIAS\LearningModule\Table\TableAdapterGUI\getData(), and ILIAS\LearningModule\Table\TableAdapterGUI\render().

233  : Table
234  {
235  $a = $this->ui->factory()->table()->action();
236 
237  if (is_null($this->table)) {
238  $columns = [];
239  foreach ($this->columns as $key => $column) {
240  $columns[$key] = $column;
241  }
242  $actions = [];
243  foreach ($this->actions as $act) {
244  switch ($act["type"]) {
245  case self::SINGLE:
246  $actions[$act["action"]] = $a->single(
247  $act["title"],
248  $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
250  );
251  break;
252  case self::STANDARD:
253  $actions[$act["action"]] = $a->standard(
254  $act["title"],
255  $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
257  );
258  break;
259  case self::MULTI:
260  $actions[$act["action"]] = $a->multi(
261  $act["title"],
262  $this->url_builder->withParameter($this->action_parameter_token, $act["action"]),
264  );
265  break;
266  }
267  if ($act["async"]) {
268  $actions[$act["action"]] = $actions[$act["action"]]->withAsync(true);
269  }
270  }
271  if ($this->order_cmd !== "") {
272  $uri = $this->df->uri(
273  ILIAS_HTTP_PATH . '/' .
274  $this->ctrl->getLinkTarget($this->parent_gui, $this->order_cmd)
275  );
276  $table_retrieval = new OrderingRetrieval($this->retrieval);
277  $this->table = $this
278  ->ui
279  ->factory()
280  ->table()
281  ->ordering($table_retrieval, $uri, $this->title, $columns)
282  ->withId($this->id)
283  ->withActions($actions)
284  ->withRequest($this->http->request());
285  } else {
286  $table_retrieval = new TableRetrieval($this->retrieval);
287  $this->table = $this
288  ->ui
289  ->factory()
290  ->table()
291  ->data($table_retrieval, $this->title, $columns)
292  ->withId($this->id)
293  ->withActions($actions)
294  ->withRequest($this->http->request());
295  }
296  }
297  return $this->table;
298  }
static http()
Fetches the global http state from ILIAS.
$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\LearningModule\Table\TableAdapterGUI::handleCommand ( )

Definition at line 208 of file class.TableAdapterGUI.php.

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

208  : void
209  {
210  $action = $this->str($this->action_parameter_token->getName());
211  if ($action !== "") {
212  if ($this->actions[$action]["type"] === self::SINGLE) {
213  $id = $this->getItemIds()[0];
214  if ($this->actions[$action]["redirect_class_path"] ?? false) {
215  $path = $this->actions[$action]["redirect_class_path"];
216  if ($this->actions[$action]["redirect_id_param"] ?? false) {
217  $this->ctrl->setParameterByClass(
218  $path[count($path) - 1],
219  $this->actions[$action]["redirect_id_param"],
220  $id
221  );
222  }
223  $cmd = $this->actions[$action]["redirect_cmd"] ?? $action;
224  $this->ctrl->redirectByClass($this->actions[$action]["redirect_class_path"], $cmd);
225  }
226  $this->parent_gui->$action($id);
227  } else {
228  $this->parent_gui->$action($this->getItemIds());
229  }
230  }
231  }
$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\LearningModule\Table\TableAdapterGUI::iconColumn ( string  $key,
string  $title,
bool  $sortable = false 
)

Definition at line 102 of file class.TableAdapterGUI.php.

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

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

◆ multiAction()

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

Definition at line 144 of file class.TableAdapterGUI.php.

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

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

◆ ordering()

ILIAS\LearningModule\Table\TableAdapterGUI::ordering ( string  $order_cmd)

Definition at line 85 of file class.TableAdapterGUI.php.

References ILIAS\LearningModule\Table\TableAdapterGUI\$order_cmd.

87  : self {
88  $this->order_cmd = $order_cmd;
89  return $this;
90  }

◆ redirect()

ILIAS\LearningModule\Table\TableAdapterGUI::redirect ( array  $class_path,
string  $cmd = "",
string  $id_param = "" 
)

Definition at line 121 of file class.TableAdapterGUI.php.

References ILIAS\LearningModule\Table\TableAdapterGUI\$last_action_key.

125  : self {
126  $act = $this->actions[$this->last_action_key] ?? false;
127  if ($act && $act["type"] === self::SINGLE) {
128  $act["redirect_class_path"] = $class_path;
129  $act["redirect_cmd"] = $cmd;
130  $act["redirect_id_param"] = $id_param;
131  $this->actions[$this->last_action_key] = $act;
132  }
133  return $this;
134  }

◆ render()

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

Definition at line 305 of file class.TableAdapterGUI.php.

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

305  : string
306  {
307  $html = $this->ui->renderer()->render($this->getTable());
308  return $html;
309  }
+ Here is the call graph for this function:

◆ replaceLastColumn()

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

Definition at line 188 of file class.TableAdapterGUI.php.

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

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

◆ singleAction()

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

Definition at line 112 of file class.TableAdapterGUI.php.

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

116  : self {
117  $this->addAction(self::SINGLE, $action, $title, $async);
118  return $this;
119  }
addAction(int $type, string $action, string $title, bool $async=false)
+ Here is the call graph for this function:

◆ standardAction()

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

Definition at line 136 of file class.TableAdapterGUI.php.

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

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

◆ textColumn()

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

Definition at line 92 of file class.TableAdapterGUI.php.

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

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

Field Documentation

◆ $action_parameter_token

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

◆ $actions

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

Definition at line 49 of file class.TableAdapterGUI.php.

◆ $columns

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

Definition at line 48 of file class.TableAdapterGUI.php.

◆ $ctrl

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

Definition at line 46 of file class.TableAdapterGUI.php.

◆ $df

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

Definition at line 41 of file class.TableAdapterGUI.php.

◆ $last_action_key

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

◆ $last_key

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

◆ $lng

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

Definition at line 43 of file class.TableAdapterGUI.php.

◆ $order_cmd

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

◆ $row_id_token

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

◆ $table

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

◆ $ui

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

Definition at line 47 of file class.TableAdapterGUI.php.

◆ $url_builder

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

◆ MULTI

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

Definition at line 35 of file class.TableAdapterGUI.php.

◆ SINGLE

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

Definition at line 34 of file class.TableAdapterGUI.php.

◆ STANDARD

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

Definition at line 33 of file class.TableAdapterGUI.php.


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