ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilObjectConsumerTableGUI Class Reference

TableGUI class for LTI consumer listing. More...

+ Inheritance diagram for ilObjectConsumerTableGUI:
+ Collaboration diagram for ilObjectConsumerTableGUI:

Public Member Functions

 __construct ()
 
 getColumns ()
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 getHtml ()
 
 isEditable ()
 
 setEditable (bool $a_editable)
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Protected Member Functions

 applyOrdering (array $records, Order $order, ?Range $range=null)
 

Protected Attributes

ilLanguage $lng
 
Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 
ILIAS Data Factory $data_factory
 
ilCtrlInterface $ctrl
 
WrapperFactory $wrapper
 
ILIAS Refinery Factory $refinery
 

Private Member Functions

 getRecords ()
 
 getActions ()
 

Private Attributes

ServerRequestInterface RequestInterface $request
 
array $records
 
bool $editable = false
 

Detailed Description

TableGUI class for LTI consumer listing.

Author
Jesús López lopez.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 40 of file class.ilObjectConsumerTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectConsumerTableGUI::__construct ( )

Definition at line 53 of file class.ilObjectConsumerTableGUI.php.

54 {
55 global $DIC;
56
57 $this->lng = $DIC->language();
58 $this->ui_factory = $DIC->ui()->factory();
59 $this->ui_renderer = $DIC->ui()->renderer();
60 $this->request = $DIC->http()->request();
61 $this->data_factory = new \ILIAS\Data\Factory();
62 $this->ctrl = $DIC->ctrl();
63 $this->wrapper = $DIC->http()->wrapper();
64 $this->refinery = $DIC->refinery();
65
66 $this->records = $this->getRecords();
67 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), getRecords(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyOrdering()

ilObjectConsumerTableGUI::applyOrdering ( array  $records,
Order  $order,
?Range  $range = null 
)
protected

Definition at line 241 of file class.ilObjectConsumerTableGUI.php.

241 : array
242 {
243 [$order_field, $order_direction] = $order->join(
244 [],
245 fn($ret, $key, $value) => [$key, $value]
246 );
247
248 usort($records, static function (array $left, array $right) use ($order_field): int {
249 $left_val = $left[$order_field] ?? '';
250 $right_val = $right[$order_field] ?? '';
251 return ilStr::strCmp($left_val, $right_val);
252 });
253
254 if ($order_direction === Order::DESC) {
255 $records = array_reverse($records);
256 }
257
258 if ($range !== null) {
259 $records = array_slice($records, $range->getStart(), $range->getLength());
260 }
261
262 return $records;
263 }
join($init, callable $fn)
Definition: Order.php:75
static strCmp(string $a, string $b)
Definition: class.ilStr.php:87

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), ILIAS\Data\Order\join(), and ilStr\strCmp().

+ Here is the call graph for this function:

◆ getActions()

ilObjectConsumerTableGUI::getActions ( )
private
Exceptions
ilCtrlException

Definition at line 108 of file class.ilObjectConsumerTableGUI.php.

