ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCMapGUI.php
Go to the documentation of this file.
1<?php
2
25{
27
28 public function __construct(
29 ilPageObject $a_pg_obj,
30 ?ilPageContent $a_content_obj,
31 string $a_hier_id,
32 string $a_pc_id = ""
33 ) {
34 global $DIC;
35
36 $this->tpl = $DIC["tpl"];
37 $this->ctrl = $DIC->ctrl();
38 $this->lng = $DIC->language();
39 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
40 }
41
42 public function executeCommand(): void
43 {
44 // get next class that processes or forwards current command
45 $next_class = $this->ctrl->getNextClass($this);
46
47 // get current command
48 $cmd = $this->ctrl->getCmd();
49
50 switch ($next_class) {
51 default:
52 $this->$cmd();
53 break;
54 }
55 }
56
57 public function insert(): void
58 {
60
62 $this->initForm("create");
63 $tpl->setContent($this->form->getHTML());
64 }
65
66 public function edit(): void
67 {
70 $this->initForm("update");
71 $this->getValues();
72 $tpl->setContent($this->form->getHTML());
73 }
74
75 public function getValues(): void
76 {
77 $values = array();
78
79 $values["location"]["latitude"] = $this->content_obj->getLatitude();
80 $values["location"]["longitude"] = $this->content_obj->getLongitude();
81 $values["location"]["zoom"] = $this->content_obj->getZoom();
82 $values["width"] = $this->content_obj->getWidth();
83 $values["height"] = $this->content_obj->getHeight();
84 $values["caption"] = ilPCMap::handleCaptionFormOutput($this->content_obj->getCaption());
85 $values["horizontal_align"] = $this->content_obj->getHorizontalAlign();
86
87 $this->form->setValuesByArray($values);
88 }
89
90 public function initForm(string $a_mode): void
91 {
92 $ilCtrl = $this->ctrl;
94
95 // edit form
96 $this->form = new ilPropertyFormGUI();
97 $this->form->setFormAction($ilCtrl->getFormAction($this));
98 if ($a_mode == "create") {
99 $this->form->setTitle($this->lng->txt("cont_insert_map"));
100 } else {
101 $this->form->setTitle($this->lng->txt("cont_update_map"));
102 }
103
104 // location
105 $loc_prop = new ilLocationInputGUI(
106 $this->lng->txt("cont_location"),
107 "location"
108 );
109 $loc_prop->setRequired(true);
110 $this->form->addItem($loc_prop);
111
112 // width
113 $width_prop = new ilNumberInputGUI(
114 $this->lng->txt("cont_width"),
115 "width"
116 );
117 $width_prop->setSize(4);
118 $width_prop->setMaxLength(4);
119 $width_prop->setRequired(true);
120 $width_prop->setMinValue(250);
121 $this->form->addItem($width_prop);
122
123 // height
124 $height_prop = new ilNumberInputGUI(
125 $this->lng->txt("cont_height"),
126 "height"
127 );
128 $height_prop->setSize(4);
129 $height_prop->setMaxLength(4);
130 $height_prop->setRequired(true);
131 $height_prop->setMinValue(200);
132 $this->form->addItem($height_prop);
133
134 // horizonal align
135 $align_prop = new ilSelectInputGUI(
136 $this->lng->txt("cont_align"),
137 "horizontal_align"
138 );
139 $options = array(
140 "Left" => $lng->txt("cont_left"),
141 "Center" => $lng->txt("cont_center"),
142 "Right" => $lng->txt("cont_right"),
143 "LeftFloat" => $lng->txt("cont_left_float"),
144 "RightFloat" => $lng->txt("cont_right_float"));
145 $align_prop->setOptions($options);
146 $this->form->addItem($align_prop);
147
148 // caption
149 $caption_prop = new ilTextAreaInputGUI(
150 $this->lng->txt("cont_caption"),
151 "caption"
152 );
153 $this->form->addItem($caption_prop);
154
155 // save/cancel buttons
156 if ($a_mode == "create") {
157 $this->form->addCommandButton("create", $lng->txt("save"));
158 $this->form->addCommandButton("cancelCreate", $lng->txt("cancel"));
159 } else {
160 $this->form->addCommandButton("update", $lng->txt("save"));
161 $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
162 }
163 }
164
165 public function create(): void
166 {
168
169 $this->initForm("create");
170 if ($this->form->checkInput()) {
171 $this->content_obj = new ilPCMap($this->getPage());
172 $location = $this->form->getInput("location");
173 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
174 $this->content_obj->setLatitude($location["latitude"]);
175 $this->content_obj->setLongitude($location["longitude"]);
176 $this->content_obj->setZoom((int) $location["zoom"]);
177 $this->content_obj->setLayout(
178 $this->form->getInput("width"),
179 $this->form->getInput("height"),
180 $this->form->getInput("horizontal_align")
181 );
182 $this->content_obj->setCaption(
183 $this->content_obj->handleCaptionInput($this->form->getInput("caption"))
184 );
185 $this->updated = $this->pg_obj->update();
186 if ($this->updated === true) {
187 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
188 return;
189 }
190 }
191 $this->displayValidationError();
192 $this->form->setValuesByPost();
193 $tpl->setContent($this->form->getHTML());
194 }
195
196 public function update(): void
197 {
199
200 $this->initForm("update");
201 if ($this->form->checkInput()) {
202 $location = $this->form->getInput("location");
203 $this->content_obj->setLatitude($location["latitude"]);
204 $this->content_obj->setLongitude($location["longitude"]);
205 $this->content_obj->setZoom((int) $location["zoom"]);
206 $this->content_obj->setLayout(
207 $this->form->getInput("width"),
208 $this->form->getInput("height"),
209 $this->form->getInput("horizontal_align")
210 );
211 $this->content_obj->setCaption(
212 $this->content_obj->handleCaptionInput($this->form->getInput("caption"))
213 );
214 $this->updated = $this->pg_obj->update();
215 if ($this->updated === true) {
216 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
217 return;
218 }
219 }
220 $this->displayValidationError();
221 $this->form->setValuesByPost();
222 $tpl->setContent($this->form->getHTML());
223 }
224}
$location
Definition: buildRTE.php:22
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 class represents a location property in a property form.
This class represents a number property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initForm(string $a_mode)
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
ilPropertyFormGUI $form
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static handleCaptionFormOutput(string $a_text)
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.
This class represents a text area property in a property form.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
global $DIC
Definition: shib_login.php:26