ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCAMDPageListGUI.php
Go to the documentation of this file.
1<?php
2
24{
26
27 public function __construct(
28 ilPageObject $a_pg_obj,
29 ?ilPageContent $a_content_obj,
30 string $a_hier_id,
31 string $a_pc_id = ""
32 ) {
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
56 public function insert(?ilPropertyFormGUI $a_form = null): void
57 {
59
61
62 if (!$a_form) {
63 $a_form = $this->initForm(true);
64 }
65 $tpl->setContent($a_form->getHTML());
66 }
67
68 public function edit(?ilPropertyFormGUI $a_form = null): void
69 {
71
73
74 if (!$a_form) {
75 $a_form = $this->initForm();
76 }
77 $tpl->setContent($a_form->getHTML());
78 }
79
80 protected function initForm(bool $a_insert = false): ilPropertyFormGUI
81 {
82 $ilCtrl = $this->ctrl;
83
84 $form = new ilPropertyFormGUI();
85 $form->setFormAction($ilCtrl->getFormAction($this));
86 if ($a_insert) {
87 $form->setTitle($this->lng->txt("cont_insert_amd_page_list"));
88 } else {
89 $form->setTitle($this->lng->txt("cont_update_amd_page_list"));
90 }
91 $form->setDescription($this->lng->txt("wiki_page_list_form_info"));
92
93 $mode = new ilSelectInputGUI($this->lng->txt("wiki_page_list_mode"), "mode");
94 $mode->setOptions(array(
95 0 => $this->lng->txt("wiki_page_list_mode_unordered"),
96 1 => $this->lng->txt("wiki_page_list_mode_ordered")
97 ));
98 $mode->setRequired(true);
99 $form->addItem($mode);
100
101 $this->record_gui = new ilAdvancedMDRecordGUI(
103 'wiki',
104 $this->getPage()->getWikiId(),
105 'wpg',
106 $this->getPage()->getId()
107 );
108 $this->record_gui->setPropertyForm($form);
109
110 if (!$a_insert) {
111 $mode->setValue($this->content_obj->getMode());
112 $this->record_gui->setSearchFormValues($this->content_obj->getFieldValues());
113 }
114
115 $this->record_gui->parse();
116
117 $no_fields = (count($form->getItems()) === 1);
118 if ($no_fields) {
119 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("wiki_pg_list_no_search_fields"));
120 }
121
122 if ($a_insert) {
123 if (!$no_fields) {
124 $form->addCommandButton("create", $this->lng->txt("select"));
125 }
126 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
127 } else {
128 if (!$no_fields) {
129 $form->addCommandButton("update", $this->lng->txt("select"));
130 }
131 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
132 }
133
134 return $form;
135 }
136
137 public function create(): void
138 {
139 $form = $this->initForm(true);
140 if ($form->checkInput()) {
141 $elements = $this->record_gui->importSearchForm();
142 if (is_array($elements)) {
143 $this->content_obj = new ilPCAMDPageList($this->getPage());
144 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
145 $this->content_obj->setData($elements, $form->getInput("mode"));
146 $this->updated = $this->pg_obj->update();
147 if ($this->updated === true) {
148 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
149 }
150 }
151 }
152
153 $this->insert($form);
154 }
155
156 public function update(): void
157 {
158 $form = $this->initForm();
159 if ($form->checkInput()) {
160 $elements = $this->record_gui->importSearchForm();
161 if (is_array($elements)) {
162 $this->content_obj->setData($elements, $form->getInput("mode"));
163 $this->updated = $this->pg_obj->update();
164 if ($this->updated === true) {
165 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
166 }
167 }
168 }
169
170 $this->pg_obj->addHierIDs();
171 $this->edit($form);
172 }
173}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insert(?ilPropertyFormGUI $a_form=null)
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
edit(?ilPropertyFormGUI $a_form=null)
initForm(bool $a_insert=false)
ilAdvancedMDRecordGUI $record_gui
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 selection list property in a property form.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc