ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Forum\Drafts\ForumDraftsTable Class Reference
+ Inheritance diagram for ILIAS\Forum\Drafts\ForumDraftsTable:
+ Collaboration diagram for ILIAS\Forum\Drafts\ForumDraftsTable:

Public Member Functions

 __construct (private readonly ilObjForum $forum, private readonly UIFactory $ui_factory, private readonly ServerRequestInterface $httpRequest, private readonly ilLanguage $lng, private readonly string $parent_cmd, private readonly ilCtrlInterface $ctrl, private readonly DataFactory $data_factory, private readonly ilObjUser $user, private readonly bool $mayEdit, private readonly ilObjForumGUI $parent_object,)
 
 getRows (\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters,)
 
 initRecords ()
 
 getComponent ()
 
 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...
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 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...
 

Private Member Functions

 getRecords (Range $range, Order $order)
 
 limitRecords (array $records, Range $range)
 
 getColumns ()
 

Private Attributes

array $records = null
 

Detailed Description

Definition at line 41 of file ForumDraftsTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Forum\Drafts\ForumDraftsTable::__construct ( private readonly ilObjForum  $forum,
private readonly UIFactory  $ui_factory,
private readonly ServerRequestInterface  $httpRequest,
private readonly ilLanguage  $lng,
private readonly string  $parent_cmd,
private readonly ilCtrlInterface  $ctrl,
private readonly DataFactory  $data_factory,
private readonly ilObjUser  $user,
private readonly bool  $mayEdit,
private readonly ilObjForumGUI  $parent_object 
)

Definition at line 46 of file ForumDraftsTable.php.

57 {
58 }

Member Function Documentation

◆ getColumns()

ILIAS\Forum\Drafts\ForumDraftsTable::getColumns ( )
private
Returns
array{ draft: \ILIAS\UI\Component\Table\Column\Link, edited_on: \ILIAS\UI\Component\Table\Column\Text }

Definition at line 179 of file ForumDraftsTable.php.

179 : array
180 {
181 return [
182 'draft' => $this->ui_factory->table()->column()->link($this->lng->txt('drafts'))->withIsSortable(
183 false
184 )->withIsSortable(false),
185 'edited_on' => $this->ui_factory->table()->column()->date(
186 $this->lng->txt('edited_on'),
187 $this->user->getDateTimeFormat()
188 )->withIsSortable(false)
189 ];
190 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponent()

ILIAS\Forum\Drafts\ForumDraftsTable::getComponent ( )

Definition at line 108 of file ForumDraftsTable.php.

108 : DataTable
109 {
110 $query_params_namespace = ['forum', 'drafts', 'delete'];
111 $uri = $this->data_factory->uri(
112 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(ilObjForumGUI::class, 'confirmDeleteThreadDrafts')
113 );
114 $url_builder = new URLBuilder($uri);
115 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
116 $query_params_namespace,
117 'table_action',
118 'draft_ids'
119 );
120
121 return $this->ui_factory
122 ->table()
123 ->data(
124 $this,
125 $this->lng->txt('drafts'),
126 $this->getColumns(),
127 )
128 ->withId(
129 'frm_drafts_' . substr(
130 md5($this->parent_cmd),
131 0,
132 3
133 ) . '_' . $this->forum->getId()
134 )
135 ->withRequest($this->httpRequest)
136 ->withActions(
137 [
138 'delete' => $this->ui_factory->table()->action()->multi(
139 $this->lng->txt('delete'),
140 $url_builder->withParameter($action_parameter_token, 'delete'),
141 $row_id_token
142 )
143 ]
144 );
145 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

ILIAS\Forum\Drafts\ForumDraftsTable::getRecords ( Range  $range,
Order  $order 
)
private
Returns
list<array{draft_id: int, draft: string, edited_on: string}>

Definition at line 157 of file ForumDraftsTable.php.

157 : array
158 {
159 $this->initRecords();
160
161 return $this->limitRecords($this->records, $range);
162 }
limitRecords(array $records, Range $range)

References ILIAS\UI\Implementation\Component\Table\$range.

◆ getRows()

ILIAS\Forum\Drafts\ForumDraftsTable::getRows ( \ILIAS\UI\Component\Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 60 of file ForumDraftsTable.php.

67 : Generator {
68 $records = $this->getRecords($range, $order);
69 foreach ($records as $record) {
70 yield $row_builder->buildDataRow((string) $record['draft_id'], $record);
71 }
72 }
getRecords(Range $range, Order $order)

◆ getTotalRowCount()

ILIAS\Forum\Drafts\ForumDraftsTable::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 147 of file ForumDraftsTable.php.

147 : ?int
148 {
149 $this->initRecords();
150
151 return count((array) $this->records);
152 }

◆ initRecords()

ILIAS\Forum\Drafts\ForumDraftsTable::initRecords ( )

Definition at line 74 of file ForumDraftsTable.php.

74 : void
75 {
76 if ($this->records === null) {
77 $this->records = [];
79 $this->user->getId(),
80 ilObjForum::lookupForumIdByObjId($this->forum->getId())
81 );
82
83 foreach ($drafts as $draft) {
84 if (!isset($draft['draft_id'], $draft['subject'], $draft['post_update'])) {
85 continue;
86 }
87
88 $draft_id = $draft['draft_id'];
89 $this->records[$draft_id] = ['draft_id' => $draft_id];
90 if ($this->mayEdit) {
91 $this->ctrl->setParameter($this->parent_object, 'draft_id', $draft_id);
92 $url = $this->ctrl->getLinkTarget($this->parent_object, 'editThreadDraft');
93 $this->records[$draft_id]['draft'] = $this->ui_factory->link()->standard(
94 $draft['subject'],
95 $url
96 );
97 $this->ctrl->setParameter($this->parent_object, 'draft_id', null);
98 } else {
99 $this->records[$draft_id]['draft'] = $draft['subject'];
100 }
101 $this->records[$draft_id]['edited_on'] = new DateTimeImmutable(
102 $draft['post_update']
103 );
104 }
105 }
106 }
static getThreadDraftData(int $post_author_id, int $forum_id)
static lookupForumIdByObjId(int $obj_id)
$url
Definition: shib_logout.php:68

References $url, ILIAS\Repository\ctrl(), ilForumPostDraft\getThreadDraftData(), ilObjForum\lookupForumIdByObjId(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ limitRecords()

ILIAS\Forum\Drafts\ForumDraftsTable::limitRecords ( array  $records,
Range  $range 
)
private
Parameters
list<array{draft_idint, draft: string, edited_on: string}> $records
Returns
list<array{draft_id: int, draft: string, edited_on: string}>

Definition at line 168 of file ForumDraftsTable.php.

168 : array
169 {
170 return array_slice($records, $range->getStart(), $range->getLength());
171 }

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

+ Here is the call graph for this function:

Field Documentation

◆ $records

array ILIAS\Forum\Drafts\ForumDraftsTable::$records = null
private

Definition at line 44 of file ForumDraftsTable.php.


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