ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCPluggedGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 require_once("./Services/COPage/classes/class.ilPCPlugged.php");
7 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
8 
20 {
24  protected $plugin_admin;
25 
29  protected $tabs;
30 
31  protected $current_plugin = null;
32 
37  public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_plugin_name = "", $a_pc_id = "")
38  {
39  global $DIC;
40 
41  $this->ctrl = $DIC->ctrl();
42  $this->plugin_admin = $DIC["ilPluginAdmin"];
43  $this->tabs = $DIC->tabs();
44  $this->lng = $DIC->language();
45  $this->tpl = $DIC["tpl"];
46 
47  $this->setPluginName($a_plugin_name);
48  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
49  }
50 
56  public function setPluginName($a_pluginname)
57  {
58  $this->pluginname = $a_pluginname;
59  }
60 
66  public function getPluginName()
67  {
68  return $this->pluginname;
69  }
70 
74  public function executeCommand()
75  {
76  $ilPluginAdmin = $this->plugin_admin;
77  $ilTabs = $this->tabs;
78  $lng = $this->lng;
80 
81  $ilTabs->setBackTarget($lng->txt("pg"), $ilCtrl->getLinkTarget($this, "returnToParent"));
82 
83  // get next class that processes or forwards current command
84  $next_class = $this->ctrl->getNextClass($this);
85 
86  // get all plugins and check, whether next class belongs to one
87  // of them, then forward
88  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
90  "COPage",
91  "pgcp"
92  );
93  foreach ($pl_names as $pl_name) {
94  if ($next_class == strtolower("il" . $pl_name . "plugingui")) {
95  $plugin = $ilPluginAdmin->getPluginObject(
97  "COPage",
98  "pgcp",
99  $pl_name
100  );
101  $plugin->setPageObj($this->getPage());
102  $this->current_plugin = $plugin;
103  $this->setPluginName($pl_name);
104  $gui_obj = $plugin->getUIClassInstance();
105  $gui_obj->setPCGUI($this);
106  $ret = $this->ctrl->forwardCommand($gui_obj);
107  }
108  }
109 
110  // get current command
111  $cmd = $this->ctrl->getCmd();
112 
113  if ($next_class == "" || $next_class == "ilpcpluggedgui") {
114  $ret = $this->$cmd();
115  }
116 
117  return $ret;
118  }
119 
123  public function insert()
124  {
125  $this->edit(true);
126  }
127 
131  public function edit($a_insert = false)
132  {
134  $tpl = $this->tpl;
135  $lng = $this->lng;
136  $ilPluginAdmin = $this->plugin_admin;
137 
138  $this->displayValidationError();
139 
140  // edit form
141  if ($a_insert) {
142  $plugin_name = $this->getPluginName();
143  } else {
144  $plugin_name = $this->content_obj->getPluginName();
145  }
146  if ($ilPluginAdmin->isActive(IL_COMP_SERVICE, "COPage", "pgcp", $plugin_name)) {
147  $plugin_obj = $ilPluginAdmin->getPluginObject(
149  "COPage",
150  "pgcp",
151  $plugin_name
152  );
153  $plugin_obj->setPageObj($this->getPage());
154  $gui_obj = $plugin_obj->getUIClassInstance();
155  $gui_obj->setPCGUI($this);
156  if ($a_insert) {
157  $gui_obj->setMode(ilPageComponentPlugin::CMD_INSERT);
158  } else {
159  $gui_obj->setMode(ilPageComponentPlugin::CMD_EDIT);
160  }
161  $html = $ilCtrl->getHTML($gui_obj);
162  }
163 
164  $tpl->setContent($html);
165  }
166 
167 
171  public function createElement(array $a_properties)
172  {
173  $this->content_obj = new ilPCPlugged($this->getPage());
174  $this->content_obj->create(
175  $this->pg_obj,
176  $this->hier_id,
177  $this->pc_id,
178  $this->current_plugin->getPluginName(),
179  $this->current_plugin->getVersion()
180  );
181  $this->content_obj->setProperties($a_properties);
182  $this->updated = $this->pg_obj->update();
183  if ($this->updated === true) {
184  return true;
185  }
186  return false;
187  }
188 
192  public function updateElement(array $a_properties)
193  {
194  $this->content_obj->setProperties($a_properties);
195  $this->content_obj->setPluginVersion($this->current_plugin->getVersion());
196  $this->updated = $this->pg_obj->update();
197  if ($this->updated === true) {
198  return true;
199  }
200  return false;
201  }
202 
206  public function returnToParent()
207  {
208  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
209  }
210 }
createElement(array $a_properties)
Create new element.
setPluginName($a_pluginname)
Set PluginName.
global $DIC
Definition: saml.php:7
Class ilPCPluggedGUI.
Class ilPCPlugged Plugged content object (see ILIAS DTD)
global $ilCtrl
Definition: ilias.php:18
updateElement(array $a_properties)
Update element.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_plugin_name="", $a_pc_id="")
Constructor public.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
returnToParent()
Return to parent.
edit($a_insert=false)
Edit section form.
executeCommand()
execute command
insert()
Insert new section form.
$ret
Definition: parser.php:6
getPluginName()
Get PluginName.
$html
Definition: example_001.php:87
const IL_COMP_SERVICE