ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCPlaceHolderGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Services/COPage/classes/class.ilPCPlaceHolder.php");
6 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
7 
23 {
28  var $pg_obj;
30  var $hier_id;
31  var $pc_id;
32  var $styleid;
33 
34  function ilPCPlaceHolderGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
35  {
36  $this->pg_obj = $a_pg_obj;
37  $this->content_obj = $a_content_obj;
38  $this->hier_id = $a_hier_id;
39  $this->pc_id = $a_pc_id;
40 
41  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
42  }
43 
44 
48  function &executeCommand()
49  {
50  global $ilCtrl;
51 
52  // get next class that processes or forwards current command
53  $next_class = $this->ctrl->getNextClass($this);
54  // get current command
55  $cmd = $this->ctrl->getCmd();
56 
57  switch($next_class)
58  {
59  case 'ilpcmediaobjectgui': //special handling
60  include_once("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
61  $media_gui = new ilPCMediaObjectGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
62  $ret = $ilCtrl->forwardCommand($media_gui);
63  break;
64 
65  default:
66  $ret =& $this->$cmd();
67  break;
68  }
69 
70 
71  return $ret;
72  }
73 
74 
79  function insert() {
80  $this->propertyGUI("create","Text","100px","insert");
81  }
82 
83 
87  function create()
88  {
89  if ($_POST["plach_height"]=="" || !preg_match("/[0-9]+/",$_POST["plach_height"])) {
90  return $this->insert();
91  exit;
92  }
93 
94  $this->content_obj = new ilPCPlaceHolder($this->dom);
95  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
96  $this->content_obj->setHeight($_POST["plach_height"]."px");
97  $this->content_obj->setContentClass($_POST['plach_type']);
98  $this->updated = $this->pg_obj->update();
99  if ($this->updated === true)
100  {
101  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
102  }
103  else
104  {
105  $this->insert();
106  }
107  }
108 
113  function edit() {
114 
115  if ($this->pg_obj->getLayoutMode() == true) {
116  $this->edit_object();
117  } else {
118  $this->forward_edit();
119  }
120  }
121 
127  function setStyleId($a_styleid)
128  {
129  $this->styleid = $a_styleid;
130  }
131 
137  function getStyleId()
138  {
139  return $this->styleid;
140  }
141 
142 
147  private function edit_object() {
148  $this->propertyGUI("saveProperties",$this->content_obj->getContentClass(),$this->content_obj->getHeight(),"save");
149  }
150 
151 
152  private function forward_edit() {
153  global $ilCtrl;
154 
155  switch ($this->content_obj->getContentClass()) {
156  case 'Media':
157  include_once("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
158  $ilCtrl->setCmdClass("ilpcmediaobjectgui");
159  $ilCtrl->setCmd("insert");
160  $media_gui = new ilPCMediaObjectGUI($this->pg_obj,$null);
161  $ret = $ilCtrl->forwardCommand($media_gui);
162 
163  break;
164  case 'Text':
165  $this->textCOSelectionGUI();
166  break;
167  case 'Question':
168  include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
169  $ilCtrl->setCmdClass("ilpcquestiongui");
170  $ilCtrl->setCmd("insert");
171  $question_gui = new ilPCQuestionGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
172  $question_gui -> setSelfAssessmentMode(true);
173  $ret = $ilCtrl->forwardCommand($question_gui);
174  break;
175  default:
176  break;
177  }
178  }
179 
180 
184  function saveProperties()
185  {
186 
187  if ($_POST["plach_height"]=="" || !preg_match("/[0-9]+/",$_POST["plach_height"])) {
188  return $this->edit_object();
189  exit;
190  }
191 
192  $this->content_obj->setContentClass($_POST['plach_type']);
193  $this->content_obj->setHeight($_POST["plach_height"]."px");
194 
195  $this->updated = $this->pg_obj->update();
196  if ($this->updated === true)
197  {
198  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
199  }
200  else
201  {
202  $this->pg_obj->addHierIDs();
203  $this->edit();
204  }
205  }
206 
210  private function propertyGUI($a_action,$a_type,$a_height,$a_mode) {
211  global $ilCtrl, $lng;
212 
213  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
214  $this->form_gui = new ilPropertyFormGUI();
215  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
216  $this->form_gui->setTitle($lng->txt("cont_ed_plachprop"));
217 
218  include_once("Services/Form/classes/class.ilRadioMatrixInputGUI.php");
219  $ttype_input = new ilRadioMatrixInputGUI($lng->txt("type"), "plach_type");
220  $options =array("Text"=>$lng->txt("cont_ed_plachtext"),"Media"=>$lng->txt("cont_ed_plachmedia"),
221  "Question"=>$lng->txt("cont_ed_plachquestion"));
222  $ttype_input->setOptions($options);
223  $ttype_input->setValue($a_type);
224  $ttype_input->setRequired(true);
225  $theight_input = new ilTextInputGUI($lng->txt("height"),"plach_height");
226  $theight_input->setSize(4);
227  $theight_input->setMaxLength(3);
228 
229  $a_height = preg_replace("/px/","",$a_height);
230  $theight_input->setValue($a_height);
231  $theight_input->setTitle($lng->txt("height")." (px)");
232  $theight_input->setRequired(true);
233 
234  $this->form_gui->addItem($ttype_input);
235  $this->form_gui->addItem($theight_input);
236 
237  $this->form_gui->addCommandButton($a_action, $lng->txt($a_mode));
238  $this->form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
239  $this->tpl->setContent($this->form_gui->getHTML());
240  }
241 
246  private function textCOSelectionGUI() {
247 
248  global $ilCtrl, $lng;
249 
250  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
251  $this->form_gui = new ilPropertyFormGUI();
252  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
253  $this->form_gui->setTitle($lng->txt("cont_ed_select_pctext"));
254 
255  // Select Question Type
256 
257  include_once("Services/Form/classes/class.ilRadioMatrixInputGUI.php");
258  $ttype_input = new ilRadioMatrixInputGUI($lng->txt("cont_ed_textitem"), "pctext_type");
259  $options = array($lng->txt("cont_ed_par"),$lng->txt("cont_ed_dtable"),
260  $lng->txt("cont_ed_atable"),$lng->txt("cont_ed_list"),$lng->txt("cont_ed_flist"),
261  $lng->txt("cont_tabs"));
262  $ttype_input->setOptions($options);
263  $this->form_gui->addItem($ttype_input);
264 
265  $this->form_gui->addCommandButton("insertPCText", $lng->txt("insert"));
266  $this->form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
267  $this->tpl->setContent($this->form_gui->getHTML());
268  }
269 
274  function insertPCText() {
275 
276  global $ilCtrl, $ilSetting;
277 
278  switch ($_POST['pctext_type']) {
279 
280  case '0': //Paragraph / Text
281 
282  // js editing? -> redirect to js page editor
283  // if ($ilSetting->get("enable_js_edit", 1) && ilPageEditorGUI::_doJSEditing())
285  {
286  $ret_class = $ilCtrl->getReturnClass($this);
287  $ilCtrl->setParameterByClass($ret_class, "pl_hier_id", $this->hier_id);
288  $ilCtrl->setParameterByClass($ret_class, "pl_pc_id", $this->pc_id);
289  $ilCtrl->redirectByClass($ret_class,
290  "insertJSAtPlaceholder");
291  }
292 
293  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
294  $ilCtrl->setCmdClass("ilpcparagraphgui");
295  $ilCtrl->setCmd("insert");
296  $paragraph_gui = new ilPCParagraphGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
297  $paragraph_gui->setStyleId($this->getStyleId());
298  $paragraph_gui->setEnableInternalLinks($this->getEnableInternalLinks());
299  $paragraph_gui->setEnableKeywords($this->getEnableKeywords());
300  $paragraph_gui->setEnableAnchors($this->getEnableAnchors());
301  $ret = $ilCtrl->forwardCommand($paragraph_gui);
302  break;
303 
304  case '1': //DataTable
305  include_once("./Services/COPage/classes/class.ilPCDataTableGUI.php");
306  $ilCtrl->setCmdClass("ilpcdatatablegui");
307  $ilCtrl->setCmd("insert");
308  $dtable_gui = new ilPCDataTableGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
309  $ret = $ilCtrl->forwardCommand($dtable_gui);
310  break;
311 
312  case '2': //Advanced Table
313  include_once("./Services/COPage/classes/class.ilPCTableGUI.php");
314  $ilCtrl->setCmdClass("ilpctablegui");
315  $ilCtrl->setCmd("insert");
316  $atable_gui = new ilPCTableGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
317  $ret = $ilCtrl->forwardCommand($atable_gui);
318  break;
319 
320  case '3': //Advanced List
321  include_once("./Services/COPage/classes/class.ilPCListGUI.php");
322  $ilCtrl->setCmdClass("ilpclistgui");
323  $ilCtrl->setCmd("insert");
324  $list_gui = new ilPCListGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
325  $ret = $ilCtrl->forwardCommand($list_gui);
326  break;
327 
328  case '4': //File List
329  include_once ("./Services/COPage/classes/class.ilPCFileListGUI.php");
330  $ilCtrl->setCmdClass("ilpcfilelistgui");
331  $ilCtrl->setCmd("insert");
332  $file_list_gui = new ilPCFileListGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
333  $file_list_gui->setStyleId($this->getStyleId());
334  $ret = $this->ctrl->forwardCommand($file_list_gui);
335  break;
336 
337  case '5': //Tabs
338  include_once ("./Services/COPage/classes/class.ilPCTabsGUI.php");
339  $ilCtrl->setCmdClass("ilpctabsgui");
340  $ilCtrl->setCmd("insert");
341  $tabs_gui = new ilPCTabsGUI($this->pg_obj,$this->content_obj,$this->hier_id,$this->pc_id);
342  $tabs_gui->setStyleId($this->getStyleId());
343  $ret = $this->ctrl->forwardCommand($tabs_gui);
344  break;
345 
346  default:
347  break;
348  }
349  }
350 
354  function cancel()
355  {
356  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
357  }
358 
359 }