ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters,)
 
 initRecords ()
 
 getComponent ()
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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 184 of file ForumDraftsTable.php.

184 : array
185 {
186 return [
187 'draft' => $this->ui_factory->table()->column()->link($this->lng->txt('drafts'))->withIsSortable(
188 false
189 )->withIsSortable(false),
190 'edited_on' => $this->ui_factory->table()->column()->date(
191 $this->lng->txt('edited_on'),
192 $this->user->getDateTimeFormat()
193 )->withIsSortable(false)
194 ];
195 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponent()

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

Definition at line 109 of file ForumDraftsTable.php.

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

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 162 of file ForumDraftsTable.php.

162 : array
163 {
164 $this->initRecords();
165
166 return $this->limitRecords($this->records, $range);
167 }
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,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Definition at line 60 of file ForumDraftsTable.php.

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

◆ getTotalRowCount()

ILIAS\Forum\Drafts\ForumDraftsTable::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $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 149 of file ForumDraftsTable.php.

153 : ?int {
154 $this->initRecords();
155
156 return count((array) $this->records);
157 }

◆ initRecords()

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

Definition at line 75 of file ForumDraftsTable.php.

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

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 173 of file ForumDraftsTable.php.

173 : array
174 {
175 return array_slice($records, $range->getStart(), $range->getLength());
176 }

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: