ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\LegalDocuments\Table\DocumentTable Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\Table\DocumentTable:
+ Collaboration diagram for ILIAS\LegalDocuments\Table\DocumentTable:

Public Member Functions

 __construct (private readonly Closure $criterion_as_component, private readonly DocumentRepository $repository, private readonly UI $ui, private readonly DocumentModal $modal, ?Closure $create=null, ?Closure $format_date=null)
 
 columns ()
 
 config (TableConfig $config)
 
 rows (TableSelection $select)
 
 mapSelection (Closure $proc, TableSelection $select)
 
 select (TableSelection $select)
 
 row (Document $document, int $sorting)
 
 showCriteria (Document $document, Closure $proc)
 
 showCriterion (Criterion $criterion)
 
 criterionName (Criterion $criterion)
 
 orderInputGui (Document $document, int $sorting)
 
 step ()
 
 ui ()
 
 name ()
 

Private Attributes

readonly Closure $create
 
readonly Closure $format_date
 

Detailed Description

Definition at line 40 of file DocumentTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\Table\DocumentTable::__construct ( private readonly Closure  $criterion_as_component,
private readonly DocumentRepository  $repository,
private readonly UI  $ui,
private readonly DocumentModal  $modal,
?Closure  $create = null,
?Closure  $format_date = null 
)
Parameters
Closure(CriterionContent)Component $criterion_as_component
null|Closure(class-string)object<class-string> $create
Closure(DateTimeImmutable)string $format_date

Definition at line 52 of file DocumentTable.php.

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

59  {
60  $this->create = $create ?? fn($class, ...$args) => new $class(...$args);
61  $this->format_date = $format_date ?? fn(DateTimeImmutable $date) => ilDatePresentation::formatDate(new ilDateTime($date->getTimestamp(), IL_CAL_UNIX));
62  }
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\DocumentTable::columns ( )
Returns
array<string, list<string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 64 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\ui().

64  : array
65  {
66  return [
67  'order' => [$this->ui->txt('tbl_docs_head_sorting'), '', '5%'],
68  'title' => [$this->ui->txt('tbl_docs_head_title'), '', '25%'],
69  'created' => [$this->ui->txt('tbl_docs_head_created')],
70  'change' => [$this->ui->txt('tbl_docs_head_last_change')],
71  'criteria' => [$this->ui->txt('tbl_docs_head_criteria')],
72  ];
73  }
+ Here is the call graph for this function:

◆ config()

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

Implements ILIAS\LegalDocuments\Table.

Definition at line 75 of file DocumentTable.php.

References ILIAS\LegalDocuments\TableConfig\setSelectableColumns(), ILIAS\LegalDocuments\TableConfig\setTitle(), and ILIAS\LegalDocuments\Table\DocumentTable\ui().

75  : void
76  {
77  $config->setTitle($this->ui->txt('tbl_docs_title'));
78  $config->setSelectableColumns('created', 'change');
79  }
+ Here is the call graph for this function:

◆ criterionName()

ILIAS\LegalDocuments\Table\DocumentTable::criterionName ( Criterion  $criterion)

Definition at line 135 of file DocumentTable.php.

References ILIAS\LegalDocuments\Value\Criterion\content().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\showCriterion().

