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

Public Member Functions

 __construct (private readonly HistoryRepository $repository, private readonly ProvideDocument $document, public readonly string $reset_command, private readonly string $auto_complete_link, private readonly UI $ui, private readonly DocumentModal $modal, private readonly Closure $create, ?Closure $format_date=null)
 
 columns ()
 
 config (TableConfig $config)
 
 rows (TableSelection $selection)
 
 name ()
 
 columns ()
 
 config (TableConfig $config)
 
 name ()
 
 rows (TableSelection $select)
 

Private Member Functions

 row (History $record)
 
 userName ()
 
 time ()
 
 showCriteria (History $record)
 

Private Attributes

readonly Closure $format_date
 

Detailed Description

Definition at line 40 of file HistoryTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\Table\HistoryTable::__construct ( private readonly HistoryRepository  $repository,
private readonly ProvideDocument  $document,
public readonly string  $reset_command,
private readonly string  $auto_complete_link,
private readonly UI  $ui,
private readonly DocumentModal  $modal,
private readonly Closure  $create,
?Closure  $format_date = null 
)
Parameters
Closure(class-string,...$constructor_args): object<class-string> $create
null|Closure(DateTimeImmutable)string $format_date

Definition at line 49 of file HistoryTable.php.

58 {
59 $this->format_date = $format_date ?? fn(DateTimeImmutable $date) => ilDatePresentation::formatDate(new ilDateTime($date->getTimestamp(), IL_CAL_UNIX));
60 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling

References ILIAS\LegalDocuments\Table\HistoryTable\$format_date, ilDatePresentation\formatDate(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

Member Function Documentation

◆ columns()

ILIAS\LegalDocuments\Table\HistoryTable::columns ( )
Returns
array<string, list<string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 62 of file HistoryTable.php.

62 : array
63 {
64 return [
65 'created' => [$this->ui->txt('tbl_hist_head_acceptance_date'), 'created'],
66 'login' => [$this->ui->txt('tbl_hist_head_login'), 'login'],
67 'firstname' => [$this->ui->txt('tbl_hist_head_firstname'), 'firstname'],
68 'lastname' => [$this->ui->txt('tbl_hist_head_lastname'), 'lastname'],
69 'document' => [$this->ui->txt('tbl_hist_head_document'), 'document'],
70 'criteria' => [$this->ui->txt('tbl_hist_head_criteria')],
71 ];
72 }

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ config()

ILIAS\LegalDocuments\Table\HistoryTable::config ( TableConfig  $config)

Implements ILIAS\LegalDocuments\Table.

Definition at line 74 of file HistoryTable.php.

74 : void
75 {
76 $config->setTitle($this->ui->txt('acceptance_history'));
77 $config->setDefaultOrderField('created');
78 $config->setDefaultOrderDirection('DESC');
79 $config->setSelectableColumns('firstname', 'lastname', 'criteria');
80
81 $filter = $config->asFilter($this->reset_command);
82 $filter->addFilterItem($this->userName());
83 $filter->addFilterItem($this->time(), true);
84 }
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setDefaultOrderField(string $a_defaultorderfield)
setDefaultOrderDirection(string $a_defaultorderdirection)
asFilter(string $reset_command)
setSelectableColumns(string ... $names)

References ILIAS\LegalDocuments\TableConfig\asFilter(), ILIAS\LegalDocuments\TableConfig\setDefaultOrderDirection(), ILIAS\LegalDocuments\TableConfig\setDefaultOrderField(), ILIAS\LegalDocuments\TableConfig\setSelectableColumns(), ILIAS\LegalDocuments\TableConfig\setTitle(), ILIAS\LegalDocuments\Table\HistoryTable\time(), ILIAS\Repository\ui(), and ILIAS\LegalDocuments\Table\HistoryTable\userName().

+ Here is the call graph for this function:

◆ name()

ILIAS\LegalDocuments\Table\HistoryTable::name ( )

Implements ILIAS\LegalDocuments\Table.

Definition at line 103 of file HistoryTable.php.

103 : string
104 {
105 return self::class;
106 }

◆ row()

ILIAS\LegalDocuments\Table\HistoryTable::row ( History  $record)
private

Definition at line 108 of file HistoryTable.php.

108 : array
109 {
110 $user = ($this->create)(ilObjUser::class, $record->creation()->user());
111
112 return [
113 'created' => ($this->format_date)($record->creation()->time()),
114 'login' => $user?->getLogin() ?? $this->ui->txt('deleted'),
115 'firstname' => $user?->getFirstname() ?? '-',
116 'lastname' => $user?->getLastname() ?? '-',
117 'document' => $this->modal->create($record->documentContent()),
118 'criteria' => $this->showCriteria($record),
119 ];
120 }
modal(string $title="", string $cancel_label="")

References ILIAS\LegalDocuments\Table\HistoryTable\$format_date, ILIAS\LegalDocuments\Value\History\creation(), ILIAS\LegalDocuments\Value\History\documentContent(), ILIAS\Repository\modal(), ILIAS\LegalDocuments\Table\HistoryTable\showCriteria(), and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\rows().

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

◆ rows()

ILIAS\LegalDocuments\Table\HistoryTable::rows ( TableSelection  $select)
Returns
list<array<string, string|Closure(): string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 86 of file HistoryTable.php.

86 : array
87 {
88 $filter = $selection->filter();
89 $period = $filter['period'] ?? [];
90 unset($filter['period']);
91 $filter = array_filter([...$filter, ...$period]);
92
93 $selection->setMaxCount($this->repository->countAll($filter));
94
95 return array_map($this->row(...), $this->repository->all(
96 $filter,
97 [$selection->getOrderField() => $selection->getOrderDirection()],
98 $selection->getOffset(),
99 $selection->getLimit()
100 ));
101 }

References ILIAS\LegalDocuments\TableSelection\filter(), ILIAS\LegalDocuments\TableSelection\getLimit(), ILIAS\LegalDocuments\TableSelection\getOffset(), ILIAS\LegalDocuments\TableSelection\getOrderDirection(), ILIAS\LegalDocuments\TableSelection\getOrderField(), ILIAS\UI\examples\Deck\repository(), ILIAS\LegalDocuments\Table\HistoryTable\row(), and ILIAS\LegalDocuments\TableSelection\setMaxCount().

+ Here is the call graph for this function:

◆ showCriteria()

ILIAS\LegalDocuments\Table\HistoryTable::showCriteria ( History  $record)
private
Returns
string|list<Component>

Definition at line 148 of file HistoryTable.php.

149 {
150 $conv = $this->document->toCondition(...);
151 $components = array_map(fn($c) => $conv($c)->asComponent(), $record->criteriaContent());
152
153 return $components === [] ?
154 $this->ui->txt('tbl_hist_cell_not_criterion') :
156 }
$components
$c
Definition: deliver.php:25

References $c, $components, ILIAS\LegalDocuments\Value\History\criteriaContent(), and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\row().

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

◆ time()

ILIAS\LegalDocuments\Table\HistoryTable::time ( )
private

Definition at line 131 of file HistoryTable.php.

132 {
133 class_exists(ilDateTime::class); // Trigger autoloader to ensure IL_CAL_UNIX is defined.
134 $duration = ($this->create)(ResettingDurationInputGUI::class, $this->ui->txt('period'), 'period');
135 $duration->setAllowOpenIntervals(true);
136 $duration->setShowTime(true);
137 $duration->setStartText($this->ui->txt('period_from'));
138 $duration->setEndText($this->ui->txt('period_until'));
139 $duration->setStart(($this->create)(ilDateTime::class, null, IL_CAL_UNIX));
140 $duration->setEnd(($this->create)(ilDateTime::class, null, IL_CAL_UNIX));
141
142 return $duration;
143 }
$duration
input GUI for a time span (start and end date)

References $duration, IL_CAL_UNIX, and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\config().

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

◆ userName()

ILIAS\LegalDocuments\Table\HistoryTable::userName ( )
private

Definition at line 122 of file HistoryTable.php.

123 {
124 $ul = ($this->create)(ilTextInputGUI::class, join('/', array_map($this->ui->txt(...), ['login', 'email', 'name'])), 'query');
125 $ul->setDataSource($this->auto_complete_link);
126 $ul->setSize(20);
127 $ul->setSubmitFormOnEnter(true);
128 return $ul;
129 }
This class represents a text property in a property form.
setDataSource(string $href, ?string $a_delimiter=null)

References ilTextInputGUI\setDataSource(), and ILIAS\Repository\ui().

Referenced by ILIAS\LegalDocuments\Table\HistoryTable\config().

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

Field Documentation

◆ $format_date

readonly Closure ILIAS\LegalDocuments\Table\HistoryTable::$format_date
private

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