From ded28dc7a2c7d702522831d9a2b97b4ee079f532 Mon Sep 17 00:00:00 2001 From: Mzhelskiy Maxim Date: Wed, 30 Jul 2014 13:17:50 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B8=D0=BD=D1=81=D1=82=D0=B0=D0=BB=D0=BB=D1=8F?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../install/backend/step/installDb.php | 36 +++++++----- application/install/backend/step/updateDb.php | 35 +++++------- .../install/backend/step/updateNote.php | 12 ---- .../install/backend/step/updateVersion.php | 57 +++++++++++++++++++ application/install/frontend/i18n/ru.php | 5 ++ ...dateNote.tpl.php => updateVersion.tpl.php} | 7 ++- application/install/index.php | 2 +- 7 files changed, 102 insertions(+), 52 deletions(-) delete mode 100644 application/install/backend/step/updateNote.php create mode 100644 application/install/backend/step/updateVersion.php rename application/install/frontend/template/steps/{updateNote.tpl.php => updateVersion.tpl.php} (61%) diff --git a/application/install/backend/step/installDb.php b/application/install/backend/step/installDb.php index 06e53c48..188f1536 100644 --- a/application/install/backend/step/installDb.php +++ b/application/install/backend/step/installDb.php @@ -36,6 +36,27 @@ class InstallStepInstallDb extends InstallStep { * @return bool */ public function process() { + if (!$aRes=$this->processDbCheck()) { + return $aRes; + } + list($oDb,$sEngineDB)=$aRes; + /** + * Запускаем импорт дампов, сначала GEO DB + */ + list($bResult,$aErrors)=array_values($this->importDumpDB($oDb,InstallCore::getDataFilePath('sql/geo.sql'),array('engine'=>$sEngineDB,'prefix'=>InstallCore::getRequest('db.table.prefix'),'check_table'=>'geo_city'))); + if ($bResult) { + /** + * Запускаем основной дамп + */ + list($bResult,$aErrors)=array_values($this->importDumpDB($oDb,InstallCore::getDataFilePath('sql/dump.sql'),array('engine'=>$sEngineDB,'prefix'=>InstallCore::getRequest('db.table.prefix'),'check_table'=>'topic'))); + if ($bResult) { + return true; + } + } + return $this->addError(join('
',$aErrors)); + } + + protected function processDbCheck() { /** * Коннект к серверу БД */ @@ -102,20 +123,7 @@ class InstallStepInstallDb extends InstallStep { if (!InstallConfig::save($aSave)) { return $this->addError(InstallConfig::$sLastError); } - /** - * Запускаем импорт дампов, сначала GEO DB - */ - list($bResult,$aErrors)=array_values($this->importDumpDB($oDb,InstallCore::getDataFilePath('sql/geo.sql'),array('engine'=>$sEngineDB,'prefix'=>InstallCore::getRequest('db.table.prefix'),'check_table'=>'geo_city'))); - if ($bResult) { - /** - * Запускаем основной дамп - */ - list($bResult,$aErrors)=array_values($this->importDumpDB($oDb,InstallCore::getDataFilePath('sql/dump.sql'),array('engine'=>$sEngineDB,'prefix'=>InstallCore::getRequest('db.table.prefix'),'check_table'=>'topic'))); - if ($bResult) { - return true; - } - } - return $this->addError(join('
',$aErrors)); + return array($oDb,$sEngineDB); } protected function getPathRootWeb() { diff --git a/application/install/backend/step/updateDb.php b/application/install/backend/step/updateDb.php index 10bcba06..7a9cf580 100644 --- a/application/install/backend/step/updateDb.php +++ b/application/install/backend/step/updateDb.php @@ -1,6 +1,6 @@ processDbCheck()) { + return $aRes; + } + list($oDb,$sEngineDB)=$aRes; + /** + * Запускаем импорт дампов, сначала GEO DB + */ return true; } } \ No newline at end of file diff --git a/application/install/backend/step/updateNote.php b/application/install/backend/step/updateNote.php deleted file mode 100644 index c0178b8f..00000000 --- a/application/install/backend/step/updateNote.php +++ /dev/null @@ -1,12 +0,0 @@ -assign('from_version',InstallCore::getStoredData('update_from_version')); + $this->assign('convert_versions',$this->aVersionConvert); + } + + public function process() { + /** + * Полчаем данные коннекта к БД из конфига + */ + InstallConfig::$sFileConfig=dirname(INSTALL_DIR).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.local.php'; + /** + * Коннект к серверу БД + */ + if (!$oDb=$this->getDBConnection(InstallConfig::get('db.params.host'),InstallConfig::get('db.params.port'),InstallConfig::get('db.params.user'),InstallConfig::get('db.params.pass'))) { + return false; + } + /** + * Выбираем БД + */ + if (!@mysqli_select_db($oDb,InstallConfig::get('db.params.dbname'))) { + return $this->addError(InstallCore::getLang('db.errors.db_query')); + } + + $sVersion=(string)InstallCore::getRequest('from_version'); + /** + * Проверяем наличие конвертора + * Конвертор представляет собой отдельный метод вида converFrom_X1_Y1_Z1_to_X2_Y2_Z2 + */ + $sMethod='convertFrom_'.str_replace('.','_',$sVersion).'_to_'.str_replace('.','_',VERSION); + if (!method_exists($this,$sMethod)) { + return $this->addError(InstallCore::getLang('steps.updateVersion.errors.not_found_convert')); + } + InstallCore::setStoredData('update_from_version',$sVersion); + /** + * Запускаем конвертор + */ + return call_user_func_array(array($this,$sMethod),array($oDb)); + } + + + /** + * Конвертор версии 1.0.3 в 2.0.0 + * + * @param $oDb + */ + public function convertFrom_1_0_3_to_2_0_0($oDb) { + + } +} \ No newline at end of file diff --git a/application/install/frontend/i18n/ru.php b/application/install/frontend/i18n/ru.php index 9b3c564d..d25d9b2e 100644 --- a/application/install/frontend/i18n/ru.php +++ b/application/install/frontend/i18n/ru.php @@ -108,6 +108,11 @@ return array( 'passwd' => 'Пароль должен быть от 3-х символов', ), ), + 'updateVersion' => array( + 'errors' => array( + 'not_found_convert' => 'Для данной версии нет возможности обновления', + ), + ), ), 'config' => array( diff --git a/application/install/frontend/template/steps/updateNote.tpl.php b/application/install/frontend/template/steps/updateVersion.tpl.php similarity index 61% rename from application/install/frontend/template/steps/updateNote.tpl.php rename to application/install/frontend/template/steps/updateVersion.tpl.php index 74baf0c9..66091bf4 100644 --- a/application/install/frontend/template/steps/updateNote.tpl.php +++ b/application/install/frontend/template/steps/updateVersion.tpl.php @@ -11,8 +11,9 @@
Ваша текущая версия: - - - + get('convert_versions') as $version) { ?> + + \ No newline at end of file diff --git a/application/install/index.php b/application/install/index.php index 706fb080..9907b4e7 100644 --- a/application/install/index.php +++ b/application/install/index.php @@ -15,7 +15,7 @@ $aGroups=array( ), 'update'=>array( - 'updateNote','checkRequirements','updateDb'=>array('hide_create_db'=>true),'updateComplete' + 'checkRequirements','updateDb'=>array('hide_create_db'=>true),'updateVersion','updateComplete' ), );