ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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, ?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
 
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 91 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

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

Referenced by getRows().

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

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

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

◆ getTemplates()

ilDidacticTemplateSettingsTableDataRetrieval::getTemplates ( )
protected
Returns
ilDidacticTemplateSetting[]

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

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

Referenced by getRecords(), and getTotalRowCount().

84  : array
85  {
87  $tpls->readInactive();
88  return $this->filter->filter($tpls->getTemplates());
89  }
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 74 of file class.ilDidacticTemplateSettingsTableDataRetrieval.php.

References getTemplates().

+ Here is the call graph for this function:

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: