ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCMap.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.ilPageContent.php");
25 
36 class ilPCMap extends ilPageContent
37 {
38  var $dom;
39  var $map_node;
40 
44  function init()
45  {
46  $this->setType("map");
47  }
48 
52  function setNode(&$a_node)
53  {
54  parent::setNode($a_node); // this is the PageContent node
55  $this->map_node =& $a_node->first_child(); // this is the Map node
56  }
57 
64  function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
65  {
66  $this->node = $this->createPageContentNode();
67 
68  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
69  $this->map_node =& $this->dom->create_element("Map");
70  $this->map_node =& $this->node->append_child($this->map_node);
71  $this->map_node->set_attribute("Latitude", "0");
72  $this->map_node->set_attribute("Longitude", "0");
73  $this->map_node->set_attribute("Zoom", "3");
74  }
75 
81  function setLatitude($a_lat)
82  {
83  if (!empty($a_lat))
84  {
85  $this->map_node->set_attribute("Latitude", $a_lat);
86  }
87  else
88  {
89  if ($this->map_node->has_attribute("Latitude"))
90  {
91  $this->map_node->remove_attribute("Latitude");
92  }
93  }
94  }
95 
101  function getLatitude()
102  {
103  if (is_object($this->map_node))
104  {
105  return $this->map_node->get_attribute("Latitude");
106  }
107  }
108 
114  function setLongitude($a_long)
115  {
116  if (!empty($a_long))
117  {
118  $this->map_node->set_attribute("Longitude", $a_long);
119  }
120  else
121  {
122  if ($this->map_node->has_attribute("Longitude"))
123  {
124  $this->map_node->remove_attribute("Longitude");
125  }
126  }
127  }
128 
134  function getLongitude()
135  {
136  if (is_object($this->map_node))
137  {
138  return $this->map_node->get_attribute("Longitude");
139  }
140  }
141 
147  function setZoom($a_zoom)
148  {
149  if (!empty($a_zoom))
150  {
151  $this->map_node->set_attribute("Zoom", $a_zoom);
152  }
153  else
154  {
155  if ($this->map_node->has_attribute("Zoom"))
156  {
157  $this->map_node->remove_attribute("Zoom");
158  }
159  }
160  }
161 
167  function getZoom()
168  {
169  if (is_object($this->map_node))
170  {
171  return $this->map_node->get_attribute("Zoom");
172  }
173  }
174 
182  function setLayout($a_width, $a_height, $a_horizontal_align)
183  {
184  if (is_object($this->map_node))
185  {
186  ilDomUtil::setFirstOptionalElement($this->dom, $this->map_node,
187  "Layout", array("MapCaption"), "", array("Width" => $a_width,
188  "Height" => $a_height, "HorizontalAlign" => $a_horizontal_align));
189  }
190  }
191 
197  function getWidth()
198  {
199  if (is_object($this->map_node))
200  {
201  $childs = $this->map_node->child_nodes();
202  foreach($childs as $child)
203  {
204  if ($child->node_name() == "Layout")
205  {
206  return $child->get_attribute("Width");
207  }
208  }
209  }
210  }
211 
217  function getHeight()
218  {
219  if (is_object($this->map_node))
220  {
221  $childs = $this->map_node->child_nodes();
222  foreach($childs as $child)
223  {
224  if ($child->node_name() == "Layout")
225  {
226  return $child->get_attribute("Height");
227  }
228  }
229  }
230  }
231 
238  {
239  if (is_object($this->map_node))
240  {
241  $childs = $this->map_node->child_nodes();
242  foreach($childs as $child)
243  {
244  if ($child->node_name() == "Layout")
245  {
246  return $child->get_attribute("HorizontalAlign");
247  }
248  }
249  }
250  }
251 
257  function setCaption($a_caption)
258  {
259  if (is_object($this->map_node))
260  {
261  ilDomUtil::setFirstOptionalElement($this->dom, $this->map_node,
262  "MapCaption", array(), $a_caption, array());
263  }
264  }
265 
271  function getCaption()
272  {
273  if (is_object($this->map_node))
274  {
275  $childs = $this->map_node->child_nodes();
276  foreach($childs as $child)
277  {
278  if ($child->node_name() == "MapCaption")
279  {
280  return $child->get_content();
281  }
282  }
283  }
284  }
285 
286  static function handleCaptionInput($a_text)
287  {
288  $a_text = str_replace(chr(13).chr(10),"<br />",$a_text);
289  $a_text = str_replace(chr(13),"<br />", $a_text);
290  $a_text = str_replace(chr(10),"<br />", $a_text);
291 
292  return $a_text;
293  }
294 
295  static function handleCaptionFormOutput($a_text)
296  {
297  $a_text = str_replace("<br />", "\n", $a_text);
298  $a_text = str_replace("<br/>", "\n", $a_text);
299 
300  return $a_text;
301  }
302 
303 }
304 
305 ?>