ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilMailAttachmentTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
27  public function __construct(?object $a_parent_obj, string $a_parent_cmd)
28  {
29  $this->setId('mail_attachments');
30 
31  $this->setDefaultOrderDirection('ASC');
32  $this->setDefaultOrderField('filename');
33 
34  parent::__construct($a_parent_obj, $a_parent_cmd);
35 
36  $this->setTitle($this->lng->txt('attachment'));
37  $this->setNoEntriesText($this->lng->txt('marked_entries'));
38 
39  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyFilter'));
40 
41  $this->setSelectAllCheckbox('filename[]');
42 
43  $this->setRowTemplate('tpl.mail_attachment_row.html', 'Services/Mail');
44 
45  $this->addMultiCommand('saveAttachments', $this->lng->txt('adopt'));
46  $this->addMultiCommand('deleteAttachments', $this->lng->txt('delete'));
47 
48  $this->addCommandButton('cancelSaveAttachments', $this->lng->txt('cancel'));
49 
50  $this->addColumn($this->lng->txt(''), '', '1px', true);
51  $this->addColumn($this->lng->txt('mail_file_name'), 'filename');
52  $this->addColumn($this->lng->txt('mail_file_size'), 'filesize');
53  $this->addColumn($this->lng->txt('create_date'), 'filecreatedate');
54  // Show all attachments on one page
55  $this->setShowRowsSelector(false);
56  $this->setLimit(PHP_INT_MAX);
57  }
58 
59  protected function fillRow(array $a_set): void
60  {
64  $this->tpl->setVariable(
65  'VAL_CHECKBOX',
66  ilLegacyFormElementsUtil::formCheckbox($a_set['checked'], 'filename[]', urlencode($a_set['filename']))
67  );
68  $this->tpl->setVariable(
69  'VAL_FILENAME',
70  $this->formatValue('filename', $a_set['filename'])
71  );
72  $this->tpl->setVariable(
73  'VAL_FILESIZE',
74  $this->formatValue('filesize', (string) $a_set['filesize'])
75  );
76  $this->tpl->setVariable(
77  'VAL_FILECREATEDATE',
78  $this->formatValue('filecreatedate', (string) $a_set['filecreatedate'])
79  );
80  }
81 
82  public function numericOrdering(string $a_field): bool
83  {
84  return $a_field === 'filesize' || $a_field === 'filecreatedate';
85  }
86 
87  protected function formatValue(string $column, string $value): ?string
88  {
89  return match ($column) {
90  'filecreatedate' => ilDatePresentation::formatDate(new ilDateTime($value, IL_CAL_UNIX)),
91  'filesize' => ilUtil::formatSize((int) $value, 'long'),
92  default => $value,
93  };
94  }
95 }
setNoEntriesText(string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
setId(string $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
__construct(VocabulariesInterface $vocabularies)
__construct(?object $a_parent_obj, string $a_parent_cmd)
setDefaultOrderField(string $a_defaultorderfield)
static formatSize(int $size, string $a_mode='short', ?ilLanguage $a_lng=null)
Returns the specified file size value in a human friendly form.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
static formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
formatValue(string $column, string $value)
setLimit(int $a_limit=0, int $a_default_limit=0)
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)
addMultiCommand(string $a_cmd, string $a_text)