diff --git a/src/mibew/install.php b/src/mibew/install.php index 8fd8c0eb..5074c133 100644 --- a/src/mibew/install.php +++ b/src/mibew/install.php @@ -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'); diff --git a/src/mibew/libs/common/locale.php b/src/mibew/libs/common/locale.php index 1efde4bc..a176d5bf 100644 --- a/src/mibew/libs/common/locale.php +++ b/src/mibew/libs/common/locale.php @@ -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); } diff --git a/src/mibew/libs/common/misc.php b/src/mibew/libs/common/misc.php index 53a91a85..ffecdb7a 100644 --- a/src/mibew/libs/common/misc.php +++ b/src/mibew/libs/common/misc.php @@ -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; } diff --git a/src/mibew/libs/init.php b/src/mibew/libs/init.php index f2983943..a1acdded 100644 --- a/src/mibew/libs/init.php +++ b/src/mibew/libs/init.php @@ -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'],