ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler Class Reference
+ Inheritance diagram for ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler:
+ Collaboration diagram for ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler:

Public Member Functions

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

Protected Member Functions

 insertCommand (array $body)
 

Protected Attributes

ILIAS DI UIServices $ui
 
ilLanguage $lng
 
ilPageObjectGUI $page_gui
 
ilObjUser $user
 
Server UIWrapper $ui_wrapper
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::__construct ( \ilPageObjectGUI  $page_gui)

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

36 {
37 global $DIC;
38
39 $this->ui = $DIC->ui();
40 $this->lng = $DIC->language();
41 $this->page_gui = $page_gui;
42 $this->user = $DIC->user();
43
44 $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
45 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ handle()

ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::handle ( array  $query,
array  $body 
)

Definition at line 47 of file class.SourceCodeCommandActionHandler.php.

47 : Server\Response
48 {
49 switch ($body["action"]) {
50 case "insert":
51 return $this->insertCommand($body);
52
53 case "update":
54 return $this->updateCommand($body);
55
56 default:
57 throw new Exception("Unknown action " . $body["action"]);
58 }
59 }

References ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler\insertCommand().

+ Here is the call graph for this function:

◆ insertCommand()

ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::insertCommand ( array  $body)
protected

Definition at line 61 of file class.SourceCodeCommandActionHandler.php.

61 : Server\Response
62 {
63 $page = $this->page_gui->getPageObject();
64
65 $hier_id = "pg";
66 $pc_id = "";
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"];
71 }
72 $manual = ((string) ($body["form/input_0"] ?? "") === "manual");
73
74 $src = new \ilPCSourceCode($page);
75 $src->create($page, $hier_id, $pc_id);
76 if (($body["pcid"] ?? "") !== "") {
77 $src->writePCId($body["pcid"]);
78 }
79 $src_gui = new \ilPCSourceCodeGUI($page, $src, "", "");
80 $src_gui->setPageConfig($page->getPageConfig());
81 $src->setLanguage($this->user->getLanguage());
82 $src->setCharacteristic('Code');
83
84 $updated = true;
85
86 if ($manual) {
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();
93 }
94 } else {
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();
102 }
103 }
104
105 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
106 }

References ILIAS\Repository\user().

Referenced by ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler\handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilLanguage ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::$lng
protected

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

◆ $page_gui

ilPageObjectGUI ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::$page_gui
protected

◆ $ui

ILIAS DI UIServices ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::$ui
protected

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

◆ $ui_wrapper

Server UIWrapper ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::$ui_wrapper
protected

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

◆ $user

ilObjUser ILIAS\COPage\PC\SourceCode\SourceCodeCommandActionHandler::$user
protected

Definition at line 32 of file class.SourceCodeCommandActionHandler.php.


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