ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  function ilPCMapGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
45  {
46  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
47  }
48 
52  function &executeCommand()
53  {
54  // get next class that processes or forwards current command
55  $next_class = $this->ctrl->getNextClass($this);
56 
57  // get current command
58  $cmd = $this->ctrl->getCmd();
59 
60  switch($next_class)
61  {
62  default:
63  $ret =& $this->$cmd();
64  break;
65  }
66 
67  return $ret;
68  }
69 
73  function insert()
74  {
75  global $tpl;
76 
77  $this->displayValidationError();
78  $this->initForm("create");
79  $tpl->setContent($this->form->getHTML());
80  }
81 
85  function edit($a_insert = false)
86  {
87  global $ilCtrl, $tpl, $lng;
88 
89  $this->displayValidationError();
90  $this->initForm("update");
91  $this->getValues();
92  $tpl->setContent($this->form->getHTML());
93 
94  return $ret;
95  }
96 
100  function getValues()
101  {
102  $values = array();
103 
104  $values["location"]["latitude"] = $this->content_obj->getLatitude();
105  $values["location"]["longitude"] = $this->content_obj->getLongitude();
106  $values["location"]["zoom"] = $this->content_obj->getZoom();
107  $values["width"] = $this->content_obj->getWidth();
108  $values["height"] = $this->content_obj->getHeight();
109  $values["caption"] = $this->content_obj->handleCaptionFormOutput($this->content_obj->getCaption());
110  $values["horizontal_align"] = $this->content_obj->getHorizontalAlign();
111 
112  $this->form->setValuesByArray($values);
113  }
114 
118  function initForm($a_mode)
119  {
120  global $ilCtrl, $lng;
121 
122  // edit form
123  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
124  $this->form = new ilPropertyFormGUI();
125  $this->form->setFormAction($ilCtrl->getFormAction($this));
126  if ($a_mode == "create")
127  {
128  $this->form->setTitle($this->lng->txt("cont_insert_map"));
129  }
130  else
131  {
132  $this->form->setTitle($this->lng->txt("cont_update_map"));
133  }
134 
135  // location
136  $loc_prop = new ilLocationInputGUI($this->lng->txt("cont_location"),
137  "location");
138  $loc_prop->setRequired(true);
139  $this->form->addItem($loc_prop);
140 
141  // width
142  $width_prop = new ilNumberInputGUI($this->lng->txt("cont_width"),
143  "width");
144  $width_prop->setSize(4);
145  $width_prop->setMaxLength(4);
146  $width_prop->setRequired(true);
147  $width_prop->setMinValue(250);
148  $this->form->addItem($width_prop);
149 
150  // height
151  $height_prop = new ilNumberInputGUI($this->lng->txt("cont_height"),
152  "height");
153  $height_prop->setSize(4);
154  $height_prop->setMaxLength(4);
155  $height_prop->setRequired(true);
156  $height_prop->setMinValue(200);
157  $this->form->addItem($height_prop);
158 
159  // horizonal align
160  $align_prop = new ilSelectInputGUI($this->lng->txt("cont_align"),
161  "horizontal_align");
162  $options = array(
163  "Left" => $lng->txt("cont_left"),
164  "Center" => $lng->txt("cont_center"),
165  "Right" => $lng->txt("cont_right"),
166  "LeftFloat" => $lng->txt("cont_left_float"),
167  "RightFloat" => $lng->txt("cont_right_float"));
168  $align_prop->setOptions($options);
169  $this->form->addItem($align_prop);
170 
171  // caption
172  $caption_prop = new ilTextAreaInputGUI($this->lng->txt("cont_caption"),
173  "caption");
174  $this->form->addItem($caption_prop);
175 
176  // save/cancel buttons
177  if ($a_mode == "create")
178  {
179  $this->form->addCommandButton("create_map", $lng->txt("save"));
180  $this->form->addCommandButton("cancelCreate", $lng->txt("cancel"));
181  }
182  else
183  {
184  $this->form->addCommandButton("update_map", $lng->txt("save"));
185  $this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
186  }
187  //$html = $form->getHTML();
188  }
189 
193  function create()
194  {
195  global $tpl;
196 
197  $this->initForm("create");
198  if ($this->form->checkInput())
199  {
200  $this->content_obj = new ilPCMap($this->dom);
201  $location = $this->form->getInput("location");
202  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
203  $this->content_obj->setLatitude($location["latitude"]);
204  $this->content_obj->setLongitude($location["longitude"]);
205  $this->content_obj->setZoom($location["zoom"]);
206  $this->content_obj->setLayout($this->form->getInput("width"),
207  $this->form->getInput("height"),
208  $this->form->getInput("horizontal_align"));
209  $this->content_obj->setCaption(
210  $this->content_obj->handleCaptionInput($this->form->getInput("caption")));
211  $this->updated = $this->pg_obj->update();
212  if ($this->updated === true)
213  {
214  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
215  return;
216  }
217  }
218  $this->displayValidationError();
219  $this->form->setValuesByPost();
220  $tpl->setContent($this->form->getHTML());
221  }
222 
226  function update()
227  {
228  $this->initForm("update");
229  if ($this->form->checkInput())
230  {
231  $location = $this->form->getInput("location");
232  $this->content_obj->setLatitude($location["latitude"]);
233  $this->content_obj->setLongitude($location["longitude"]);
234  $this->content_obj->setZoom($location["zoom"]);
235  $this->content_obj->setLayout($this->form->getInput("width"),
236  $this->form->getInput("height"),
237  $this->form->getInput("horizontal_align"));
238  $this->content_obj->setCaption(
239  $this->content_obj->handleCaptionInput($this->form->getInput("caption")));
240  $this->updated = $this->pg_obj->update();
241  if ($this->updated === true)
242  {
243  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
244  return;
245  }
246  }
247  $this->displayValidationError();
248  $this->form->setValuesByPost();
249  $tpl->setContent($this->form->getHTML());
250  }
251 }
252 ?>