ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCPlaceHolderGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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.ilPCPlaceHolder.php");
25 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26 
42 {
47  var $pg_obj;
49  var $hier_id;
50  var $pc_id;
51  var $styleid;
52 
53  function ilPCPlaceHolderGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
54  {
55  $this->pg_obj = $a_pg_obj;
56  $this->content_obj = $a_content_obj;
57  $this->hier_id = $a_hier_id;
58  $this->pc_id = $a_pc_id;
59 
60  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
61  }
62 
63 
67  function &executeCommand()
68  {
69  global $ilCtrl;
70 
71  // get next class that processes or forwards current command
72  $next_class = $this->ctrl->getNextClass($this);
73  // get current command
74  $cmd = $this->ctrl->getCmd();
75 
76  switch($next_class)
77  {
78  case 'ilpcmediaobjectgui': //special handling
79  include_once("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
80  $media_gui = new ilPCMediaObjectGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
81  $ret = $ilCtrl->forwardCommand($media_gui);
82  break;
83 
84  default:
85  $ret =& $this->$cmd();
86  break;
87  }
88 
89 
90  return $ret;
91  }
92 
93 
98  function insert() {
99  $this->propertyGUI("create","Text","100px","insert");
100  }
101 
102 
106  function create()
107  {
108  if ($_POST["plach_height"]=="" || !preg_match("/[0-9]+/",$_POST["plach_height"])) {
109  return $this->insert();
110  exit;
111  }
112 
113  $this->content_obj = new ilPCPlaceHolder($this->dom);
114  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
115  $this->content_obj->setHeight($_POST["plach_height"]."px");
116  $this->content_obj->setContentClass($_POST['plach_type']);
117  $this->updated = $this->pg_obj->update();
118  if ($this->updated === true)
119  {
120  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
121  }
122  else
123  {
124  $this->insert();
125  }
126  }
127 
132  function edit() {
133 
134  if ($this->pg_obj->getLayoutMode() == true) {
135  $this->edit_object();
136  } else {
137  $this->forward_edit();
138  }
139  }
140 
146  function setStyleId($a_styleid)
147  {
148  $this->styleid = $a_styleid;
149  }
150 
156  function getStyleId()
157  {
158  return $this->styleid;
159  }
160 
161 
166  private function edit_object() {
167  $this->propertyGUI("saveProperties",$this->content_obj->getContentClass(),$this->content_obj->getHeight(),"save");
168  }
169 
170 
171  private function forward_edit() {
172  global $ilCtrl;
173 
174  switch ($this->content_obj->getContentClass()) {
175  case 'Media':
176  include_once("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
177  $ilCtrl->setCmdClass("ilpcmediaobjectgui");
178  $ilCtrl->setCmd("insert");
179  $media_gui = new ilPCMediaObjectGUI($this->pg_obj,$null);
180  $ret = $ilCtrl->forwardCommand($media_gui);
181 
182  break;
183  case 'Text':
184  $this->textCOSelectionGUI();
185  break;
186  case 'Question':
187  include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
188  $ilCtrl->setCmdClass("ilpcquestiongui");
189  $ilCtrl->setCmd("insert");
190  $question_gui = new ilPCQuestionGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
191  $question_gui -> setSelfAssessmentMode(true);
192  $ret = $ilCtrl->forwardCommand($question_gui);
193  break;
194  default:
195  break;
196  }
197  }
198 
199 
203  function saveProperties()
204  {
205 
206  if ($_POST["plach_height"]=="" || !preg_match("/[0-9]+/",$_POST["plach_height"])) {
207  return $this->edit_object();
208  exit;
209  }
210 
211  $this->content_obj->setContentClass($_POST['plach_type']);
212  $this->content_obj->setHeight($_POST["plach_height"]."px");
213 
214  $this->updated = $this->pg_obj->update();
215  if ($this->updated === true)
216  {
217  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
218  }
219  else
220  {
221  $this->pg_obj->addHierIDs();
222  $this->edit();
223  }
224  }
225 
229  private function propertyGUI($a_action,$a_type,$a_height,$a_mode) {
230  global $ilCtrl, $lng;
231 
232  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
233  $this->form_gui = new ilPropertyFormGUI();
234  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
235  $this->form_gui->setTitle($lng->txt("cont_ed_plachprop"));
236 
237  include_once("Services/Form/classes/class.ilRadioMatrixInputGUI.php");
238  $ttype_input = new ilRadioMatrixInputGUI($lng->txt("type"), "plach_type");
239  $options =array("Text"=>$lng->txt("cont_ed_plachtext"),"Media"=>$lng->txt("cont_ed_plachmedia"),
240  "Question"=>$lng->txt("cont_ed_plachquestion"));
241  $ttype_input->setOptions($options);
242  $ttype_input->setValue($a_type);
243  $ttype_input->setRequired(true);
244  $theight_input = new ilTextInputGUI($lng->txt("height"),"plach_height");
245  $theight_input->setSize(4);
246  $theight_input->setMaxLength(3);
247 
248  $a_height = preg_replace("/px/","",$a_height);
249  $theight_input->setValue($a_height);
250  $theight_input->setTitle($lng->txt("height")." (px)");
251  $theight_input->setRequired(true);
252 
253  $this->form_gui->addItem($ttype_input);
254  $this->form_gui->addItem($theight_input);
255 
256  $this->form_gui->addCommandButton($a_action, $lng->txt($a_mode));
257  $this->form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
258  $this->tpl->setContent($this->form_gui->getHTML());
259  }
260 
265  private function textCOSelectionGUI() {
266 
267  global $ilCtrl, $lng;
268 
269  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
270  $this->form_gui = new ilPropertyFormGUI();
271  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
272  $this->form_gui->setTitle($lng->txt("cont_ed_select_pctext"));
273 
274  // Select Question Type
275 
276  include_once("Services/Form/classes/class.ilRadioMatrixInputGUI.php");
277  $ttype_input = new ilRadioMatrixInputGUI($lng->txt("cont_ed_textitem"), "pctext_type");
278  $options = array($lng->txt("cont_ed_par"),$lng->txt("cont_ed_dtable"),
279  $lng->txt("cont_ed_atable"),$lng->txt("cont_ed_list"),$lng->txt("cont_ed_flist"));
280  $ttype_input->setOptions($options);
281  $this->form_gui->addItem($ttype_input);
282 
283  $this->form_gui->addCommandButton("insertPCText", $lng->txt("insert"));
284  $this->form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
285  $this->tpl->setContent($this->form_gui->getHTML());
286  }
287 
292  function insertPCText() {
293 
294  global $ilCtrl;
295  switch ($_POST['pctext_type']) {
296 
297  case '0': //Paragraph / Text
298  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
299  $ilCtrl->setCmdClass("ilpcparagraphgui");
300  $ilCtrl->setCmd("insert");
301  $paragraph_gui = new ilPCParagraphGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
302  $paragraph_gui->setStyleId($this->getStyleId());
303  $paragraph_gui->setEnableInternalLinks($this->getEnableInternalLinks());
304  $paragraph_gui->setEnableKeywords($this->getEnableKeywords());
305  $paragraph_gui->setEnableAnchors($this->getEnableAnchors());
306  $ret = $ilCtrl->forwardCommand($paragraph_gui);
307  break;
308 
309  case '1': //DataTable
310  include_once("./Services/COPage/classes/class.ilPCDataTableGUI.php");
311  $ilCtrl->setCmdClass("ilpcdatatablegui");
312  $ilCtrl->setCmd("insert");
313  $dtable_gui = new ilPCDataTableGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
314  $ret = $ilCtrl->forwardCommand($dtable_gui);
315  break;
316 
317  case '2': //Advanced Table
318  include_once("./Services/COPage/classes/class.ilPCTableGUI.php");
319  $ilCtrl->setCmdClass("ilpctablegui");
320  $ilCtrl->setCmd("insert");
321  $atable_gui = new ilPCTableGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
322  $ret = $ilCtrl->forwardCommand($atable_gui);
323  break;
324 
325  case '3': //Advanced List
326  include_once("./Services/COPage/classes/class.ilPCListGUI.php");
327  $ilCtrl->setCmdClass("ilpclistgui");
328  $ilCtrl->setCmd("insert");
329  $list_gui = new ilPCListGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
330  $ret = $ilCtrl->forwardCommand($list_gui);
331  break;
332 
333  case '4': //File List
334  include_once ("./Services/COPage/classes/class.ilPCFileListGUI.php");
335  $ilCtrl->setCmdClass("ilpcfilelistgui");
336  $ilCtrl->setCmd("insert");
337  $file_list_gui = new ilPCFileListGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
338  $file_list_gui->setStyleId($this->getStyleId());
339  $ret = $this->ctrl->forwardCommand($file_list_gui);
340  break;
341 
342  default:
343  break;
344  }
345  }
346 
347 
348 }