ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler Class Reference
+ Inheritance diagram for ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler:
+ Collaboration diagram for ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler:

Public Member Functions

 __construct (\ilPageObjectGUI $page_gui)
 
 handle (array $query, array $body)
 

Protected Member Functions

 insertCommand (array $body, bool $auto=false)
 
 insertParagraph (string $pcid, string $after_pcid, string $content, string $characteristic, bool $from_placeholder=false)
 Insert paragraph. More...
 
 autoInsertCommand (array $body)
 
 updateCommand (array $body, bool $auto=false)
 
 updateParagraph (string $pcid, string $content, string $characteristic)
 Update paragraph. More...
 
 autoUpdateCommand (array $body)
 
 split (array $body, bool $auto=false)
 
 getFullIdForPCId (\ilPageObject $page, string $pc_id)
 Get full id for pc id. More...
 
 getContentForSaving (string $pcid, string $content, string $characteristic)
 
 mergePrevious (array $body)
 Merge with previous paragraph. More...
 
 cancelCommand (array $body)
 Cancel paragraph. More...
 
 deleteCommand (array $body)
 Delete paragraph. More...
 
 getIdForPCId (string $pcid)
 

Protected Attributes

ilPCParagraph $content_obj
 
ILIAS DI UIServices $ui
 
ilLanguage $lng
 
ilPageObjectGUI $page_gui
 
ilObjUser $user
 
ParagraphResponseFactory $response_factory
 
Server UIWrapper $ui_wrapper
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 27 of file class.ParagraphCommandActionHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::__construct ( \ilPageObjectGUI  $page_gui)

Definition at line 37 of file class.ParagraphCommandActionHandler.php.

