ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMailTemplateTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Table/classes/class.ilTable2GUI.php';
5 require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
6 require_once 'Services/Mail/classes/class.ilMailTemplateService.php';
7 
13 {
17  protected $ctrl;
18 
22  protected $contexts = array();
23 
27  protected $readOnly = false;
28 
34  public function __construct($a_parent_obj, $a_parent_cmd, $readOnly = false)
35  {
36  global $DIC;
37 
38  $this->readOnly = $readOnly;
39 
40  $this->ctrl = $DIC->ctrl();
41 
42  $this->setId('mail_man_tpl');
43  parent::__construct($a_parent_obj, $a_parent_cmd);
44 
45  $this->setTitle($this->lng->txt('mail_templates'));
46  $this->setDefaultOrderDirection('ASC');
47  $this->setDefaultOrderField('title');
48 
49  if (!$this->readOnly) {
50  $this->addColumn('', '', '1%', true);
51  $this->setSelectAllCheckbox('tpl_id');
52  $this->addMultiCommand('confirmDeleteTemplate', $this->lng->txt('delete'));
53  }
54 
55  $this->addColumn($this->lng->txt('title'), 'title', '30%');
56  $this->addColumn($this->lng->txt('mail_template_context'), 'context', '20%');
57  /*$this->addColumn($this->lng->txt('language'), 'lang', '20%');*/
58  $this->addColumn($this->lng->txt('action'), '', '10%');
59 
60  $this->setRowTemplate('tpl.mail_template_row.html', 'Services/Mail');
61  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
62 
64  }
65 
71  protected function formatCellValue($column, array $row)
72  {
73  if ($column == 'tpl_id') {
74  return ilUtil::formCheckbox(false, 'tpl_id[]', $row[$column]);
75  } elseif ($column == 'lang') {
76  return $this->lng->txt('meta_l_' . $row[$column]);
77  } elseif ($column == 'context') {
78  if (isset($this->contexts[$row[$column]])) {
79  return $this->contexts[$row[$column]]->getTitle();
80  } else {
81  return $this->lng->txt('mail_template_orphaned_context');
82  }
83  }
84 
85  return $row[$column];
86  }
87 
91  protected function fillRow($row)
92  {
93  foreach ($row as $column => $value) {
94  if ($column == 'tpl_id' && $this->readOnly) {
95  continue;
96  }
97 
98  $value = $this->formatCellValue($column, $row);
99  $this->tpl->setVariable('VAL_' . strtoupper($column), $value);
100  }
101 
102  $this->ctrl->setParameter($this->getParentObject(), 'tpl_id', $row['tpl_id']);
103  $actions = new ilAdvancedSelectionListGUI();
104  $actions->setListTitle($this->lng->txt('actions'));
105  $actions->setId('act_' . $row['tpl_id']);
106  if (count($this->contexts)) {
107  if (!$this->readOnly) {
108  $actions->addItem($this->lng->txt('edit'), '', $this->ctrl->getLinkTarget($this->parent_obj, 'showEditTemplateForm'));
109  } else {
110  $actions->addItem($this->lng->txt('view'), '', $this->ctrl->getLinkTarget($this->parent_obj, 'showEditTemplateForm'));
111  }
112  }
113  if (!$this->readOnly) {
114  $actions->addItem(
115  $this->lng->txt('delete'),
116  '',
117  $this->ctrl->getLinkTarget($this->parent_obj, 'confirmDeleteTemplate')
118  );
119  }
120  $this->tpl->setVariable('VAL_ACTION', $actions->getHTML());
121  $this->ctrl->clearParameters($this->getParentObject());
122  }
123 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
global $DIC
Definition: saml.php:7
__construct($a_parent_obj, $a_parent_cmd, $readOnly=false)
getParentObject()
Get parent object.
setId($a_val)
Set id.
static getTemplateContexts($a_id=null)
Returns an array of mail template contexts, the key of each entry matches its id. ...
Class ilMailTemplateTableGUI.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
$column
Definition: 39dropdown.php:62
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public