Версия полностью совместимая c CMS
This commit is contained in:
parent
7ce493414e
commit
75bb35d5bf
21 changed files with 1404 additions and 783 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Controller_Installer
|
||||
{
|
||||
protected $db;
|
||||
protected $db_manager;
|
||||
protected $installPath;
|
||||
public $_registry;
|
||||
|
||||
|
|
@ -11,15 +11,20 @@ class Controller_Installer
|
|||
$this->_registry = $_registry;
|
||||
}
|
||||
|
||||
public function setUp($db, $installPath)
|
||||
public function setUp($db_manager, $installPath)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->db_manager = $db_manager;
|
||||
$this->installPath = $installPath;
|
||||
}
|
||||
|
||||
function getSetupFile($name)
|
||||
{
|
||||
return Path::join(call_user_func($this->installPath, $name), "setup.php");
|
||||
$setup = Path::join(call_user_func($this->installPath, $name), "install.json");
|
||||
return $setup;
|
||||
}
|
||||
|
||||
function getUninstallFile($name){
|
||||
return Path::join(call_user_func($this->installPath, $name), "sql", "uninstall.json");
|
||||
}
|
||||
|
||||
// Проверка версии обновления
|
||||
|
|
@ -38,22 +43,33 @@ class Controller_Installer
|
|||
|
||||
function installSQL(array $sql, $version_new, $version_old, $name)
|
||||
{
|
||||
require_once "core/setup.php";
|
||||
$result = [];
|
||||
$json_installer = new Database_JsonInstall($this->db_manager);
|
||||
foreach ($sql as $version => $install) {
|
||||
if (version_compare($version, $version_new, "<=") && version_compare($version, $version_old, ">")) {
|
||||
// this->installPath this->db
|
||||
$file = Path::join(call_user_func($this->installPath, $name), "sql", $install);
|
||||
Setup::batchSQL($this->db, $file);
|
||||
$json_installer->install($file,null);
|
||||
$result[] = $version;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function uninstall($name){
|
||||
$uninstall = $this->getUninstallFile($name);
|
||||
if (file_exists($uninstall)) {
|
||||
$json_installer = new Database_JsonInstall($this->db_manager);
|
||||
$json_installer->install($uninstall,null);
|
||||
}
|
||||
$this->_registry->removeKey($name);
|
||||
$this->_registry->write();
|
||||
}
|
||||
// Устанавливает обновления если есть
|
||||
function doUpdates($name, $force = false) // Установка модуля
|
||||
{
|
||||
$result = array();
|
||||
$setup = $this->getSetupFile($name);
|
||||
if (file_exists($setup) && ($this->isChanged($name) || $force)) {
|
||||
|
||||
$registry = $this->_registry;
|
||||
$settings = new Settings($setup);
|
||||
$settings->read();
|
||||
|
|
@ -67,21 +83,29 @@ class Controller_Installer
|
|||
$version_old = "0.0";
|
||||
$registry->writeKey(array($name), array());
|
||||
}
|
||||
|
||||
if (version_compare($version_old, $settings->get('version'), "!=")) {
|
||||
$sql = $settings->get('sql');
|
||||
if (is_array($sql)) {
|
||||
$this->installSQL($sql, $version_new, $version_old, $name);
|
||||
$res = $this->installSQL($sql, $version_new, $version_old, $name);
|
||||
if($res){
|
||||
$result[]=$res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Обновление версии меню
|
||||
$registry->removeKey($name);
|
||||
$registry->writeKey(array($name), $settings->get('settings'));
|
||||
$registry->writeKey(array($name),
|
||||
array('version' => $version_new,
|
||||
'time' => filemtime($setup)));
|
||||
$registry->write();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function install($dbinit_path,$dbfill_path=null){
|
||||
$json_installer = new Database_JsonInstall($this->db_manager);
|
||||
$json_installer->install($dbinit_path,$dbfill_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue