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

Private Member Functions

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

Private Attributes

readonly Closure $format_date
 

Detailed Description

<History>

Definition at line 44 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)object<class-string> $create
null|Closure(DateTimeImmutable)string $create

Definition at line 53 of file HistoryTable.php.

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

62  {
63  $this->format_date = $format_date ?? fn(DateTimeImmutable $date) => ilDatePresentation::formatDate(new ilDateTime($date->getTimestamp(), IL_CAL_UNIX));
64  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const 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 66 of file HistoryTable.php.

References ILIAS\Repository\ui().

66  : array
67  {
68  return [
69  'created' => [$this->ui->txt('tbl_hist_head_acceptance_date'), 'created'],
70  'login' => [$this->ui->txt('tbl_hist_head_login'), 'login'],
71  'firstname' => [$this->ui->txt('tbl_hist_head_firstname'), 'firstname'],
72  'lastname' => [$this->ui->txt('tbl_hist_head_lastname'), 'lastname'],
73  'document' => [$this->ui->txt('tbl_hist_head_document'), 'document'],
74  'criteria' => [$this->ui->txt('tbl_hist_head_criteria')],
75  ];
76  }
+ Here is the call graph for this function:

◆ config()

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

Implements ILIAS\LegalDocuments\Table.

Definition at line 78 of file HistoryTable.php.

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().

78  : void
79  {
80  $config->setTitle($this->ui->txt('acceptance_history'));
81  $config->setDefaultOrderField('created');
82  $config->setDefaultOrderDirection('DESC');
83  $config->setSelectableColumns('firstname', 'lastname', 'criteria');
84 
85  $filter = $config->asFilter($this->reset_command);
86  $filter->addFilterItem($this->userName());
87  $filter->addFilterItem($this->time(), true);
88  }
+ Here is the call graph for this function:

◆ name()

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

Implements ILIAS\LegalDocuments\Table.

Definition at line 107 of file HistoryTable.php.

107  : string
108  {
109  return self::class;
110  }

◆ row()

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

Definition at line 112 of file HistoryTable.php.

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().

112  : array
113  {
114  $user = ($this->create)(ilObjUser::class, $record->creation()->user());
115 
116  return [
117  'created' => ($this->format_date)($record->creation()->time()),
118  'login' => $user?->getLogin() ?? $this->ui->txt('deleted'),
119  'firstname' => $user?->getFirstname() ?? '-',
120  'lastname' => $user?->getLastname() ?? '-',
121  'document' => $this->modal->create($record->documentContent()),
122  'criteria' => $this->showCriteria($record),
123  ];
124  }
modal(string $title="", string $cancel_label="")
+ 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 90 of file HistoryTable.php.

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().

90  : array
91  {
92  $filter = $selection->filter();
93  $period = $filter['period'] ?? [];
94  unset($filter['period']);
95  $filter = array_filter([...$filter, ...$period]);
96 
97  $selection->setMaxCount($this->repository->countAll($filter));
98 
99  return array_map($this->row(...), $this->repository->all(
100  $filter,
101  [$selection->getOrderField() => $selection->getOrderDirection()],
102  $selection->getOffset(),
103  $selection->getLimit()
104  ));
105  }
+ Here is the call graph for this function:

◆ showCriteria()

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

Definition at line 152 of file HistoryTable.php.

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

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

153  {
154  $conv = $this->document->toCondition(...);
155  $components = array_map(fn($c) => $conv($c)->asComponent(), $record->criteriaContent());
156 
157  return $components === [] ?
158  $this->ui->txt('tbl_hist_cell_not_criterion') :
159  $components;
160  }
+ 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 135 of file HistoryTable.php.

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

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

136  {
137  class_exists(ilDateTime::class); // Trigger autoloader to ensure IL_CAL_UNIX is defined.
138  $duration = ($this->create)(ResettingDurationInputGUI::class, $this->ui->txt('period'), 'period');
139  $duration->setAllowOpenIntervals(true);
140  $duration->setShowTime(true);
141  $duration->setStartText($this->ui->txt('period_from'));
142  $duration->setEndText($this->ui->txt('period_until'));
143  $duration->setStart(($this->create)(ilDateTime::class, null, IL_CAL_UNIX));
144  $duration->setEnd(($this->create)(ilDateTime::class, null, IL_CAL_UNIX));
145 
146  return $duration;
147  }
const IL_CAL_UNIX
$duration
+ 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 126 of file HistoryTable.php.

References ILIAS\Repository\ui().

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

127  {
128  $ul = ($this->create)(ilTextInputGUI::class, join('/', array_map($this->ui->txt(...), ['login', 'email', 'name'])), 'query');
129  $ul->setDataSource($this->auto_complete_link);
130  $ul->setSize(20);
131  $ul->setSubmitFormOnEnter(true);
132  return $ul;
133  }
+ 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

Definition at line 47 of file HistoryTable.php.

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


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