ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
5require_once("./Services/COPage/classes/class.ilPCContentTemplate.php");
6require_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 {
62
64 $form = $this->initForm();
65 $tpl->setContent($form->getHTML());
66 }
67
71 public function initForm()
72 {
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 {
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}
An exception for terminatinating execution or to throw for unit testing.
Class ilPCContentTemplateGUI.
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor.
insert()
Insert content template.
Content templates are not existing in the page.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46