| 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'])) |
|---|
| | 71 | if (isset($_REQUEST['de_linkm_sitemap_set_root'])) |
|---|
| | 72 | { |
|---|
| | 73 | $root = $_REQUEST['de_linkm_sitemap_set_root']; |
|---|
| | 74 | } |
|---|
| | 75 | |
|---|
| | 76 | if (!empty($root)) |
|---|
| | 77 | { |
|---|
| | 78 | // User has specified a root topic to use in component config or request parameter |
|---|
| | 79 | $qb = midcom_db_topic::new_query_builder(); |
|---|
| | 80 | $qb->add_constraint('guid', '=', $root); |
|---|
| | 81 | $qb->add_constraint('up', 'INTREE', $site_root->id); |
|---|
| | 82 | $topics = $qb->execute(); |
|---|
| | 83 | if (empty($topics)) |
|---|
| | 84 | { |
|---|
| | 85 | $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Could not open root topic with GUID {$root}, please check your setup: " . mgd_errstr()); |
|---|
| | 86 | // This will exit |
|---|
| | 87 | } |
|---|
| | 88 | |
|---|
| | 89 | $this->_root_node_id = $topics[0]->id; |
|---|
| | 90 | } |
|---|
| | 91 | |
|---|
| | 92 | $this->_show_levels = 99; |
|---|
| | 93 | if (isset($_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 | | } |
|---|
| 120 | | } |
|---|
| 121 | | else |
|---|
| 122 | | { |
|---|
| 123 | | // Use the site root node |
|---|
| 124 | | $this->_root_node_id = $this->_nap->get_root_node(); |
|---|
| 125 | | } |
|---|
| 126 | | |
|---|
| | 96 | } |
|---|