ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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->setLimit(PHP_INT_MAX);
56  }
57 
58  protected function fillRow(array $a_set): void
59  {
63  $this->tpl->setVariable(
64  'VAL_CHECKBOX',
65  ilLegacyFormElementsUtil::formCheckbox($a_set['checked'], 'filename[]', urlencode($a_set['filename']))
66  );
67  $this->tpl->setVariable(
68  'VAL_FILENAME',
69  $this->formatValue('filename', $a_set['filename'])
70  );
71  $this->tpl->setVariable(
72  'VAL_FILESIZE',
73  $this->formatValue('filesize', (string) $a_set['filesize'])
74  );
75  $this->tpl->setVariable(
76  'VAL_FILECREATEDATE',
77  $this->formatValue('filecreatedate', (string) $a_set['filecreatedate'])
78  );
79  }
80 
81  public function numericOrdering(string $a_field): bool
82  {
83  return $a_field === 'filesize' || $a_field === 'filecreatedate';
84  }
85 
86  protected function formatValue(string $column, string $value): ?string
87  {
88  switch ($column) {
89  case 'filecreatedate':
91 
92  case 'filesize':
93  return ilUtil::formatSize((int) $value, 'long');
94 
95  default:
96  return $value;
97  }
98  }
99 }
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)
__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)
__construct(Container $dic, ilPlugin $plugin)
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)