29 protected \ILIAS\DI\UIServices
$ui;
30 protected \ilLanguage
$lng;
39 $this->
ui = $DIC->ui();
40 $this->
lng = $DIC->language();
42 $this->
user = $DIC->user();
44 $this->ui_wrapper =
new Server\UIWrapper($this->
ui, $this->
lng);
49 switch ($body[
"action"]) {
54 return $this->updateCommand($body);
57 throw new Exception(
"Unknown action " . $body[
"action"]);
63 $page = $this->page_gui->getPageObject();
67 if (!in_array($body[
"after_pcid"], [
"",
"pg"])) {
68 $hier_ids = $page->getHierIdsForPCIds([$body[
"after_pcid"]]);
69 $hier_id = $hier_ids[$body[
"after_pcid"]];
70 $pc_id = $body[
"after_pcid"];
72 $manual = ((string) ($body[
"form/input_0"] ??
"") ===
"manual");
74 $src = new \ilPCSourceCode($page);
75 $src->create($page, $hier_id, $pc_id);
76 if (($body[
"pcid"] ??
"") !==
"") {
77 $src->writePCId($body[
"pcid"]);
79 $src_gui = new \ilPCSourceCodeGUI($page, $src,
"",
"");
80 $src_gui->setPageConfig($page->getPageConfig());
81 $src->setLanguage($this->
user->getLanguage());
82 $src->setCharacteristic(
'Code');
87 $form = $src_gui->getManualFormAdapter();
88 if ($form->isValid()) {
89 $src->setDownloadTitle(str_replace(
'"',
'', $form->getData(
"title")));
90 $src->setSubCharacteristic($form->getData(
"subchar"));
91 $src->setShowLineNumbers($form->getData(
"linenumbers") ?
"y" :
"n");
92 $updated = $page->update();
95 $form = $src_gui->getImportFormAdapter();
96 if ($form->isValid()) {
97 $src->importFile((
string) $form->getData(
"input_file"));
98 $src->setDownloadTitle(str_replace(
'"',
'', $form->getData(
"title")));
99 $src->setSubCharacteristic($form->getData(
"subchar"));
100 $src->setShowLineNumbers($form->getData(
"linenumbers") ?
"y" :
"n");
101 $updated = $page->update();
105 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
108 protected function updateCommand(array $body): Server\Response
110 $page = $this->page_gui->getPageObject();
113 $pc_src = $page->getContentObjectForPcId($body[
"pcid"]);
114 $src_gui = new \ilPCSourceCodeGUI($page, $pc_src,
"", $body[
"pcid"]);
115 $form = $src_gui->getEditingFormAdapter();
116 if ($form->isValid()) {
117 $pc_src->setDownloadTitle(str_replace(
'"',
'', $form->getData(
"title")));
118 $pc_src->setSubCharacteristic($form->getData(
"subchar"));
119 $pc_src->setShowLineNumbers($form->getData(
"linenumbers") ?
"y" :
"n");
121 $pc_src->input2xml($body[
"code"], 0,
false)
123 $updated = $page->update();
125 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
Server UIWrapper $ui_wrapper
handle(array $query, array $body)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insertCommand(array $body)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilPageObjectGUI $page_gui
__construct(\ilPageObjectGUI $page_gui)