ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilDidacticTemplateSettingsTableDataRetrieval Class Reference
+ Inheritance diagram for ilDidacticTemplateSettingsTableDataRetrieval:
+ Collaboration diagram for ilDidacticTemplateSettingsTableDataRetrieval:

Public Member Functions

 __construct (ilDidacticTemplateSettingsTableFilter $filter, ilLanguage $lng, UIFactory $ui_factory, UIRenderer $ui_renderer, StaticURLService $static_url, DataFactory $data_factory)
 
 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...
 
 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

 getTemplates ()
 
 getRecords (Order $order, Range $range)
 

Protected Attributes

ilDidacticTemplateSettingsTableFilter $filter
 
ilLanguage $lng
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
StaticURLService $static_url
 
DataFactory $data_factory
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSettingsTableDataRetrieval::__construct ( ilDidacticTemplateSettingsTableFilter  $filter,
ilLanguage  $lng,
UIFactory  $ui_factory,
UIRenderer  $ui_renderer,
StaticURLService  $static_url,
DataFactory  $data_factory 
)

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

References $data_factory, $filter, $lng, $static_url, $ui_factory, $ui_renderer, ILIAS\Repository\filter(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ getRecords()

ilDidacticTemplateSettingsTableDataRetrieval::getRecords ( Order  $order,
Range  $range 
)
protected

Definition at line 93 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

93 : array
94 {
95 $records = [];
96 foreach ($this->getTemplates() as $tpl) {
97 /* @var $tpl ilDidacticTemplateSetting */
98 $atxt = '';
99 foreach ($tpl->getAssignments() as $obj_type) {
100 $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
101 }
102 $title_desc = $tpl->getPresentationTitle()
103 . "<br><br>"
104 . $tpl->getPresentationDescription()
105 . (trim($tpl->getInfo()) ? "<br><br>" . $tpl->getInfo() : '')
106 . ($tpl->isAutoGenerated() ? "<br><br>" . $this->lng->txt("didactic_auto_generated") : '');
107
108 $scope_str = '';
109 if (count($tpl->getEffectiveFrom()) > 0) {
110 $scope_str .= $this->lng->txt('didactic_scope_list_header');
111 foreach ($tpl->getEffectiveFrom() as $ref_id) {
112 $link = $this->ui_renderer->render($this->ui_factory->link()->standard(
114 (string) $this->static_url->builder()->build(
116 $this->data_factory->refId($ref_id)
117 )
118 ));
119 $scope_str .= "<br>";
120 $scope_str .= $link;
121 }
122 } else {
123 $scope_str .= (isset($a_set['local']) ? $this->lng->txt('meta_local') : $this->lng->txt('meta_global'));
124 }
125 $scope_str .= "<br>";
126
127 $icon_label = '';
128 $icon_path = $tpl->getIconHandler()->getAbsolutePath();
129 foreach ($tpl->getAssignments() as $obj_type) {
130 $icon_label = $this->lng->txt('objs_' . $obj_type);
131 }
132 if ($icon_path) {
133 $icon = $this->ui_factory->symbol()->icon()->custom(
134 $icon_path,
135 $icon_label
136 );
137 }
138
139 $icon_active = $this->ui_factory->symbol()->icon()->custom(
140 $tpl->isEnabled() ?
141 ilUtil::getImagePath('standard/icon_ok.svg') :
142 ilUtil::getImagePath('standard/icon_not_ok.svg'),
143 $tpl->isEnabled() ? $this->lng->txt('active') : $this->lng->txt('inactive'),
144 Icon::MEDIUM
145 );
146
147 $record = [
148 'template_id' => $tpl->getId(),
149 'title' => $title_desc,
150 'applicable' => $atxt,
151 'scope' => $scope_str,
152 'enabled' => $icon_active,
153 'automatically_generated' => $tpl->isAutoGenerated()
154 ];
155 if (isset($icon)) {
156 $record['icon'] = $icon;
157 }
158 $records[] = $record;
159 }
160 list($order_field, $order_direction) = $order->join([], fn($ret, $key, $value) => [$key, $value]);
161 usort($records, fn($a, $b) => $a[$order_field] <=> $b[$order_field]);
162 if (
163 $order_direction === 'DESC'
164 ) {
165 $records = array_reverse($records);
166 }
167 $selected_records = array_slice(
168 $records,
169 $range->getStart(),
171 );
172 return $selected_records;
173 }
join($init, callable $fn)
Definition: Order.php:75
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
Util class various functions, usage as namespace.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:29
$ref_id
Definition: ltiauth.php:66
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\UI\Implementation\Component\Table\$range, $ref_id, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilUtil\getImagePath(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), ILIAS\Data\Order\join(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRows()

ilDidacticTemplateSettingsTableDataRetrieval::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.

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

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 56 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

64 : Generator {
65 $records = $this->getRecords($order, $range);
66 foreach ($records as $record) {
67 $row = $row_builder->buildDataRow((string) $record['template_id'], $record);
68 if ($record['automatically_generated']) {
69 $row = $row->withDisabledAction('didactic_do_export');
70 }
71 yield $row;
72 }
73 }
buildDataRow(string $id, array $record)

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow().

+ Here is the call graph for this function:

◆ getTemplates()

ilDidacticTemplateSettingsTableDataRetrieval::getTemplates ( )
protected
Returns
ilDidacticTemplateSetting[]

Definition at line 86 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

86 : array
87 {
89 $tpls->readInactive();
90 return $this->filter->filter($tpls->getTemplates());
91 }

References ILIAS\Repository\filter(), and ilDidacticTemplateSettings\getInstance().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ilDidacticTemplateSettingsTableDataRetrieval::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 75 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

79 : ?int {
80 return count($this->getTemplates());
81 }

Field Documentation

◆ $data_factory

DataFactory ilDidacticTemplateSettingsTableDataRetrieval::$data_factory
protected

Definition at line 38 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

Referenced by __construct().

◆ $filter

ilDidacticTemplateSettingsTableFilter ilDidacticTemplateSettingsTableDataRetrieval::$filter
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilDidacticTemplateSettingsTableDataRetrieval::$lng
protected

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

Referenced by __construct().

◆ $static_url

StaticURLService ilDidacticTemplateSettingsTableDataRetrieval::$static_url
protected

Definition at line 37 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

Referenced by __construct().

◆ $ui_factory

UIFactory ilDidacticTemplateSettingsTableDataRetrieval::$ui_factory
protected

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

Referenced by __construct().

◆ $ui_renderer

UIRenderer ilDidacticTemplateSettingsTableDataRetrieval::$ui_renderer
protected

Definition at line 36 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

Referenced by __construct().


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