References $DIC, ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\$page_gui, ILIAS\Repository\lng(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

38  {
39  global $DIC;
40 
41  $this->ui = $DIC->ui();
42  $this->lng = $DIC->language();
43  $this->page_gui = $page_gui;
44  $this->user = $DIC->user();
45  $this->response_factory = new ParagraphResponseFactory();
46  $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
47  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ autoInsertCommand()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::autoInsertCommand ( array  $body)
protected

Definition at line 123 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\insertCommand().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

125  : Server\Response {
126  return $this->insertCommand($body, true);
127  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ autoUpdateCommand()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::autoUpdateCommand ( array  $body)
protected

Definition at line 161 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateCommand().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

161  : Server\Response
162  {
163  return $this->updateCommand($body, true);
164  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelCommand()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::cancelCommand ( array  $body)
protected

Cancel paragraph.

Exceptions

Definition at line 344 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateParagraph().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

344  : Server\Response
345  {
346  $remove_section_for_pcid = $body["data"]["removeSectionFromPcid"];
347  $par_text = $body["data"]["paragraphText"];
348  $par_characteristic = $body["data"]["paragraphCharacteristic"];
349 
350  $page = $this->page_gui->getPageObject();
351  $page->addHierIDs();
352  $paragraph = $page->getContentObjectForPcId($remove_section_for_pcid);
353  $parent = $page->getParentContentObjectForPcId($remove_section_for_pcid);
354  $parent_pc_id = $parent->getPCId();
355 
356  $updated = true;
357 
358  // case 1: parent section exists and new characteristic is not empty
359  if ($parent->getType() == "sec") {
360  $updated = $this->updateParagraph($remove_section_for_pcid, $par_text, $par_characteristic);
361 
362  if ($updated) {
363  $page->addHierIDs();
364  $page->moveContentAfter($paragraph->getHierId(), $parent->getHierId());
365  $updated = $page->update();
366  }
367 
368  if ($updated) {
369  $page->addHierIDs();
370  $hid = $page->getHierIdForPcId($parent_pc_id);
371  $updated = $page->deleteContents(
372  [$hid],
373  true,
374  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
375  );
376  }
377 
378  if ($updated) {
379  $updated = $page->update();
380  }
381  }
382  return $this->ui_wrapper->sendPage($this->page_gui, $updated);
383  }
updateParagraph(string $pcid, string $content, string $characteristic)
Update paragraph.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteCommand()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::deleteCommand ( array  $body)
protected

Delete paragraph.

Definition at line 388 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getIdForPCId().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

388  : Server\Response
389  {
390  $pcids = [$body["data"]["pcid"]];
391 
392  $page = $this->page_gui->getPageObject();
393 
394  $hids = array_map(
395  function ($pcid) {
396  return $this->getIdForPCId($pcid);
397  },
398  $pcids
399  );
400 
401  $updated = $page->deleteContents(
402  $hids,
403  true,
404  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
405  );
406 
407  return $this->ui_wrapper->sendPage($this->page_gui, $updated);
408  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContentForSaving()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::getContentForSaving ( string  $pcid,
string  $content,
string  $characteristic 
)
protected

Definition at line 228 of file class.ParagraphCommandActionHandler.php.

References IL_INSERT_AFTER, IL_INSERT_CHILD, ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\insertParagraph(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateParagraph().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\insertParagraph(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\split(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateParagraph().

232  : string {
233  $content = str_replace(" ", " ", $content);
234  return "<div id='" .
235  $pcid . "' class='ilc_text_block_" .
236  $characteristic . "'>" . $content . "</div>";
237  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFullIdForPCId()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::getFullIdForPCId ( \ilPageObject  $page,
string  $pc_id 
)
protected

Get full id for pc id.

Definition at line 216 of file class.ParagraphCommandActionHandler.php.

References $id, and ilPageObject\getHierIdsForPCIds().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\insertParagraph(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\split(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateParagraph().

219  : string {
220  $id = "pg:";
221  if (!in_array($pc_id, ["", "pg"])) {
222  $hier_ids = $page->getHierIdsForPCIds([$pc_id]);
223  $id = ($hier_ids[$pc_id] ?? "") . ":" . $pc_id;
224  }
225  return $id;
226  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdForPCId()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::getIdForPCId ( string  $pcid)
protected

Definition at line 410 of file class.ParagraphCommandActionHandler.php.

References $id.

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\deleteCommand().

410  : string
411  {
412  $page = $this->page_gui->getPageObject();
413  $id = "pg:";
414  if (!in_array($pcid, ["", "pg"])) {
415  $hier_ids = $page->getHierIdsForPCIds([$pcid]);
416  $id = $hier_ids[$pcid] . ":" . $pcid;
417  }
418  return $id;
419  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ handle()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::handle ( array  $query,
array  $body 
)

Definition at line 49 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\autoInsertCommand(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\autoUpdateCommand(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\cancelCommand(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\deleteCommand(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\insertCommand(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\mergePrevious(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\split(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateCommand().

49  : Server\Response
50  {
51  switch ($body["action"]) {
52  case "insert":
53  return $this->insertCommand($body);
54 
55  case "update":
56  return $this->updateCommand($body);
57 
58  case "update.auto":
59  return $this->autoUpdateCommand($body);
60 
61  case "insert.auto":
62  return $this->autoInsertCommand($body);
63 
64  case "split":
65  return $this->split($body);
66 
67  case "cmd.sec.class":
68  return $this->sectionClassCommand($body);
69 
70  case "cmd.merge.previous":
71  return $this->mergePrevious($body);
72 
73  case "cmd.cancel":
74  return $this->cancelCommand($body);
75 
76  case "delete":
77  return $this->deleteCommand($body);
78 
79  default:
80  throw new Exception("Unknown action " . $body["action"]);
81  }
82  }
+ Here is the call graph for this function:

◆ insertCommand()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::insertCommand ( array  $body,
bool  $auto = false 
)
protected

Definition at line 84 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\insertParagraph().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\autoInsertCommand(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

87  : Server\Response {
88  $updated = $this->insertParagraph($body["data"]["pcid"], $body["data"]["after_pcid"], $body["data"]["content"], $body["data"]["characteristic"], $body["data"]["fromPlaceholder"]);
89 
90  return $this->response_factory->getResponseObject($this->page_gui, $updated, $body["data"]["pcid"]);
91  }
insertParagraph(string $pcid, string $after_pcid, string $content, string $characteristic, bool $from_placeholder=false)
Insert paragraph.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertParagraph()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::insertParagraph ( string  $pcid,
string  $after_pcid,
string  $content,
string  $characteristic,
bool  $from_placeholder = false 
)
protected

Insert paragraph.

Returns
array|bool|string
Exceptions

Definition at line 99 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getContentForSaving(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getFullIdForPCId(), and ilUtil\stripSlashes().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getContentForSaving(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\insertCommand().

105  {
106  $page = $this->page_gui->getPageObject();
107 
108  $pcid = ":" . $pcid;
109  $insert_id = $this->getFullIdForPCId($page, $after_pcid);
110  $content = $this->getContentForSaving($pcid, $content, $characteristic);
111 
112  $this->content_obj = new \ilPCParagraph($page);
113  return $this->content_obj->saveJS(
114  $page,
115  $content,
116  \ilUtil::stripSlashes($characteristic),
117  \ilUtil::stripSlashes($pcid),
118  $insert_id,
119  $from_placeholder
120  );
121  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getFullIdForPCId(\ilPageObject $page, string $pc_id)
Get full id for pc id.
getContentForSaving(string $pcid, string $content, string $characteristic)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mergePrevious()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::mergePrevious ( array  $body)
protected

Merge with previous paragraph.

Definition at line 318 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateParagraph().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

318  : Server\Response
319  {
320  $page = $this->page_gui->getPageObject();
321 
322  $updated = $this->updateParagraph(
323  $body["data"]["previousPcid"],
324  $body["data"]["newPreviousContent"],
325  $body["data"]["previousCharacteristic"]
326  );
327 
328  $page->addHierIDs();
329  $hier_id = $page->getHierIdForPcId($body["data"]["pcid"]);
330  $updated = $page->deleteContents(
331  [$hier_id],
332  true,
333  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
334  );
335  return $this->ui_wrapper->sendPage($this->page_gui, $updated);
336  }
updateParagraph(string $pcid, string $content, string $characteristic)
Update paragraph.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ split()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::split ( array  $body,
bool  $auto = false 
)
protected

Definition at line 166 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getContentForSaving(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getFullIdForPCId(), and ilUtil\stripSlashes().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

169  : Server\Response {
170  $page = $this->page_gui->getPageObject();
171 
172  $pcid = ":" . $body["data"]["pcid"];
173  $insert_id = "";
174  if ($body["data"]["insert_mode"]) {
175  $insert_id = $this->getFullIdForPCId($page, $body["data"]["after_pcid"]);
176  }
177 
178  $content = $this->getContentForSaving($pcid, $body["data"]["text"], $body["data"]["characteristic"]);
179 
180  $content_obj = new \ilPCParagraph($page);
181  $updated = $content_obj->saveJS(
182  $page,
183  $content,
184  \ilUtil::stripSlashes($body["data"]["characteristic"]),
185  \ilUtil::stripSlashes($pcid),
186  $insert_id,
187  $body["data"]["fromPlaceholder"] ?? false
188  );
189  $current_after_id = $body["data"]["pcid"];
190  $all_pc_ids[] = $current_after_id;
191 
192  foreach ($body["data"]["new_paragraphs"] as $p) {
193  if ($updated === true) {
194  $page->addHierIDs();
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(
199  $page,
200  $content,
201  \ilUtil::stripSlashes($p["model"]["characteristic"]),
202  ":" . \ilUtil::stripSlashes($p["pcid"]),
203  $insert_id
204  );
205  $all_pc_ids[] = $p["pcid"];
206  $current_after_id = $p["pcid"];
207  }
208  }
209 
210  return $this->response_factory->getResponseObjectMulti($this->page_gui, $updated, $all_pc_ids);
211  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getFullIdForPCId(\ilPageObject $page, string $pc_id)
Get full id for pc id.
saveJS(ilPageObject $a_pg_obj, string $a_content, string $a_char, string $a_pc_id, string $a_insert_at="", bool $from_placeholder=false)
Save input coming from ajax.
getContentForSaving(string $pcid, string $content, string $characteristic)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCommand()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::updateCommand ( array  $body,
bool  $auto = false 
)
protected

Definition at line 129 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateParagraph().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\autoUpdateCommand(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\handle().

132  : Server\Response {
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"]);
135  }
updateParagraph(string $pcid, string $content, string $characteristic)
Update paragraph.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateParagraph()

ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::updateParagraph ( string  $pcid,
string  $content,
string  $characteristic 
)
protected

Update paragraph.

Returns
array|bool|string
Exceptions

Definition at line 143 of file class.ParagraphCommandActionHandler.php.

References ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getContentForSaving(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getFullIdForPCId(), and ilUtil\stripSlashes().

Referenced by ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\cancelCommand(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\getContentForSaving(), ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\mergePrevious(), and ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler\updateCommand().

147  {
148  $page = $this->page_gui->getPageObject();
149 
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(
154  $page,
155  $content,
156  \ilUtil::stripSlashes($characteristic),
157  \ilUtil::stripSlashes($pcid)
158  );
159  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getFullIdForPCId(\ilPageObject $page, string $pc_id)
Get full id for pc id.
getContentForSaving(string $pcid, string $content, string $characteristic)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $content_obj

ilPCParagraph ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::$content_obj
protected

Definition at line 29 of file class.ParagraphCommandActionHandler.php.

◆ $lng

ilLanguage ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::$lng
protected

Definition at line 31 of file class.ParagraphCommandActionHandler.php.

◆ $page_gui

ilPageObjectGUI ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::$page_gui
protected

◆ $response_factory

ParagraphResponseFactory ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::$response_factory
protected

Definition at line 34 of file class.ParagraphCommandActionHandler.php.

◆ $ui

ILIAS DI UIServices ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::$ui
protected

Definition at line 30 of file class.ParagraphCommandActionHandler.php.

◆ $ui_wrapper

Server UIWrapper ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::$ui_wrapper
protected

Definition at line 35 of file class.ParagraphCommandActionHandler.php.

◆ $user

ilObjUser ILIAS\COPage\PC\Paragraph\ParagraphCommandActionHandler::$user
protected

Definition at line 33 of file class.ParagraphCommandActionHandler.php.


The documentation for this class was generated from the following file: