ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCMapGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPCMap.php");
25 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26 
38 {
39 
44  public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
45  {
46  global $DIC;
47 
48  $this->tpl = $DIC["tpl"];
49  $this->ctrl = $DIC->ctrl();
50  $this->lng = $DIC->language();
51  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
52  }
53 
57  public function executeCommand()
58  {
59  // get next class that processes or forwards current command
60  $next_class = $this->ctrl->getNextClass($this);
61 
62  // get current command
63  $cmd = $this->ctrl->getCmd();
64 
65  switch ($next_class) {
66  default:
67  $ret = $this->$cmd();
68  break;
69  }
70 
71  return $ret;
72  }
73 
77  public function insert()
78  {
79  $tpl = $this->tpl;
80 
81  $this->displayValidationError();
82  $this->initForm("create");
83  $tpl->setContent($this->form->getHTML());
84  }
85 
89  public function edit($a_insert = false)
90  {
92  $tpl = $this->tpl;
93  $lng = $this->lng;
94 
95  $this->displayValidationError();
96  $this->initForm("update");
97  $this->getValues();
98  $tpl->setContent($this->form->getHTML());
99 
100  return $ret;
101  }
102 
106  public function getValues()
107  {
108  $values = array();
109 
110  $values["location"]["latitude"] = $this->content_obj->getLatitude();
111  $values["location"]["longitude"] = $this->content_obj->getLongitude();
112  $values["location"]["zoom"] = $this->content_obj->getZoom();
113  $values["width"] = $this->content_obj->getWidth();
114  $values["height"] = $this->content_obj->getHeight();
115  $values["caption"] = $this->content_obj->handleCaptionFormOutput($this->content_obj->getCaption());
116  $values["horizontal_align"] = $this->content_obj->getHorizontalAlign();
117 
118  $this->form->setValuesByArray($values);
119  }
120 
124  public function initForm($a_mode)
125  {
127  $lng = $this->lng;
128 
129  // edit form
130  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
131  $this->form = new ilPropertyFormGUI();
132  $this->form->setFormAction($ilCtrl->getFormAction($this));
133  if ($a_mode == "create") {
134  $this->form->setTitle($this->lng->txt("cont_insert_map"));
135  } else {
136  $this->form->setTitle($this->lng->txt("cont_update_map"));
137  }
138 
139  // location
140  $loc_prop = new ilLocationInputGUI(
141  $this->lng->txt("cont_location"),
142  "location"
143  );
144  $loc_prop->setRequired(true);
145  $this->form->addItem($loc_prop);
146 
147  // width
148  $width_prop = new ilNumberInputGUI(
149  $this->lng->txt("cont_width"),
150  "width"
151  );
152  $width_prop->setSize(4);
153  $width_prop->setMaxLength(4);
154  $width_prop->setRequired(true);
155  $width_prop->setMinValue(250);
156  $this->form->addItem($width_prop);
157 
158  // height
159  $height_prop = new ilNumberInputGUI(
160  $this->lng->txt("cont_height"),
161  "height"
162  );
163  $height_prop->setSize(4);
164  $height_prop->setMaxLength(4);
165  $height_prop->setRequired(true);
166  $height_prop->setMinValue(200);
167  $this->form->addItem($height_prop);
168 
169  // horizonal align
170  $align_prop = new ilSelectInputGUI(
171  $this->lng->txt("cont_align"),
172  "horizontal_align"
173  );
174  $options = array(
175  "Left" => $lng->txt("cont_left"),
176  "Center" => $lng->txt("cont_center"),
177  "Right" => $lng->txt("cont_right"),
178  "LeftFloat" => $lng->txt("cont_left_float"),
179  "RightFloat" => $lng->txt("cont_right_float"));
180  $align_prop->setOptions($options);
181  $this->form->addItem($align_prop);
182 
183  // caption
184  $caption_prop = new ilTextAreaInputGUI(
185  $this->lng->txt("cont_caption"),
186  "caption"
187  );
188  $this->form->addItem($caption_prop);
189 
190  // save/cancel buttons
191  if ($a_mode == "create") {
192  $this->form->addCommandButton("create_map", $lng->txt("save"));
193  $this->form->addCommandButton("cancelCreate", $lng->txt("cancel"));
194  } else {
195  $this->form->addCommandButton("update_map", $lng->txt("save"));
196  $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
197  }
198  //$html = $form->getHTML();
199  }
200 
204  public function create()
205  {
206  $tpl = $this->tpl;
207 
208  $this->initForm("create");
209  if ($this->form->checkInput()) {
210  $this->content_obj = new ilPCMap($this->getPage());
211  $location = $this->form->getInput("location");
212  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
213  $this->content_obj->setLatitude($location["latitude"]);
214  $this->content_obj->setLongitude($location["longitude"]);
215  $this->content_obj->setZoom($location["zoom"]);
216  $this->content_obj->setLayout(
217  $this->form->getInput("width"),
218  $this->form->getInput("height"),
219  $this->form->getInput("horizontal_align")
220  );
221  $this->content_obj->setCaption(
222  $this->content_obj->handleCaptionInput($this->form->getInput("caption"))
223  );
224  $this->updated = $this->pg_obj->update();
225  if ($this->updated === true) {
226  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
227  return;
228  }
229  }
230  $this->displayValidationError();
231  $this->form->setValuesByPost();
232  $tpl->setContent($this->form->getHTML());
233  }
234 
238  public function update()
239  {
240  $tpl = $this->tpl;
241 
242  $this->initForm("update");
243  if ($this->form->checkInput()) {
244  $location = $this->form->getInput("location");
245  $this->content_obj->setLatitude($location["latitude"]);
246  $this->content_obj->setLongitude($location["longitude"]);
247  $this->content_obj->setZoom($location["zoom"]);
248  $this->content_obj->setLayout(
249  $this->form->getInput("width"),
250  $this->form->getInput("height"),
251  $this->form->getInput("horizontal_align")
252  );
253  $this->content_obj->setCaption(
254  $this->content_obj->handleCaptionInput($this->form->getInput("caption"))
255  );
256  $this->updated = $this->pg_obj->update();
257  if ($this->updated === true) {
258  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
259  return;
260  }
261  }
262  $this->displayValidationError();
263  $this->form->setValuesByPost();
264  $tpl->setContent($this->form->getHTML());
265  }
266 }
insert()
Insert new map form.
initForm($a_mode)
Init map creation/update form.
This class represents a selection list property in a property form.
edit($a_insert=false)
Edit map form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$location
Definition: buildRTE.php:44
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
Class ilPCMap.
create()
Create new Map.
global $ilCtrl
Definition: ilias.php:18
executeCommand()
execute command
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
This class represents a number property in a property form.
$values
This class represents a location property in a property form.
displayValidationError()
display validation errors
getValues()
Get values from object into form.
setSize($a_size)
Set Size.
This class represents a text area property in a property form.
$ret
Definition: parser.php:6
Class ilPCMapGUI.
update()
Update Map.
setRequired($a_required)
Set Required.