$arSitemap['SETTINGS'][$arRes["ENTITY_TYPE"] . '_AUTO'][$arRes['ENTITY_ID']] = 'Y'; } if (empty($arSitemap['SETTINGS']['FILENAME_FORUM'])) { $arSitemap['SETTINGS']['FILENAME_FORUM'] = "sitemap_forum_#FORUM_ID#.xml"; } $SITE_ID = $arSitemap['SITE_ID']; } } if (strlen($SITE_ID) > 0) { $dbSite = Main\SiteTable::getByPrimary($SITE_ID); $arSite = $dbSite->fetch(); if (!is_array($arSite)) { $SITE_ID = ''; } else { $arSite['DOMAINS'] = array(); $robotsFile = new RobotsFile($SITE_ID); if ($robotsFile->isExists()) { $arHostsList = $robotsFile->getRules('Host'); foreach ($arHostsList as $rule) { $host = $rule[1]; if (strncmp($host, 'https://', 8) === 0) { $host = substr($host, 8); $bDefaultHttps = true; } $arSite['DOMAINS'][] = $host; } } if ($arSite['SERVER_NAME'] != '') { $arSite['DOMAINS'][] = $arSite['SERVER_NAME']; } $dbDomains = Bitrix\Main\SiteDomainTable::getList(array('filter' => array('LID' => $SITE_ID), 'select' => array('DOMAIN')));
protected static function actionAdd($name, $arFields) { if ($name == 'ADDELEMENT') { if (!self::checkElement($arFields)) { return; } // we don't have the GLOBAL_ACTIVE flag in $arFields so we should check it manually if (is_array($arFields['IBLOCK_SECTION']) && count($arFields['IBLOCK_SECTION']) > 0) { $arNewSections = array(); $arFilter = array('ID' => $arFields['IBLOCK_SECTION'], 'IBLOCK_ID' => $arFields['IBLOCK_ID'], 'GLOBAL_ACTIVE' => 'Y'); $dbRes = \CIBlockSection::getList(array(), $arFilter, false, array('ID')); while ($ar = $dbRes->fetch()) { $arNewSections[] = $ar['ID']; } if (count($arNewSections) <= 0) { // element is added to inactive sections return; } $arFields['IBLOCK_SECTION'] = $arNewSections; } } elseif ($name == 'ADDSECTION') { $dbRes = \CIBlockSection::getList(array(), array('ID' => $arFields['ID'], 'GLOBAL_ACTIVE' => 'Y'), false, array('ID')); if (!$dbRes->fetch()) { // section is added to inactive branch return; } } $arSitemaps = SitemapIblockTable::getByIblock($arFields, $name == 'ADDSECTION' ? SitemapIblockTable::TYPE_SECTION : SitemapIblockTable::TYPE_ELEMENT); $arFields['TIMESTAMP_X'] = ConvertTimeStamp(false, "FULL"); if (isset($arFields['IBLOCK_SECTION']) && is_array($arFields['IBLOCK_SECTION']) && count($arFields['IBLOCK_SECTION']) > 0) { $arFields['IBLOCK_SECTION_ID'] = min($arFields['IBLOCK_SECTION']); } if (count($arSitemaps) > 0) { $arSiteDirs = array(); $dbSite = SiteTable::getList(array('select' => array('LID', 'DIR'))); while ($arSite = $dbSite->fetch()) { $arSiteDirs[$arSite['LID']] = $arSite['DIR']; } foreach ($arSitemaps as $arSitemap) { $arFields['LANG_DIR'] = $arSiteDirs[$arSitemap['SITE_ID']]; $rule = array('url' => $name == 'ADDSECTION' ? \CIBlock::replaceDetailUrl($arSitemaps[0]['SECTION_PAGE_URL'], $arFields, false, "S") : \CIBlock::replaceDetailUrl($arSitemaps[0]['DETAIL_PAGE_URL'], $arFields, false, "E"), 'lastmod' => MakeTimeStamp($arFields['TIMESTAMP_X'])); $fileName = str_replace(array('#IBLOCK_ID#', '#IBLOCK_CODE#', '#IBLOCK_XML_ID#'), array($arFields['IBLOCK_ID'], $arSitemap['IBLOCK_CODE'], $arSitemap['IBLOCK_XML_ID']), $arSitemap['SITEMAP_FILE_IBLOCK']); $sitemapFile = new SitemapFile($fileName, $arSitemap); $sitemapFile->appendIblockEntry($rule['url'], $rule['lastmod']); $sitemapIndex = new SitemapIndex($arSitemap['SITEMAP_FILE'], $arSitemap); $sitemapIndex->appendIndexEntry($sitemapFile); if ($arSitemap['ROBOTS'] == 'Y') { $robotsFile = new RobotsFile($arSitemap['SITE_ID']); $robotsFile->addRule(array(RobotsFile::SITEMAP_RULE, $sitemapIndex->getUrl())); } } } }
$arSites[$arRes['LID']] = $arRes; } $arCurrentSite = isset($arSites[$siteId]) ? $arSites[$siteId] : $arDefaultSite; $siteId = $arCurrentSite['LID']; $arRobotsConfig = array('common' => array(array('*', Loc::getMessage('SEO_ROBOTS_COMMON'))), 'yandex' => array(array('Yandex', Loc::getMessage('SEO_ROBOTS_YANDEX')), array('YandexBot', Loc::getMessage('SEO_ROBOTS_YANDEXBOT')), array('YandexMedia', Loc::getMessage('SEO_ROBOTS_YANDEXMEDIA')), array('YandexImages', Loc::getMessage('SEO_ROBOTS_YANDEXIMAGES')), array('YandexBlogs', Loc::getMessage('SEO_ROBOTS_YANDEXBLOGS')), array('YandexNews', Loc::getMessage('SEO_ROBOTS_YANDEXNEWS')), array('YandexMetrika', Loc::getMessage('SEO_ROBOTS_YANDEXMETRIKA')), array('YandexMarket', Loc::getMessage('SEO_ROBOTS_YANDEXMARKET'))), 'google' => array(array('Googlebot', Loc::getMessage('SEO_ROBOTS_GOOGLEBOT')), array('Googlebot-News', Loc::getMessage('SEO_ROBOTS_GOOGLEBOT_NEWS')), array('Googlebot-Image', Loc::getMessage('SEO_ROBOTS_GOOGLEBOT_IMAGE')), array('Googlebot-Video', Loc::getMessage('SEO_ROBOTS_GOOGLEBOT_VIDEO')), array('Googlebot-Mobile', Loc::getMessage('SEO_ROBOTS_GOOGLEBOT_MOBILE')))); $bVendor = COption::GetOptionString('main', 'vendor', '') == '1c_bitrix'; if (!$bVendor) { unset($arRobotsConfig['yandex']); } $aTabs = array(); foreach ($arRobotsConfig as $key => $arConfig) { $aTabs[] = array("DIV" => "seo_robots_" . $key, "TAB" => Loc::getMessage('SEO_ROBOTS_' . $key), "TITLE" => Loc::getMessage('SEO_ROBOTS_TITLE_' . $key)); } $aTabs[] = array("DIV" => "seo_robots_edit", "TAB" => Loc::getMessage('SEO_ROBOTS_EDIT'), "TITLE" => Loc::getMessage('SEO_ROBOTS_TITLE_EDIT'), 'ONSELECT' => 'seoParser.compile();'); $tabControl = new \CAdminTabControl("seoRobotsTabControl", $aTabs, true, true); $robotsFile = new RobotsFile($siteId); if ($_SERVER['REQUEST_METHOD'] == 'POST' && check_bitrix_sessid() && strlen($_POST["save"]) > 0) { $robotsFile->putContents($_REQUEST['ROBOTS']); LocalRedirect(BX_ROOT . "/admin/seo_robots.php?lang=" . LANGUAGE_ID . '&site_id=' . $siteId . "&" . $tabControl->ActiveTabParam()); } $hostName = $arCurrentSite['SERVER_NAME']; if (strlen($hostName) <= 0) { $hostName = COption::GetOptionString('main', 'server_name', ''); } CJSCore::RegisterExt('seo_robots', array('js' => '/bitrix/js/seo/robots.js', 'css' => '/bitrix/panel/seo/robots.css', 'lang' => BX_ROOT . '/modules/seo/lang/' . LANGUAGE_ID . '/js_robots.php', 'lang_additional' => array('SEO_HOST' => $hostName, 'SEO_SITE_ID' => $siteId))); $APPLICATION->addHeadScript('/bitrix/js/main/utils.js'); $APPLICATION->addHeadScript('/bitrix/js/main/file_dialog.js'); CJSCore::Init('seo_robots'); $APPLICATION->SetTitle(Loc::getMessage("SEO_ROBOTS_EDIT_TITLE")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $aMenu = array();
$msg = Loc::getMessage('SITEMAP_RUN_FINALIZE'); } } else { SitemapRuntimeTable::clearByPid($PID); $arFiles = array(); $sitemapFile = new SitemapIndex($arSitemap['SETTINGS']['FILENAME_INDEX'], $arSitemapSettings); if (count($NS['XML_FILES']) > 0) { foreach ($NS['XML_FILES'] as $xmlFile) { $arFiles[] = new IO\File(IO\Path::combine($sitemapFile->getSiteRoot(), $xmlFile), $arSitemap['SITE_ID']); } } $sitemapFile->createIndex($arFiles); $arExistedSitemaps = array(); if ($arSitemap['SETTINGS']['ROBOTS'] == 'Y') { $sitemapUrl = $sitemapFile->getUrl(); $robotsFile = new RobotsFile($arSitemap['SITE_ID']); $robotsFile->addRule(array(RobotsFile::SITEMAP_RULE, $sitemapUrl)); $arSitemapLinks = $robotsFile->getRules(RobotsFile::SITEMAP_RULE); if (count($arSitemapLinks) > 1) { foreach ($arSitemapLinks as $rule) { if ($rule[1] != $sitemapUrl) { $arExistedSitemaps[] = $rule[1]; } } } } $v = $arValueSteps['index']; } } } if ($v == $arValueSteps['index']) {
protected static function actionAdd($arMessage, $arTopic, $arForum = array()) { if (($arSitemaps = self::checkParams($arMessage, $arTopic, $arForum)) && $arSitemaps) { foreach ($arSitemaps as $arSitemap) { $sitemapFile = new SitemapFile($arSitemap["fileName"], $arSitemap); $sitemapFile->appendIblockEntry($arSitemap['url'], $arSitemap['date']); $sitemapIndex = new SitemapIndex($arSitemap['SITEMAP_FILE'], $arSitemap); $sitemapIndex->appendIndexEntry($sitemapFile); if ($arSitemap['ROBOTS'] == 'Y') { $robotsFile = new RobotsFile($arSitemap['SITE_ID']); $robotsFile->addRule(array(RobotsFile::SITEMAP_RULE, $sitemapIndex->getUrl())); } } } }