ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilLogComponentTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
24 {
27  protected bool $editable = true;
28 
29  public function __construct(object $a_parent_obj, string $a_parent_cmd = "")
30  {
31  global $DIC;
32  $this->component_repo = $DIC["component.repository"];
33 
34  $this->setId('il_log_component');
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36  }
37 
41  public function setEditable(bool $a_status): void
42  {
43  $this->editable = $a_status;
44  }
45 
49  public function isEditable(): bool
50  {
51  return $this->editable;
52  }
53 
57  public function init(): void
58  {
59  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
61 
62  $this->setRowTemplate('tpl.log_component_row.html', 'components/ILIAS/Logging');
63  $this->addColumn($this->lng->txt('log_component_col_component'), 'component_sortable');
64  $this->addColumn($this->lng->txt('log_component_col_level'), 'level');
65 
66  $this->setDefaultOrderField('component_sortable');
67 
68  if ($this->isEditable()) {
69  $this->addCommandButton('saveComponentLevels', $this->lng->txt('save'));
70  $this->addCommandButton('resetComponentLevels', $this->lng->txt('log_component_btn_reset'));
71  }
72 
73  $this->setShowRowsSelector(false);
74  $this->setLimit(500);
75  }
76 
80  public function getSettings(): ilLoggingDBSettings
81  {
82  return $this->settings;
83  }
84 
88  public function parse(): void
89  {
90  $components = ilLogComponentLevels::getInstance()->getLogComponents();
91  $rows = array();
92  foreach ($components as $component) {
93  $row['id'] = $component->getComponentId();
94  if ($component->getComponentId() == 'log_root') {
95  $row['component'] = 'Root';
96  $row['component_sortable'] = '_' . $row['component'];
97  } else {
98  if ($this->component_repo->hasComponentId(
99  $component->getComponentId()
100  )) {
101  $row['component'] = $this->component_repo->getComponentById(
102  $component->getComponentId()
103  )->getName();
104  } else {
105  $row['component'] = "Unknown (" . $component->getComponentId() . ")";
106  }
107  $row['component_sortable'] = $row['component'];
108  }
109  $row['level'] = (int) $component->getLevel();
110  $rows[] = $row;
111  }
112  $this->setMaxCount(count($rows));
113  $this->setData($rows);
114  }
115 
119  protected function fillRow(array $a_set): void
120  {
121  $this->tpl->setVariable('CNAME', $a_set['component']);
122  if ($a_set['id'] == 'log_root') {
123  $this->tpl->setVariable('TXT_DESC', $this->lng->txt('log_component_root_desc'));
124  }
125 
126  $default_option_value = ilLoggingDBSettings::getInstance()->getLevel();
127  $array_options = ilLogLevel::getLevelOptions();
128  $default_option = array( 0 => $this->lng->txt('default') . " (" . $array_options[$default_option_value] . ")");
129  $array_options = $default_option + $array_options;
130 
131  $levels = new ilSelectInputGUI('', 'level[' . $a_set['id'] . ']');
132  $levels->setOptions($array_options);
133  $levels->setValue($a_set['level']);
134  $this->tpl->setVariable('C_SELECT_LEVEL', $levels->render());
135  }
136 }
setData(array $a_data)
Readable part of repository interface to ilComponentDataDB.
This class represents a selection list property in a property form.
setFormAction(string $a_form_action, bool $a_multipart=false)
ilComponentRepository $component_repo
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
static getLevelOptions()
setId(string $a_val)
$components
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setEditable(bool $a_status)
Set ediatable (write permission granted)
isEditable()
Check if ediatable (write permission granted)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
global $DIC
Definition: shib_login.php:26
__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)
Component logger with individual log levels by component id.
setMaxCount(int $a_max_count)
set max.
__construct(object $a_parent_obj, string $a_parent_cmd="")