ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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,)
 
 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

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

Protected Attributes

ilDidacticTemplateSettingsTableFilter $filter
 
ilLanguage $lng
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSettingsTableDataRetrieval::__construct ( ilDidacticTemplateSettingsTableFilter  $filter,
ilLanguage  $lng,
UIFactory  $ui_factory,
UIRenderer  $ui_renderer 
)

Member Function Documentation

◆ getRecords()

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

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

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\LTI\ToolProvider\$key, $ref_id, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilUtil\getImagePath(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), getTemplates(), ILIAS\Data\Order\join(), and ILIAS\Repository\lng().

Referenced by getRows().

83  : array
84  {
85  $records = [];
86  foreach ($this->getTemplates() as $tpl) {
87  /* @var $tpl ilDidacticTemplateSetting */
88  $atxt = '';
89  foreach ($tpl->getAssignments() as $obj_type) {
90  $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
91  }
92  $title_desc = $tpl->getPresentationTitle()
93  . "<br><br>"
94  . $tpl->getPresentationDescription()
95  . (trim($tpl->getInfo()) ? "<br><br>" . $tpl->getInfo() : '')
96  . ($tpl->isAutoGenerated() ? "<br><br>" . $this->lng->txt("didactic_auto_generated") : '');
97 
98  $scope_str = '';
99  if (count($tpl->getEffectiveFrom()) > 0) {
100  $scope_str .= $this->lng->txt('didactic_scope_list_header');
101  foreach ($tpl->getEffectiveFrom() as $ref_id) {
102  $link = $this->ui_renderer->render($this->ui_factory->link()->standard(
104  ilLink::_getLink($ref_id)
105  ));
106  $scope_str .= "<br>";
107  $scope_str .= $link;
108  }
109  } else {
110  $scope_str .= (isset($a_set['local']) ? $this->lng->txt('meta_local') : $this->lng->txt('meta_global'));
111  }
112  $scope_str .= "<br>";
113 
114  $icon_label = '';
115  $icon_path = $tpl->getIconHandler()->getAbsolutePath();
116  foreach ($tpl->getAssignments() as $obj_type) {
117  $icon_label = $this->lng->txt('objs_' . $obj_type);
118  }
119  if ($icon_path) {
120  $icon = $this->ui_factory->symbol()->icon()->custom(
121  $icon_path,
122  $icon_label
123  );
124  }
125 
126  $icon_active = $this->ui_factory->symbol()->icon()->custom(
127  $tpl->isEnabled() ?
128  ilUtil::getImagePath('standard/icon_ok.svg') :
129  ilUtil::getImagePath('standard/icon_not_ok.svg'),
130  $tpl->isEnabled() ? $this->lng->txt('active') : $this->lng->txt('inactive'),
131  Icon::MEDIUM
132  );
133 
134  $record = [
135  'template_id' => $tpl->getId(),
136  'title' => $title_desc,
137  'applicable' => $atxt,
138  'scope' => $scope_str,
139  'enabled' => $icon_active,
140  'automatically_generated' => $tpl->isAutoGenerated()
141  ];
142  if (isset($icon)) {
143  $record['icon'] = $icon;
144  }
145  $records[] = $record;
146  }
147  list($order_field, $order_direction) = $order->join([], fn($ret, $key, $value) => [$key, $value]);
148  usort($records, fn($a, $b) => $a[$order_field] <=> $b[$order_field]);
149  if (
150  $order_direction === 'DESC'
151  ) {
152  $records = array_reverse($records);
153  }
154  $selected_records = array_slice(
155  $records,
156  $range->getStart(),
157  $range->getLength()
158  );
159  return $selected_records;
160  }
join($init, callable $fn)
Definition: Order.php:59
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:28
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
string $key
Consumer key/client ID value.
Definition: System.php:193
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

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

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), and getRecords().

55  : Generator {
56  $records = $this->getRecords($order, $range);
57  foreach ($records as $record) {
58  $row = $row_builder->buildDataRow((string) $record['template_id'], $record);
59  if ($record['automatically_generated']) {
60  $row = $row->withDisabledAction('didactic_do_export');
61  }
62  yield $row;
63  }
64  }
buildDataRow(string $id, array $record)
+ Here is the call graph for this function:

◆ getTemplates()

ilDidacticTemplateSettingsTableDataRetrieval::getTemplates ( )
protected
Returns
ilDidacticTemplateSetting[]

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

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

Referenced by getRecords(), and getTotalRowCount().

76  : array
77  {
79  $tpls->readInactive();
80  return $this->filter->filter($tpls->getTemplates());
81  }
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTotalRowCount()

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

References getTemplates().

+ Here is the call graph for this function:

Field Documentation

◆ $filter

ilDidacticTemplateSettingsTableFilter ilDidacticTemplateSettingsTableDataRetrieval::$filter
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilDidacticTemplateSettingsTableDataRetrieval::$lng
protected

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

Referenced by __construct().

◆ $ui_factory

UIFactory ilDidacticTemplateSettingsTableDataRetrieval::$ui_factory
protected

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

Referenced by __construct().

◆ $ui_renderer

UIRenderer ilDidacticTemplateSettingsTableDataRetrieval::$ui_renderer
protected

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

Referenced by __construct().


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