}
     } else {
         $arErrors[] = GetMessage("IBLOCK_CML2_FILE_ERROR");
     }
     $NS["STEP"]++;
 } elseif ($NS["STEP"] < 4) {
     if ($fp = fopen($ABS_FILE_NAME, "ab")) {
         $obExport = new CIBlockCMLExport();
         if ($obExport->Init($fp, $NS["IBLOCK_ID"], $NS["next_step"], true, $_SESSION["BX_CML2_EXPORT"]["work_dir"], $_SESSION["BX_CML2_EXPORT"]["file_dir"])) {
             if ($NS["DOWNLOAD_CLOUD_FILES"] === "N") {
                 $obExport->DoNotDownloadCloudFiles();
             }
             if ($NS["STEP"] == 1) {
                 $obExport->StartExport();
                 $obExport->StartExportMetadata();
                 $obExport->ExportProperties($_SESSION["BX_CML2_EXPORT"]["PROPERTY_MAP"]);
                 $NS["STEP"]++;
             } elseif ($NS["STEP"] == 2) {
                 $result = $obExport->ExportSections($_SESSION["BX_CML2_EXPORT"]["SECTION_MAP"], $start_time, $INTERVAL, $NS["SECTIONS_FILTER"], $_SESSION["BX_CML2_EXPORT"]["PROPERTY_MAP"]);
                 if ($result) {
                     $NS["SECTIONS"] += $result;
                 } else {
                     $obExport->EndExportMetadata();
                     $obExport->StartExportCatalog();
                     $NS["STEP"]++;
                 }
             } elseif ($NS["STEP"] == 3) {
                 $result = $obExport->ExportElements($_SESSION["BX_CML2_EXPORT"]["PROPERTY_MAP"], $_SESSION["BX_CML2_EXPORT"]["SECTION_MAP"], $start_time, $INTERVAL, 0, $NS["ELEMENTS_FILTER"]);
                 if ($result) {
                     $NS["ELEMENTS"] += $result;
                 } else {
 function Export($documentId)
 {
     $work_dir = CTempFile::GetDirectoryName();
     CheckDirPath($work_dir);
     $file = "import";
     $file_name = $work_dir . $file . ".xml";
     $file_dir = $file . "_files/";
     $arcname = $work_dir . $file . '.tar.gz';
     if ($fp = fopen($file_name, "ab")) {
         $documentService = $this->workflow->GetService("DocumentService");
         $document = $documentService->GetDocument($documentId);
         $obExport = new CIBlockCMLExport();
         $step = array();
         $PROPERTY_MAP = array();
         $SECTION_MAP = array();
         if ($obExport->Init($fp, $document["IBLOCK_ID"], $step, true, $work_dir, $file_dir)) {
             $obExport->StartExport();
             $obExport->StartExportMetadata();
             $obExport->ExportProperties($PROPERTY_MAP);
             $obExport->ExportSections($SECTION_MAP, time(), 0);
             $obExport->EndExportMetadata();
             $obExport->StartExportCatalog(true, true);
             $obExport->ExportElements($PROPERTY_MAP, $SECTION_MAP, time(), 0, 0, array("SHOW_NEW" => "Y", "IBLOCK_ID" => $document["IBLOCK_ID"], "=ID" => $document["ID"]));
             $obExport->EndExportCatalog();
             $obExport->EndExport();
             fclose($fp);
             include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . '/modules/main/classes/general/tar_gz.php';
             $ob = new CArchiver($arcname);
             $res = $ob->Add('"' . $file_name . '"', false, $work_dir);
             if ($res) {
                 $res = $ob->Add('"' . $work_dir . $file_dir . '"', false, $work_dir);
             }
             if ($res) {
                 return $arcname;
             } else {
                 return '';
             }
         } else {
             return '';
         }
     } else {
         return '';
     }
 }
Esempio n. 3
0
 protected function _exportIBlockXML($iblockCode)
 {
     if (!$this->_checkIBlockCode($iblockCode)) {
         return false;
     }
     $arIB =& $this->_arIBlockData[$iblockCode];
     self::deleteDirFilesEx($arIB['EXPORT_WORK_DIR_FULL_PATH'], true);
     unlink($arIB['XML_FILE_FULL_PATH']);
     $fpXmlFile = fopen($arIB['XML_FILE_FULL_PATH'], "ab");
     if (!$fpXmlFile) {
         echo "Can't create / open xml file \n";
         return false;
     }
     $start_time = time();
     $nextStep = array();
     $arSectionMap = false;
     $arPropertyMap = false;
     $arSectionFilter = array('IBLOCK_ID' => $arIB['IBLOCK_ID']);
     $arElementFilter = array('IBLOCK_ID' => $arIB['IBLOCK_ID']);
     $INTERVAL = 0;
     /**
      * @var CIBlockCMLExport $obExport
      */
     $obExport = new CIBlockCMLExport();
     if ($obExport->Init($fpXmlFile, $arIB['IBLOCK_ID'], $nextStep, true, $arIB['EXPORT_FULL_PATH'], $arIB['EXPORT_WORK_DIR'])) {
         // <КоммерческаяИнформация>
         $obExport->StartExport();
         // <Классификатор>
         $obExport->StartExportMetadata();
         // <Свойства>
         $obExport->ExportProperties($arPropertyMap);
         // </Свойства>
         // <Группы>
         $result = $obExport->ExportSections($arSectionMap, $start_time, $INTERVAL, $arSectionFilter);
         // </Группы>
         // </Классификатор>
         $obExport->EndExportMetadata();
         // <Каталог>
         $obExport->StartExportCatalog();
         // <Товары>
         $result = $obExport->ExportElements($arPropertyMap, $arSectionMap, $start_time, $INTERVAL, 0, $arElementFilter);
         // </Товары>
         // </Каталог>
         $obExport->EndExportCatalog();
         // </КоммерческаяИнформация>
         $obExport->EndExport();
     } else {
         echo "\nCan't initialize xml-export for \"{$arIB['IBLOCK_ID']}\".\n Perhaps Minimal access for IBlock lower than \"W\"\n";
     }
     if ($fpXmlFile) {
         fclose($fpXmlFile);
     }
 }
Esempio n. 4
0
    }
}
foreach ($arExport as $arBlock) {
    $ABS_FILE_NAME = $_SERVER["DOCUMENT_ROOT"] . $arBlock["FILE"];
    $IBLOCK_ID = $arBlock["ID"];
    if ($fp = fopen($ABS_FILE_NAME, "wb")) {
        $WORK_DIR_NAME = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/") + 1);
        $next_step = array();
        $obExport = new CIBlockCMLExport();
        $obExport->Init($fp, $IBLOCK_ID, $next_step, true, $WORK_DIR_NAME, substr(substr($ABS_FILE_NAME, 0, -4) . "_files" . "/", strlen($WORK_DIR_NAME)));
        $bCatalog = $obExport->next_step["catalog"];
        $obExport->next_step["catalog"] = false;
        $obExport->StartExport();
        $obExport->StartExportMetadata();
        $PROPERTY_MAP = false;
        $obExport->ExportProperties($PROPERTY_MAP);
        $SECTION_MAP = false;
        $obExport->ExportSections($SECTION_MAP, time(), 0);
        $obExport->EndExportMetadata();
        $obExport->StartExportCatalog();
        if ($arBlock["XML_ID"] === "FUTURE-1C-CATALOG") {
            //Goods
            $saved_work_dir = $obExport->work_dir;
            $saved_file_dir = $obExport->file_dir;
            $i = 0;
            do {
                $i++;
                $ABS_FILE_NAME = $_SERVER["DOCUMENT_ROOT"] . "/exp/" . sprintf("%03d", $arBlock["NUM"] + $i) . "_" . $arBlock["TYPE"] . "_" . $arBlock["XML_ID"] . "_ru.xml";
                $fi = fopen($ABS_FILE_NAME, "wb");
                $work_dir = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/") + 1);
                $file_dir = substr(substr($ABS_FILE_NAME, 0, -4) . "_files" . "/", strlen($work_dir));