CanDoOperation('seo_tools'))
{
$APPLICATION->AuthForm(Loc::getMessage("ACCESS_DENIED"));
}
if(!Main\Loader::includeModule('seo'))
{
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
ShowError(Loc::getMessage("SEO_ERROR_NO_MODULE"));
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
}
$errors = '';
$siteId = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : '';
$arCurrentSite = array();
$arDefaultSite = array();
$arSites = array();
$dbSites = Bitrix\Main\SiteTable::getList(
array(
'order' => array('DEF' => 'DESC', 'NAME' => 'ASC'),
'select' => array('LID', 'NAME', 'DEF', 'DIR', 'DOC_ROOT', 'SERVER_NAME')
)
);
while($arRes = $dbSites->fetch(Converter::getHtmlConverter()))
{
if($arRes['DOC_ROOT'] == '')
{
$arRes['DOC_ROOT'] = Converter::getHtmlConverter()->encode(
Main\SiteTable::getDocumentRoot($arRes['LID'])
);
}
if($arRes['DEF'] == 'Y')
{
$arDefaultSite = $arRes;
}
$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() && $_POST["save"] <> '')
{
$robotsFile->putContents($_REQUEST['ROBOTS']);
LocalRedirect(BX_ROOT."/admin/seo_robots.php?lang=".LANGUAGE_ID.'&site_id='.$siteId."&".$tabControl->ActiveTabParam());
}
$hostName = $arCurrentSite['SERVER_NAME'];
if($hostName == '')
{
$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();
$arDDMenu = array();
$arDDMenu[] = array(
"HTML" => "".Loc::getMessage("SEO_ROBOTS_CHOOSE_SITE")."",
"ACTION" => false
);
foreach($arSites as $arRes)
{
$arDDMenu[] = array(
"HTML" => "[".$arRes["LID"]."] ".$arRes["NAME"],
"LINK" => "seo_robots.php?lang=".LANGUAGE_ID."&site_id=".$arRes['LID']
);
}
$aContext = array();
$aContext[] = array(
"TEXT" => $arCurrentSite['NAME'],
"MENU" => $arDDMenu
);
$context = new CAdminContextMenu($aContext);
$context->Show();
if(!empty($errors))
{
CAdminMessage::ShowMessage(join("\n", $errors));
}
?>