diff --git a/.gitignore b/.gitignore index 86da76219..f4cc72dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ /.vagrant/* /composer.lock /composer.local.json -/config/app.php +/config/app_local.php /config/.env /config/projects/* /coverage/* diff --git a/README.md b/README.md index 9592f650d..2724f22f5 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,12 @@ And then point your browser to `http://localhost:8765/` For any other use than a simple test we recommend to configure your preferred web server like Nginx/Apache and point to `webroot/` as vhost document root. +## Configuration + +You can further configure your BEdita Manager instance in `config/app_local.php` with environment and project specific settings. + +Have look at the main [Manager configuration wiki page](https://github.com/bedita/manager/wiki/Manager-App-Configuration) on how to customize your Manager instance. + ## Docker ### Pull official image diff --git a/composer.json b/composer.json index 87da61fd6..f2a2d277d 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "dereuromark/cakephp-ide-helper": "~1.17.0", "phpstan/phpstan": "^1.5", "phpunit/phpunit": "^9", - "psy/psysh": "@stable" + "cakephp/repl": "^0.1" }, "autoload": { "psr-4": { @@ -61,7 +61,7 @@ "@test", "@cs-check" ], - "analyse": "vendor/bin/phpstan analyse", + "stan": "vendor/bin/phpstan analyse", "cs-check": "vendor/bin/phpcs --extensions=php --colors -p ./src ./tests ./config", "cs-fix": "vendor/bin/phpcbf --extensions=php --colors ./src ./tests ./config", "test": "vendor/bin/phpunit --colors=always", diff --git a/config/.env.example b/config/.env.example index 459006ac0..c3d186100 100644 --- a/config/.env.example +++ b/config/.env.example @@ -19,6 +19,9 @@ export APP_DEFAULT_LOCALE="en_US" export BEDITA_API="https://bedita-api-url" export BEDITA_API_KEY="bedita-api-key" +# Uncomment this line and set a random string to define the security salt as environment variable. +# export SECURITY_SALT="#######" + # Uncomment these to define cache configuration via environment variables. #export CACHE_DURATION="+2 minutes" #export CACHE_DEFAULT_URL="file://tmp/cache/?prefix=${APP_NAME}_default&duration=${CACHE_DURATION}" diff --git a/config/app.default.php b/config/app.default.php deleted file mode 100644 index e5b4b587d..000000000 --- a/config/app.default.php +++ /dev/null @@ -1,915 +0,0 @@ - filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN), - - /** - * Configure basic information about the application. - * - * - namespace - The namespace to find app classes under. - * - defaultLocale - The default locale for translation, formatting currencies and numbers, date and time. - * - encoding - The encoding used for HTML + database connections. - * - base - The base directory the app resides in. If false this - * will be auto detected. - * - dir - Name of app directory. - * - webroot - The webroot directory. - * - wwwRoot - The file path to webroot. - * - baseUrl - To configure CakePHP to *not* use mod_rewrite and to - * use CakePHP pretty URLs, remove these .htaccess - * files: - * /.htaccess - * /webroot/.htaccess - * And uncomment the baseUrl key below. - * - fullBaseUrl - A base URL to use for absolute links. When set to false (default) - * CakePHP generates required value based on `HTTP_HOST` environment variable. - * However, you can define it manually to optimize performance or if you - * are concerned about people manipulating the `Host` header. - * - imageBaseUrl - Web path to the public images directory under webroot. - * - cssBaseUrl - Web path to the public css directory under webroot. - * - jsBaseUrl - Web path to the public js directory under webroot. - * - paths - Configure paths for non class based resources. Supports the - * `plugins`, `templates`, `locales` subkeys, which allow the definition of - * paths for plugins, view templates and locale files respectively. - */ - 'App' => [ - 'namespace' => 'App', - 'encoding' => env('APP_ENCODING', 'UTF-8'), - 'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'), - 'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'UTC'), - 'base' => false, - 'dir' => 'src', - 'webroot' => 'webroot', - 'wwwRoot' => WWW_ROOT, - //'baseUrl' => env('SCRIPT_NAME'), - 'fullBaseUrl' => false, - 'imageBaseUrl' => 'img/', - 'cssBaseUrl' => 'css/', - 'jsBaseUrl' => 'js/', - 'paths' => [ - 'plugins' => [ROOT . DS . 'plugins' . DS], - 'templates' => [APP . 'Template' . DS], - 'locales' => [APP . 'Locale' . DS], - ], - ], - - /** - * Security and encryption configuration - * - * - salt - A random string used in security hashing methods. - * The salt value is also used as the encryption key. - * You should treat it as extremely sensitive data. - */ - 'Security' => [ - 'salt' => env('SECURITY_SALT', '__SALT__'), - ], - - /** - * Apply timestamps with the last modified time to static assets (js, css, images). - * Will append a querystring parameter containing the time the file was modified. - * This is useful for busting browser caches. - * - * Set to true to apply timestamps when debug is true. Set to 'force' to always - * enable timestamping regardless of debug value. - */ - 'Asset' => [ - // 'timestamp' => true, - // 'cacheTime' => '+1 year' - ], - - /** - * Configure the cache adapters. - */ - 'Cache' => [ - 'default' => [ - 'className' => FileEngine::class, - 'path' => CACHE, - 'url' => env('CACHE_DEFAULT_URL', null), - ], - - /** - * Configure the cache used for general framework caching. - * Translation cache files are stored with this configuration. - * Duration will be set to '+2 minutes' in bootstrap.php when debug = true - * If you set 'className' => 'Null' core cache will be disabled. - */ - '_cake_core_' => [ - 'className' => FileEngine::class, - 'prefix' => 'myapp_cake_core_', - 'path' => CACHE . 'persistent' . DS, - 'serialize' => true, - 'duration' => '+1 years', - 'url' => env('CACHE_CAKECORE_URL', null), - ], - - /** - * Configure the cache used for schema types caching. - * Duration will be set to '+2 minutes' in bootstrap.php when debug = true - */ - '_schema_types_' => [ - 'className' => FileEngine::class, - 'prefix' => 'schema_types_', - 'path' => CACHE . 'schema_types' . DS, - 'serialize' => true, - 'duration' => '+1 day', - 'url' => env('CACHE_SCHEMATYPES_URL', null), - ], - - /** - * Configure the cache used for project configuration caching. - * Duration will be set to '+2 minutes' in bootstrap.php when debug = true - */ - '_project_config_' => [ - 'className' => FileEngine::class, - 'prefix' => '_project_config_', - 'path' => CACHE . 'project_config' . DS, - 'serialize' => true, - 'duration' => '+1 day', - 'url' => env('CACHE_PROJECTCONFIG_URL', null), - ], - - /** - * Configure the cache for model and datasource caches. This cache - * configuration is used to store schema descriptions, and table listings - * in connections. - * Duration will be set to '+2 minutes' in bootstrap.php when debug = true - */ - '_cake_model_' => [ - 'className' => FileEngine::class, - 'prefix' => 'myapp_cake_model_', - 'path' => CACHE . 'models' . DS, - 'serialize' => true, - 'duration' => '+1 years', - 'url' => env('CACHE_CAKEMODEL_URL', null), - ], - - /** - * Thumbnails cache - * Duration will be set to '+2 minutes' in bootstrap.php when debug = true - * If you set 'className' => 'Null' core cache will be disabled. - */ - '_thumbs_' => [ - 'className' => 'File', - 'prefix' => 'thumbs_', - 'path' => CACHE . 'thumbs/', - 'serialize' => true, - 'duration' => '+1 years', - 'url' => env('CACHE_THUMBS_URL', null), - ], - - /** - * Configure the cache for routes. The cached routes collection is built the - * first time the routes are processed through `config/routes.php`. - * Duration will be set to '+2 seconds' in bootstrap.php when debug = true - */ - '_cake_routes_' => [ - 'className' => FileEngine::class, - 'prefix' => 'myapp_cake_routes_', - 'path' => CACHE, - 'serialize' => true, - 'duration' => '+1 years', - 'url' => env('CACHE_CAKEROUTES_URL', null), - ], - ], - - /** - * Configure the Error and Exception handlers used by your application. - * - * By default errors are displayed using Debugger, when debug is true and logged - * by Cake\Log\Log when debug is false. - * - * In CLI environments exceptions will be printed to stderr with a backtrace. - * In web environments an HTML page will be displayed for the exception. - * With debug true, framework errors like Missing Controller will be displayed. - * When debug is false, framework errors will be coerced into generic HTTP errors. - * - * Options: - * - * - `errorLevel` - int - The level of errors you are interested in capturing. - * - `trace` - boolean - Whether or not backtraces should be included in - * logged errors/exceptions. - * - `log` - boolean - Whether or not you want exceptions logged. - * - `exceptionRenderer` - string - The class responsible for rendering uncaught exceptions. - * The chosen class will be used for for both CLI and web environments. If you want different - * classes used in CLI and web environments you'll need to write that conditional logic as well. - * The conventional location for custom renderers is in `src/Error`. Your exception renderer needs to - * implement the `render()` method and return either a string or Http\Response. - * `errorRenderer` - string - The class responsible for rendering PHP errors. The selected - * class will be used for both web and CLI contexts. If you want different classes for each environment - * you'll need to write that conditional logic as well. Error renderers need to - * to implement the `Cake\Error\ErrorRendererInterface`. - * - `skipLog` - array - List of exceptions to skip for logging. Exceptions that - * extend one of the listed exceptions will also be skipped for logging. - * E.g.: - * `'skipLog' => ['Cake\Http\Exception\NotFoundException', 'Cake\Http\Exception\UnauthorizedException']` - * - `extraFatalErrorMemory` - int - The number of megabytes to increase the memory limit by - * when a fatal error is encountered. This allows - * breathing room to complete logging or error handling. - * - `ignoredDeprecationPaths` - array - A list of glob compatible file paths that deprecations - * should be ignored in. Use this to ignore deprecations for plugins or parts of - * your application that still emit deprecations. - */ - 'Error' => [ - 'errorLevel' => E_ALL, - 'exceptionRenderer' => 'BEdita\WebTools\Error\ExceptionRenderer', - 'skipLog' => [], - 'log' => true, - 'trace' => true, - 'ignoredDeprecationPaths' => [], - ], - - /* - * Debugger configuration - * - * Define development error values for Cake\Error\Debugger - * - * - `editor` Set the editor URL format you want to use. - * By default atom, emacs, macvim, phpstorm, sublime, textmate, and vscode are - * available. You can add additional editor link formats using - * `Debugger::addEditor()` during your application bootstrap. - * - `outputMask` A mapping of `key` to `replacement` values that - * `Debugger` should replace in dumped data and logs generated by `Debugger`. - */ - 'Debugger' => [ - 'editor' => 'vscode', - ], - - /** - * Email configuration. - * - * By defining transports separately from delivery profiles you can easily - * re-use transport configuration across multiple profiles. - * - * You can specify multiple configurations for production, development and - * testing. - * - * Each transport needs a `className`. Valid options are as follows: - * - * Mail - Send using PHP mail function - * Smtp - Send using SMTP - * Debug - Do not send the email, just return the result - * - * You can add custom transports (or override existing transports) by adding the - * appropriate file to src/Mailer/Transport. Transports should be named - * 'YourTransport.php', where 'Your' is the name of the transport. - */ - 'EmailTransport' => [ - 'default' => [ - 'className' => MailTransport::class, - /** - * The keys host, port, timeout, username, password, client and tls - * are used in SMTP transports - */ - 'host' => 'localhost', - 'port' => 25, - 'timeout' => 30, - /* - * It is recommended to set these options through your environment or app_local.php - */ - //'username' => null, - //'password' => null, - 'client' => null, - 'tls' => false, - 'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null), - ], - ], - - /** - * Email delivery profiles - * - * Delivery profiles allow you to predefine various properties about email - * messages from your application and give the settings a name. This saves - * duplication across your application and makes maintenance and development - * easier. Each profile accepts a number of keys. See `Cake\Mailer\Email` - * for more information. - */ - 'Email' => [ - 'default' => [ - 'transport' => 'default', - 'from' => 'you@localhost', - /* - * Will by default be set to config value of App.encoding, if that exists otherwise to UTF-8. - */ - //'charset' => 'utf-8', - //'headerCharset' => 'utf-8', - ], - ], - - /** - * Connection information used by the ORM to connect - * to your application's datastores. - * - * ### Notes - * - Drivers include Mysql Postgres Sqlite Sqlserver - * See vendor\cakephp\cakephp\src\Database\Driver for complete list - * - Do not use periods in database name - it may lead to error. - * See https://github.com/cakephp/cakephp/issues/6471 for details. - * - 'encoding' is recommended to be set to full UTF-8 4-Byte support. - * E.g set it to 'utf8mb4' in MariaDB and MySQL and 'utf8' for any - * other RDBMS. - */ - 'Datasources' => [ - /* - * These configurations should contain permanent settings used - * by all environments. - * - * The values in app_local.php will override any values set here - * and should be used for local and per-environment configurations. - * - * Environment variable based configurations can be loaded here or - * in app_local.php depending on the applications needs. - */ - 'default' => [ - 'className' => Connection::class, - 'driver' => Mysql::class, - 'persistent' => false, - 'timezone' => 'UTC', - - /* - * For MariaDB/MySQL the internal default changed from utf8 to utf8mb4, aka full utf-8 support, in CakePHP 3.6 - */ - //'encoding' => 'utf8mb4', - - /* - * If your MySQL server is configured with `skip-character-set-client-handshake` - * then you MUST use the `flags` config to set your charset encoding. - * For e.g. `'flags' => [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4']` - */ - 'flags' => [], - 'cacheMetadata' => true, - 'log' => false, - - /** - * CakePHP will use the default DB port based on the driver selected - * MySQL on MAMP uses port 8889, MAMP users will want to uncomment - * the following line and set the port accordingly - */ - //'port' => 'non_standard_port_number', - 'host' => 'localhost', - 'username' => 'my_app', - 'password' => 'secret', - 'database' => 'my_app', - 'encoding' => 'utf8', - 'timezone' => 'UTC', - 'flags' => [], - 'cacheMetadata' => true, - 'log' => false, - - /** - * Set identifier quoting to true if you are using reserved words or - * special characters in your table or column names. Enabling this - * setting will result in queries built using the Query Builder having - * identifiers quoted when creating SQL. It should be noted that this - * decreases performance because each query needs to be traversed and - * manipulated before being executed. - */ - 'quoteIdentifiers' => false, - - /** - * During development, if using MySQL < 5.6, uncommenting the - * following line could boost the speed at which schema metadata is - * fetched from the database. It can also be set directly with the - * mysql configuration directive 'innodb_stats_on_metadata = 0' - * which is the recommended value in production environments - */ - //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'], - - 'url' => env('DATABASE_URL', null), - ], - - /** - * The test connection is used during the test suite. - */ - 'test' => [ - 'className' => Connection::class, - 'driver' => Mysql::class, - 'persistent' => false, - 'timezone' => 'UTC', - 'flags' => [], - 'cacheMetadata' => true, - 'quoteIdentifiers' => false, - 'log' => false, - //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'], - 'host' => 'localhost', - //'port' => 'non_standard_port_number', - 'username' => 'my_app', - 'password' => 'secret', - 'database' => 'test_myapp', - 'encoding' => 'utf8', - 'url' => env('DATABASE_TEST_URL', null), - ], - ], - - /** - * Configures logging options - */ - 'Log' => [ - 'debug' => [ - 'className' => FileLog::class, - 'path' => LOGS, - 'file' => 'debug', - 'url' => env('LOG_DEBUG_URL', null), - 'scopes' => false, - 'levels' => ['notice', 'info', 'debug'], - ], - 'error' => [ - 'className' => FileLog::class, - 'path' => LOGS, - 'file' => 'error', - 'url' => env('LOG_ERROR_URL', null), - 'scopes' => false, - 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], - ], - // To enable this dedicated query log, you need set your datasource's log flag to true - 'queries' => [ - 'className' => FileLog::class, - 'path' => LOGS, - 'file' => 'queries', - 'url' => env('LOG_QUERIES_URL', null), - 'scopes' => ['queriesLog'], - ], - ], - - /** - * Session configuration. - * - * Contains an array of settings to use for session configuration. The - * `defaults` key is used to define a default preset to use for sessions, any - * settings declared here will override the settings of the default config. - * - * ## Options - * - * - `cookie` - The name of the cookie to use. Defaults to value set for `session.name` php.ini config. - * Avoid using `.` in cookie names, as PHP will drop sessions from cookies with `.` in the name. - * - `cookiePath` - The url path for which session cookie is set. Maps to the - * `session.cookie_path` php.ini config. Defaults to base path of app. - * - `timeout` - The time in minutes the session should be valid for. - * Pass 0 to disable checking timeout. - * Please note that php.ini's session.gc_maxlifetime must be equal to or greater - * than the largest Session['timeout'] in all served websites for it to have the - * desired effect. - * - `defaults` - The default configuration set to use as a basis for your session. - * There are four built-in options: php, cake, cache, database. - * - `handler` - Can be used to enable a custom session handler. Expects an - * array with at least the `engine` key, being the name of the Session engine - * class to use for managing the session. CakePHP bundles the `CacheSession` - * and `DatabaseSession` engines. - * - `ini` - An associative array of additional ini values to set. - * - * The built-in `defaults` options are: - * - * - 'php' - Uses settings defined in your php.ini. - * - 'cake' - Saves session files in CakePHP's /tmp directory. - * - 'database' - Uses CakePHP's database sessions. - * - 'cache' - Use the Cache class to save sessions. - * - * To define a custom session handler, save it at src/Network/Session/.php. - * Make sure the class implements PHP's `SessionHandlerInterface` and set - * Session.handler to - * - * To use database sessions, load the SQL file located at config/schema/sessions.sql - */ - 'Session' => [ - 'defaults' => 'php', - ], - - /** - * API configuration. - * - * Contains an array of setting to use for API client configuration. - * - * ## Options - * - * - `apiBaseUrl` - The base URL for BEdita API instance. - * - `apiKey` - The API key to use with BEdita API instance. - * - `log` - Loggin options, optional log file with `log_file`. - */ - 'API' => [ - 'apiBaseUrl' => env('BEDITA_API'), - 'apiKey' => env('BEDITA_API_KEY', null), - 'log' => [ - //'log_file' => LOGS . 'api.log', - ], - // 'guzzleConfig' => [ // Optional custom configuration for underlying GuzzleHTTP client. - // 'timeout' => 3, - // ], - ], - - /** - * Modules configuration. - * - * Keys must be actual API endpoint names like `documents`, `users` or `folders`. - * Modules order will follow key order of this configuration. - * In case of core or plugin modules not directly served by ModulesController - * (generally modules not related to bject types) a 'route' attribute can be specified for - * custom controller and action rules. - * - * Array value may contain: - * - * 'label' - module label to display, if not set `key` will be used - * 'shortLabel' - short label, 3 character recommended - * 'color' - primary color code, - * 'route' - (optional) custom route (named route or absolute/relative URL) used by plugin modules mainly - * 'secondaryColor' - secondary color code, - * 'sort' - sort order to be used in index; use a field name prepending optionl `-` sign - * to indicate a descendant order, f.i. '-title' will sort by title in reverse alphabetical order - * (default is '-id'), - * 'icon' - icon code, f.i. `icon-article`, have a look in - * `webroot/css/be-icons-codes.css` for a complete list of codes - */ - 'Modules' => [ - 'objects' => [ - 'shortLabel' => 'obj', - 'color' => '#230637', - // 'secondaryColor' => '#d95700', - 'sort' => '-modified', - // 'icon' => 'icon-cube', - ], - 'folders' => [ - 'color' => '#072440', - ], - 'documents' => [ - 'color' => '#cc4700', - ], - 'events' => [ - 'color' => '#09c', - ], - 'news' => [ - 'color' => '#036', - ], - 'locations' => [ - 'color' => '#641', - ], - 'media' => [ - 'color' => '#a80019', - ], - 'images' => [ - 'color' => '#d5002b', - ], - 'videos' => [ - 'color' => '#d5002b', - ], - 'audio' => [ - 'color' => '#d5002b', - ], - 'files' => [ - 'color' => '#d5002b', - ], - 'users' => [ - 'color' => '#000000', - ], - 'profiles' => [ - 'color' => '#093', - ], - ], - - /** - * Modules accesses per role(s) - */ - // 'AccessControl' => [ - // 'manager' => [ - // 'hidden' => ['objects'], - // 'readonly' => ['documents'], - // ], - // 'guest' => [ - // 'hidden' => ['objects', 'users'], - // 'readonly' => ['documents'], - // ], - // ], - - /** - * Properties display configuration settings. - * - * Every key in this array is a module name, for each one we may have: - * - * - 'view' properties groups to present in object view, where groups are: - * + '_keep' special group of properties to keep and display even if not found in object - * + '_hide' special group of properties to not display - * + 'core' always open on the top - * + 'publish' publishing related - * + 'advanced' for power users - * + 'other' remaining attributes - * + any custom name can be added as key, like 'my_group' or 'some_info' - * => a tab named `My Group` or `Some Info` will be generated - * + inside any of the groups above an optional '_element' can define a custom view element for this group - * - * - 'index' properties to display in index view (other than `id`, `status` and `modified`, always displayed if set) - * - * - 'relations' relations ordering by relation name, containing these optional keys - * + 'main' first relations to show on main column, other relations will be appended - * + 'aside' relations to show on right aside column - * + '_element' associative array with custom view element to use for a relation, defined like - * '{relation_name}' => '{MyPlugin.template_path}' - * + '_hidden' array of relations to hide, not viewable in view(s) - * + '_readonly' array of readonly relations, to show in readonly mode in view(s) - * - * - 'filter' filters to display - * - 'bulk' bulk actions list - * - 'fastCreate' fields for fast creation forms, by type - * - 'labels' to customize labels of properties names and their options, it can have two keys `fields` and `options` - * + 'fields' contains an associative array with property names as keys and labels as values - * + 'options' contains an associative array with property names as keys and an array containing option items and the custom labels to use - * A special custom element 'Form/empty' can be used to hide a property group or relation via `_element` - */ - // 'Properties' => [ - // 'foos' => [ - // 'view' => [ - // '_keep' => [ - // 'some_field', - // ], - // '_hide' => [ - // 'some_other_field', - // ], - // 'core' => [ - // 'some_field', - // 'title', - // ], - // 'publish' => [ - // 'publish_field', - // ], - // 'advanced' => [ - // // Use custom element in `MyPlugin` to display this group - // '_element' => 'MyPlugin/advanced', - // 'extra_field', - // ], - // ], - // 'index' => [ - // 'name', - // 'surname', - // 'username', - // ], - // 'relations' => [ - // 'main' => [ - // 'foo_with', - // 'fooed_by', - // ], - // 'aside' => [ - // 'fooing', - // ], - // '_element' => [ - // // use custom element in `MyPlugin` for `fooed_by` - // 'fooed_by' => 'MyPlugin.fooed_by', - // ], - // '_hidden' => [ - // 'download', - // 'downloadable_by', - // ], - // '_readonly' => [ - // 'seealso', - // ], - // ], - // 'filter' => [ - // 'select_field', - // 'another_one', - // ], - // 'bulk' => [ - // 'status', - // 'other_field', - // ], - // 'fastCreate' => [ - // 'required' => ['status', 'title'], - // 'all' => ['status', 'title', 'description'], - // ], - // 'labels' => [ - // 'fields' => [ - // 'description' => 'summary', - // ], - // 'options' => [ - // 'status' => [ - // 'on' => 'published', - // 'off' => 'archived', - // 'draft' => 'in progress', - // ], - // ], - // ], - // ], - // ], - - /** - * Custom view elements configuration. - * Load an element from a `Plugin` and not from core App inside a module. - * - * Example configuration: - * - * ``` - * 'documents` => [ - * 'Form/included' => 'MyPlugin', - * ], - * ``` - * In this example: if current module is `documents` => `Form/included` element is loaded from `MyPlugin` plugin - */ - // 'Elements' => [ - // // 'documents' => [ - // // 'Form/included' => 'MyPlugin', - // // ], - // ], - - /** - * Additional plugins to load with this format: 'PluginName' => load options array - * Where options array may contain - * - * - `debugOnly` - boolean - (default: false) Whether or not you want to load the plugin when in 'debug' mode only - * - `bootstrap` - boolean - (default: true) Whether or not you want the $plugin/config/bootstrap.php file loaded. - * - `routes` - boolean - (default: true) Whether or not you want to load the $plugin/config/routes.php file. - * - `ignoreMissing` - boolean - (default: true) Set to true to ignore missing bootstrap/routes files. - * - `autoload` - boolean - (default: false) Whether or not you want an autoloader registered - */ - // 'Plugins' => [ - // 'MyPlugin' => ['autoload' => true, 'bootstrap' => true, 'routes' => true], // a simple plugin - - // Uncomment to enable `DebugKit` - 'debug' mode is required - //'DebugKit' => ['bootstrap' => true, 'debugOnly' => true], - // ], - - /** - * Pagination default settings - * - * - sizeAvailable => available page size on modules view index - */ - // 'Pagination' => [ - // 'sizeAvailable' => [10, 20, 50, 100], - // ], - - /** - * Export default settings - * - * - limit => max number of exported elements on export all - * - formats => array of formats enabled for export - * - default => default format - */ - // 'Export' => [ - // 'limit' => 10000, - // 'formats' => [ - // 'CSV' => 'csv', // label => value - // 'Open Document' => 'ods', - // 'MS Excel' => 'xlsx' - // ], - // 'default' => 'xlsx' - // ], - - /** - * I18n setup for frontend. - * - * - 'I18n.locales': array of supported locales and language code used as `prefix` like `/en` - * - 'I18n.default': default language code - * - 'I18n.languages': array of supported language codes with their names - * - 'I18n.lang': language code in use (written by the application) - * - 'I18n.timezone': timezone code to use (i.e. 'UTC') - * - 'I18n.cookie': array representing cookie config used by middleware - * - 'I18n.switchLangUrl': url used by middleware to switch lang - * - * Uncomment the following 'I18n' array to activate multilanguage support - */ - // 'I18n' => [ - // 'locales' => [ - // 'en_US' => 'en', - // 'it_IT' => 'it', - // // etc. - // ], - // 'default' => 'en', - // 'languages' => [ - // 'en' => 'English', - // 'it' => 'Italiano', - // // etc. - // ], - // 'timezone' => 'UTC', - // 'cookie' => [ - // 'name' => 'BEditaWebI18n', - // 'create' => true, - // ], - // 'switchLangUrl' => '/lang', - // ], - - /** - * Display an alert message in a top bar. - * Useful to announce mainteinance or to specify a non-production environment - * - * - text => text message to display - * - color => background color to use - */ - // 'AlertMessage' => [ - // 'text' => 'Test Message', - // 'color' => '#498fde', - // ], - - /** - * Maps providers and access tokens - */ - // 'Maps' => [ - // 'mapbox' => [ - // 'token' => '###', - // ], - // ], - - - /** - * Location providers and access tokens - */ - // 'Location' => [ - // 'google' => [ - // 'url' => '###', - // 'key' => '###', - // ], - // ], - - /** - * Project data that can override data from `/home` API call - * Currently only `name` is used - */ - // 'Project' => [ - // 'name' => 'My Project', - // ], - - /** - * Translator engine configuration - */ - // 'Translator' => [ - // 'class' => '\App\Core\I18n\DummyTranslator', - // 'options' => [ - // 'url' => 'www.my-dummy-translator.com', - // 'apiKey' => 'abcde', - // ], - // ], - - /** - * Default RichTextEditor configuration. - */ - // 'RichTextEditor' => [ - // 'default' => [ - // 'toolbar' => [ - // 'heading', - // '|', - // 'bold', - // 'italic', - // 'underline', - // 'strikethrough', - // 'code', - // 'subscript', - // 'superscript', - // 'removeFormat', - // '|', - // 'alignment', - // '|', - // 'placeholders', - // 'specialCharacters', - // 'link', - // 'bulletedList', - // 'numberedList', - // 'blockQuote', - // 'insertTable', - // 'horizontalLine', - // '|', - // 'undo', - // 'redo', - // '|', - // 'editSource', - // ], - // ], - // ], - - /** - * Control handler configuration. - * This adds custom handlers to render object fields controls. - * - * In the following example: cats.moustaches control is rendered through Path\To\SomeClass::countMoustaches - */ - // 'Control' => [ - // 'handlers' => [ - // 'cats' => [ - // 'moustaches' => [ - // 'class' => 'Path\To\SomeClass', - // 'method' => 'countMoustaches', - // ], - // ], - // ], - // ], - - /** - * Editors configuration. - * concurrentCheckTime: the time in milliseconds that a concurrent access is considered still active - */ - // 'Editors' => [ - // 'concurrentCheckTime' => 30000, // 30 seconds - // ], - - /** - * The under work config. When set, a courtesy page is shown with `Maintenance.message` on it. - */ - // 'Maintenance' => [ - // 'message' => 'This page won\'t be available for some time. Try later', - // ] -]; diff --git a/config/app.php b/config/app.php new file mode 100644 index 000000000..21ee4b469 --- /dev/null +++ b/config/app.php @@ -0,0 +1,405 @@ + filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN), + + /** + * Configure basic information about the application. + * + * - namespace - The namespace to find app classes under. + * - defaultLocale - The default locale for translation, formatting currencies and numbers, date and time. + * - encoding - The encoding used for HTML + database connections. + * - base - The base directory the app resides in. If false this + * will be auto detected. + * - dir - Name of app directory. + * - webroot - The webroot directory. + * - wwwRoot - The file path to webroot. + * - baseUrl - To configure CakePHP to *not* use mod_rewrite and to + * use CakePHP pretty URLs, remove these .htaccess + * files: + * /.htaccess + * /webroot/.htaccess + * And uncomment the baseUrl key below. + * - fullBaseUrl - A base URL to use for absolute links. + * CakePHP generates required value based on `HTTP_HOST` environment variable. + * However, you can define it manually to optimize performance or if you + * are concerned about people manipulating the `Host` header. + * - imageBaseUrl - Web path to the public images directory under webroot. + * - cssBaseUrl - Web path to the public css directory under webroot. + * - jsBaseUrl - Web path to the public js directory under webroot. + * - paths - Configure paths for non class based resources. Supports the + * `plugins`, `templates`, `locales` subkeys, which allow the definition of + * paths for plugins, view templates and locale files respectively. + */ + 'App' => [ + 'namespace' => 'App', + 'encoding' => env('APP_ENCODING', 'UTF-8'), + 'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'), + 'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'UTC'), + 'base' => false, + 'dir' => 'src', + 'webroot' => 'webroot', + 'wwwRoot' => WWW_ROOT, + //'baseUrl' => env('SCRIPT_NAME'), + 'fullBaseUrl' => false, + 'imageBaseUrl' => 'img/', + 'cssBaseUrl' => 'css/', + 'jsBaseUrl' => 'js/', + 'paths' => [ + 'plugins' => [ROOT . DS . 'plugins' . DS], + 'templates' => [APP . 'Template' . DS], + 'locales' => [APP . 'Locale' . DS], + ], + ], + + /* + * Security and encryption configuration + * + * - salt - A random string used in security hashing methods. + * The salt value is also used as the encryption key. + * You should treat it as extremely sensitive data. + */ + 'Security' => [ + 'salt' => env('SECURITY_SALT'), + ], + + /* + * Apply timestamps with the last modified time to static assets (js, css, images). + * Will append a querystring parameter containing the time the file was modified. + * This is useful for busting browser caches. + * + * Set to true to apply timestamps when debug is true. Set to 'force' to always + * enable timestamping regardless of debug value. + */ + 'Asset' => [ + //'timestamp' => true, + // 'cacheTime' => '+1 year' + ], + + /** + * Configure the cache adapters. + */ + 'Cache' => [ + 'default' => [ + 'className' => FileEngine::class, + 'path' => CACHE, + 'url' => env('CACHE_DEFAULT_URL', null), + ], + + /** + * Configure the cache used for general framework caching. + * Translation cache files are stored with this configuration. + * Duration will be set to '+2 minutes' in bootstrap.php when debug = true + * If you set 'className' => 'Null' core cache will be disabled. + */ + '_cake_core_' => [ + 'className' => FileEngine::class, + 'prefix' => 'manager_cake_core_', + 'path' => CACHE . 'persistent/', + 'serialize' => true, + 'duration' => '+1 years', + 'url' => env('CACHE_CAKECORE_URL', null), + ], + + /** + * Configure the cache used for schema types caching. + * Duration will be set to '+2 minutes' in bootstrap.php when debug = true + */ + '_schema_types_' => [ + 'className' => FileEngine::class, + 'prefix' => 'schema_types_', + 'path' => CACHE . 'schema_types/', + 'serialize' => true, + 'duration' => '+1 day', + 'url' => env('CACHE_SCHEMATYPES_URL', null), + ], + + /** + * Configure the cache used for project configuration caching. + * Duration will be set to '+2 minutes' in bootstrap.php when debug = true + */ + '_project_config_' => [ + 'className' => FileEngine::class, + 'prefix' => '_project_config_', + 'path' => CACHE . 'project_config/', + 'serialize' => true, + 'duration' => '+1 day', + 'url' => env('CACHE_PROJECTCONFIG_URL', null), + ], + + /** + * Configure the cache for model and datasource caches. This cache + * configuration is used to store schema descriptions, and table listings + * in connections. + * Duration will be set to '+2 minutes' in bootstrap.php when debug = true + */ + '_cake_model_' => [ + 'className' => FileEngine::class, + 'prefix' => 'manager_cake_model_', + 'path' => CACHE . 'models/', + 'serialize' => true, + 'duration' => '+1 years', + 'url' => env('CACHE_CAKEMODEL_URL', null), + ], + + /** + * Thumbnails cache + * Duration will be set to '+2 minutes' in bootstrap.php when debug = true + * If you set 'className' => 'Null' core cache will be disabled. + */ + '_thumbs_' => [ + 'className' => FileEngine::class, + 'prefix' => 'thumbs_', + 'path' => CACHE . 'thumbs/', + 'serialize' => true, + 'duration' => '+1 years', + 'url' => env('CACHE_THUMBS_URL', null), + ], + + /* + * Configure the cache for routes. The cached routes collection is built the + * first time the routes are processed through `config/routes.php`. + * Duration will be set to '+2 seconds' in bootstrap.php when debug = true + */ + '_cake_routes_' => [ + 'className' => FileEngine::class, + 'prefix' => 'manager_cake_routes_', + 'path' => CACHE, + 'serialize' => true, + 'duration' => '+1 years', + 'url' => env('CACHE_CAKEROUTES_URL', null), + ], + ], + + /** + * Configure the Error and Exception handlers used by your application. + * + * By default errors are displayed using Debugger, when debug is true and logged + * by Cake\Log\Log when debug is false. + * + * In CLI environments exceptions will be printed to stderr with a backtrace. + * In web environments an HTML page will be displayed for the exception. + * With debug true, framework errors like Missing Controller will be displayed. + * When debug is false, framework errors will be coerced into generic HTTP errors. + * + * Options: + * + * - `errorLevel` - int - The level of errors you are interested in capturing. + * - `trace` - boolean - Whether or not backtraces should be included in + * logged errors/exceptions. + * - `log` - boolean - Whether or not you want exceptions logged. + * - `exceptionRenderer` - string - The class responsible for rendering + * uncaught exceptions. If you choose a custom class you should place + * the file for that class in src/Error. This class needs to implement a + * render method. + * - `skipLog` - array - List of exceptions to skip for logging. Exceptions that + * extend one of the listed exceptions will also be skipped for logging. + * E.g.: + * `'skipLog' => ['Cake\Http\Exception\NotFoundException', 'Cake\Http\Exception\UnauthorizedException']` + * - `extraFatalErrorMemory` - int - The number of megabytes to increase + * the memory limit by when a fatal error is encountered. This allows + * breathing room to complete logging or error handling. + * - `ignoredDeprecationPaths` - array - A list of glob compatible file paths that deprecations + * should be ignored in. Use this to ignore deprecations for plugins or parts of + * your application that still emit deprecations. + */ + 'Error' => [ + 'errorLevel' => E_ALL, + 'exceptionRenderer' => ExceptionRenderer::class, + 'skipLog' => [], + 'log' => true, + 'trace' => true, + 'ignoredDeprecationPaths' => [], + ], + + /* + * Debugger configuration + * + * Define development error values for Cake\Error\Debugger + * + * - `editor` Set the editor URL format you want to use. + * By default atom, emacs, macvim, phpstorm, sublime, textmate, and vscode are + * available. You can add additional editor link formats using + * `Debugger::addEditor()` during your application bootstrap. + * - `outputMask` A mapping of `key` to `replacement` values that + * `Debugger` should replace in dumped data and logs generated by `Debugger`. + */ + 'Debugger' => [ + 'editor' => 'vscode', + ], + + /** + * Configures logging options + */ + 'Log' => [ + 'debug' => [ + 'className' => FileLog::class, + 'path' => LOGS, + 'file' => 'debug', + 'url' => env('LOG_DEBUG_URL', null), + 'scopes' => false, + 'levels' => ['notice', 'info', 'debug'], + ], + 'error' => [ + 'className' => FileLog::class, + 'path' => LOGS, + 'file' => 'error', + 'url' => env('LOG_ERROR_URL', null), + 'scopes' => false, + 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], + ], + ], + + /** + * Session configuration. + * + * Contains an array of settings to use for session configuration. The + * `defaults` key is used to define a default preset to use for sessions, any + * settings declared here will override the settings of the default config. + * + * ## Options + * + * - `cookie` - The name of the cookie to use. Defaults to 'CAKEPHP'. Avoid using `.` in cookie names, + * as PHP will drop sessions from cookies with `.` in the name. + * - `cookiePath` - The url path for which session cookie is set. Maps to the + * `session.cookie_path` php.ini config. Defaults to base path of app. + * - `timeout` - The time in minutes the session should be valid for. + * Pass 0 to disable checking timeout. + * Please note that php.ini's session.gc_maxlifetime must be equal to or greater + * than the largest Session['timeout'] in all served websites for it to have the + * desired effect. + * - `defaults` - The default configuration set to use as a basis for your session. + * There are four built-in options: php, cake, cache, database. + * - `handler` - Can be used to enable a custom session handler. Expects an + * array with at least the `engine` key, being the name of the Session engine + * class to use for managing the session. CakePHP bundles the `CacheSession` + * and `DatabaseSession` engines. + * - `ini` - An associative array of additional ini values to set. + * + * The built-in `defaults` options are: + * + * - 'php' - Uses settings defined in your php.ini. + * - 'cake' - Saves session files in CakePHP's /tmp directory. + * - 'database' - Uses CakePHP's database sessions. + * - 'cache' - Use the Cache class to save sessions. + * + * To define a custom session handler, save it at src/Network/Session/.php. + * Make sure the class implements PHP's `SessionHandlerInterface` and set + * Session.handler to + * + * To use database sessions, load the SQL file located at config/schema/sessions.sql + */ + 'Session' => [ + 'defaults' => 'php', + 'cookie' => 'BEDITA-MANAGER', + ], + + /** + * API configuration. + * + * Contains an array of setting to use for API client configuration. + * + * ## Options + * + * - `apiBaseUrl` - The base URL for BEdita API instance. + * - `apiKey` - The API key to use with BEdita API instance. + * - `log` - Loggin options, optional log file with `log_file`. + */ + 'API' => [ + 'apiBaseUrl' => env('BEDITA_API'), + 'apiKey' => env('BEDITA_API_KEY', null), + 'log' => [ + //'log_file' => LOGS . 'api.log', + ], + ], + + /** + * Modules configuration. + * + * Keys must be actual API endpoint names like `documents`, `users` or `folders`. + * Modules order will follow key order of this configuration. + * In case of core or plugin modules not directly served by ModulesController + * (generally modules not related to bject types) a 'route' attribute can be specified for + * custom controller and action rules. + * + * Array value may contain: + * + * 'label' - module label to display, if not set `key` will be used + * 'shortLabel' - short label, 3 character recommended + * 'color' - primary color code, + * 'route' - (optional) custom route (named route or absolute/relative URL) used by plugin modules mainly + * 'secondaryColor' - secondary color code, + * 'sort' - sort order to be used in index; use a field name prepending optionl `-` sign + * to indicate a descendant order, f.i. '-title' will sort by title in reverse alphabetical order + * (default is '-id'), + * 'icon' - icon code, f.i. `icon-article`, have a look in + * `webroot/css/be-icons-codes.css` for a complete list of codes + */ + 'Modules' => [ + 'objects' => [ + 'shortLabel' => 'obj', + 'color' => '#230637', + // 'secondaryColor' => '#d95700', + 'sort' => '-modified', + // 'icon' => 'icon-cube', + ], + 'folders' => [ + 'color' => '#072440', + ], + 'documents' => [ + 'color' => '#cc4700', + ], + 'events' => [ + 'color' => '#09c', + ], + 'news' => [ + 'color' => '#036', + ], + 'locations' => [ + 'color' => '#641', + ], + 'media' => [ + 'color' => '#a80019', + ], + 'images' => [ + 'color' => '#d5002b', + ], + 'videos' => [ + 'color' => '#d5002b', + ], + 'audio' => [ + 'color' => '#d5002b', + ], + 'files' => [ + 'color' => '#d5002b', + ], + 'users' => [ + 'color' => '#000000', + ], + 'profiles' => [ + 'color' => '#093', + ], + ], + + /** + * Export default settings + * + * - limit => max number of exported elements on export all + */ + 'Export' => [ + 'limit' => 10000, + ], +]; diff --git a/config/app_local.example.php b/config/app_local.example.php new file mode 100644 index 000000000..bc91bbc37 --- /dev/null +++ b/config/app_local.example.php @@ -0,0 +1,412 @@ + filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN), + + /* + * Security and encryption configuration + * + * - salt - A random string used in security hashing methods. + * The salt value is also used as the encryption key. + * You should treat it as extremely sensitive data. + */ + 'Security' => [ + 'salt' => env('SECURITY_SALT', '__SALT__'), + ], + + /** + * API configuration. + * + * Contains an array of setting to use for API client configuration. + * + * ## Options + * + * - `apiBaseUrl` - The base URL for BEdita API instance. + * - `apiKey` - The API key to use with BEdita API instance. + * - `log` - Loggin options, optional log file with `log_file`. + * - `guzzleConfig` - Optional custom configuration for underlying GuzzleHTTP client. + */ + // 'API' => [ + // 'apiBaseUrl' => 'https://api.example.com', + // 'apiKey' => 'MY-API-KEY', + // 'log' => [ + // //'log_file' => LOGS . 'api.log', + // ], + // //'guzzleConfig' => [ + // // 'timeout' => 3, + // //], + // ], + + /** + * Additional plugins to load with this format: 'PluginName' => load options array + * Where options array may contain + * + * - `debugOnly` - boolean - (default: false) Whether or not you want to load the plugin when in 'debug' mode only + * - `bootstrap` - boolean - (default: true) Whether or not you want the $plugin/config/bootstrap.php file loaded. + * - `routes` - boolean - (default: true) Whether or not you want to load the $plugin/config/routes.php file. + * - `ignoreMissing` - boolean - (default: true) Set to true to ignore missing bootstrap/routes files. + * - `autoload` - boolean - (default: false) Whether or not you want an autoloader registered + */ + //'Plugins' => [ + // 'MyPlugin' => ['autoload' => true], // a simple plugin + //], + + /** + * Project data that can override data from `/home` API call + * Currently only `name` is used + */ + // 'Project' => [ + // 'name' => 'My Project', + // ], + + /** + * Modules accesses per role(s) + */ + // 'AccessControl' => [ + // 'manager' => [ + // 'hidden' => ['objects'], + // 'readonly' => ['documents'], + // ], + // 'guest' => [ + // 'hidden' => ['objects', 'users'], + // 'readonly' => ['documents'], + // ], + // ], + + /** + * Modules configuration. + * + * Keys must be actual API endpoint names like `documents`, `users` or `folders`. + * Modules order will follow key order of this configuration. + * In case of core or plugin modules not directly served by ModulesController + * (generally modules not related to bject types) a 'route' attribute can be specified for + * custom controller and action rules. + * + * Array value may contain: + * + * 'label' - module label to display, if not set `key` will be used + * 'shortLabel' - short label, 3 character recommended + * 'color' - primary color code, + * 'route' - (optional) custom route (named route or absolute/relative URL) used by plugin modules mainly + * 'secondaryColor' - secondary color code, + * 'sort' - sort order to be used in index; use a field name prepending optionl `-` sign + * to indicate a descendant order, f.i. '-title' will sort by title in reverse alphabetical order + * (default is '-id'), + * 'icon' - icon code, f.i. `icon-article`, have a look in + * `webroot/css/be-icons-codes.css` for a complete list of codes + */ + // 'Modules' => [ + // 'objects' => [ + // 'shortLabel' => 'obj', + // 'color' => '#230637', + // // 'secondaryColor' => '#d95700', + // 'sort' => '-modified', + // // 'icon' => 'icon-cube', + // ], + // 'folders' => [ + // 'color' => '#072440', + // ], + // 'documents' => [ + // 'color' => '#cc4700', + // ], + // 'events' => [ + // 'color' => '#09c', + // ], + // 'news' => [ + // 'color' => '#036', + // ], + // 'locations' => [ + // 'color' => '#641', + // ], + // 'media' => [ + // 'color' => '#a80019', + // ], + // 'images' => [ + // 'color' => '#d5002b', + // ], + // 'videos' => [ + // 'color' => '#d5002b', + // ], + // 'audio' => [ + // 'color' => '#d5002b', + // ], + // 'files' => [ + // 'color' => '#d5002b', + // ], + // 'users' => [ + // 'color' => '#000000', + // ], + // 'profiles' => [ + // 'color' => '#093', + // ], + // ], + + /** + * Properties display configuration settings. + * + * Every key in this array is a module name, for each one we may have: + * + * - 'view' properties groups to present in object view, where groups are: + * + '_keep' special group of properties to keep and display even if not found in object + * + '_hide' special group of properties to not display + * + 'core' always open on the top + * + 'publish' publishing related + * + 'advanced' for power users + * + 'other' remaining attributes + * + any custom name can be added as key, like 'my_group' or 'some_info' + * => a tab named `My Group` or `Some Info` will be generated + * + inside any of the groups above an optional '_element' can define a custom view element for this group + * + * - 'index' properties to display in index view (other than `id`, `status` and `modified`, always displayed if set) + * + * - 'relations' relations ordering by relation name, containing these optional keys + * + 'main' first relations to show on main column, other relations will be appended + * + 'aside' relations to show on right aside column + * + '_element' associative array with custom view element to use for a relation, defined like + * '{relation_name}' => '{MyPlugin.template_path}' + * + '_hidden' array of relations to hide, not viewable in view(s) + * + '_readonly' array of readonly relations, to show in readonly mode in view(s) + * + * - 'filter' filters to display + * - 'bulk' bulk actions list + * - 'fastCreate' fields for fast creation forms, by type + * + * A special custom element 'Form/empty' can be used to hide a property group or relation via `_element` + */ + // 'Properties' => [ + // 'foos' => [ + // 'view' => [ + // '_keep' => [ + // 'some_field', + // ], + // '_hide' => [ + // 'some_other_field', + // ], + // 'core' => [ + // 'some_field', + // 'title', + // ], + // 'publish' => [ + // 'publish_field', + // ], + // 'advanced' => [ + // // Use custom element in `MyPlugin` to display this group + // '_element' => 'MyPlugin/advanced', + // 'extra_field', + // ], + // ], + // 'index' => [ + // 'name', + // 'surname', + // 'username', + // ], + // 'relations' => [ + // 'main' => [ + // 'foo_with', + // 'fooed_by', + // ], + // 'aside' => [ + // 'fooing', + // ], + // '_element' => [ + // // use custom element in `MyPlugin` for `fooed_by` + // 'fooed_by' => 'MyPlugin.fooed_by', + // ], + // '_hidden' => [ + // 'download', + // 'downloadable_by', + // ], + // '_readonly' => [ + // 'seealso', + // ], + // ], + // 'filter' => [ + // 'select_field', + // 'another_one', + // ], + // 'bulk' => [ + // 'status', + // 'other_field', + // ], + // 'fastCreate' => [ + // 'required' => ['status', 'title'], + // 'all' => ['status', 'title', 'description'], + // ], + // ], + // ], + + /** + * I18n setup. + * + * - 'I18n.locales': array of supported locales and language code used as `prefix` like `/en` + * - 'I18n.default': default language code + * - 'I18n.languages': array of supported language codes with their names + * - 'I18n.lang': language code in use (written by the application) + * - 'I18n.timezone': timezone code to use (i.e. 'UTC') + * - 'I18n.cookie': array representing cookie config used by middleware + * - 'I18n.switchLangUrl': url used by middleware to switch lang + * + * Uncomment the following 'I18n' array to activate multilanguage support + */ + // 'I18n' => [ + // 'locales' => [ + // 'en_US' => 'en', + // 'it_IT' => 'it', + // // etc. + // ], + // 'default' => 'en', + // 'languages' => [ + // 'en' => 'English', + // 'it' => 'Italiano', + // // etc. + // ], + // 'timezone' => 'UTC', + // 'cookie' => [ + // 'name' => 'BEditaWebI18n', + // 'create' => true, + // ], + // 'switchLangUrl' => '/lang', + // ], + /** + * Display an alert message in a top bar. + * Useful to announce mainteinance or to specify a non-production environment + * + * - text => text message to display + * - color => background color to use + */ + // 'AlertMessage' => [ + // 'text' => 'Test Message', + // 'color' => '#498fde', + // ], + + /** + * Maps providers and access tokens + */ + // 'Maps' => [ + // 'mapbox' => [ + // 'token' => '###', + // ], + // ], + + + /** + * Location providers and access tokens + */ + // 'Location' => [ + // 'google' => [ + // 'url' => '###', + // 'key' => '###', + // ], + // ], + + /** + * Translator engine configuration + */ + // 'Translator' => [ + // 'class' => '\App\Core\I18n\DummyTranslator', + // 'options' => [ + // 'url' => 'www.my-dummy-translator.com', + // 'apiKey' => 'abcde', + // ], + // ], + + /** + * Pagination default settings + * + * - sizeAvailable => available page size on modules view index + */ + // 'Pagination' => [ + // 'sizeAvailable' => [10, 20, 50, 100], + // ], + + /** + * Export default settings + * + * - limit => max number of exported elements on export all + */ + // 'Export' => [ + // 'limit' => 10000, + // ], + + /** + * Default RichTextEditor configuration. + */ + // 'RichTextEditor' => [ + // 'default' => [ + // 'toolbar' => [ + // 'heading', + // '|', + // 'bold', + // 'italic', + // 'underline', + // 'strikethrough', + // 'code', + // 'subscript', + // 'superscript', + // 'removeFormat', + // '|', + // 'alignment', + // '|', + // 'placeholders', + // 'specialCharacters', + // 'link', + // 'bulletedList', + // 'numberedList', + // 'blockQuote', + // 'insertTable', + // 'horizontalLine', + // '|', + // 'undo', + // 'redo', + // '|', + // 'editSource', + // ], + // ], + // ], + + /** + * Control handler configuration. + * This adds custom handlers to render object fields controls. + * + * In the following example: cats.moustaches control is rendered through Path\To\SomeClass::countMoustaches + */ + // 'Control' => [ + // 'handlers' => [ + // 'cats' => [ + // 'moustaches' => [ + // 'class' => 'Path\To\SomeClass', + // 'method' => 'countMoustaches', + // ], + // ], + // ], + // ], + + /** + * Editors configuration. + * concurrentCheckTime: the time in milliseconds that a concurrent access is considered still active + */ + // 'Editors' => [ + // 'concurrentCheckTime' => 30000, // 30 seconds + // ], + + /** + * The under work config. When set, a courtesy page is shown with `Maintenance.message` on it. + */ + // 'Maintenance' => [ + // 'message' => 'This page won\'t be available for some time. Try later', + // ] +]; diff --git a/config/bootstrap.php b/config/bootstrap.php index c211a2860..057d8bafa 100644 --- a/config/bootstrap.php +++ b/config/bootstrap.php @@ -33,14 +33,10 @@ use Cake\Core\Configure; use Cake\Core\Configure\Engine\IniConfig; use Cake\Core\Configure\Engine\PhpConfig; -use Cake\Database\TypeFactory; -use Cake\Datasource\ConnectionManager; use Cake\Error\ErrorTrap; use Cake\Error\ExceptionTrap; use Cake\Http\ServerRequest; use Cake\Log\Log; -use Cake\Mailer\Mailer; -use Cake\Mailer\TransportFactory; use Cake\Routing\Router; use Cake\Utility\Security; @@ -185,9 +181,6 @@ unset($fullBaseUrl); Cache::setConfig(Configure::consume('Cache')); -ConnectionManager::setConfig(Configure::consume('Datasources')); -TransportFactory::setConfig(Configure::consume('EmailTransport')); -Mailer::setConfig(Configure::consume('Email')); Log::setConfig(Configure::consume('Log')); Security::setSalt(Configure::consume('Security.salt')); @@ -207,31 +200,6 @@ return $detector->isTablet(); }); -/* - * You can enable default locale format parsing by adding calls - * to `useLocaleParser()`. This enables the automatic conversion of - * locale specific date formats. For details see - * @link https://book.cakephp.org/4/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data - */ -TypeFactory::build('time'); -TypeFactory::build('date'); -TypeFactory::build('datetime'); -TypeFactory::build('timestamp'); -// TypeFactory::build('datetimefractional')->useLocaleParser(); -// TypeFactory::build('timestampfractional')->useLocaleParser(); -// TypeFactory::build('datetimetimezone')->useLocaleParser(); -// TypeFactory::build('timestamptimezone')->useLocaleParser(); - -/* - * Custom Inflector rules, can be set to correctly pluralize or singularize - * table, model, controller names or whatever other string is passed to the - * inflection functions. - */ -//Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); -//Inflector::rules('irregular', ['red' => 'redlings']); -//Inflector::rules('uninflected', ['dontinflectme']); -//Inflector::rules('transliteration', ['/å/' => 'aa']); - /** * CSRF whitelist * diff --git a/src/Application.php b/src/Application.php index 0c393c330..2aec20a42 100644 --- a/src/Application.php +++ b/src/Application.php @@ -64,7 +64,7 @@ public function bootstrap(): void * Debug Kit should not be installed on a production system */ if (Configure::read('debug')) { - $this->addPlugin('DebugKit'); + $this->addOptionalPlugin('DebugKit'); } $this->addPlugin('BEdita/WebTools'); @@ -81,6 +81,7 @@ protected function bootstrapCli(): void { $this->addOptionalPlugin('Bake'); $this->addOptionalPlugin('IdeHelper'); + $this->addOptionalPlugin('Cake/Repl'); $this->loadPluginsFromConfig(); } diff --git a/src/Command/ConsoleCommand.php b/src/Command/ConsoleCommand.php deleted file mode 100644 index 297659a4c..000000000 --- a/src/Command/ConsoleCommand.php +++ /dev/null @@ -1,90 +0,0 @@ -err('Unable to load Psy\Shell.'); - $io->err(''); - $io->err('Make sure you have installed psysh as a dependency,'); - $io->err('and that Psy\Shell is registered in your autoloader.'); - $io->err(''); - $io->err('If you are using composer run'); - $io->err(''); - $io->err('$ php composer.phar require --dev psy/psysh'); - $io->err(''); - - return static::CODE_ERROR; - } - - $io->out('You can exit with `CTRL-C` or `exit`'); - $io->out(''); - - Log::drop('debug'); - Log::drop('error'); - $io->setLoggers(false); - restore_error_handler(); - restore_exception_handler(); - - $psy = new PsyShell(new PsyConfiguration([ - 'updateCheck' => 'never', - ])); - $psy->run(); - } - - /** - * Display help for this console. - * - * @param \Cake\Console\ConsoleOptionParser $parser The parser to update - * @return \Cake\Console\ConsoleOptionParser - */ - public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser - { - $parser->setDescription( - 'This shell provides a REPL that you can use to interact with ' . - 'your application in a command line designed to run PHP code. ' . - 'You can use it to run adhoc queries with your models, or ' . - 'explore the features of CakePHP and your application.' . - "\n\n" . - 'You will need to have psysh installed for this Shell to work.' - ); - - return $parser; - } -} diff --git a/src/Console/Installer.php b/src/Console/Installer.php index bc865408f..6d6f076d7 100644 --- a/src/Console/Installer.php +++ b/src/Console/Installer.php @@ -1,4 +1,6 @@ isInteractive()) { - $validator = function ($arg) { - if (in_array($arg, ['Y', 'y', 'N', 'n'])) { - return $arg; - } - throw new Exception('This is not a valid answer. Please choose Y or n.'); - }; - $setFolderPermissions = $io->askAndValidate( - 'Set Folder Permissions ? (Default to Y) [Y,n]? ', - $validator, - 10, - 'Y' - ); - - if (in_array($setFolderPermissions, ['Y', 'y'])) { - static::setFolderPermissions($rootDir, $io); - } - } else { - static::setFolderPermissions($rootDir, $io); - } - + static::setFolderPermissions($rootDir, $io); static::setSecuritySalt($rootDir, $io); - if (class_exists('\Cake\Codeception\Console\Installer')) { - \Cake\Codeception\Console\Installer::customizeCodeceptionBinary($event); + if (class_exists(CodeceptionInstaller::class)) { + CodeceptionInstaller::customizeCodeceptionBinary($event); } } /** - * Create the config/app.php file if it does not exist. + * Create config/app_local.php file if it does not exist. * * @param string $dir The application's root directory. * @param \Composer\IO\IOInterface $io IO interface to write to console. * @return void */ - public static function createAppConfig($dir, $io): void + public static function createAppLocalConfig($dir, $io): void { - $appConfig = $dir . '/config/app.php'; - $defaultConfig = $dir . '/config/app.default.php'; - if (!file_exists($appConfig)) { - copy($defaultConfig, $appConfig); - $io->write('Created `config/app.php` file'); + $appLocalConfig = $dir . '/config/app_local.php'; + $appLocalConfigTemplate = $dir . '/config/app_local.example.php'; + if (!file_exists($appLocalConfig)) { + copy($appLocalConfigTemplate, $appLocalConfig); + $io->write('Created `config/app_local.php` file'); } } @@ -151,15 +133,35 @@ public static function createWritableDirectories($dir, $io): void */ public static function setFolderPermissions($dir, $io): void { + // ask if the permissions should be changed + if ($io->isInteractive()) { + $validator = function ($arg) { + if (in_array($arg, ['Y', 'y', 'N', 'n'])) { + return $arg; + } + throw new Exception('This is not a valid answer. Please choose Y or n.'); + }; + $setFolderPermissions = $io->askAndValidate( + 'Set Folder Permissions ? (Default to Y) [Y,n]? ', + $validator, + 10, + 'Y' + ); + + if (in_array($setFolderPermissions, ['n', 'N'])) { + return; + } + } + // Change the permissions on a path and output the results. - $changePerms = function ($path, $perms, $io) { - // Get permission bits from stat(2) result. + $changePerms = function ($path) use ($io) { $currentPerms = fileperms($path) & 0777; - if (($currentPerms & $perms) == $perms) { + $worldWritable = $currentPerms | 0007; + if ($worldWritable == $currentPerms) { return; } - $res = chmod($path, $currentPerms | $perms); + $res = chmod($path, $worldWritable); if ($res) { $io->write('Permissions set on ' . $path); } else { @@ -167,7 +169,7 @@ public static function setFolderPermissions($dir, $io): void } }; - $walker = function ($dir, $perms, $io) use (&$walker, $changePerms) { + $walker = function ($dir) use (&$walker, $changePerms) { $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $path = $dir . '/' . $file; @@ -176,15 +178,14 @@ public static function setFolderPermissions($dir, $io): void continue; } - $changePerms($path, $perms, $io); - $walker($path, $perms, $io); + $changePerms($path); + $walker($path); } }; - $worldWritable = bindec('0000000111'); - $walker($dir . '/tmp', $worldWritable, $io); - $changePerms($dir . '/tmp', $worldWritable, $io); - $changePerms($dir . '/logs', $worldWritable, $io); + $walker($dir . '/tmp'); + $changePerms($dir . '/tmp'); + $changePerms($dir . '/logs'); } /** @@ -197,7 +198,7 @@ public static function setFolderPermissions($dir, $io): void public static function setSecuritySalt($dir, $io): void { $newKey = hash('sha256', Security::randomBytes(64)); - static::setSecuritySaltInFile($dir, $io, $newKey, 'app.php'); + static::setSecuritySaltInFile($dir, $io, $newKey, 'app_local.php'); } /** diff --git a/src/Plugin.php b/src/Plugin.php index d790481cb..eaa6c73ff 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -23,7 +23,7 @@ class Plugin extends CakePlugin { /** - * Loaded BE4Web application plugins + * Loaded BEdita Manager application plugins * Auxiliary & internally loaded plugins like `DebugKit`, `Bake` and `TwigView` are exluded * * @return array @@ -35,6 +35,7 @@ public static function loadedAppPlugins(): array 'Bake', 'DebugKit', 'IdeHelper', + 'Cake/Repl', 'BEdita/WebTools', 'BEdita/I18n', 'Migrations', diff --git a/tests/TestCase/Command/ConsoleCommandTest.php b/tests/TestCase/Command/ConsoleCommandTest.php deleted file mode 100644 index 310321e61..000000000 --- a/tests/TestCase/Command/ConsoleCommandTest.php +++ /dev/null @@ -1,52 +0,0 @@ - for more details. - */ -namespace App\Test\TestCase\Command; - -use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; -use Cake\TestSuite\TestCase; - -/** - * Console Command tests. - * - * {@see \App\Command\Console} Test Case - * - * @coversDefaultClass \App\Command\Console - */ -class ConsoleCommandTest extends TestCase -{ - use ConsoleIntegrationTestTrait; - - /** - * @inheritDoc - */ - public function setUp(): void - { - parent::setUp(); - $this->useCommandRunner(); - } - - /** - * Test help output - * - * @return void - * @covers ::buildOptionParser() - */ - public function testConsoleHelp(): void - { - $this->exec('console -h'); - - $this->assertExitCode(0); - $this->assertOutputContains('You will need to have psysh installed for this Shell to work.'); - } -}