ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCDataTableEditorGUI.php
Go to the documentation of this file.
1<?php
2
20
25{
26 protected \ILIAS\COPage\InternalGUIService $gui;
27 protected \ILIAS\DI\UIServices $ui;
28 protected \ilLanguage $lng;
29 protected \ilCtrl $ctrl;
30
31 public function __construct()
32 {
33 global $DIC;
34
35 $this->lng = $DIC->language();
36 $this->ctrl = $DIC->ctrl();
37 $this->ui = $DIC->ui();
38 $this->gui = $DIC->copage()->internal()->gui();
39 }
40
41 public function getEditorElements(
42 UIWrapper $ui_wrapper,
43 string $page_type,
44 ilPageObjectGUI $page_gui,
45 int $style_id
46 ): array {
47 global $DIC;
48
49 $lng = $DIC->language();
50 $lng->loadLanguageModule("content");
51
52 $acc = new ilAccordionGUI();
53 $acc->addItem($lng->txt("cont_set_manuall"), $this->getCreationForm($page_gui, $ui_wrapper, $style_id));
54 $acc->addItem($lng->txt("cont_paste_from_spreadsheet"), $this->getImportForm($page_gui, $ui_wrapper, $style_id));
55 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
56
57 $form = $this->getCreationForm($page_gui, $ui_wrapper, $style_id);
58 return [
59 "creation_form" => $acc->getHTML(true),
60 "icon" => $ui_wrapper->getRenderedIcon("pedt"),
61 "top_actions" => $this->getTopActions($ui_wrapper, $page_gui),
62 "cell_info" => $this->getCellInfo(),
63 "cell_actions" => $this->getCellActions($ui_wrapper, $page_gui, $style_id),
64 "merge_actions" => $this->getMergeActions($ui_wrapper, $page_gui, $style_id),
65 "number_input_modal" => $this->getModalNumberInputTemplate()
66 ];
67 }
68
69 protected function getCreationForm(
70 ilPageObjectGUI $page_gui,
71 UIWrapper $ui_wrapper,
72 int $style_id
73 ): string {
74 $lng = $this->lng;
75
76 $tab_gui = new ilPCDataTableGUI($page_gui->getPageObject(), null, "", "");
77 $tab_gui->setStyleId($style_id);
78
80 $form = $tab_gui->initCreationForm();
81
82 $html = $ui_wrapper->getRenderedForm(
83 $form,
84 [
85 ["Page", "component.save", $lng->txt("insert")],
86 ["Page", "component.cancel", $lng->txt("cancel")]
87 ]
88 );
89
90 return $html;
91 }
92
93 protected function getEditForm(
94 ilPageObjectGUI $page_gui,
95 UIWrapper $ui_wrapper,
96 int $style_id,
97 string $pcid
98 ): string {
99 $lng = $this->lng;
100
102 $tab = $page_gui->getPageObject()->getContentObjectForPcId($pcid);
103 $tab_gui = new ilPCDataTableGUI($page_gui->getPageObject(), $tab, "", $pcid);
104 $tab_gui->setStyleId($style_id);
105
107 $form = $tab_gui->initEditingForm();
108
109 $html = $ui_wrapper->getRenderedForm(
110 $form,
111 [
112 ["Page", "component.update.back", $lng->txt("save")],
113 /*["Page", "component.back", $lng->txt("cancel")]*/
114 ]
115 );
116
117 return $html;
118 }
119
120
121 protected function getImportForm(
122 ilPageObjectGUI $page_gui,
123 UIWrapper $ui_wrapper,
124 int $style_id
125 ): string {
126 $lng = $this->lng;
127
128 $tab_gui = new ilPCDataTableGUI($page_gui->getPageObject(), null, "", "");
129 $tab_gui->setStyleId($style_id);
130
132 $form = $tab_gui->initImportForm();
133
134 $html = $ui_wrapper->getRenderedForm(
135 $form,
136 [
137 ["Page", "component.save", $lng->txt("insert")],
138 ["Page", "component.cancel", $lng->txt("cancel")]
139 ]
140 );
141
142 return $html;
143 }
144
145 protected function getTopActions(UIWrapper $ui_wrapper, ilPageObjectGUI $page_gui): string
146 {
147 $ui = $this->ui;
148 $ctrl = $this->ctrl;
149
151 $lng->loadLanguageModule("content");
152 $tpl = new \ilTemplate("tpl.table_top_actions.html", true, true, "components/ILIAS/COPage/Editor");
153
154 $quit_button = $ui_wrapper->getRenderedButton(
155 $lng->txt("cont_finish_table_editing"),
156 "button",
157 "component.back",
158 null,
159 "Table",
160 true
161 );
162
163 /*
164 $b = $ui->factory()->button()->primary(
165 $lng->txt("cont_finish_table_editing"),
166 $ctrl->getLinkTarget($page_gui, "edit")
167 );*/
168
169 //$tpl->setVariable("QUIT_BUTTON", $ui->renderer()->renderAsync($b));
170 $tpl->setVariable("QUIT_BUTTON", $quit_button);
171
172 $html = $ui_wrapper->getRenderedViewControl(
173 [
174 ["Table", "switch.edit.table", $lng->txt("cont_edit_table")],
175 ["Table", "switch.format.cells", $lng->txt("cont_format_cells")],
176 ["Table", "switch.merge.cells", $lng->txt("cont_merge_cells")]
177 ]
178 );
179 $tpl->setVariable("SWITCH", $html);
180
181 return $tpl->get();
182 }
183
184 public function getEditComponentForm(
185 UIWrapper $ui_wrapper,
186 string $page_type,
187 \ilPageObjectGUI $page_gui,
188 int $style_id,
189 string $pcid
190 ): string {
191 return $this->getTopActions($ui_wrapper, $page_gui) .
192 $this->getEditForm($page_gui, $ui_wrapper, $style_id, $pcid) .
193 $this->getAdvancedSettingsLink($page_gui, $pcid);
194 }
195
196 protected function getAdvancedSettingsLink(
197 \ilPageObjectGUI $page_gui,
198 string $pcid
199 ): string {
200 $page = $page_gui->getPageObject();
202 $tab = $page->getContentObjectForPcId($pcid);
203 $tab_gui = new ilPCDataTableGUI($page_gui->getPageObject(), $tab, "", $pcid);
204 $link = $this->ui->factory()->button()->shy(
205 $this->lng->txt("cont_table_adv_settings"),
206 $this->ctrl->getLinkTarget($tab_gui, "editProperties")
207 );
208 return $this->ui->renderer()->renderAsync($link);
209 }
210
211 protected function getCellInfo(): string
212 {
213 return "<div id='ilPageEditLegend' class='subtitle'>" .
214 "<p>" . $this->lng->txt("cont_table_cell_edit_info_1") . "</p>" .
215 "<p>" . $this->lng->txt("cont_table_cell_edit_info_2") . "</p>" .
216 "<p>" . $this->lng->txt("cont_table_cell_edit_info_3") . "</p>" .
217 "</div>";
218 }
219
220 protected function getCellActions(
221 UIWrapper $ui_wrapper,
222 ilPageObjectGUI $page_gui,
223 int $style_id = 0
224 ): string {
225 $lng = $this->lng;
226
227 $tab_gui = new ilPCDataTableGUI($page_gui->getPageObject(), null, "", "");
228 $tab_gui->setStyleId($style_id);
229
231 $form = $tab_gui->initCellPropertiesForm();
232
233 /*
234 $html = $ui_wrapper->getRenderedForm(
235 $form,
236 [
237 ["Table", "toggle.merge", $lng->txt("cont_merge_cells")],
238 ["Table", "properties.set", $lng->txt("cont_set_properties")],
239 ["Page", "component.back", $lng->txt("cancel")]
240 ]
241 );*/
242
243 $html = $ui_wrapper->getRenderedForm(
244 $form,
245 [
246 ["Table", "properties.set", $lng->txt("cont_set_properties")],
247 ]
248 );
249
250 return $html;
251 }
252
253 protected function getMergeActions(
254 UIWrapper $ui_wrapper,
255 ilPageObjectGUI $page_gui,
256 int $style_id = 0
257 ): string {
258 $lng = $this->lng;
259
260 $html = $ui_wrapper->getRenderedButton(
261 $lng->txt("cont_merge_cells"),
262 "button",
263 "toggle.merge",
264 null,
265 "Table"
266 );
267
268 return '<div class="copg-edit-button-group">' . $html . '</div>';
269 }
270
271 public function getModalNumberInputTemplate(): array
272 {
273 $form = $this
274 ->gui
275 ->form(["ilPCDataTableGUI"], "#")
276 ->select(
277 "number",
278 "#select-title#",
279 [
280 "1" => "1",
281 "2" => "2",
282 "3" => "3",
283 "4" => "4",
284 "5" => "5",
285 "6" => "6",
286 "7" => "7",
287 "8" => "8",
288 "9" => "9",
289 "10" => "10"
290 ],
291 "",
292 "1"
293 )
294 ->required();
295 $components = $this
296 ->gui
297 ->modal("#modal-title#")
298 ->form($form, "#on-form-submit-click#")->getTriggerButtonComponents(
299 "#button-title#",
300 true
301 );
302
303 $modalt["signal"] = $components["modal"]->getShowSignal()->getId();
304 $modalt["modal"] = $this->ui->renderer()->renderAsync($components["modal"]);
305 $modalt["button"] = $this->ui->renderer()->renderAsync($components["button"]);
306
307 return $modalt;
308 }
309
310}
$components
getRenderedForm(\ilPropertyFormGUI $form, array $buttons)
getRenderedButton(string $content, string $type, string $action, ?array $data=null, string $component="", bool $primary=false, string $aria_label="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getEditorElements(UIWrapper $ui_wrapper, string $page_type, ilPageObjectGUI $page_gui, int $style_id)
getEditComponentForm(UIWrapper $ui_wrapper, string $page_type, \ilPageObjectGUI $page_gui, int $style_id, string $pcid)
Get rendered editor elements.
getMergeActions(UIWrapper $ui_wrapper, ilPageObjectGUI $page_gui, int $style_id=0)
getTopActions(UIWrapper $ui_wrapper, ilPageObjectGUI $page_gui)
ILIAS COPage InternalGUIService $gui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPageObjectGUI.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26