ILIAS  release_8 Revision v8.24
class.ilForumDraftsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected bool $mayEdit = false;
28
29 public function __construct(ilObjForumGUI $a_parent_obj, string $a_parent_cmd, bool $mayEdit)
30 {
31 $this->mayEdit = $mayEdit;
32 $this->setId('frm_drafts_' . substr(md5($a_parent_cmd), 0, 3) . '_' . $a_parent_obj->getObject()->getId());
33
34 parent::__construct($a_parent_obj, $a_parent_cmd);
35 $this->initTableColumns();
36 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), 'showThreads'));
37 $this->setRowTemplate('tpl.forums_threads_drafts_table.html', 'Modules/Forum');
38 }
39
40 public function initTableColumns(): void
41 {
42 $this->addColumn('', 'check', '1px', true);
43 $this->addColumn($this->lng->txt('drafts'), '');
44 $this->addColumn($this->lng->txt('edited_on'), '');
45
46 $this->addMultiCommand('confirmDeleteThreadDrafts', $this->lng->txt('delete'));
47 $this->setSelectAllCheckbox('draft_ids');
48 }
49
50 protected function fillRow(array $a_set): void
51 {
52 global $DIC;
53
54 $selected_draft_ids = [];
55 if ($DIC->http()->wrapper()->post()->has('draft_ids')) {
56 $selected_draft_ids = $DIC->http()->wrapper()->post()->retrieve(
57 'draft_ids',
58 $DIC->refinery()->kindlyTo()->listOf($DIC->refinery()->kindlyTo()->int())
59 );
60 }
61
62 $this->tpl->setVariable(
63 'VAL_CHECK',
65 in_array($a_set['draft_id'], $selected_draft_ids, true),
66 'draft_ids[]',
67 (string) $a_set['draft_id']
68 )
69 );
70
71 if ($this->mayEdit) {
72 $this->ctrl->setParameter($this->getParentObject(), 'draft_id', $a_set['draft_id']);
73 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'editThreadDraft');
74 $this->ctrl->setParameter($this->getParentObject(), 'draft_id', null);
75 $this->tpl->setVariable('VAL_EDIT_URL', $url);
76 $this->tpl->setVariable('VAL_LINKED_SUBJECT', $a_set['subject']);
77 } else {
78 $this->tpl->setVariable('VAL_UNLINKED_SUBJECT', $a_set['subject']);
79 }
80
81 $date = ilDatePresentation::formatDate(new ilDateTime($a_set['post_update'], IL_CAL_DATETIME));
82 $this->tpl->setVariable('VAL_DATE', $date);
83 }
84}
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
Class ilForumDraftsTableGUI.
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(ilObjForumGUI $a_parent_obj, string $a_parent_cmd, bool $mayEdit)
static formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
Class ilObjForumGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url