19 declare(strict_types=1);
46 private readonly
bool $read_only =
false,
53 array $visible_column_ids,
57 ?array $additional_parameters,
60 foreach ($records as $record) {
61 yield $row_builder->buildDataRow($record[
'tpl_id'], $record)
63 'setAsContextDefault',
64 isset($record[
'is_default']) && $record[
'is_default']
67 'unsetAsContextDefault',
68 !isset($record[
'is_default']) || !$record[
'is_default']
75 if ($this->records ===
null) {
77 foreach ($this->service->listAllTemplatesAsArray() as $item) {
79 'tpl_id' => (string) $item[
'tpl_id'],
80 'title' => $item[
'title'],
81 'context' => $this->
getContext($item[
'context'], $item[
'is_default'] ??
false),
82 'is_default' => $item[
'is_default'] ??
false,
90 $query_params_namespace = [
'mail',
'template'];
91 $table_uri = $this->data_factory->uri($this->http_request->getUri()->__toString());
93 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
94 $query_params_namespace,
99 return $this->ui_factory->table()
102 $this->
lng->txt(
'mail_templates'),
105 ->withActions($this->
getActions($url_builder, $action_parameter_token, $row_id_token))
109 ->withOrder(
new Order(
'title', Order::ASC))
110 ->withRequest($this->http_request);
113 public function getContext(
string $value,
bool $default =
false): string
115 if (isset($this->contexts[$value])) {
116 $is_default_suffix =
'';
118 $is_default_suffix = $this->
lng->txt(
'mail_template_default');
122 $this->contexts[$value]->
getTitle(),
127 return $this->
lng->txt(
'mail_template_orphaned_context');
134 return count((array) $this->records);
162 if ($this->contexts !== []) {
163 $actions[
'edit'] = $this->ui_factory->table()->action()->single(
164 $this->
lng->txt(
'edit'),
165 $url_builder->
withParameter($action_parameter_token,
'showEditTemplateForm'),
169 $actions[
'view'] = $this->ui_factory->table()->action()->single(
170 $this->
lng->txt(
'view'),
171 $url_builder->
withParameter($action_parameter_token,
'showEditTemplateForm'),
176 if (!$this->read_only) {
177 $actions[
'delete'] = $this->ui_factory->table()->action()->standard(
178 $this->
lng->txt(
'delete'),
179 $url_builder->
withParameter($action_parameter_token,
'confirmDeleteTemplate'),
184 $actions[
'unsetAsContextDefault'] = $this->ui_factory->table()->action()->single(
185 $this->
lng->txt(
'mail_template_unset_as_default'),
186 $url_builder->
withParameter($action_parameter_token,
'unsetAsContextDefault'),
190 $actions[
'setAsContextDefault'] = $this->ui_factory->table()->action()->single(
191 $this->
lng->txt(
'mail_template_set_as_default'),
192 $url_builder->
withParameter($action_parameter_token,
'setAsContextDefault'),
214 [$order_field, $order_direction] = $order->
join(
216 fn($ret, $key, $value) => [$key, $value]
218 usort($records,
static fn(array $left, array $right):
int =>
ilStr::strCmp(
219 $left[$order_field] ??
'',
220 $right[$order_field] ??
'' 223 if ($order_direction === Order::DESC) {
224 $records = array_reverse($records);
239 'title' => $this->ui_factory->table()->column()
240 ->text($this->
lng->txt(
'title')),
241 'context' => $this->ui_factory->table()->column()
242 ->text($this->
lng->txt(
'mail_template_context'))
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
__construct(private readonly ServerRequestInterface $http_request, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly DataFactory $data_factory, private readonly ilMailTemplateService $service, private readonly bool $read_only=false,)
getContext(string $value, bool $default=false)
join($init, callable $fn)
Interface Observer Contains several chained tasks and infos about them.
getRecords(Range $range, Order $order)
Both the subject and the direction need to be specified when expressing an order. ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getTemplateContexts(?array $a_id=null)
Returns an array of mail template contexts, the key of each entry matches its id. ...
limitRecords(array $records, Range $range)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
static strCmp(string $a, string $b)
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
orderRecords(array $records, Order $order)
getRows(ILIAS\UI\Component\Table\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...
A simple class to express a naive range of whole positive numbers.