ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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, ?array $filter_data, ?array $additional_parameters)
 
 getTotalRowCount (?array $filter_data, ?array $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, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

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

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

Referenced by getHtml().

+ Here is the call graph for this function:
+ Here is the caller 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 208 of file class.ilObjectConsumerTableGUI.php.

208 : string
209 {
210 $table = $this->ui_factory->table()
211 ->data($this->lng->txt('lti_object_consumer'), $this->getColumns(), $this)
212 ->withOrder(new Order('title', Order::ASC))
213 ->withActions($this->getActions())
214 ->withRequest($this->request);
215
216 return $this->ui_renderer->render($table);
217 }
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29

References getActions(), and 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,
?array  $filter_data,
?array  $additional_parameters 
)
Exceptions
ilObjectNotFoundException
ilDatabaseException

Implements ILIAS\UI\Component\Table\DataRetrieval.

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

170 : Generator
171 {
172 foreach ($this->records as $record) {
173 $record["active"] = $this->ui_factory->symbol()->icon()->custom(
174 $record["active"] ?
175 'assets/images/standard/icon_ok.svg' :
176 'assets/images/standard/icon_not_ok.svg',
177 $record["active"] ? $this->lng->txt('active') : $this->lng->txt('inactive'),
178 Icon::MEDIUM
179 );
180
181 $role = ilObjectFactory::getInstanceByObjId($record['role'], false);
182 if ($role instanceof ilObjRole) {
183 $record['role'] = $role->getTitle();
184 } else {
185 $record['role'] = '';
186 }
187
188 $record["objects"] = '';
189 $obj_types = ilObjLTIAdministration::getActiveObjectTypes($record["id"]);
190 if ($obj_types) {
191 foreach ($obj_types as $obj_type) {
192 $record["objects"] .= $GLOBALS['DIC']->language()->txt('objs_' . $obj_type) . '<br/>';
193 }
194 }
195
196 yield $row_builder->buildDataRow((string) $record["id"], $record);
197 }
198 }
static getActiveObjectTypes(int $a_consumer_id)
Class ilObjRole.
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 ( ?array  $filter_data,
?array  $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 200 of file class.ilObjectConsumerTableGUI.php.

200 : ?int
201 {
202 return count($this->records);
203 }

◆ isEditable()

ilObjectConsumerTableGUI::isEditable ( )

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

219 : bool
220 {
221 return $this->editable;
222 }

References $editable.

Referenced by getActions().

+ Here is the caller graph for this function:

◆ setEditable()

ilObjectConsumerTableGUI::setEditable ( bool  $a_editable)

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

224 : void
225 {
226 $this->editable = $a_editable;
227 }

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.

Referenced by isEditable().

◆ $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: