ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
5 require_once("./Services/COPage/classes/class.ilPageContent.php");
6 
17 class ilPCMap extends ilPageContent
18 {
19  public $map_node;
20 
24  public function init()
25  {
26  $this->setType("map");
27  }
28 
32  public 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  public 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  public function setLatitude($a_lat)
62  {
63  if (!empty($a_lat)) {
64  $this->map_node->set_attribute("Latitude", $a_lat);
65  } else {
66  if ($this->map_node->has_attribute("Latitude")) {
67  $this->map_node->remove_attribute("Latitude");
68  }
69  }
70  }
71 
77  public function getLatitude()
78  {
79  if (is_object($this->map_node)) {
80  return $this->map_node->get_attribute("Latitude");
81  }
82  }
83 
89  public function setLongitude($a_long)
90  {
91  if (!empty($a_long)) {
92  $this->map_node->set_attribute("Longitude", $a_long);
93  } else {
94  if ($this->map_node->has_attribute("Longitude")) {
95  $this->map_node->remove_attribute("Longitude");
96  }
97  }
98  }
99 
105  public function getLongitude()
106  {
107  if (is_object($this->map_node)) {
108  return $this->map_node->get_attribute("Longitude");
109  }
110  }
111 
117  public function setZoom($a_zoom)
118  {
119  if (!empty($a_zoom)) {
120  $this->map_node->set_attribute("Zoom", $a_zoom);
121  } else {
122  if ($this->map_node->has_attribute("Zoom")) {
123  $this->map_node->remove_attribute("Zoom");
124  }
125  }
126  }
127 
133  public function getZoom()
134  {
135  if (is_object($this->map_node)) {
136  return $this->map_node->get_attribute("Zoom");
137  }
138  }
139 
147  public function setLayout($a_width, $a_height, $a_horizontal_align)
148  {
149  if (is_object($this->map_node)) {
150  ilDomUtil::setFirstOptionalElement(
151  $this->dom,
152  $this->map_node,
153  "Layout",
154  array("MapCaption"),
155  "",
156  array("Width" => $a_width,
157  "Height" => $a_height, "HorizontalAlign" => $a_horizontal_align)
158  );
159  }
160  }
161 
167  public function getWidth()
168  {
169  if (is_object($this->map_node)) {
170  $childs = $this->map_node->child_nodes();
171  foreach ($childs as $child) {
172  if ($child->node_name() == "Layout") {
173  return $child->get_attribute("Width");
174  }
175  }
176  }
177  }
178 
184  public function getHeight()
185  {
186  if (is_object($this->map_node)) {
187  $childs = $this->map_node->child_nodes();
188  foreach ($childs as $child) {
189  if ($child->node_name() == "Layout") {
190  return $child->get_attribute("Height");
191  }
192  }
193  }
194  }
195 
201  public function getHorizontalAlign()
202  {
203  if (is_object($this->map_node)) {
204  $childs = $this->map_node->child_nodes();
205  foreach ($childs as $child) {
206  if ($child->node_name() == "Layout") {
207  return $child->get_attribute("HorizontalAlign");
208  }
209  }
210  }
211  }
212 
218  public function setCaption($a_caption)
219  {
220  if (is_object($this->map_node)) {
221  ilDomUtil::setFirstOptionalElement(
222  $this->dom,
223  $this->map_node,
224  "MapCaption",
225  array(),
226  $a_caption,
227  array()
228  );
229  }
230  }
231 
237  public function getCaption()
238  {
239  if (is_object($this->map_node)) {
240  $childs = $this->map_node->child_nodes();
241  foreach ($childs as $child) {
242  if ($child->node_name() == "MapCaption") {
243  return $child->get_content();
244  }
245  }
246  }
247  }
248 
249  public static function handleCaptionInput($a_text)
250  {
251  $a_text = str_replace(chr(13) . chr(10), "<br />", $a_text);
252  $a_text = str_replace(chr(13), "<br />", $a_text);
253  $a_text = str_replace(chr(10), "<br />", $a_text);
254 
255  return $a_text;
256  }
257 
258  public static function handleCaptionFormOutput($a_text)
259  {
260  $a_text = str_replace("<br />", "\n", $a_text);
261  $a_text = str_replace("<br/>", "\n", $a_text);
262 
263  return $a_text;
264  }
265 
272  public function modifyPageContentPostXsl($a_html, $a_mode)
273  {
274  $c_pos = 0;
275  $start = strpos($a_html, "[[[[[Map;");
276  if (is_int($start)) {
277  $end = strpos($a_html, "]]]]]", $start);
278  }
279  $i = 1;
280  while ($end > 0) {
281  $param = substr($a_html, $start + 9, $end - $start - 9);
282 
283  $param = explode(";", $param);
284  if (is_numeric($param[0]) && is_numeric($param[1]) && is_numeric($param[2])) {
285  include_once("./Services/Maps/classes/class.ilMapUtil.php");
286  $map_gui = ilMapUtil::getMapGUI();
287  $map_gui->setMapId("map_" . $i)
288  ->setLatitude($param[0])
289  ->setLongitude($param[1])
290  ->setZoom($param[2])
291  ->setWidth($param[3] . "px")
292  ->setHeight($param[4] . "px")
293  ->setEnableTypeControl(true)
294  ->setEnableNavigationControl(true)
295  ->setEnableCentralMarker(true);
296  $h2 = substr($a_html, 0, $start) .
297  $map_gui->getHtml() .
298  substr($a_html, $end + 5);
299  $a_html = $h2;
300  $i++;
301  }
302  $start = strpos($a_html, "[[[[[Map;", $start + 5);
303  $end = 0;
304  if (is_int($start)) {
305  $end = strpos($a_html, "]]]]]", $start);
306  }
307  }
308 
309  return $a_html;
310  }
311 }
getCaption()
Get Caption.
modifyPageContentPostXsl($a_html, $a_mode)
Modify page content after xsl.
getLongitude()
Get longitude of map.
getZoom()
Get zoom of map.
setLatitude($a_lat)
Set latitude of map.
setLayout($a_width, $a_height, $a_horizontal_align)
Set Layout.
$end
Definition: saml1-acs.php:18
static handleCaptionFormOutput($a_text)
setType($a_type)
Set Type.
getLatitude()
Get latitude of map.
Class ilPCMap.
getHorizontalAlign()
Get Horizontal Alignment.
Class ilPageContent.
static handleCaptionInput($a_text)
setLongitude($a_long)
Set longitude of map.
static getMapGUI()
Get an instance of the GUI class.
getHeight()
Get Height.
const IL_INSERT_AFTER
init()
Init page content component.
getWidth()
Get Width.
Create styles array
The data for the language used.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
setCaption($a_caption)
Set Caption.
$i
Definition: disco.tpl.php:19
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create map node in xml.
setZoom($a_zoom)
Set zoom of map.
setNode($a_node)
Set node.