GetByID($ID);
if($arType = $rsType->Fetch())
{
return $arType["ID"];
}
else
{
$arFields = array(
"ID" => $ID,
"SECTIONS" => $SECTIONS,
"LANG" => array(),
);
$rsLanguages = CLanguage::GetList();
while($arLanguage = $rsLanguages->Fetch())
{
$MY_MESS = IncludeModuleLangFile(__FILE__, $arLanguage["LID"], true);
$arFields["LANG"][$arLanguage["LID"]] = array(
"NAME" => $MY_MESS["IBLOCK_INSTALL_".mb_strtoupper($ID)."_NAME"],
"SECTION_NAME" => $MY_MESS["IBLOCK_INSTALL_".mb_strtoupper($ID)."_SECTIONS_NAME"],
"ELEMENT_NAME" => $MY_MESS["IBLOCK_INSTALL_".mb_strtoupper($ID)."_ELEMENTS_NAME"],
);
}
$result = $obType->Add($arFields);
if($result)
return $result;
else
return false;
}
}
$createNews = ($_REQUEST['news'] ?? '') === 'Y';
$news_dir = trim((string)$_REQUEST['news_dir'] ?? 'news');
$createCatalog = ($_REQUEST['catalog'] ?? '') === 'Y';
$catalog_dir = trim((string)($_REQUEST['catalog_dir'] ?? 'catalog'));
if($obModule->errors===false)
{
if ($createNews && CheckIBlockType("news", "N"))
{
//This makes translation checker happy
//$MY_MESS['IBLOCK_INSTALL_NEWS_NAME']
//$MY_MESS['IBLOCK_INSTALL_NEWS_SECTIONS_NAME']
//$MY_MESS['IBLOCK_INSTALL_NEWS_ELEMENTS_NAME']
//$MY_MESS['IBLOCK_INSTALL_NEWS_SECTION_NAME']
//$MY_MESS['IBLOCK_INSTALL_NEWS_ELEMENT_NAME']
$sites = CSite::GetList('', '', Array("ACTIVE"=>"Y"));
while($site = $sites->Fetch())
{
$MY_MESS = IncludeModuleLangFile(__FILE__, $site["LANGUAGE_ID"], true);
$obBlock = new CIBlock;
$arFields = array(
"LID" => $site["LID"],
"NAME" => GetMessage("IBLOCK_INSTALL_COMPANY_NEWS"),
"IBLOCK_TYPE_ID" => "news",
"CODE" => "comp_news",
"LIST_PAGE_URL" => "#SITE_DIR#/".$news_dir."/index.php",
"DETAIL_PAGE_URL" => "#SITE_DIR#/".$news_dir."/index.php?news=#ID#",
"ELEMENTS_NAME" => $MY_MESS["IBLOCK_INSTALL_NEWS_ELEMENTS_NAME"],
"ELEMENT_NAME" => $MY_MESS["IBLOCK_INSTALL_NEWS_ELEMENT_NAME"],
"GROUP_ID" => CIBlock::getDefaultRights(),
);
if($id = $obBlock->Add($arFields))
{
$obBlockProperty = new CIBlockProperty;
$arFields = array(
"IBLOCK_ID" => $id,
"NAME" => GetMessage("IBLOCK_INSTALL_SOURCE"),
"CODE" => "SOURCE",
"COL_COUNT" => "30",
);
$obBlockProperty->Add($arFields);
}
if($news_dir !== '')
{
$source = $_SERVER['DOCUMENT_ROOT']."/bitrix/modules/iblock/install/public/news/";
$target = $site['ABS_DOC_ROOT'].$site["DIR"].$news_dir."/";
if(file_exists($source))
{
CheckDirPath($target);
$dh = opendir($source);
while($file = readdir($dh))
{
if($file == "." || $file == "..")
continue;
if($bReWriteAdditionalFiles_n || !file_exists($target.$file))
{
$fh = fopen($source.$file, "rb");
$php_source = fread($fh, filesize($source.$file));
fclose($fh);
if(preg_match_all('/GetMessage\("(.*?)"\)/', $php_source, $matches))
{
IncludeModuleLangFile($source.$file, $site["LANGUAGE_ID"]);
$MESS["IBLOCK_INSTALL_PUBLIC_IBLOCK_ID"] = $id;
foreach($matches[0] as $i => $text)
{
$php_source = str_replace(
$text,
'"'.GetMessage($matches[1][$i]).'"',
$php_source
);
}
}
$fh = fopen($target.$file, "wb");
fwrite($fh, $php_source);
fclose($fh);
@chmod($target.$file, BX_FILE_PERMISSIONS);
}
}
}
}
}
}
if ($createCatalog && CheckIBlockType("catalog", "Y"))
{
//This makes translation checker happy
//$MY_MESS['IBLOCK_INSTALL_CATALOG_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_SECTIONS_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_ELEMENTS_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_SECTION_NAME']
//$MY_MESS['IBLOCK_INSTALL_CATALOG_ELEMENT_NAME']
$sites = CSite::GetList('', '', Array("ACTIVE"=>"Y"));
while($site = $sites->Fetch())
{
$MY_MESS = IncludeModuleLangFile(__FILE__, $site["LANGUAGE_ID"], true);
$obBlock = new CIBlock;
$arFields = array(
"LID" => $site["LID"],
"NAME" => GetMessage("IBLOCK_INSTALL_PRODUCTS"),
"IBLOCK_TYPE_ID" => "catalog",
"CODE" => "comp_catalog",
"LIST_PAGE_URL" => "#SITE_DIR#/".$catalog_dir."/index.php",
"DETAIL_PAGE_URL" => "#SITE_DIR#/".$catalog_dir."/index.php?ID=#ID#",
"ELEMENTS_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_ELEMENTS_NAME"],
"ELEMENT_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_ELEMENT_NAME"],
"SECTIONS_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_SECTIONS_NAME"],
"SECTION_NAME" => $MY_MESS["IBLOCK_INSTALL_CATALOG_SECTION_NAME"],
"GROUP_ID" => CIBlock::getDefaultRights(),
);
if($id = $obBlock->Add($arFields))
{
$obBlockProperty = new CIBlockProperty;
$arFields = array(
"IBLOCK_ID" => $id,
"NAME" => GetMessage("IBLOCK_INSTALL_SIMILAR_PRODUCTS"),
"CODE" => "ANALOG",
"PROPERTY_TYPE" => "E",
"MULTIPLE" => "Y",
"LINK_IBLOCK_ID" => $id,
);
$obBlockProperty->Add($arFields);
}
if ($catalog_dir !== '')
{
$source = $_SERVER['DOCUMENT_ROOT']."/bitrix/modules/iblock/install/public/catalog/";
$target = $site['ABS_DOC_ROOT'].$site["DIR"].$catalog_dir."/";
if(file_exists($source))
{
CheckDirPath($target);
$dh = opendir($source);
while($file = readdir($dh))
{
if($file == "." || $file == "..")
continue;
if($bReWriteAdditionalFiles_c || !file_exists($target.$file))
{
$fh = fopen($source.$file, "rb");
$php_source = fread($fh, filesize($source.$file));
fclose($fh);
if(preg_match_all('/GetMessage\("(.*?)"\)/', $php_source, $matches))
{
IncludeModuleLangFile($source.$file, $site["LANGUAGE_ID"]);
$MESS["IBLOCK_INSTALL_PUBLIC_IBLOCK_ID"] = $id;
foreach($matches[0] as $i => $text)
{
$php_source = str_replace(
$text,
'"'.GetMessage($matches[1][$i]).'"',
$php_source
);
}
}
$fh = fopen($target.$file, "wb");
fwrite($fh, $php_source);
fclose($fh);
@chmod($target.$file, BX_FILE_PERMISSIONS);
}
}
}
}
}
}
}
if(!empty($obModule->errors) && is_array($obModule->errors)):
CAdminMessage::ShowMessage(array(
"TYPE"=>"ERROR",
"MESSAGE" =>GetMessage("MOD_INST_ERR"),
"DETAILS"=>implode("
", $obModule->errors),
"HTML"=>true
));
else:
CAdminMessage::ShowNote(GetMessage("MOD_INST_OK"));
endif;
if($obModule->errors===false && $createNews && $news_dir !== ''):
?>
=GetMessage("IBLOCK_DEMO_DIR")?>
=GetMessage("IBLOCK_SITE")?> |
=GetMessage("IBLOCK_LINK")?> |
[=$site["ID"]?>] = htmlspecialcharsbx($site["NAME"]);?> |
=GetMessage("IBLOCK_DEMO_DIR")?>
=GetMessage("IBLOCK_SITE")?> |
=GetMessage("IBLOCK_LINK")?> |
[=$site["ID"]?>] =htmlspecialcharsbx($site["NAME"])?> |
=$site["DIR"].$catalog_dir?>/">=$site["DIR"].$catalog_dir?>/ |