ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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...
 

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: , edited_on: }

Definition at line 179 of file ForumDraftsTable.php.

References ILIAS\Repository\lng(), ilCalendarSettings\TIME_FORMAT_12, and ILIAS\Repository\user().

Referenced by ILIAS\Forum\Drafts\ForumDraftsTable\getComponent().

179  : array
180  {
181  if ((int) $this->user->getTimeFormat() === ilCalendarSettings::TIME_FORMAT_12) {
182  $format = $this->data_factory->dateFormat()->withTime12($this->user->getDateFormat());
183  } else {
184  $format = $this->data_factory->dateFormat()->withTime24($this->user->getDateFormat());
185  }
186 
187  return [
188  'draft' => $this->ui_factory->table()->column()->link($this->lng->txt('drafts'))->withIsSortable(
189  false
190  )->withIsSortable(false),
191  'edited_on' => $this->ui_factory->table()->column()->date(
192  $this->lng->txt('edited_on'),
193  $format
194  )->withIsSortable(false)
195  ];
196  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

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

Definition at line 108 of file ForumDraftsTable.php.

References ILIAS\Repository\ctrl(), ILIAS\Forum\Drafts\ForumDraftsTable\getColumns(), and ILIAS\Repository\lng().

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  }
+ 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.

References ILIAS\Forum\Drafts\ForumDraftsTable\initRecords(), and ILIAS\Forum\Drafts\ForumDraftsTable\limitRecords().

Referenced by ILIAS\Forum\Drafts\ForumDraftsTable\getRows().

157  : array
158  {
159  $this->initRecords();
160 
161  return $this->limitRecords($this->records, $range);
162  }
limitRecords(array $records, Range $range)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

References ILIAS\Forum\Drafts\ForumDraftsTable\getRecords().

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)
+ Here is the call graph for this function:

◆ 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.

References ILIAS\Forum\Drafts\ForumDraftsTable\initRecords().

147  : ?int
148  {
149  $this->initRecords();
150 
151  return count((array) $this->records);
152  }
+ Here is the call graph for this function:

◆ initRecords()

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

Definition at line 74 of file ForumDraftsTable.php.

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

Referenced by ILIAS\Forum\Drafts\ForumDraftsTable\getRecords(), and ILIAS\Forum\Drafts\ForumDraftsTable\getTotalRowCount().

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 lookupForumIdByObjId(int $obj_id)
$url
Definition: shib_logout.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getThreadDraftData(int $post_author_id, int $forum_id)
+ Here is the call graph for this function:
+ Here is the caller 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.

References ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

Referenced by ILIAS\Forum\Drafts\ForumDraftsTable\getRecords().

+ Here is the call graph for this function:
+ Here is the caller 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: