- Модуль: mobileapp
- Путь к файлу: ~/bitrix/modules/mobileapp/lib/designer/manager.php
- Класс: BitrixMobileAppDesignerManager
- Вызов: Manager::copyFromTemplate
static function copyFromTemplate($folder, $appCode, $useOffline = false, $templateCode = "simple")
{
if(!in_array($templateCode, self::getTemplateList()))
{
$templateCode = "simple";
}
$appFolderPath = Application::getDocumentRoot() . "/" . $folder . "/";
$offlineTemplate = Application::getDocumentRoot() . "/bitrix/modules/mobileapp/templates_app/offline/";
$templatePath = Application::getDocumentRoot() . "/bitrix/modules/mobileapp/templates_app/".$templateCode."/";
$directory = new Directory($templatePath);
if($directory->isExists())
{
if (!Directory::isDirectoryExists($appFolderPath))
{
if($useOffline)
{
CopyDirFiles($offlineTemplate, $appFolderPath."/offline");
}
$items = $directory->getChildren();
foreach ($items as $entry)
{
/**
* @var $entry BitrixMainIOFileSystemEntry
*/
$filePath = $entry->getPath();
$appFilePath = $appFolderPath . $entry->getName();
if($entry instanceof Directory)
{
CopyDirFiles($filePath, $appFolderPath."/".$entry->getName(),true,true);
}
else
{
$file = new File($entry->getPath());
File::putFileContents(
$appFilePath,
str_replace(Array("#folder#", "#code#"), Array($folder, $appCode),$file->getContents())
);
}
}
}
}
}