59 lines
No EOL
1.4 KiB
PHP
59 lines
No EOL
1.4 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);
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|