19declare(strict_types=1);
31use Psr\Http\Message\ServerRequestInterface;
32use Psr\Http\Message\RequestInterface;
48 private ServerRequestInterface|RequestInterface
$request;
60 public function __construct(?
object $a_parent_obj, ?
string $a_parent_cmd)
64 $this->
lng = $DIC->language();
65 $this->ui_factory =
$DIC->ui()->factory();
66 $this->ui_renderer =
$DIC->ui()->renderer();
67 $this->ui_service =
$DIC->uiService();
68 $this->request =
$DIC->http()->request();
69 $this->data_factory = new \ILIAS\Data\Factory();
70 $this->
ctrl = $DIC->ctrl();
71 $this->wrapper =
$DIC->http()->wrapper();
74 $this->parent_obj = $a_parent_obj;
75 $this->parent_cmd = $a_parent_cmd;
80 $this->acceptProviderAsGlobal =
true;
85 $this->resetProviderToUserScope =
true;
90 $this->selectProviderForm =
true;
100 array $visible_column_ids,
103 mixed $additional_viewcontrol_data,
105 mixed $additional_parameters
109 $record[
"icon"] = $record[
"icon"] ??
"lti";
110 $record[
"icon"] = $this->ui_factory->symbol()->icon()->standard($record[
"icon"], $record[
"icon"], IconAlias::SMALL);
112 if ($this->selectProviderForm) {
113 $this->
ctrl->setParameter($this->parent_obj,
'provider_id', $record[
'id']);
114 $record[
"title"] = $this->ui_factory->link()->standard($record[
'title'], $this->
ctrl->getLinkTarget($this->parent_obj,
"save"));
116 $this->
ctrl->setParameter($this->parent_obj,
'provider_id', $record[
'id']);
130 yield $row_builder->
buildDataRow((
string) $record[
"id"], $record);
135 mixed $additional_viewcontrol_data,
137 mixed $additional_parameters
139 return count($this->records);
144 $this->records =
$data;
149 [$order_field, $order_direction] = $order->
join(
151 fn($ret, $key, $value) => [$key, $value]
154 $order_field = (string) $order_field;
155 $sortable_records = array_map(
function (array $record) use ($order_field): array {
157 'sort_key' => $this->getSortableValue($record, $order_field),
162 usort($sortable_records,
static function (array $left, array $right):
int {
166 $records = array_column($sortable_records,
'record');
168 if ($order_direction === Order::DESC) {
169 $records = array_reverse($records);
181 return match ($order_field) {
182 'category' => $this->getCategoryTranslation((
string) ($record[
'category'] ??
'')),
183 'outcome' => $this->getHasOutcomeFormatted((
bool) ($record[
'outcome'] ??
false)),
184 'internal' => $this->getIsInternalFormatted(!(
bool) ($record[
'external'] ??
false)),
185 'with_key' => $this->getIsWithKeyFormatted(!(
bool) ($record[
'provider_key_customizable'] ??
false)),
186 'availability' => $this->getAvailabilityLabel($record),
187 'own_provider' => $this->getOwnProviderLabel($record),
188 'provider_creator' => $this->getProviderCreatorLabel($record),
189 default => (string) ($record[$order_field] ??
''),
196 public function getHTML(
bool $hasWriteAccess =
false): string
198 $table = $this->ui_factory->table()
199 ->data($this, $this->
lng->txt(
'tbl_provider_header'), $this->getColumns())
200 ->withOrder(
new Order(
'title', Order::ASC))
201 ->withRange(
new Range(0, 20))
202 ->withRequest($this->request);
204 if ($hasWriteAccess) {
205 $table = $table->withActions($this->getActions());
208 return $this->ui_renderer->render($table);
214 'icon' => $this->ui_factory->table()->column()->statusIcon($this->
lng->txt(
'icon')),
215 'title' => $this->ui_factory->table()->column()->link($this->
lng->txt(
'title')),
216 'description' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_description')),
217 'category' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_category'))->withIsOptional(
true),
218 'keywords' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_keywords')),
219 'outcome' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_outcome'))->withIsOptional(
true),
220 'internal' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_internal'))->withIsOptional(
true),
221 'with_key' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_with_key')),
222 'availability' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_availability')),
223 'own_provider' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_own_provider'))->withIsOptional(
true),
224 'provider_creator' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_provider_creator'))->withIsOptional(
true),
225 'usages_untrashed' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_usages_untrashed')),
226 'usages_trashed' => $this->ui_factory->table()->column()->text($this->
lng->txt(
'tbl_lti_prov_usages_trashed'))->withIsOptional(
true),
235 $df = new \ILIAS\Data\Factory();
236 $here_uri = $df->uri($this->request->getUri()->__toString());
239 $query_params_namespace = [
'provider',
'table'];
240 list($url_builder, $id_token, $action_token) = $url_builder->acquireParameters(
241 $query_params_namespace,
246 $query = $this->wrapper->query();
247 if ($query->has($action_token->getName())) {
248 $action = $query->retrieve($action_token->getName(), $this->refinery->to()->string());
249 $ids = $query->retrieve($id_token->getName(), $this->refinery->custom()->transformation(fn($v) => $v));
253 $id = $ids[0] ??
null;
254 $this->
ctrl->setParameter($this->parent_obj,
'provider_id',
$id);
257 case "delete_global":
258 if (count($ids) > 1) {
259 $this->
ctrl->setParameter($this->parent_obj,
'provider_ids', implode(
",", $ids));
262 $id = $ids[0] ??
null;
263 $this->
ctrl->setParameter($this->parent_obj,
'provider_id',
$id);
268 if (count($ids) > 1) {
269 $this->
ctrl->setParameter($this->parent_obj,
'provider_ids', implode(
",", $ids));
272 $id = $ids[0] ??
null;
273 $this->
ctrl->setParameter($this->parent_obj,
'provider_id',
$id);
278 if (count($ids) > 1) {
279 $this->
ctrl->setParameter($this->parent_obj,
'provider_ids', implode(
",", $ids));
282 $id = $ids[0] ??
null;
283 $this->
ctrl->setParameter($this->parent_obj,
'provider_id',
$id);
288 if (count($ids) > 1) {
289 $this->
ctrl->setParameter($this->parent_obj,
'provider_ids', implode(
",", $ids));
292 $id = $ids[0] ??
null;
293 $this->
ctrl->setParameter($this->parent_obj,
'provider_id',
$id);
302 "edit" => $this->ui_factory->table()->action()->single(
303 $this->
lng->txt(
'lti_action_edit_provider'),
304 $url_builder->withParameter($action_token,
"edit"),
309 if ($this->acceptProviderAsGlobal) {
310 $actions[
"global"] = $this->ui_factory->table()->action()->standard(
311 $this->
lng->txt(
'lti_action_accept_provider_as_global'),
312 $url_builder->withParameter($action_token,
"global"),
315 $actions[
"delete_user"] = $this->ui_factory->table()->action()->standard(
316 $this->
lng->txt(
'lti_delete_provider'),
317 $url_builder->withParameter($action_token,
"delete_user"),
322 if ($this->resetProviderToUserScope) {
323 $actions[
"reset"] = $this->ui_factory->table()->action()->standard(
324 $this->
lng->txt(
'lti_action_reset_provider_to_user_scope'),
325 $url_builder->withParameter($action_token,
"reset"),
328 $actions[
"delete_global"] = $this->ui_factory->table()->action()->standard(
329 $this->
lng->txt(
'lti_delete_provider'),
330 $url_builder->withParameter($action_token,
"delete_global"),
342 return $hasOutcome ?
$DIC->language()->txt(
'yes') :
'';
349 return $isInternal ?
$DIC->language()->txt(
'yes') :
'';
356 return $isWithKey ?
$DIC->language()->txt(
'yes') :
'';
362 return $categories[$category];
369 return match (
$data[
'availability']) {
381 if (
$data[
'creator'] ==
$DIC->user()->getId()) {
382 return $DIC->language()->txt(
'yes');
396 if (
$data[
'creator']) {
401 return $user->getFullname();
404 return $DIC->language()->txt(
'deleted_user');
416 'title' => $this->ui_factory->input()->field()->text($this->
lng->txt(
"title")),
417 'keywords' => $this->ui_factory->input()->field()->text($this->
lng->txt(
"tbl_lti_prov_keywords")),
418 'outcome' => $this->ui_factory->input()->field()->select($this->
lng->txt(
"tbl_lti_prov_outcome"), [
419 'yes' => $this->lng->txt(
'yes'),
420 'no' => $this->lng->txt(
'no'),
422 'internal' => $this->ui_factory->input()->field()->select($this->
lng->txt(
"tbl_lti_prov_internal"), [
423 'yes' => $this->lng->txt(
'yes'),
424 'no' => $this->lng->txt(
'no'),
426 'with_key' => $this->ui_factory->input()->field()->select($this->
lng->txt(
"tbl_lti_prov_with_key"), [
427 'yes' => $this->lng->txt(
'yes'),
428 'no' => $this->lng->txt(
'no'),
433 $active = array_fill(0, count($filter_inputs),
true);
435 return $this->ui_service->filter()->standard(
436 'lti_consumer_provider_table',
437 $this->
ctrl->getLinkTarget($this->parent_obj, $this->parent_cmd),
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
join($init, callable $fn)
A simple class to express a naive range of whole positive numbers.
static getCategoriesSelectOptions()
const AVAILABILITY_CREATE
const AVAILABILITY_EXISTING
const CMD_RESET_PROVIDER_TO_USER_SCOPE_MULTI
const CMD_DELETE_GLOBAL_PROVIDER_MULTI
const CMD_SHOW_GLOBAL_PROVIDER_FORM
const CMD_SHOW_USER_PROVIDER_FORM
const CMD_DELETE_USER_PROVIDER
const CMD_RESET_PROVIDER_TO_USER_SCOPE
const CMD_DELETE_GLOBAL_PROVIDER
const CMD_ACCEPT_PROVIDER_AS_GLOBAL_MULTI
const CMD_ACCEPT_PROVIDER_AS_GLOBAL
const CMD_DELETE_USER_PROVIDER_MULTI
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 recor...
getAvailabilityLabel(array $data)
ServerRequestInterface RequestInterface $request
getIsWithKeyFormatted(bool $isWithKey)
applyOrdering(array $records, Order $order, ?Range $range=null)
getHasOutcomeFormatted(bool $hasOutcome)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
getIsInternalFormatted(bool $isInternal)
bool $resetProviderToUserScope
enableResetProviderToUserScope()
ILIAS UI Renderer $ui_renderer
getProviderCreatorLabel(array $data)
getSortableValue(array $record, string $order_field)
getCategoryTranslation(string $category)
getHTML(bool $hasWriteAccess=false)
enableAcceptProviderAsGlobal()
bool $acceptProviderAsGlobal
enableSelectProviderForm()
ILIAS Data Factory $data_factory
getOwnProviderLabel(array $data)
__construct(?object $a_parent_obj, ?string $a_parent_cmd)
ILIAS Refinery Factory $refinery
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static strCmp(string $a, string $b)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes how an icon could be modified during construction of UI.
buildDataRow(string $id, array $record)
This is how the factory for UI elements looks.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...