Replace INSTALLATION_IN_PROGRESS const with MAINTENANCE_MODE

This commit is contained in:
Dmitriy Simushev 2014-11-11 13:31:38 +00:00
parent 1deebaff20
commit d446b9a78f
4 changed files with 15 additions and 14 deletions

View File

@ -17,7 +17,7 @@
* limitations under the License.
*/
define('INSTALLATION_IN_PROGRESS', true);
define('MAINTENANCE_MODE', 'install');
// Initialize libraries
require_once(dirname(__FILE__) . '/libs/init.php');

View File

@ -57,8 +57,8 @@ function get_available_locales()
static $available_locales = null;
if (is_null($available_locales)) {
if (installation_in_progress()) {
// We cannot rely on the database during installation, thus we only
if (get_maintenance_mode() !== false) {
// We cannot rely on the database during maintenance, thus we only
// can use discovered locales as available locales.
$available_locales = discover_locales();
} else {
@ -728,9 +728,9 @@ function load_messages($locale)
if (!isset($messages[$locale])) {
$messages[$locale] = array();
if (installation_in_progress()) {
if (get_maintenance_mode() !== false) {
// Load localized strings from files because we cannot rely on the
// database during installation.
// database during maintenance.
$locale_file = MIBEW_FS_ROOT . "/locales/{$locale}/translation.po";
$locale_data = read_locale_file($locale_file);
@ -859,9 +859,9 @@ function get_localized_string($string, $locale)
// The string is not localized, save it to the database to provide an
// ability to translate it from the UI later. At the same time we cannot
// rely on the database during installation, thus we should check if the
// installation is in progress.
if (!installation_in_progress()) {
// rely on the database during maintenance, thus we should check the
// current system state.
if (get_maintenance_mode() === false) {
save_message($locale, $string, $string);
}

View File

@ -23,15 +23,16 @@ function div($a, $b)
}
/**
* Checks if currently processed script is installation script.
* Checks if the system is under maintenance and gets maintenance mode name.
*
* @return boolean
* @return boolean|string Name of maintenace mode or boolean false if the system
* is not in maintenance mode.
*/
function installation_in_progress()
function get_maintenance_mode()
{
if (!defined('INSTALLATION_IN_PROGRESS')) {
if (!defined('MAINTENANCE_MODE')) {
return false;
}
return INSTALLATION_IN_PROGRESS;
return MAINTENANCE_MODE;
}

View File

@ -69,7 +69,7 @@ if (function_exists("date_default_timezone_set")) {
@date_default_timezone_set($timezone);
}
if (!installation_in_progress()) {
if (get_maintenance_mode() === false) {
// Initialize the database
\Mibew\Database::initialize(
$configs['database']['host'],