} restore_exception_handler(); ?> <script type="text/javascript"> window.location = '<?php echo $_REQUEST["apply"] == "Y" ? Cutil::JSEscape("/bitrix/admin/" . MODULE_ID . "_bizproc_workflow_edit.php?lang=" . LANGUAGE_ID . "&entity=" . AddSlashes(ENTITY) . "&ID=" . $ID . "&back_url_list=" . urlencode($_REQUEST["back_url_list"])) : Cutil::JSEscape($back_url); ?> '; </script> <?php die; } if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_REQUEST['export_template'] == 'Y' && check_bitrix_sessid()) { $APPLICATION->RestartBuffer(); if ($ID > 0) { $datum = CBPWorkflowTemplateLoader::ExportTemplate($ID); header("HTTP/1.1 200 OK"); header("Content-Type: application/force-download; name=\"bp-" . $ID . ".bpt\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . (function_exists('mb_strlen') ? mb_strlen($datum, 'ISO-8859-1') : strlen($datum))); header("Content-Disposition: attachment; filename=\"bp-" . $ID . ".bpt\""); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Expires: 0"); header("Pragma: public"); echo $datum; } die; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_REQUEST['import_template'] == 'Y' && check_bitrix_sessid()) { $APPLICATION->RestartBuffer(); //CUtil::DecodeUriComponent($_POST);
/** * @param int $iblockId This variable is the id iblock. * @return string * @throws Main\ArgumentNullException * @throws Main\ArgumentOutOfRangeException */ public static function export($iblockId) { $iblockId = intval($iblockId); if ($iblockId <= 0) { throw new Main\ArgumentNullException("iblockId"); } $db = \CIBlock::GetList(array(), array("ID" => $iblockId, "CHECK_PERMISSIONS" => "N")); $iblock = $db->Fetch(); if (!$iblock) { throw new Main\ArgumentOutOfRangeException("iblockId"); } if (!$iblock["CODE"]) { throw new Main\ArgumentException("Parameter 'CODE' is required.", "matches"); } $list = new \CList($iblockId); $fields = $list->getFields(); foreach ($fields as $fieldId => $field) { if ($field["TYPE"] == "NAME") { $iblock["~NAME_FIELD"] = array("NAME" => $field["NAME"], "SETTINGS" => $field["SETTINGS"], "DEFAULT_VALUE" => $field["DEFAULT_VALUE"], "SORT" => $field["SORT"]); break; } } $iblockUtf8 = Main\Text\Encoding::convertEncodingArray($iblock, LANG_CHARSET, "UTF-8"); $iblockUtf8 = serialize($iblockUtf8); $iblockUtf8Length = Main\Text\String::getBinaryLength($iblockUtf8); $datum = str_pad($iblockUtf8Length, 10, "0", STR_PAD_LEFT) . $iblockUtf8; if (intval($iblock["PICTURE"]) > 0) { $picture = \CFile::MakeFileArray($iblock["PICTURE"]); if (isset($picture["tmp_name"]) && !empty($picture["tmp_name"])) { $f = fopen($picture["tmp_name"], "rb"); $pictureData = fread($f, filesize($picture["tmp_name"])); fclose($f); $pictureTypeLength = Main\Text\String::getBinaryLength($picture["type"]); $pictureLength = Main\Text\String::getBinaryLength($pictureData); $datum .= "P" . str_pad($pictureTypeLength, 10, "0", STR_PAD_LEFT) . $picture["type"] . str_pad($pictureLength, 10, "0", STR_PAD_LEFT) . $pictureData; } } $documentType = self::getDocumentType($iblock["IBLOCK_TYPE_ID"], $iblockId); $templatesList = \CBPWorkflowTemplateLoader::GetList(array(), array("DOCUMENT_TYPE" => $documentType), false, false, array("ID", "AUTO_EXECUTE", "NAME", "DESCRIPTION", "SYSTEM_CODE")); while ($templatesListItem = $templatesList->Fetch()) { $bpDescrUtf8 = Main\Text\Encoding::convertEncodingArray($templatesListItem, LANG_CHARSET, "UTF-8"); $bpDescrUtf8 = serialize($bpDescrUtf8); $bpDescrUtf8Length = Main\Text\String::getBinaryLength($bpDescrUtf8); $datum .= "B" . str_pad($bpDescrUtf8Length, 10, "0", STR_PAD_LEFT) . $bpDescrUtf8; $bp = \CBPWorkflowTemplateLoader::ExportTemplate($templatesListItem["ID"], false); $bpLength = Main\Text\String::getBinaryLength($bp); $datum .= str_pad($bpLength, 10, "0", STR_PAD_LEFT) . $bp; } if (function_exists("gzcompress")) { $datum = "compressed" . gzcompress($datum, 9); } return $datum; }