ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPCMap.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once("./Services/COPage/classes/class.ilPageContent.php");
6
18{
20
24 function init()
25 {
26 $this->setType("map");
27 }
28
32 function setNode(&$a_node)
33 {
34 parent::setNode($a_node); // this is the PageContent node
35 $this->map_node =& $a_node->first_child(); // this is the Map node
36 }
37
44 function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
45 {
46 $this->node = $this->createPageContentNode();
47
48 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
49 $this->map_node =& $this->dom->create_element("Map");
50 $this->map_node =& $this->node->append_child($this->map_node);
51 $this->map_node->set_attribute("Latitude", "0");
52 $this->map_node->set_attribute("Longitude", "0");
53 $this->map_node->set_attribute("Zoom", "3");
54 }
55
61 function setLatitude($a_lat)
62 {
63 if (!empty($a_lat))
64 {
65 $this->map_node->set_attribute("Latitude", $a_lat);
66 }
67 else
68 {
69 if ($this->map_node->has_attribute("Latitude"))
70 {
71 $this->map_node->remove_attribute("Latitude");
72 }
73 }
74 }
75
81 function getLatitude()
82 {
83 if (is_object($this->map_node))
84 {
85 return $this->map_node->get_attribute("Latitude");
86 }
87 }
88
94 function setLongitude($a_long)
95 {
96 if (!empty($a_long))
97 {
98 $this->map_node->set_attribute("Longitude", $a_long);
99 }
100 else
101 {
102 if ($this->map_node->has_attribute("Longitude"))
103 {
104 $this->map_node->remove_attribute("Longitude");
105 }
106 }
107 }
108
114 function getLongitude()
115 {
116 if (is_object($this->map_node))
117 {
118 return $this->map_node->get_attribute("Longitude");
119 }
120 }
121
127 function setZoom($a_zoom)
128 {
129 if (!empty($a_zoom))
130 {
131 $this->map_node->set_attribute("Zoom", $a_zoom);
132 }
133 else
134 {
135 if ($this->map_node->has_attribute("Zoom"))
136 {
137 $this->map_node->remove_attribute("Zoom");
138 }
139 }
140 }
141
147 function getZoom()
148 {
149 if (is_object($this->map_node))
150 {
151 return $this->map_node->get_attribute("Zoom");
152 }
153 }
154
162 function setLayout($a_width, $a_height, $a_horizontal_align)
163 {
164 if (is_object($this->map_node))
165 {
166 ilDomUtil::setFirstOptionalElement($this->dom, $this->map_node,
167 "Layout", array("MapCaption"), "", array("Width" => $a_width,
168 "Height" => $a_height, "HorizontalAlign" => $a_horizontal_align));
169 }
170 }
171
177 function getWidth()
178 {
179 if (is_object($this->map_node))
180 {
181 $childs = $this->map_node->child_nodes();
182 foreach($childs as $child)
183 {
184 if ($child->node_name() == "Layout")
185 {
186 return $child->get_attribute("Width");
187 }
188 }
189 }
190 }
191
197 function getHeight()
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("Height");
207 }
208 }
209 }
210 }
211
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("HorizontalAlign");
227 }
228 }
229 }
230 }
231
237 function setCaption($a_caption)
238 {
239 if (is_object($this->map_node))
240 {
241 ilDomUtil::setFirstOptionalElement($this->dom, $this->map_node,
242 "MapCaption", array(), $a_caption, array());
243 }
244 }
245
251 function getCaption()
252 {
253 if (is_object($this->map_node))
254 {
255 $childs = $this->map_node->child_nodes();
256 foreach($childs as $child)
257 {
258 if ($child->node_name() == "MapCaption")
259 {
260 return $child->get_content();
261 }
262 }
263 }
264 }
265
266 static function handleCaptionInput($a_text)
267 {
268 $a_text = str_replace(chr(13).chr(10),"<br />",$a_text);
269 $a_text = str_replace(chr(13),"<br />", $a_text);
270 $a_text = str_replace(chr(10),"<br />", $a_text);
271
272 return $a_text;
273 }
274
275 static function handleCaptionFormOutput($a_text)
276 {
277 $a_text = str_replace("<br />", "\n", $a_text);
278 $a_text = str_replace("<br/>", "\n", $a_text);
279
280 return $a_text;
281 }
282
289 function modifyPageContentPostXsl($a_html, $a_mode)
290 {
291 $c_pos = 0;
292 $start = strpos($a_html, "[[[[[Map;");
293 if (is_int($start))
294 {
295 $end = strpos($a_html, "]]]]]", $start);
296 }
297 $i = 1;
298 while ($end > 0)
299 {
300 $param = substr($a_html, $start + 9, $end - $start - 9);
301
302 $param = explode(";", $param);
303 if (is_numeric($param[0]) && is_numeric($param[1]) && is_numeric($param[2]))
304 {
305 include_once("./Services/Maps/classes/class.ilMapUtil.php");
306 $map_gui = ilMapUtil::getMapGUI();
307 $map_gui->setMapId("map_".$i)
308 ->setLatitude($param[0])
309 ->setLongitude($param[1])
310 ->setZoom($param[2])
311 ->setWidth($param[3]."px")
312 ->setHeight($param[4]."px")
313 ->setEnableTypeControl(true)
314 ->setEnableNavigationControl(true)
315 ->setEnableCentralMarker(true);
316 $h2 = substr($a_html, 0, $start).
317 $map_gui->getHtml().
318 substr($a_html, $end + 5);
319 $a_html = $h2;
320 $i++;
321 }
322 $start = strpos($a_html, "[[[[[Map;", $start + 5);
323 $end = 0;
324 if (is_int($start))
325 {
326 $end = strpos($a_html, "]]]]]", $start);
327 }
328 }
329
330 return $a_html;
331 }
332
333}
334
335?>
const IL_INSERT_AFTER
static getMapGUI()
Get an instance of the GUI class.
Class ilPCMap.
setZoom($a_zoom)
Set zoom of map.
static handleCaptionFormOutput($a_text)
getHorizontalAlign()
Get Horizontal Alignment.
getLongitude()
Get longitude of map.
getHeight()
Get Height.
setLongitude($a_long)
Set longitude of map.
setLatitude($a_lat)
Set latitude of map.
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create map node in xml.
getWidth()
Get Width.
getZoom()
Get zoom of map.
modifyPageContentPostXsl($a_html, $a_mode)
Modify page content after xsl.
setNode(&$a_node)
Set node.
setCaption($a_caption)
Set Caption.
static handleCaptionInput($a_text)
getCaption()
Get Caption.
getLatitude()
Get latitude of map.
init()
Init page content component.
setLayout($a_width, $a_height, $a_horizontal_align)
Set Layout.
Class ilPageContent.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType($a_type)
Set Type.