ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
21  protected $current_plugin = null;
22 
27  function ilPCPluggedGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id,
28  $a_plugin_name = "", $a_pc_id = "")
29  {
30  global $ilCtrl;
31  $this->setPluginName($a_plugin_name);
32  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
33  }
34 
40  function setPluginName($a_pluginname)
41  {
42  $this->pluginname = $a_pluginname;
43  }
44 
50  function getPluginName()
51  {
52  return $this->pluginname;
53  }
54 
58  function &executeCommand()
59  {
60  global $ilPluginAdmin, $ilTabs, $lng, $ilCtrl;
61 
62  $ilTabs->setBackTarget($lng->txt("pg"), $ilCtrl->getLinkTarget($this, "returnToParent"));
63 
64  // get next class that processes or forwards current command
65  $next_class = $this->ctrl->getNextClass($this);
66 
67  // get all plugins and check, whether next class belongs to one
68  // of them, then forward
69  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE,
70  "COPage", "pgcp");
71  foreach ($pl_names as $pl_name)
72  {
73  if ($next_class == strtolower("il".$pl_name."plugingui"))
74  {
75  $plugin = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE,
76  "COPage", "pgcp", $pl_name);
77  $this->current_plugin = $plugin;
78  $this->setPluginName($pl_name);
79  $gui_obj = $plugin->getUIClassInstance();
80  $gui_obj->setPCGUI($this);
81  $ret = $this->ctrl->forwardCommand($gui_obj);
82  }
83  }
84 
85  // get current command
86  $cmd = $this->ctrl->getCmd();
87 
88  if ($next_class == "" || $next_class == "ilpcpluggedgui")
89  {
90  $ret = $this->$cmd();
91  }
92 
93  return $ret;
94  }
95 
99  function insert()
100  {
101  $this->edit(true);
102  }
103 
107  function edit($a_insert = false)
108  {
109  global $ilCtrl, $tpl, $lng, $ilPluginAdmin;
110 
111  $this->displayValidationError();
112 
113  // edit form
114  if ($a_insert)
115  {
116  $plugin_name = $this->getPluginName();
117  }
118  else
119  {
120  $plugin_name = $this->content_obj->getPluginName();
121  }
122  if ($ilPluginAdmin->isActive(IL_COMP_SERVICE, "COPage", "pgcp", $plugin_name))
123  {
124  $plugin_obj = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE, "COPage",
125  "pgcp", $plugin_name);
126  $gui_obj = $plugin_obj->getUIClassInstance();
127  $gui_obj->setPCGUI($this);
128  if ($a_insert)
129  {
130  $gui_obj->setMode(ilPageComponentPlugin::CMD_INSERT);
131  }
132  else
133  {
134  $gui_obj->setMode(ilPageComponentPlugin::CMD_EDIT);
135  }
136  $html = $ilCtrl->getHTML($gui_obj);
137  }
138 
139  $tpl->setContent($html);
140  }
141 
142 
146  function createElement(array $a_properties)
147  {
148  $this->content_obj = new ilPCPlugged($this->getPage());
149  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id,
150  $this->current_plugin->getPluginName(), $this->current_plugin->getVersion());
151  $this->content_obj->setProperties($a_properties);
152  $this->updated = $this->pg_obj->update();
153  if ($this->updated === true)
154  {
155  return true;
156  }
157  return false;
158  }
159 
163  function updateElement(array $a_properties)
164  {
165  $this->content_obj->setProperties($a_properties);
166  $this->content_obj->setPluginVersion($this->current_plugin->getVersion());
167  $this->updated = $this->pg_obj->update();
168  if ($this->updated === true)
169  {
170  return true;
171  }
172  return false;
173  }
174 
178  function returnToParent()
179  {
180  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
181  }
182 
183 }
184 ?>