ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCPluggedGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected string $pluginname = "";
27 protected ilTabsGUI $tabs;
31
32 public function __construct(
33 ilPageObject $a_pg_obj,
34 ?ilPageContent $a_content_obj,
35 string $a_hier_id,
36 string $a_plugin_name = "",
37 string $a_pc_id = ""
38 ) {
39 global $DIC;
40
41 $this->ctrl = $DIC->ctrl();
42 $this->component_repository = $DIC["component.repository"];
43 $this->component_factory = $DIC["component.factory"];
44 $this->tabs = $DIC->tabs();
45 $this->lng = $DIC->language();
46 $this->tpl = $DIC["tpl"];
47
48 $this->setPluginName($a_plugin_name);
49 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
50 }
51
52 public function setPluginName(string $a_pluginname): void
53 {
54 $this->pluginname = $a_pluginname;
55 }
56
57 public function getPluginName(): string
58 {
59 return $this->pluginname;
60 }
61
66 public function executeCommand()
67 {
68 $ilTabs = $this->tabs;
70 $ilCtrl = $this->ctrl;
71 $ret = "";
72
73 $ilTabs->setBackTarget($lng->txt("pg"), $ilCtrl->getLinkTarget($this, "returnToParent"));
74
75 // get next class that processes or forwards current command
76 $next_class = $this->ctrl->getNextClass($this);
77
78 // get all plugins and check, whether next class belongs to one
79 // of them, then forward
80 $plugins = $this->component_repository->getPluginSlotById("pgcp")->getActivePlugins();
81 foreach ($plugins as $pl) {
82 $pl_name = $pl->getName();
83 if ($next_class == strtolower("il" . $pl_name . "plugingui")) {
84 $plugin = $this->component_factory->getPlugin($pl->getId());
85 $plugin->setPageObj($this->getPage());
86 $this->current_plugin = $plugin;
87 $this->setPluginName($pl_name);
88 $gui_obj = $plugin->getUIClassInstance();
89 $gui_obj->setPCGUI($this);
90 $ret = $this->ctrl->forwardCommand($gui_obj);
91 }
92 }
93
94 // get current command
95 $cmd = $this->ctrl->getCmd();
96
97 if ($next_class == "" || $next_class == "ilpcpluggedgui") {
98 $ret = $this->$cmd();
99 }
100
101 return $ret;
102 }
103
104 public function insert(): void
105 {
106 $this->edit(true);
107 }
108
109 public function edit(bool $a_insert = false): void
110 {
111 $ilCtrl = $this->ctrl;
113 $html = "";
114
115 $this->displayValidationError();
116
117 // edit form
118 if ($a_insert) {
119 $plugin_name = $this->getPluginName();
120 } else {
121 $plugin_name = $this->content_obj->getPluginName();
122 }
123 $plugin = $this->component_repository->getPluginByName($plugin_name);
124 if ($plugin->isActive()) {
125 $plugin_obj = $this->component_factory->getPlugin($plugin->getId());
126 $plugin_obj->setPageObj($this->getPage());
127 $gui_obj = $plugin_obj->getUIClassInstance();
128 $gui_obj->setPCGUI($this);
129 if ($a_insert) {
130 $gui_obj->setMode(ilPageComponentPlugin::CMD_INSERT);
131 } else {
132 $gui_obj->setMode(ilPageComponentPlugin::CMD_EDIT);
133 }
134 $html = $ilCtrl->getHTML($gui_obj);
135 }
136
137 if ($html != "") {
138 $tpl->setContent($html);
139 }
140 }
141
142 public function createElement(array $a_properties): bool
143 {
144 $this->content_obj = new ilPCPlugged($this->getPage());
145 $this->content_obj->create(
146 $this->pg_obj,
147 $this->hier_id,
148 $this->pc_id,
149 $this->current_plugin->getPluginName(),
150 $this->current_plugin->getVersion()
151 );
152 $this->content_obj->setProperties($a_properties);
153 $this->updated = $this->pg_obj->update();
154 if ($this->updated === true) {
155 return true;
156 }
157 return false;
158 }
159
160 public function updateElement(array $a_properties): bool
161 {
162 $this->content_obj->setProperties($a_properties);
163 $this->content_obj->setPluginVersion($this->current_plugin->getVersion());
164 $this->updated = $this->pg_obj->update();
165 if ($this->updated === true) {
166 return true;
167 }
168 return false;
169 }
170
171 public function returnToParent(): void
172 {
173 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
174 }
175}
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilComponentRepository $component_repository
ilComponentFactory $component_factory
edit(bool $a_insert=false)
createElement(array $a_properties)
setPluginName(string $a_pluginname)
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_plugin_name="", string $a_pc_id="")
updateElement(array $a_properties)
ilPageComponentPlugin $current_plugin
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...
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
ilGlobalTemplateInterface $tpl
Content object of ilPageObject (see ILIAS DTD).
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
Readable part of repository interface to ilComponentDataDB.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26