135  : Component
136  {
137  return ($this->criterion_as_component)($criterion->content());
138  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapSelection()

ILIAS\LegalDocuments\Table\DocumentTable::mapSelection ( Closure  $proc,
TableSelection  $select 
)

Definition at line 86 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\select(), and ILIAS\LegalDocuments\Table\DocumentTable\step().

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

86  : array
87  {
88  $step = $this->step();
89  return array_map(fn($x) => $proc($x, $step()), $this->select($select));
90  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ name()

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

Implements ILIAS\LegalDocuments\Table.

Definition at line 165 of file DocumentTable.php.

165  : string
166  {
167  return self::class;
168  }

◆ orderInputGui()

ILIAS\LegalDocuments\Table\DocumentTable::orderInputGui ( Document  $document,
int  $sorting 
)

Definition at line 140 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\$create, and ILIAS\LegalDocuments\Value\Document\id().

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

141  {
142  $input = ($this->create)(ilNumberInputGUI::class, '', 'order[' . $document->id() . ']');
143  $input->setValue((string) $sorting);
144  $input->setMaxLength(4);
145  $input->setSize(2);
146  $input->setDisabled(true);
147 
148  return $input;
149  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ row()

ILIAS\LegalDocuments\Table\DocumentTable::row ( Document  $document,
int  $sorting 
)

Definition at line 97 of file DocumentTable.php.

References ILIAS\LegalDocuments\Value\Document\content(), ILIAS\LegalDocuments\Value\Document\meta(), ILIAS\Repository\modal(), ILIAS\LegalDocuments\Table\DocumentTable\orderInputGui(), ILIAS\LegalDocuments\Table\DocumentTable\showCriteria(), and ILIAS\LegalDocuments\Table\DocumentTable\showCriterion().

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

97  : array
98  {
99  $render_order = $this->orderInputGui($document, $sorting);
100 
101  return [
102  'order' => fn() => $render_order->render(),
103  'title' => $this->modal->create($document->content()),
104  'created' => ($this->format_date)($document->meta()->creation()->time()),
105  'change' => ($this->format_date)($document->meta()->lastModification()->time()),
106  'criteria' => $this->showCriteria($document, $this->showCriterion(...)),
107  ];
108  }
showCriteria(Document $document, Closure $proc)
orderInputGui(Document $document, int $sorting)
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\DocumentTable::rows ( TableSelection  $select)
Returns
list<array<string, string|Closure(): string>>

Implements ILIAS\LegalDocuments\Table.

Definition at line 81 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\mapSelection(), and ILIAS\LegalDocuments\Table\DocumentTable\row().

81  : array
82  {
83  return $this->mapSelection($this->row(...), $select);
84  }
row(Document $document, int $sorting)
mapSelection(Closure $proc, TableSelection $select)
+ Here is the call graph for this function:

◆ select()

ILIAS\LegalDocuments\Table\DocumentTable::select ( TableSelection  $select)

Definition at line 92 of file DocumentTable.php.

References ILIAS\UI\examples\Deck\repository().

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\mapSelection().

92  : array
93  {
94  return $this->repository->all();
95  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showCriteria()

ILIAS\LegalDocuments\Table\DocumentTable::showCriteria ( Document  $document,
Closure  $proc 
)
Parameters
Closure(Criterion)list<Component> $proc

Definition at line 113 of file DocumentTable.php.

References ILIAS\LegalDocuments\Value\Document\criteria(), and ILIAS\LegalDocuments\Table\DocumentTable\ui().

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

114  {
115  if ([] === $document->criteria()) {
116  return $this->ui->txt('tbl_docs_cell_not_criterion');
117  }
118  return array_merge(...array_map(
119  $proc,
120  $document->criteria()
121  ));
122  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showCriterion()

ILIAS\LegalDocuments\Table\DocumentTable::showCriterion ( Criterion  $criterion)
Returns
list<Component>

Definition at line 127 of file DocumentTable.php.

References ILIAS\LegalDocuments\Table\DocumentTable\criterionName(), and ILIAS\LegalDocuments\Table\DocumentTable\ui().

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

127  : array
128  {
129  return [
130  $this->criterionName($criterion),
131  $this->ui->create()->legacy('<br/>'),
132  ];
133  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ step()

ILIAS\LegalDocuments\Table\DocumentTable::step ( )

Definition at line 151 of file DocumentTable.php.

Referenced by ILIAS\LegalDocuments\Table\DocumentTable\mapSelection().

151  : Closure
152  {
153  $step = 0;
154  return static function () use (&$step): int {
155  $step += 10;
156  return $step;
157  };
158  }
+ Here is the caller graph for this function:

◆ ui()

ILIAS\LegalDocuments\Table\DocumentTable::ui ( )

Field Documentation

◆ $create

readonly Closure ILIAS\LegalDocuments\Table\DocumentTable::$create
private

◆ $format_date

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

Definition at line 45 of file DocumentTable.php.


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