59 lines
No EOL
1.6 KiB
PHP
59 lines
No EOL
1.6 KiB
PHP
<?php
|
|
|
|
require_once 'core/path.php';
|
|
require_once 'creole/util/sql/SQLStatementExtractor.php';
|
|
|
|
/**
|
|
* Обработка файлов для установки
|
|
*/
|
|
class Setup
|
|
{
|
|
/**
|
|
* Содержимое PHP файла
|
|
*/
|
|
static function fileContent($file, array $tpl)
|
|
{
|
|
ob_start();
|
|
include $file;
|
|
$result = ob_get_contents();
|
|
ob_clean();
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Копирует файлы шаблонной директории
|
|
*/
|
|
static function copyTemplatePath($srcPath, $dstPath, array $tpl, $tplFile = 'tpl')
|
|
{
|
|
$out = new Path($srcPath);
|
|
$path = new Path($dstPath);
|
|
$files = $path->getContentRec(null, array(".svn"));
|
|
|
|
foreach ($files as $file) {
|
|
if (Path::getExtension($file) == $tplFile) {
|
|
// Шаблон
|
|
$dst = $out->append($path->relPath (Path::skipExtension($file)));
|
|
Path::prepare($dst);
|
|
file_put_contents($dst, self::fileContent($file, $tpl));
|
|
} else {
|
|
// Обычный файл
|
|
$dst = $out->append($path->relPath ($file));
|
|
Path::prepare($dst);
|
|
copy($file, $dst);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Выполнение Списка SQL команд
|
|
*/
|
|
static function batchSQL(Connection $conn, $file)
|
|
{
|
|
$stmtList = SQLStatementExtractor::extractFile ($file);
|
|
foreach ($stmtList as $stmt) {
|
|
$conn->executeQuery ($stmt);
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|