diff --git a/.gitignore b/.gitignore index 0e3a1292..d275a528 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ src/absent_* src/release* # Do not index actual configuration files -src/mibew/configs/config.php +src/mibew/configs/config.yml src/tests/server_side/mibew/libs/config.php # Do not index avatars diff --git a/src/mibew/README.txt b/src/mibew/README.txt index b179872d..9e297ea7 100644 --- a/src/mibew/README.txt +++ b/src/mibew/README.txt @@ -13,8 +13,8 @@ INSTALLATION 2. Upload all the files contained in this archive (retaining the directory structure) into created folder. Be sure to chmod the mibew folder to 755 and the install folder to 644. 3. Add a MySQL database with the name 'mibew' -4. Copy /mibew/configs/default_config.php to /mibew/configs/config.php -5. Edit /mibew/configs/config.php to the information needed to connect to the database +4. Copy /mibew/configs/default_config.yml to /mibew/configs/config.yml +5. Edit /mibew/configs/config.yml to the information needed to connect to the database 6. Using your web browser visit http:///mibew/install/ and hit 'Create tables' 7. Remove /mibew/install/ directory from your server @@ -32,11 +32,11 @@ The owner should have all rights on the folder /mibew/files/avatar UPDATE -1. Backup your /mibew/configs/config.php +1. Backup your /mibew/configs/config.yml 2. Backup your /mibew/files/avatar folder. 3. Delete the items in the mibew folder on the server. 4. Upload all the files contained in the downloaded archive (retaining the directory structure) into mibew folder. -5. Re-edit the MySQL database settings you config.php +5. Re-edit the MySQL database settings you config.yml 6. Visit http:///mibew/install/ and follow the instructions to update database (if needed). 7. Remove /mibew/install/ directory from your server 8. Restore contents of /mibew/files/avatar folder. \ No newline at end of file diff --git a/src/mibew/configs/default_config.php b/src/mibew/configs/default_config.php deleted file mode 100644 index c3c3227f..00000000 --- a/src/mibew/configs/default_config.php +++ /dev/null @@ -1,65 +0,0 @@ - 'plugin_name', - 'config' => array( - 'weight' => 100, - 'some_configurable_value' => 'value' - ) -) -*/ diff --git a/src/mibew/configs/default_config.yml b/src/mibew/configs/default_config.yml new file mode 100644 index 00000000..3d0e512a --- /dev/null +++ b/src/mibew/configs/default_config.yml @@ -0,0 +1,39 @@ +# IMPORTANT: Before install mibew copy this file to config.yml and fill it with +# your own settings! + + +# Application path on server +mibew_root: /mibew + +# MySQL Database parameters +database: + host: "" + db: "" + login: "" + pass: "" + tables_prefix: "" + use_persistent_connection: false + +# Mailbox +mailbox: mibew@yourdomain.com + +# Locales +## Native name will be used in this locale +home_locale: en +## If user does not provide known lang +default_locale: en + +# Plugins +plugins: [] + +## Exapmle of plugins configuration +# plugins: +# - +# name: "VendorName:PluginName" +# config: +# weight: 100 +# some_configurable_value: value +# - +# name: "VendorName:AnotherPluginName" +# config: +# very_important_value: "$3.50" diff --git a/src/mibew/libs/classes/Mibew/Installer.php b/src/mibew/libs/classes/Mibew/Installer.php index 99eea6fe..6723acb8 100644 --- a/src/mibew/libs/classes/Mibew/Installer.php +++ b/src/mibew/libs/classes/Mibew/Installer.php @@ -368,9 +368,9 @@ class Installer { if ($real_base_path != MIBEW_WEB_ROOT) { $this->errors[] = getlocal( - "Please, check file {0}
Wrong value of \$mibewroot variable, should be \"{1}\"", + "Please, check file {0}
Wrong value of \"mibew_root\" variable, should be \"{1}\"", array( - $real_base_path . "/configs/config.php", + $real_base_path . "/configs/config.yml", $real_base_path ) ); @@ -699,7 +699,7 @@ class Installer ); } catch(\PDOException $e) { $this->errors[] = getlocal( - "Could not connect. Please check server settings in config.php. Error: {0}", + "Could not connect. Please check server settings in config.yml. Error: {0}", array($e->getMessage()) ); diff --git a/src/mibew/libs/common/configurations.php b/src/mibew/libs/common/configurations.php index 30bd75e9..a399060b 100644 --- a/src/mibew/libs/common/configurations.php +++ b/src/mibew/libs/common/configurations.php @@ -15,6 +15,8 @@ * limitations under the License. */ +use Symfony\Component\Yaml\Parser as YamlParser; + /** * Loads system configurations. * @@ -27,25 +29,8 @@ function load_system_configs() static $configs = null; if (is_null($configs)) { - // Load and "parse" configs file. While configs are written in a php - // file include is the only option to load and parse them. - include(MIBEW_FS_ROOT . "/configs/config.php"); - - $configs = array( - 'mibew_root' => $mibewroot, - 'database' => array( - 'host' => $mysqlhost, - 'db' => $mysqldb, - 'login' => $mysqllogin, - 'pass' => $mysqlpass, - 'tables_prefix' => $mysqlprefix, - 'use_persistent_connection' => $use_persistent_connection, - ), - 'mailbox' => $mibew_mailbox, - 'home_locale' => $home_locale, - 'default_locale' => $default_locale, - 'plugins' => $plugins_list, - ); + $parser = new YamlParser(); + $configs = $parser->parse(file_get_contents(MIBEW_FS_ROOT . '/configs/config.yml')); } return $configs; diff --git a/src/mibew/libs/common/locale.php b/src/mibew/libs/common/locale.php index 78dea1b9..bd611900 100644 --- a/src/mibew/libs/common/locale.php +++ b/src/mibew/libs/common/locale.php @@ -27,7 +27,7 @@ define('LOCALE_COOKIE_NAME', 'mibew_locale'); /** * Verified value of the $default_locale configuration parameter (see - * "configs/default_config.php" for details) + * "configs/default_config.yml" for details) */ define( 'DEFAULT_LOCALE', @@ -38,7 +38,7 @@ define( /** * Verified value of the $home_locale configuration parameter (see - * "configs/default_config.php" for details) + * "configs/default_config.yml" for details) */ define( 'HOME_LOCALE', diff --git a/src/mibew/libs/init.php b/src/mibew/libs/init.php index 4520bd0a..77ecb371 100644 --- a/src/mibew/libs/init.php +++ b/src/mibew/libs/init.php @@ -20,6 +20,16 @@ */ define('MIBEW_FS_ROOT', dirname(dirname(__FILE__))); +// Initialize classes autoloading +require_once(MIBEW_FS_ROOT . '/libs/classes/Mibew/Autoloader.php'); +Mibew\Autoloader::register(MIBEW_FS_ROOT . '/libs/classes'); + +// Automatically load plugins +Mibew\Autoloader::register(MIBEW_FS_ROOT . '/plugins'); + +// Initialize external dependencies +require_once(MIBEW_FS_ROOT . '/vendor/autoload.php'); + // Load system configurations require_once(MIBEW_FS_ROOT . '/libs/common/configurations.php'); $configs = load_system_configs(); @@ -41,16 +51,6 @@ define('MIBEW_WEB_ROOT', $mibewroot); // Include system constants file require_once(MIBEW_FS_ROOT . '/libs/common/constants.php'); -// Initialize classes autoloading -require_once(MIBEW_FS_ROOT . '/libs/classes/Mibew/Autoloader.php'); -Mibew\Autoloader::register(MIBEW_FS_ROOT . '/libs/classes'); - -// Automatically load plugins -Mibew\Autoloader::register(MIBEW_FS_ROOT . '/plugins'); - -// Initialize external dependencies -require_once(MIBEW_FS_ROOT . '/vendor/autoload.php'); - // Include common libs require_once(MIBEW_FS_ROOT . '/libs/common/verification.php'); require_once(MIBEW_FS_ROOT . '/libs/common/locale.php'); @@ -73,7 +73,7 @@ if (is_secure_request()) { session_start(); if (function_exists("date_default_timezone_set")) { - // TODO try to get timezone from config.php/session etc. + // TODO try to get timezone from config.yml/session etc. // autodetect timezone @date_default_timezone_set(function_exists("date_default_timezone_get") ? @date_default_timezone_get() : "GMT"); } @@ -91,7 +91,7 @@ if (!installation_in_progress()) { if (!empty($configs['plugins'])) { // A list of plugins is defined in $plugins_list variable in - // configs/config.php + // configs/config.yml \Mibew\Plugin\Manager::loadPlugins($configs['plugins']); } }