108 : array
109 {
110 if (!$this->isEditable()) {
111 return [];
112 }
113
114 $df = new \ILIAS\Data\Factory();
115 $here_uri = $df->uri($this->request->getUri()->__toString());
116 $url_builder = new URLBuilder($here_uri);
117
118 $query_params_namespace = ['lti_consumer_table'];
119 list($url_builder, $id_token, $action_token) = $url_builder->acquireParameters(
120 $query_params_namespace,
121 "consumer_id",
122 "action"
123 );
124
125 $query = $this->wrapper->query();
126 if ($query->has($action_token->getName())) {
127 $action = $query->retrieve($action_token->getName(), $this->refinery->to()->string());
128 $ids = $query->retrieve($id_token->getName(), $this->refinery->custom()->transformation(fn($v) => $v));
129 $id = $ids[0] ?? null;
130
131 switch ($action) {
132 case "edit":
133 $this->ctrl->setParameterByClass(ilObjLTIAdministrationGUI::class, 'cid', $id);
134 $this->ctrl->redirectByClass(ilObjLTIAdministrationGUI::class, 'editConsumer');
135 break;
136 case "delete":
137 $this->ctrl->setParameterByClass(ilObjLTIAdministrationGUI::class, 'cid', $id);
138 $this->ctrl->redirectByClass(ilObjLTIAdministrationGUI::class, 'deleteLTIConsumer');
139 break;
140 case "status":
141 $this->ctrl->setParameterByClass(ilObjLTIAdministrationGUI::class, 'cid', $id);
142 $this->ctrl->redirectByClass(ilObjLTIAdministrationGUI::class, 'changeStatusLTIConsumer');
143 break;
144 }
145 }
146
147 return [
148 $this->ui_factory->table()->action()->single(
149 $this->lng->txt('edit'),
150 $url_builder->withParameter($action_token, "edit"),
151 $id_token
152 ),
153 $this->ui_factory->table()->action()->single(
154 $this->lng->txt('delete'),
155 $url_builder->withParameter($action_token, "delete"),
156 $id_token
157 ),
158 $this->ui_factory->table()->action()->single(
159 $this->lng->txt('activate') . " / " . $this->lng->txt('deactivate'),
160 $url_builder->withParameter($action_token, "status"),
161 $id_token
162 )
163 ];
164 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, ILIAS\Repository\ctrl(), isEditable(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getColumns()

ilObjectConsumerTableGUI::getColumns ( )

Definition at line 69 of file class.ilObjectConsumerTableGUI.php.

69 : array
70 {
71 return [
72 'active' => $this->ui_factory->table()->column()->statusIcon($this->lng->txt('active')),
73 'title' => $this->ui_factory->table()->column()->text($this->lng->txt('title')),
74 'description' => $this->ui_factory->table()->column()->text($this->lng->txt('description')),
75 'prefix' => $this->ui_factory->table()->column()->text($this->lng->txt('prefix')),
76 'language' => $this->ui_factory->table()->column()->text($this->lng->txt('in_use')),
77 'objects' => $this->ui_factory->table()->column()->text($this->lng->txt('objects')),
78 'role' => $this->ui_factory->table()->column()->text($this->lng->txt('role'))
79 ];
80 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getHtml()

ilObjectConsumerTableGUI::getHtml ( )
Exceptions
ilCtrlException

Definition at line 219 of file class.ilObjectConsumerTableGUI.php.

219 : string
220 {
221 $table = $this->ui_factory->table()
222 ->data($this, $this->lng->txt('lti_object_consumer'), $this->getColumns())
223 ->withOrder(new Order('title', Order::ASC))
224 ->withRange(new Range(0, 20))
225 ->withActions($this->getActions())
226 ->withRequest($this->request);
227
228 return $this->ui_renderer->render($table);
229 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

ilObjectConsumerTableGUI::getRecords ( )
private

Definition at line 82 of file class.ilObjectConsumerTableGUI.php.

82 : array
83 {
84 $dataConnector = new ilLTIDataConnector();
85
86 $consumer_data = $dataConnector->getGlobalToolConsumerSettings();
87
88 $result = array();
89
90 foreach ($consumer_data as $cons) {
91 $result[] = array(
92 "id" => $cons->getExtConsumerId(),
93 "active" => $cons->getActive(),
94 "title" => $cons->getTitle(),
95 "description" => $cons->getDescription(),
96 "prefix" => $cons->getPrefix(),
97 "language" => $cons->getLanguage(),
98 "role" => $cons->getRole(),
99 );
100 }
101
102 return $result;
103 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getRows()

ilObjectConsumerTableGUI::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
Exceptions
ilObjectNotFoundException
ilDatabaseException

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 170 of file class.ilObjectConsumerTableGUI.php.

178 : Generator {
179 $records = $this->applyOrdering($this->records, $order, $range);
180 foreach ($records as $record) {
181 $record["active"] = $this->ui_factory->symbol()->icon()->custom(
182 $record["active"] ?
183 'assets/images/standard/icon_ok.svg' :
184 'assets/images/standard/icon_not_ok.svg',
185 $record["active"] ? $this->lng->txt('active') : $this->lng->txt('inactive'),
186 Icon::MEDIUM
187 );
188
189 $role = ilObjectFactory::getInstanceByObjId($record['role'], false);
190 if ($role instanceof ilObjRole) {
191 $record['role'] = $role->getTitle();
192 } else {
193 $record['role'] = '';
194 }
195
196 $record["objects"] = '';
197 $obj_types = ilObjLTIAdministration::getActiveObjectTypes($record["id"]);
198 if ($obj_types) {
199 foreach ($obj_types as $obj_type) {
200 $record["objects"] .= $GLOBALS['DIC']->language()->txt('objs_' . $obj_type) . '<br/>';
201 }
202 }
203
204 yield $row_builder->buildDataRow((string) $record["id"], $record);
205 }
206 }
static getActiveObjectTypes(int $a_consumer_id)
Class ilObjRole.
applyOrdering(array $records, Order $order, ?Range $range=null)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
buildDataRow(string $id, array $record)
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS, ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), ilObjLTIAdministration\getActiveObjectTypes(), ilObjectFactory\getInstanceByObjId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ilObjectConsumerTableGUI::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

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

212 : ?int {
213 return count($this->records);
214 }

◆ isEditable()

ilObjectConsumerTableGUI::isEditable ( )

Definition at line 231 of file class.ilObjectConsumerTableGUI.php.

231 : bool
232 {
233 return $this->editable;
234 }

Referenced by getActions().

+ Here is the caller graph for this function:

◆ setEditable()

ilObjectConsumerTableGUI::setEditable ( bool  $a_editable)

Definition at line 236 of file class.ilObjectConsumerTableGUI.php.

236 : void
237 {
238 $this->editable = $a_editable;
239 }

Field Documentation

◆ $ctrl

ilCtrlInterface ilObjectConsumerTableGUI::$ctrl
protected

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

◆ $data_factory

ILIAS Data Factory ilObjectConsumerTableGUI::$data_factory
protected

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

◆ $editable

bool ilObjectConsumerTableGUI::$editable = false
private

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

◆ $lng

ilLanguage ilObjectConsumerTableGUI::$lng
protected

Definition at line 42 of file class.ilObjectConsumerTableGUI.php.

◆ $records

array ilObjectConsumerTableGUI::$records
private

Definition at line 50 of file class.ilObjectConsumerTableGUI.php.

◆ $refinery

ILIAS Refinery Factory ilObjectConsumerTableGUI::$refinery
protected

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

◆ $request

ServerRequestInterface RequestInterface ilObjectConsumerTableGUI::$request
private

Definition at line 45 of file class.ilObjectConsumerTableGUI.php.

◆ $ui_factory

Factory ilObjectConsumerTableGUI::$ui_factory
protected

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

◆ $ui_renderer

ILIAS UI Renderer ilObjectConsumerTableGUI::$ui_renderer
protected

Definition at line 44 of file class.ilObjectConsumerTableGUI.php.

◆ $wrapper

WrapperFactory ilObjectConsumerTableGUI::$wrapper
protected

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


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