ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
27  {
28  global $DIC;
29 
30  $this->tpl = $DIC["tpl"];
31  $this->ctrl = $DIC->ctrl();
32  $this->lng = $DIC->language();
33  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
34  }
35 
39  public function executeCommand()
40  {
41  // get next class that processes or forwards current command
42  $next_class = $this->ctrl->getNextClass($this);
43 
44  // get current command
45  $cmd = $this->ctrl->getCmd();
46 
47  switch ($next_class) {
48  default:
49  $ret = $this->$cmd();
50  break;
51  }
52 
53  return $ret;
54  }
55 
59  public function insert()
60  {
61  $tpl = $this->tpl;
62 
63  $this->displayValidationError();
64  $form = $this->initForm();
65  $tpl->setContent($form->getHTML());
66  }
67 
71  public function initForm()
72  {
74  $lng = $this->lng;
75 
76  // edit form
77  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
78  $form = new ilPropertyFormGUI();
79  $form->setFormAction($ilCtrl->getFormAction($this));
80  $form->setTitle($this->lng->txt("cont_ed_insert_templ"));
81 
82  $radg = new ilRadioGroupInputGUI($lng->txt("cont_template"), "page_templ");
83  $radg->setRequired(true);
84 
85  $ts = $this->getPage()->getContentTemplates();
86  foreach ($ts as $t) {
87  $op = new ilRadioOption($t["title"], $t["id"] . ":" . $t["parent_type"]);
88  $radg->addOption($op);
89  }
90 
91  $form->addItem($radg);
92 
93 
94  $form->addCommandButton("create_templ", $lng->txt("insert"));
95  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
96 
97  return $form;
98  }
99 
103  public function create()
104  {
105  $tpl = $this->tpl;
106 
107  $form = $this->initForm();
108  if ($form->checkInput()) {
109  $this->content_obj = new ilPCContentTemplate($this->getPage());
110  $this->content_obj->create(
111  $this->pg_obj,
112  $this->hier_id,
113  $this->pc_id,
114  $form->getInput("page_templ")
115  );
116  $this->updated = $this->pg_obj->update();
117  if ($this->updated === true) {
118  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
119  return;
120  }
121  }
122  $this->displayValidationError();
123  $form->setValuesByPost();
124  $tpl->setContent($form->getHTML());
125  }
126 }
This class represents an option in a radio group.
insert()
Insert content template.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
Content templates are not existing in the page.
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor.
global $ilCtrl
Definition: ilias.php:18
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
This class represents a property in a property form.
Class ilPCContentTemplateGUI.
if(isset($_POST['submit'])) $form
displayValidationError()
display validation errors
$ret
Definition: parser.php:6
setRequired($a_required)
Set Required.