30 protected \ILIAS\DI\UIServices
$ui;
31 protected \ilLanguage
$lng;
41 $this->
ui = $DIC->ui();
42 $this->
lng = $DIC->language();
44 $this->
user = $DIC->user();
46 $this->ui_wrapper =
new Server\UIWrapper($this->
ui, $this->
lng);
51 switch ($body[
"action"]) {
65 return $this->
split($body);
68 return $this->sectionClassCommand($body);
70 case "cmd.merge.previous":
80 throw new Exception(
"Unknown action " . $body[
"action"]);
88 $updated = $this->
insertParagraph($body[
"data"][
"pcid"], $body[
"data"][
"after_pcid"], $body[
"data"][
"content"], $body[
"data"][
"characteristic"], $body[
"data"][
"fromPlaceholder"]);
90 return $this->response_factory->getResponseObject($this->page_gui, $updated, $body[
"data"][
"pcid"]);
103 string $characteristic,
104 bool $from_placeholder =
false
106 $page = $this->page_gui->getPageObject();
109 $insert_id = $this->getFullIdForPCId($page, $after_pcid);
110 $content = $this->getContentForSaving($pcid, $content, $characteristic);
112 $this->content_obj = new \ilPCParagraph($page);
113 return $this->content_obj->saveJS(
133 $updated = $this->updateParagraph($body[
"data"][
"pcid"], $body[
"data"][
"content"], $body[
"data"][
"characteristic"]);
134 return $this->response_factory->getResponseObject($this->page_gui, $updated, $body[
"data"][
"pcid"]);
146 string $characteristic
148 $page = $this->page_gui->getPageObject();
150 $pcid = $this->getFullIdForPCId($page, $pcid);
151 $content = $this->getContentForSaving($pcid, $content, $characteristic);
152 $this->content_obj = new \ilPCParagraph($page);
153 return $this->content_obj->saveJS(
163 return $this->updateCommand($body,
true);
170 $page = $this->page_gui->getPageObject();
172 $pcid =
":" . $body[
"data"][
"pcid"];
174 if ($body[
"data"][
"insert_mode"]) {
175 $insert_id = $this->getFullIdForPCId($page, $body[
"data"][
"after_pcid"]);
178 $content = $this->getContentForSaving($pcid, $body[
"data"][
"text"], $body[
"data"][
"characteristic"]);
180 $content_obj = new \ilPCParagraph($page);
181 $updated = $content_obj->saveJS(
187 $body[
"data"][
"fromPlaceholder"] ??
false
189 $current_after_id = $body[
"data"][
"pcid"];
190 $all_pc_ids[] = $current_after_id;
192 foreach ($body[
"data"][
"new_paragraphs"] as $p) {
193 if ($updated ===
true) {
195 $insert_id = $this->getFullIdForPCId($page, $current_after_id);
196 $content = $this->getContentForSaving($p[
"pcid"], $p[
"model"][
"text"], $p[
"model"][
"characteristic"]);
197 $content_obj = new \ilPCParagraph($page);
198 $updated = $content_obj->saveJS(
205 $all_pc_ids[] = $p[
"pcid"];
206 $current_after_id = $p[
"pcid"];
210 return $this->response_factory->getResponseObjectMulti($this->page_gui, $updated, $all_pc_ids);
221 if (!in_array($pc_id, [
"",
"pg"])) {
223 $id = ($hier_ids[$pc_id] ??
"") .
":" . $pc_id;
231 string $characteristic
233 $content = str_replace(
" ",
" ", $content);
235 $pcid .
"' class='ilc_text_block_" .
236 $characteristic .
"'>" . $content .
"</div>";
245 protected function sectionClassCommand(array $body):
Server\
Response
247 $insert_mode = $body[
"data"][
"insert_mode"];
248 $after_pcid = $body[
"data"][
"after_pcid"];
249 $pcid = $body[
"data"][
"pcid"];
250 $content = $body[
"data"][
"text"];
251 $characteristic = $body[
"data"][
"characteristic"];
252 $old_section_characteristic = $body[
"data"][
"old_section_characteristic"];
253 $new_section_characteristic = $body[
"data"][
"new_section_characteristic"];
257 $updated = $this->updateParagraph($pcid, $content, $characteristic);
259 $updated = $this->insertParagraph($pcid, $after_pcid, $content, $characteristic);
265 $page = $this->page_gui->getPageObject();
270 if (!is_null($parent) && $parent->getType() ==
"sec" && $new_section_characteristic !=
"") {
271 $parent->setCharacteristic($new_section_characteristic);
272 $updated = $page->
update();
275 elseif ((is_null($parent) || $parent->getType() !=
"sec") && $old_section_characteristic ==
"" && $new_section_characteristic !=
"") {
276 $sec = new \ilPCSection($page);
278 $sec->create($page, $hier_ids[$pcid], $pcid);
279 $sec->setCharacteristic($new_section_characteristic);
281 $sec->writePCId($sec_pcid);
282 $updated = $page->
update();
287 $sec_node_pc_id = $sec->getDomNode()->firstChild->getAttribute(
"PCID");
289 $node = $par->getDomNode();
290 $node->parentNode->removeChild($node);
292 $updated = $page->
update();
294 elseif ((!is_null($parent) && $parent->getType() ==
"sec") && $old_section_characteristic !=
"" && $new_section_characteristic ==
"") {
296 $sec_node_pc_id = $parent->getDomNode()->getAttribute(
"PCID");
297 $sec_node_hier_id = $page->getHierIdForPCId($sec_node_pc_id);
299 $childs_reverse = array_reverse(iterator_to_array($parent->getDomNode()->firstChild->childNodes));
300 foreach ($childs_reverse as $child) {
302 $child->parentNode->removeChild($child);
307 $node = $parent->getDomNode();
308 $node->parentNode->removeChild($node);
309 $updated = $page->
update();
312 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
320 $page = $this->page_gui->getPageObject();
322 $updated = $this->updateParagraph(
323 $body[
"data"][
"previousPcid"],
324 $body[
"data"][
"newPreviousContent"],
325 $body[
"data"][
"previousCharacteristic"]
333 $this->page_gui->getPageConfig()->getEnableSelfAssessment()
335 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
346 $remove_section_for_pcid = $body[
"data"][
"removeSectionFromPcid"];
347 $par_text = $body[
"data"][
"paragraphText"];
348 $par_characteristic = $body[
"data"][
"paragraphCharacteristic"];
350 $page = $this->page_gui->getPageObject();
354 $parent_pc_id = $parent->getPCId();
359 if ($parent->getType() ==
"sec") {
360 $updated = $this->updateParagraph($remove_section_for_pcid, $par_text, $par_characteristic);
365 $updated = $page->
update();
374 $this->page_gui->getPageConfig()->getEnableSelfAssessment()
379 $updated = $page->
update();
382 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
390 $pcids = [$body[
"data"][
"pcid"]];
392 $page = $this->page_gui->getPageObject();
396 return $this->getIdForPCId($pcid);
404 $this->page_gui->getPageConfig()->getEnableSelfAssessment()
407 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
412 $page = $this->page_gui->getPageObject();
414 if (!in_array($pcid, [
"",
"pg"])) {
416 $id = $hier_ids[$pcid] .
":" . $pcid;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
deleteCommand(array $body)
Delete paragraph.
mergePrevious(array $body)
Merge with previous paragraph.
updateCommand(array $body, bool $auto=false)
getIdForPCId(string $pcid)
autoInsertCommand(array $body)
split(array $body, bool $auto=false)
cancelCommand(array $body)
Cancel paragraph.
__construct(\ilPageObjectGUI $page_gui)
insertCommand(array $body, bool $auto=false)
handle(array $query, array $body)
autoUpdateCommand(array $body)
ParagraphResponseFactory $response_factory
ilPageObjectGUI $page_gui
insertParagraph(string $pcid, string $after_pcid, string $content, string $characteristic, bool $from_placeholder=false)
Insert paragraph.
Server UIWrapper $ui_wrapper
updateParagraph(string $pcid, string $content, string $characteristic)
Update paragraph.
ilPCParagraph $content_obj
getFullIdForPCId(\ilPageObject $page, string $pc_id)
Get full id for pc id.
getContentForSaving(string $pcid, string $content, string $characteristic)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
insertContentNode(DOMNode $a_cont_node, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="")
insert a content node before/after a sibling or as first child of a parent
getContentObjectForPcId(string $pcid)
Get content object for pc id.
update(bool $a_validate=true, bool $a_no_history=false)
update complete page content in db (dom xml content is used)
deleteContents(array $a_hids, bool $a_update=true, bool $a_self_ass=false, bool $move_operation=false)
Delete multiple content objects.
getHierIdForPcId(string $pcid)
getParentContentObjectForPcId(string $pcid)
Get parent content object for pc id.
moveContentAfter(string $a_source, string $a_target, string $a_spcid="", string $a_tpcid="")
move content object from position $a_source before position $a_target (both hierarchical content ids)
addHierIDs()
Add hierarchical ID (e.g.
getHierIdsForPCIds(array $a_pc_ids)
Get hier ids for a set of pc ids.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...