function ___SitemapPluginArticles2($CatId, $Level)
{
    global $sitemap_articles;
    if (isset($sitemap_articles[$CatId])) {
        foreach ($sitemap_articles[$CatId] as $art) {
            SitemapAddObject($Level, $art[0], $art[1], '');
        }
    }
}
function ___SitemapPluginDownloads2($CatId, $Level)
{
    global $sitemap_downloads;
    if (isset($sitemap_downloads[$CatId])) {
        foreach ($sitemap_downloads[$CatId] as $d) {
            SitemapAddObject($Level, $d[0], $d[1], '');
        }
    }
}
function ___SitemapPluginForumTopics($ForumId, $Level)
{
    global $sitemap_forum_topics;
    if (isset($sitemap_forum_topics[$ForumId])) {
        foreach ($sitemap_forum_topics[$ForumId] as $topic) {
            SitemapAddObject($Level, $topic[0], $topic[1], '');
        }
    }
}
function ___SitemapPluginGalleryImages($CatId, $Level)
{
    global $sitemap_gallery;
    if (isset($sitemap_gallery[$CatId])) {
        foreach ($sitemap_gallery[$CatId] as $index => $img) {
            if ($img[0] == '') {
                $img[0] = 'Изображение ' . strval($index + 1);
            }
            SitemapAddObject($Level, $img[0], $img[1], '');
        }
    }
}
function ___SitemapPagesPlugin($Page, $Level)
{
    global $pages_tree;
    if ($Page['type'] != 'page') {
        $child_ids = $pages_tree->GetAllChildId($Page['id']);
        $find_page = false;
        foreach ($child_ids as $cid) {
            if ($pages_tree->IdCats[$cid]['type'] == 'page') {
                $find_page = true;
            }
        }
        if (!$find_page) {
            return false;
            // Останавливаем вывод дочерних элементов
        }
    }
    SitemapAddObject($Level, $Page['title'], $Page['link']);
}
global $sitemap_show_objects;
$sitemap_show_objects = System::config('general/sitemap_show_objects');
$sitemap_news_topics = array();
$sitemap_news = array();
// Получаем разделы и новости
$news_topicsdb = System::database()->Select('news_topics');
foreach ($news_topicsdb as $t) {
    $sitemap_news_topics[] = array($t['id'], $t['title'], Ufu('index.php?name=news&topic=' . SafeDB($t['id'], 11, int), 'news/{topic}/'));
}
if ($sitemap_show_objects) {
    // Загружаем новости
    $newsdb = System::database()->Select('news', "`enabled`='1' and `view`='4'", null, 'date');
    foreach ($newsdb as $n) {
        $sitemap_news[$n['topic_id']][] = array($n['title'], Ufu('index.php?name=news&op=readfull&news=' . SafeDB($n['id'], 11, int) . '&topic=' . SafeDB($n['topic_id'], 11, int), 'news/{topic}/{news}/'));
    }
    unset($newsdb);
}
// Выводим
if (count($sitemap_news_topics) > 0) {
    SitemapAddCategory('Новости');
    foreach ($sitemap_news_topics as $t) {
        global $sitemap_show_objects;
        SitemapAddObject(0, $t[1], $t[2]);
        if ($sitemap_show_objects && isset($sitemap_news[$t[0]])) {
            foreach ($sitemap_news[$t[0]] as $n) {
                SitemapAddObject(1, $n[0], $n[1], '');
            }
        }
    }
}
unset($sitemap_news, $sitemap_news_topics);