ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCContentTemplateGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Services/COPage/classes/class.ilPCContentTemplate.php");
6 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
7 
21 {
22 
26  function ilPCContentTemplateGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
27  {
28  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
29  }
30 
34  function executeCommand()
35  {
36  // get next class that processes or forwards current command
37  $next_class = $this->ctrl->getNextClass($this);
38 
39  // get current command
40  $cmd = $this->ctrl->getCmd();
41 
42  switch($next_class)
43  {
44  default:
45  $ret = $this->$cmd();
46  break;
47  }
48 
49  return $ret;
50  }
51 
55  function insert()
56  {
57  global $tpl;
58 
59  $this->displayValidationError();
60  $form = $this->initForm();
61  $tpl->setContent($form->getHTML());
62  }
63 
67  function initForm()
68  {
69  global $ilCtrl, $lng;
70 
71  // edit form
72  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
73  $form = new ilPropertyFormGUI();
74  $form->setFormAction($ilCtrl->getFormAction($this));
75  $form->setTitle($this->lng->txt("cont_ed_insert_templ"));
76 
77  $radg = new ilRadioGroupInputGUI($lng->txt("cont_template"), "page_templ");
78  $radg->setRequired(true);
79 
80  $ts = $this->getPage()->getContentTemplates();
81  foreach ($ts as $t)
82  {
83  $op = new ilRadioOption($t["title"], $t["id"].":".$t["parent_type"]);
84  $radg->addOption($op);
85  }
86 
87  $form->addItem($radg);
88 
89 
90  $form->addCommandButton("create_templ", $lng->txt("insert"));
91  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
92 
93  return $form;
94  }
95 
99  function create()
100  {
101  global $tpl;
102 
103  $form = $this->initForm();
104  if ($form->checkInput())
105  {
106  $this->content_obj = new ilPCContentTemplate($this->getPage());
107  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id,
108  $form->getInput("page_templ"));
109  $this->updated = $this->pg_obj->update();
110  if ($this->updated === true)
111  {
112  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
113  return;
114  }
115  }
116  $this->displayValidationError();
117  $form->setValuesByPost();
118  $tpl->setContent($form->getHTML());
119  }
120 
121 }
122 ?>