| 67 | | if ( $root != null |
|---|
| 68 | | && $root != '') |
|---|
| 69 | | { |
|---|
| 70 | | // User has specified a root topic to use |
|---|
| 71 | | $this->_root_folder = new midcom_db_topic($root); |
|---|
| 72 | | if (!$this->_root_folder) |
|---|
| 73 | | { |
|---|
| 74 | | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Could not open root topic with GUID {$root} please check your component configuration: " . mgd_errstr()); |
|---|
| 75 | | } |
|---|
| 76 | | // FIXME: Use in_tree constraint with Midgard 1.8 here |
|---|
| 77 | | if (! mgd_is_in_topic_tree($this->_nap->get_root_node(), $this->_root_folder->id)) |
|---|
| 78 | | { |
|---|
| 79 | | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "The topic with GUID {$root} is not within the content tree as indicated by NAP. Check your configuration."); |
|---|
| 80 | | } |
|---|
| 81 | | |
|---|
| 82 | | $this->_root_node_id = $this->_root_folder->id; |
|---|
| | 67 | $this->_request_data['skip_topics'] = $this->_config->get('skip_topics'); |
|---|
| | 68 | $user_root = ''; |
|---|
| | 69 | if(isset($_REQUEST['de_linkm_sitemap_set_root'])) |
|---|
| | 70 | { |
|---|
| | 71 | $user_root = $_REQUEST['de_linkm_sitemap_set_root']; |
|---|
| | 72 | } |
|---|
| | 73 | if(isset($_REQUEST['de_linkm_sitemap_set_levels'])) |
|---|
| | 74 | { |
|---|
| | 75 | $this->_show_levels = $_REQUEST['de_linkm_sitemap_set_levels']; |
|---|
| | 76 | } |
|---|
| | 77 | else |
|---|
| | 78 | { |
|---|
| | 79 | $this->_show_levels = 99; |
|---|
| | 80 | } |
|---|
| | 81 | if ( ($root != null |
|---|
| | 82 | && $root != '') |
|---|
| | 83 | || ($user_root != null |
|---|
| | 84 | && $user_root != '') |
|---|
| | 85 | ) |
|---|
| | 86 | { |
|---|
| | 87 | if ( $user_root != null |
|---|
| | 88 | && $user_root != '') |
|---|
| | 89 | { |
|---|
| | 90 | // User has specified a root topic to use by request parameter |
|---|
| | 91 | $this->_root_folder = new midcom_db_topic($user_root); |
|---|
| | 92 | if (!$this->_root_folder) |
|---|
| | 93 | { |
|---|
| | 94 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Could not open root topic with GUID {$user_root} please check your component configuration: " . mgd_errstr()); |
|---|
| | 95 | } |
|---|
| | 96 | // FIXME: Use in_tree constraint with Midgard 1.8 here |
|---|
| | 97 | if (! mgd_is_in_topic_tree($this->_nap->get_root_node(), $this->_root_folder->id)) |
|---|
| | 98 | { |
|---|
| | 99 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "The topic with GUID {$user_root} is not within the content tree as indicated by NAP. Check your configuration."); |
|---|
| | 100 | } |
|---|
| | 101 | |
|---|
| | 102 | $this->_root_node_id = $this->_root_folder->id; |
|---|
| | 103 | } |
|---|
| | 104 | else |
|---|
| | 105 | { |
|---|
| | 106 | // User has specified a root topic to use in component config |
|---|
| | 107 | $this->_root_folder = new midcom_db_topic($root); |
|---|
| | 108 | if (!$this->_root_folder) |
|---|
| | 109 | { |
|---|
| | 110 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Could not open root topic with GUID {$root} please check your component configuration: " . mgd_errstr()); |
|---|
| | 111 | } |
|---|
| | 112 | // FIXME: Use in_tree constraint with Midgard 1.8 here |
|---|
| | 113 | if (! mgd_is_in_topic_tree($this->_nap->get_root_node(), $this->_root_folder->id)) |
|---|
| | 114 | { |
|---|
| | 115 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "The topic with GUID {$root} is not within the content tree as indicated by NAP. Check your configuration."); |
|---|
| | 116 | } |
|---|
| | 117 | |
|---|
| | 118 | $this->_root_node_id = $this->_root_folder->id; |
|---|
| | 119 | } |
|---|
| 275 | | |
|---|
| 276 | | // Start a new node and display it |
|---|
| 277 | | $data['node'] = $this->_current_node; |
|---|
| 278 | | midcom_show_style('node-start'); |
|---|
| 279 | | midcom_show_style('node'); |
|---|
| 280 | | |
|---|
| 281 | | // Try to load Child elements |
|---|
| 282 | | $subnodes = $this->_nap->list_nodes($nodeid); |
|---|
| 283 | | $leaves = null; |
|---|
| 284 | | if ($subnodes === false) |
|---|
| 285 | | { |
|---|
| 286 | | midcom_show_style('node-end'); |
|---|
| 287 | | return false; |
|---|
| 288 | | } |
|---|
| 289 | | if ($this->_config->get('hide_leaves') == false) |
|---|
| 290 | | { |
|---|
| 291 | | $leaves = $this->_nap->list_leaves($nodeid, $data); |
|---|
| 292 | | if ($leaves === false) |
|---|
| | 312 | $topics_to_skip = explode(',',$this->_config->get('skip_topics')); |
|---|
| | 313 | if(!in_array($this->_current_node[MIDCOM_NAV_GUID],$topics_to_skip)) |
|---|
| | 314 | { |
|---|
| | 315 | |
|---|
| | 316 | // Start a new node and display it |
|---|
| | 317 | $data['node'] = $this->_current_node; |
|---|
| | 318 | midcom_show_style('node-start'); |
|---|
| | 319 | midcom_show_style('node'); |
|---|
| | 320 | |
|---|
| | 321 | // Try to load Child elements |
|---|
| | 322 | $subnodes = $this->_nap->list_nodes($nodeid); |
|---|
| | 323 | $leaves = null; |
|---|
| | 324 | if ($subnodes === false) |
|---|
| 297 | | } |
|---|
| 298 | | |
|---|
| 299 | | // Now display all subnodes and the leaves in the right order |
|---|
| 300 | | if ($this->_config->get('leaves_first')) |
|---|
| 301 | | { |
|---|
| 302 | | if (! $this->_show_leaves($leaves, $data)) |
|---|
| 303 | | { |
|---|
| 304 | | midcom_show_style('node-end'); |
|---|
| 305 | | return false; |
|---|
| 306 | | } |
|---|
| | 329 | if ($this->_config->get('hide_leaves') == false) |
|---|
| | 330 | { |
|---|
| | 331 | $leaves = $this->_nap->list_leaves($nodeid, $data); |
|---|
| | 332 | if ($leaves === false) |
|---|
| | 333 | { |
|---|
| | 334 | midcom_show_style('node-end'); |
|---|
| | 335 | return false; |
|---|
| | 336 | } |
|---|
| | 337 | } |
|---|
| | 338 | |
|---|
| | 339 | // Now display all subnodes and the leaves in the right order |
|---|
| | 340 | if ($this->_config->get('leaves_first')) |
|---|
| | 341 | { |
|---|
| | 342 | if (! $this->_show_leaves($leaves, $data)) |
|---|
| | 343 | { |
|---|
| | 344 | midcom_show_style('node-end'); |
|---|
| | 345 | return false; |
|---|
| | 346 | } |
|---|
| | 347 | |
|---|
| | 348 | if (!$this->_show_subnodes($subnodes, $data)) |
|---|
| | 349 | { |
|---|
| | 350 | midcom_show_style('node-end'); |
|---|
| | 351 | return false; |
|---|
| | 352 | } |
|---|
| | 353 | } |
|---|
| | 354 | else |
|---|
| | 355 | { |
|---|
| | 356 | if (! $this->_show_subnodes($subnodes, $data)) |
|---|
| | 357 | { |
|---|
| | 358 | midcom_show_style('node-end'); |
|---|
| | 359 | return false; |
|---|
| | 360 | } |
|---|
| 308 | | if (!$this->_show_subnodes($subnodes, $data)) |
|---|
| 309 | | { |
|---|
| 310 | | midcom_show_style('node-end'); |
|---|
| 311 | | return false; |
|---|
| 312 | | } |
|---|
| 313 | | } |
|---|
| 314 | | else |
|---|
| 315 | | { |
|---|
| 316 | | if (! $this->_show_subnodes($subnodes, $data)) |
|---|
| 317 | | { |
|---|
| 318 | | midcom_show_style('node-end'); |
|---|
| 319 | | return false; |
|---|
| 320 | | } |
|---|
| 321 | | |
|---|
| 322 | | if (! $this->_show_leaves($leaves, $data)) |
|---|
| 323 | | { |
|---|
| 324 | | midcom_show_style('node-end'); |
|---|
| 325 | | return false; |
|---|
| 326 | | } |
|---|
| 327 | | } |
|---|
| 328 | | |
|---|
| 329 | | // Close current node |
|---|
| 330 | | midcom_show_style('node-end'); |
|---|
| 331 | | |
|---|
| 332 | | // Clean up |
|---|
| 333 | | $this->_current_node = $previous; |
|---|
| 334 | | |
|---|
| | 362 | if (! $this->_show_leaves($leaves, $data)) |
|---|
| | 363 | { |
|---|
| | 364 | midcom_show_style('node-end'); |
|---|
| | 365 | return false; |
|---|
| | 366 | } |
|---|
| | 367 | } |
|---|
| | 368 | |
|---|
| | 369 | // Close current node |
|---|
| | 370 | midcom_show_style('node-end'); |
|---|
| | 371 | |
|---|
| | 372 | // Clean up |
|---|
| | 373 | $this->_current_node = $previous; |
|---|
| | 374 | } |
|---|