ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCLayoutTemplateGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 public function __construct(
27 ilPageObject $a_pg_obj,
28 ?ilPageContent $a_content_obj,
29 string $a_hier_id,
30 string $a_pc_id = ""
31 ) {
32 global $DIC;
33
34 $this->tpl = $DIC["tpl"];
35 $this->ctrl = $DIC->ctrl();
36 $this->lng = $DIC->language();
37 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
38 }
39
43 public function executeCommand(): void
44 {
45 // get next class that processes or forwards current command
46 $next_class = $this->ctrl->getNextClass($this);
47
48 // get current command
49 $cmd = $this->ctrl->getCmd();
50
51 switch ($next_class) {
52 default:
53 $this->$cmd();
54 break;
55 }
56 }
57
61 public function insert(): void
62 {
64
66 $form = $this->initForm();
67 $tpl->setContent($form->getHTML());
68 }
69
74 {
75 $ilCtrl = $this->ctrl;
77
78 // edit form
79 $form = new ilPropertyFormGUI();
80 $form->setFormAction($ilCtrl->getFormAction($this));
81 $form->setTitle($this->lng->txt("cont_ed_insert_lay"));
82
83 $config = $this->getPage()->getPageConfig();
84 $templates = ilPageLayout::activeLayouts($config->getLayoutTemplateType());
85 $first = true;
86 if ($templates) {
87 $use_template = new ilRadioGroupInputGUI($this->lng->txt("cont_layout"), "tmpl");
88 $use_template->setRequired(true);
89 $form->addItem($use_template);
90
91 foreach ($templates as $templ) {
92 $templ->readObject();
93 $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), (string) $templ->getId());
94 $use_template->addOption($opt);
95 if ($first) {
96 $use_template->setValue((string) $templ->getId());
97 $first = false;
98 }
99 }
100 }
101
102 $form->addCommandButton("create", $lng->txt("insert"));
103 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
104
105 return $form;
106 }
107
111 public function create(): void
112 {
114
115 $form = $this->initForm();
116 if ($form->checkInput()) {
117 $this->content_obj = new ilPCLayoutTemplate($this->getPage());
118 $this->content_obj->create(
119 $this->pg_obj,
120 $this->hier_id,
121 $this->pc_id,
122 (int) $form->getInput("tmpl")
123 );
124 $this->updated = $this->pg_obj->update();
125 if ($this->updated === true) {
126 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
127 return;
128 }
129 }
130 $this->displayValidationError();
131 $form->setValuesByPost();
132 $tpl->setContent($form->getHTML());
133 }
134}
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...
@ilCtrl_isCalledBy ilPCLayoutTemplateGUI: ilPageEditorGUI
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
initCreationForm()
Init creation from.
insert()
Insert content template.
Layout templates are not existing in the page.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
ilGlobalTemplateInterface $tpl
Content object of ilPageObject (see ILIAS DTD).
static activeLayouts(int $a_module=0)
Get active layouts.
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