• Модуль: learning
  • Путь к файлу: ~/bitrix/modules/learning/classes/general/export.php
  • Класс: CCoursePackage
  • Вызов: CCoursePackage::CreatePackage
function CreatePackage($PACKAGE_DIR)
{
	if ($this->LAST_ERROR <> '')
		return false;

	//Add last slash
	if (mb_substr($PACKAGE_DIR, -1, 1) != "/")
		$PACKAGE_DIR .= "/";

	$path = $_SERVER["DOCUMENT_ROOT"].$PACKAGE_DIR;

	CheckDirPath($path);

	if (!is_dir($path) || !is_writable($path))
	{
		$this->LAST_ERROR = GetMessage("LEARNING_BAD_PACKAGE");
		return false;
	}

	RewriteFile($path."/res1.xml", $this->_CreateCourseToc());
	RewriteFile($path."/imsmanifest.xml", $this->CreateManifest());

	//XML Resource Data
	foreach ($this->arItems as $res_id => $content)
	{
		RewriteFile($path."/res".$res_id.".xml", $content);
	}

	//Resource
	$dbres_path = $path."/dbresources/";
	CheckDirPath($dbres_path);

	foreach ($this->arResources as $res_id => $arFiles)
	{
		$res_path = $path."/resources/res".$res_id."/";

		CheckDirPath($res_path);
		foreach ($arFiles as $arFile)
		{
			if (array_key_exists("DB", $arFile))
			{
				$arTempFile = CFile::MakeFileArray($arFile["DB"]);
				if($arTempFile && isset($arTempFile["tmp_name"]))
					@copy($arTempFile["tmp_name"], $dbres_path.$arFile["ID"]);
			}
			else
			{
				@copy($_SERVER["DOCUMENT_ROOT"].$arFile["SRC"], $res_path.$arFile["ID"]);
			}
		}
	}

	return true;
}