ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Course\Grouping\Table\GroupingRetrieval Class Reference
+ Inheritance diagram for ILIAS\Course\Grouping\Table\GroupingRetrieval:
+ Collaboration diagram for ILIAS\Course\Grouping\Table\GroupingRetrieval:

Public Member Functions

 __construct (protected int $content_obj_id, protected ilLanguage $lng, protected UIFactory $ui_factory, protected DataFactory $data_factory, protected StaticURL $static_url)
 
 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...
 
 getAllGroupingIDs ()
 
 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...
 
 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 Member Functions

 buildLinkToObject (int $ref_id)
 
 buildLinkListing (int ... $ref_ids)
 
 sortRecords (array $records, Order $order)
 

Detailed Description

Definition at line 39 of file GroupingRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Course\Grouping\Table\GroupingRetrieval::__construct ( protected int  $content_obj_id,
protected ilLanguage  $lng,
protected UIFactory  $ui_factory,
protected DataFactory  $data_factory,
protected StaticURL  $static_url 
)

Definition at line 41 of file GroupingRetrieval.php.

47 {
48 }

Member Function Documentation

◆ buildLinkListing()

ILIAS\Course\Grouping\Table\GroupingRetrieval::buildLinkListing ( int ...  $ref_ids)
protected

Definition at line 117 of file GroupingRetrieval.php.

117 : UnorderedListing
118 {
119 $links = [];
120 foreach ($ref_ids as $ref_id) {
121 $link = $this->buildLinkToObject($ref_id);
122 if ($link !== null) {
123 $links[] = $link;
124 }
125 }
126 return $this->ui_factory->listing()->unordered($links);
127 }
$ref_id
Definition: ltiauth.php:66

References $ref_id.

Referenced by ILIAS\Course\Grouping\Table\GroupingRetrieval\getRows().

+ Here is the caller graph for this function:

◆ buildLinkToObject()

ILIAS\Course\Grouping\Table\GroupingRetrieval::buildLinkToObject ( int  $ref_id)
protected

Definition at line 105 of file GroupingRetrieval.php.

105 : ?StandardLink
106 {
107 $ref_id = $this->data_factory->refId($ref_id);
108 if (ilObject::_exists($ref_id->toInt(), true)) {
109 $type = ilObject::_lookupType($ref_id->toInt(), true);
110 $title = ilObject::_lookupTitle($ref_id->toObjectId()->toInt());
111 $link = $this->static_url->builder()->build($type, $ref_id);
112 return $this->ui_factory->link()->standard($title, (string) $link);
113 }
114 return null;
115 }
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupTitle(int $obj_id)

References $ref_id, ilObject\_exists(), ilObject\_lookupTitle(), and ilObject\_lookupType().

Referenced by ILIAS\Course\Grouping\Table\GroupingRetrieval\getRows().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllGroupingIDs()

ILIAS\Course\Grouping\Table\GroupingRetrieval::getAllGroupingIDs ( )
Returns
int[]

Definition at line 95 of file GroupingRetrieval.php.

95 : array
96 {
97 return ilObjCourseGrouping::_getVisibleGroupings($this->content_obj_id);
98 }
static _getVisibleGroupings(int $a_obj_id)
Returns a list of all groupings for which the current user hast write permission on all assigned obje...

References ilObjCourseGrouping\_getVisibleGroupings().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\Course\Grouping\Table\GroupingRetrieval::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.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 50 of file GroupingRetrieval.php.

57 : Generator {
58 $grouping_ids = $this->getAllGroupingIDs();
59
60 $records = [];
61 foreach ($grouping_ids as $grouping_id) {
62 $grouping = new ilObjCourseGrouping($grouping_id);
63 $record = [];
64
65 $record[GroupingHandler::COL_TITLE] = $grouping->getTitle();
66 $record[GroupingHandler::COL_DESCRIPTION] = $grouping->getDescription();
67
68 $link = $this->buildLinkToObject($grouping->getContainerRefId());
69 if ($link !== null) {
70 $record[GroupingHandler::COL_SOURCE] = $link;
71 }
72
73 $record[GroupingHandler::COL_UNIQUE_FIELD] = $this->lng->txt($grouping->getUniqueField());
74
75 $condition_ref_ids = [];
76 foreach ($grouping->getAssignedItems() as $condition) {
77 $condition_ref_ids[] = $condition['target_ref_id'];
78 }
79 $record[GroupingHandler::COL_ASSIGNED_OBJS] = $this->buildLinkListing(...$condition_ref_ids);
80
81 $records[$grouping->getId()] = $record;
82 }
83
84 $records = $this->sortRecords($records, $order);
85 $records = array_slice($records, $range->getStart(), $range->getLength(), true);
86
87 foreach ($records as $id => $record) {
88 yield $row_builder->buildDataRow((string) $id, $record);
89 }
90 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilObj<module_name>

References ILIAS\Course\Grouping\Table\GroupingRetrieval\buildLinkListing(), ILIAS\Course\Grouping\Table\GroupingRetrieval\buildLinkToObject(), ILIAS\Course\Grouping\Table\GroupingHandler\COL_ASSIGNED_OBJS, ILIAS\Course\Grouping\Table\GroupingHandler\COL_DESCRIPTION, ILIAS\Course\Grouping\Table\GroupingHandler\COL_SOURCE, ILIAS\Course\Grouping\Table\GroupingHandler\COL_TITLE, ILIAS\Course\Grouping\Table\GroupingHandler\COL_UNIQUE_FIELD, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Course\Grouping\Table\GroupingRetrieval::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 100 of file GroupingRetrieval.php.

100 : ?int
101 {
102 return count($this->getAllGroupingIDs());
103 }

◆ sortRecords()

ILIAS\Course\Grouping\Table\GroupingRetrieval::sortRecords ( array  $records,
Order  $order 
)
protected

Definition at line 129 of file GroupingRetrieval.php.

129 : array
130 {
131 $order_field = array_keys($order->get())[0] ?? GroupingHandler::COL_TITLE;
132 $order_direction = $order->get()[$order_field] ?? Order::ASC;
133
134 $ordering_callable_without_direction = match ($order_field) {
136 fn($a, $b) => $a[$order_field] ?? '' <=> $b[$order_field] ?? '',
138 fn($a, $b) => $a[GroupingHandler::COL_SOURCE]?->getLabel() ?? '' <=> $b[GroupingHandler::COL_SOURCE]?->getLabel() ?? '',
140 function ($a, $b) {
141 $a_items = ($a[GroupingHandler::COL_ASSIGNED_OBJS] ?? null)?->getItems() ?? [];
142 $b_items = ($b[GroupingHandler::COL_ASSIGNED_OBJS] ?? null)?->getItems() ?? [];
143 $a_first_item_label = ($a_items[0] ?? null)?->getLabel() ?? '';
144 $b_first_item_label = ($b_items[0] ?? null)?->getLabel() ?? '';
145 return $a_first_item_label <=> $b_first_item_label;
146 }
147 };
148 $ordering_callable = fn($a, $b) => $order_direction === Order::ASC ?
149 $ordering_callable_without_direction($a, $b) :
150 $ordering_callable_without_direction($b, $a);
151
152 uasort($records, $ordering_callable);
153 return $records;
154 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\Data\Order\ASC, ILIAS\Course\Grouping\Table\GroupingHandler\COL_ASSIGNED_OBJS, ILIAS\Course\Grouping\Table\GroupingHandler\COL_DESCRIPTION, ILIAS\Course\Grouping\Table\GroupingHandler\COL_SOURCE, ILIAS\Course\Grouping\Table\GroupingHandler\COL_TITLE, ILIAS\Course\Grouping\Table\GroupingHandler\COL_UNIQUE_FIELD, ILIAS\Data\Order\get(), and ILIAS\Test\Questions\Presentation\getLabel.

+ Here is the call graph for this function:

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