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

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\MediaObject\MediaObjectCommandActionHandler::__construct ( \ilPageObjectGUI  $page_gui)

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

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
46 $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
47 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler\$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\MediaObject\MediaObjectCommandActionHandler::handle ( array  $query,
array  $body 
)

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

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 default:
59 throw new Exception("Unknown action " . $body["action"]);
60 }
61 }

References ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler\insertCommand().

+ Here is the call graph for this function:

◆ insertCommand()

ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler::insertCommand ( array  $body)
protected

Definition at line 63 of file class.MediaObjectCommandActionHandler.php.

63 : Server\Response
64 {
65 $page = $this->page_gui->getPageObject();
67
68 $hier_id = "pg";
69 $pc_id = "";
70 if (!in_array($body["after_pcid"], ["", "pg"])) {
71 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
72 $hier_id = $hier_ids[$body["after_pcid"]];
73 $pc_id = $body["after_pcid"];
74 }
75
76
77 // if (!$mob_gui->checkFormInput()) {
78 $pc_media = new \ilPCMediaObject($page);
79 $pc_media->createMediaObject();
80 $mob = $pc_media->getMediaObject();
81
82 $mob_gui = new \ilObjMediaObjectGUI("");
83 $mob_gui->initForm("create");
84 $ok = false;
85 $error = "";
86 if ($mob_gui->checkFormInput()) {
87 $ok = true;
88 try {
89 $mob_gui->setObjectPerCreationForm($mob);
90 } catch (\Exception $e) {
91 $ok = false;
92 $error = $e->getMessage();
93 }
94 $media_item = $mob->getMediaItem("Standard");
95 if (!is_null($media_item)) {
96 $pc_media->createAlias($page, $hier_id, $pc_id);
97 }
98 $updated = $page->update();
99 }
100 if (!$ok) {
101 if ($mob_gui->getForm()->getInput("standard_type") === "File") {
102 $edit_gui = new \ilPCMediaObjectEditorGUI();
103 $form = $edit_gui->getUploadForm($lng);
104 if ($error !== "") {
105 $input = $form->getItemByPostVar("standard_file");
106 $input->setAlert($error);
107 }
108 $form->checkInput();
109 $form->setValuesByPost();
110 $rendered_form = $edit_gui->getRenderedUploadForm(
111 $this->ui_wrapper,
112 $lng,
113 $form
114 );
115 return $this->ui_wrapper->sendFormError($rendered_form);
116 } else {
117 $edit_gui = new \ilPCMediaObjectEditorGUI();
118 $form = $edit_gui->getUrlForm($lng);
119 $form->checkInput();
120 $form->setValuesByPost();
121 $rendered_form = $edit_gui->getRenderedUrlForm(
122 $this->ui_wrapper,
123 $lng,
124 $form
125 );
126 return $this->ui_wrapper->sendFormError($rendered_form);
127 }
128 }
129
130
131 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
132 }
ilErrorHandling $error
Definition: class.ilias.php:69

References Vendor\Package\$e, ILIAS\$error, and ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler\$lng.

Referenced by ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler\handle().

+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilLanguage ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler::$lng
protected

◆ $page_gui

ilPageObjectGUI ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler::$page_gui
protected

◆ $ui

ILIAS DI UIServices ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler::$ui
protected

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

◆ $ui_wrapper

Server UIWrapper ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler::$ui_wrapper
protected

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

◆ $user

ilObjUser ILIAS\COPage\PC\MediaObject\MediaObjectCommandActionHandler::$user
protected

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


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