ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
class.ilObjBenchmarkGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\HTTP\Wrapper\WrapperFactory as WrapperFactoryAlias;
22
28{
31 private WrapperFactoryAlias $wrapper;
32
33 public function __construct(int $id = 0, int $id_type = self::REPOSITORY_NODE_ID, int $parent_node_id = 0)
34 {
35 parent::__construct($id, $id_type, $parent_node_id);
36
37 global $DIC;
38 $this->wrapper = $DIC->http()->wrapper();
39 $this->bench = $DIC["ilBench"];
40 }
41
42 public function getType(): string
43 {
45 }
46
47 public function executeCommand(): void
48 {
49 $this->checkPermission('read');
50
51 $this->lng->loadLanguageModule($this->getType());
52 $this->prepareOutput();
53
54 switch ($this->ctrl->getNextClass($this)) {
55 case strtolower(ilPermissionGUI::class):
56 $this->tabs_gui->activateTab('permissions');
57 $perm_gui = new ilPermissionGUI($this);
58 $this->ctrl->forwardCommand($perm_gui);
59 break;
60
61 default:
62 $cmd = $this->ctrl->getCmd("view");
63 switch ($cmd) {
64 case 'settings':
65 case 'update':
66 $this->tabs_gui->activateTab('settings');
67 $this->checkPermission('write');
68 $this->$cmd();
69 break;
70
71 case 'view':
72 case 'slowest_first':
73 case 'sorted_by_sql':
74 case 'by_first_table':
75 $this->getViewSubtabs();
76 $this->tabs_gui->activateTab('view');
77 $this->tabs_gui->activateSubTab($cmd);
78 $this->view();
79 break;
80 }
81 }
82 }
83
84 public function getAdminTabs(): void
85 {
86 $this->tabs_gui->addTab(
87 'view',
88 $this->lng->txt('view'),
89 $this->ctrl->getLinkTarget($this, 'view')
90 );
91
92 if ($this->checkPermissionBool('write')) {
93 $this->tabs_gui->addTab(
94 'settings',
95 $this->lng->txt('settings'),
96 $this->ctrl->getLinkTarget($this, 'settings')
97 );
98 }
99 if ($this->checkPermissionBool('edit_permission')) {
100 $this->tabs_gui->addTab(
101 'permissions',
102 $this->lng->txt('perm_settings'),
103 $this->ctrl->getLinkTargetByClass([self::class, ilPermissionGUI::class], 'perm')
104 );
105 }
106 }
107
108 private function getViewSubtabs(): void
109 {
110 $this->tabs_gui->addSubTab(
111 'view',
112 $this->lng->txt('adm_db_bench_chronological'),
113 $this->ctrl->getLinkTarget($this, 'view')
114 );
115
116 $this->tabs_gui->addSubTab(
117 'slowest_first',
118 $this->lng->txt('adm_db_bench_slowest_first'),
119 $this->ctrl->getLinkTarget($this, 'slowest_first')
120 );
121
122 $this->tabs_gui->addSubTab(
123 'sorted_by_sql',
124 $this->lng->txt('adm_db_bench_sorted_by_sql'),
125 $this->ctrl->getLinkTarget($this, 'sorted_by_sql')
126 );
127
128 $this->tabs_gui->addSubTab(
129 'by_first_table',
130 $this->lng->txt('adm_db_bench_by_first_table'),
131 $this->ctrl->getLinkTarget($this, 'by_first_table')
132 );
133 }
134
135 private function settings(): void
136 {
137 $this->form = new ilPropertyFormGUI();
138
139 // Activate DB Benchmark
140 $cb = new ilCheckboxInputGUI($this->lng->txt("adm_activate_db_benchmark"), ilBenchmark::ENABLE_DB_BENCH);
141 $cb->setChecked((bool) $this->settings->get(ilBenchmark::ENABLE_DB_BENCH));
142 $cb->setInfo($this->lng->txt("adm_activate_db_benchmark_desc"));
143 $this->form->addItem($cb);
144
145 // DB Benchmark User
146 $ti = new ilTextInputGUI($this->lng->txt("adm_db_benchmark_user"), ilBenchmark::DB_BENCH_USER);
147 $login = ilObjUser::_lookupLogin((int) ($this->settings->get(ilBenchmark::DB_BENCH_USER)));
148 $ti->setValue($login);
149 $ti->setInfo($this->lng->txt("adm_db_benchmark_user_desc"));
150 $this->form->addItem($ti);
151
152 $this->form->setTitle($this->lng->txt("adm_db_benchmark"));
153 $this->form->setFormAction($this->ctrl->getFormAction($this));
154 $this->form->addCommandButton('update', $this->lng->txt('save'));
155
156 $this->tpl->setContent($this->form->getHTML());
157 }
158
159 public function update(): void
160 {
161 if ($this->wrapper->post()->has(ilBenchmark::ENABLE_DB_BENCH)
162 && $this->wrapper->post()->has(ilBenchmark::DB_BENCH_USER)) {
163 $activate = $this->wrapper->post()->retrieve(ilBenchmark::ENABLE_DB_BENCH, $this->refinery->kindlyTo()->bool());
164 if ($activate) {
165 $user_name = $this->wrapper->post()->retrieve(ilBenchmark::DB_BENCH_USER, $this->refinery->kindlyTo()->string());
166 $this->bench->clearData();
167 $this->bench->enableDbBenchmarkForUserName($user_name);
168 }
169 } else {
170 $this->bench->clearData();
171 $this->bench->disableDbBenchmark();
172 }
173
174 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
175 $this->ctrl->redirect($this, 'settings');
176 }
177
178 public function view(): void
179 {
180 $cmd = $this->ctrl->getCmd("view");
181 $mode = $cmd === 'view' ? 'chronological' : $cmd;
182
183 $table = new ilBenchmarkTableGUI($this, $cmd, $this->bench->getDbBenchRecords(), $mode);
184 $this->tpl->setContent($table->getHTML());
185 }
186}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilBenchmark.
This class represents a checkbox property in a property form.
@ilCtrl_isCalledBy ilObjBenchmarkGUI: ilAdministrationGUI @ilCtrl_Calls ilObjBenchmarkGUI: ilPermissi...
getType()
Functions that must be overwritten.
__construct(int $id=0, int $id_type=self::REPOSITORY_NODE_ID, int $parent_node_id=0)
getAdminTabs()
administration tabs show only permissions and trash folder
executeCommand()
execute command
view()
view object content (repository/workspace switch)
WrapperFactoryAlias $wrapper
static _lookupLogin(int $a_user_id)
New implementation of ilObjectGUI.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
This class represents a property form user interface.
This class represents a text property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form(?array $class_path, string $cmd, string $submit_caption="")
global $DIC
Definition: shib_login.php:26