ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCPluggedGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPCPlugged.php");
25 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26 
38 {
39 
44  function ilPCPluggedGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id,
45  $a_plugin_name = "", $a_pc_id = "")
46  {
47  global $ilCtrl;
48 
49  $this->setPluginName($a_plugin_name);
50  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
51 
52  if ($a_plugin_name != "")
53  {
54  $ilCtrl->setParameter($this, "plugin_name", rawurlencode($a_plugin_name));
55  }
56  $ilCtrl->saveParameter($this, "plugin_name");
57  }
58 
64  function setPluginName($a_pluginname)
65  {
66  $this->pluginname = $a_pluginname;
67  }
68 
74  function getPluginName()
75  {
76  return $this->pluginname;
77  }
78 
82  function &executeCommand()
83  {
84  // get next class that processes or forwards current command
85  $next_class = $this->ctrl->getNextClass($this);
86 
87  // get current command
88  $cmd = $this->ctrl->getCmd();
89 
90  switch($next_class)
91  {
92  default:
93  $ret =& $this->$cmd();
94  break;
95  }
96 
97  return $ret;
98  }
99 
103  function insert()
104  {
105  $this->edit(true);
106  }
107 
111  function edit($a_insert = false)
112  {
113  global $ilCtrl, $tpl, $lng, $ilPluginAdmin;
114 
115  $this->displayValidationError();
116 
117  // edit form
118  if ($a_insert)
119  {
120  $plugin_name = $this->getPluginName();
121  }
122  else
123  {
124  $plugin_name = $this->content_obj->getPluginName();
125  }
126  if ($ilPluginAdmin->isActive(IL_COMP_SERVICE, "COPage", "pgcp", $plugin_name))
127  {
128  $plugin_obj = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE, "COPage",
129  "pgcp", $plugin_name);
130  if ($a_insert)
131  {
132  $plugin_obj->setMode(ilPageComponentPlugin::CMD_INSERT);
133  }
134  else
135  {
136  $plugin_obj->setMode(ilPageComponentPlugin::CMD_EDIT);
137  }
138  $html = $ilCtrl->getHTML($plugin_obj);
139  }
140 
141  $tpl->setContent($html);
142  }
143 
144 
148  function create()
149  {
150  $this->content_obj = new ilPCPlugged($this->dom);
151  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
152  $properties = array(
153  "Table" => $_POST["table"]
154  );
155  $this->content_obj->setProperties($properties);
156  $this->updated = $this->pg_obj->update();
157  if ($this->updated === true)
158  {
159  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
160  }
161  else
162  {
163  $this->insert();
164  }
165  }
166 
170  function update()
171  {
172  $properties = array(
173  "Table" => $_POST["table"]);
174  $this->content_obj->setProperties($properties);
175  $this->updated = $this->pg_obj->update();
176  if ($this->updated === true)
177  {
178  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
179  }
180  else
181  {
182  $this->pg_obj->addHierIDs();
183  $this->edit();
184  }
185  }
186 }
187 ?>