ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCContentTemplateGUI.php
Go to the documentation of this file.
1<?php
2
28{
29 public function __construct(
30 ilPageObject $a_pg_obj,
31 ?ilPageContent $a_content_obj,
32 string $a_hier_id,
33 string $a_pc_id = ""
34 ) {
35 global $DIC;
36
37 $this->tpl = $DIC["tpl"];
38 $this->ctrl = $DIC->ctrl();
39 $this->lng = $DIC->language();
40 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
41 }
42
46 public function executeCommand(): void
47 {
48 // get next class that processes or forwards current command
49 $next_class = $this->ctrl->getNextClass($this);
50
51 // get current command
52 $cmd = $this->ctrl->getCmd();
53
54 switch ($next_class) {
55 default:
56 $this->$cmd();
57 break;
58 }
59 }
60
64 public function insert(): void
65 {
67
69 $form = $this->initForm();
70 $tpl->setContent($form->getHTML());
71 }
72
76 public function initForm(): ilPropertyFormGUI
77 {
78 $ilCtrl = $this->ctrl;
80
81 // edit form
82 $form = new ilPropertyFormGUI();
83 $form->setFormAction($ilCtrl->getFormAction($this));
84 $form->setTitle($this->lng->txt("cont_ed_insert_templ"));
85
86 $radg = new ilRadioGroupInputGUI($lng->txt("cont_template"), "page_templ");
87 $radg->setRequired(true);
88
89 $ts = $this->getPage()->getContentTemplates();
90 foreach ($ts as $t) {
91 $op = new ilRadioOption($t["title"], $t["id"] . ":" . $t["parent_type"]);
92 $radg->addOption($op);
93 }
94
95 $form->addItem($radg);
96
97
98 $form->addCommandButton("create", $lng->txt("insert"));
99 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
100
101 return $form;
102 }
103
107 public function create(): void
108 {
110
111 $form = $this->initForm();
112 if ($form->checkInput()) {
113 $this->content_obj = new ilPCContentTemplate($this->getPage());
114 $this->content_obj->create(
115 $this->pg_obj,
116 $this->hier_id,
117 $this->pc_id,
118 $form->getInput("page_templ")
119 );
120 $this->updated = $this->pg_obj->update();
121 if ($this->updated === true) {
122 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
123 return;
124 }
125 }
126 $this->displayValidationError();
127 $form->setValuesByPost();
128 $tpl->setContent($form->getHTML());
129 }
130}
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insert()
Insert content template.
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
ilGlobalTemplateInterface $tpl
Content object of ilPageObject (see ILIAS DTD).
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
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.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26