diff --git a/flextype/bootstrap.php b/flextype/bootstrap.php index ae0b88a3..37198c19 100755 --- a/flextype/bootstrap.php +++ b/flextype/bootstrap.php @@ -42,70 +42,70 @@ Session::start(); $registry = new Registry(); /** - * Load core settings + * Load flextype settings * * 1. Set settings files paths. - * 2. Load system default and site settings files. + * 2. Load flextype default and flextype custom settings files. * 3. Merge settings. * 4. Add settings into the registry. */ -$default_settings_file_path = PATH['config']['default'] . '/settings.yaml'; -$site_settings_file_path = PATH['config']['site'] . '/settings.yaml'; +$default_flextype_settings_file_path = PATH['config']['default'] . '/settings.yaml'; +$custom_flextype_settings_file_path = PATH['config']['site'] . '/settings.yaml'; -// Set settings if Flextype settings and Site settings config files exist -if (! Filesystem::has($default_settings_file_path) || ! Filesystem::has($site_settings_file_path)) { - throw new RuntimeException('Flextype settings or Site settings config files does not exist.'); +// Set settings if Flextype Default settings and Flextype Custom settings config files exist +if (! Filesystem::has($default_flextype_settings_file_path) || ! Filesystem::has($custom_flextype_settings_file_path)) { + throw new RuntimeException('Flextype Default settings or Flextype Custom settings config files does not exist.'); } -if (($content = Filesystem::read($default_settings_file_path)) === false) { - throw new RuntimeException('Load file: ' . $default_settings_file_path . ' - failed!'); +if (($content = Filesystem::read($default_flextype_settings_file_path)) === false) { + throw new RuntimeException('Load file: ' . $default_flextype_settings_file_path . ' - failed!'); } else { if (trim($content) === '') { - $default_settings = []; + $default_flextype_settings = []; } else { - $default_settings = Yaml::decode($content); + $default_flextype_settings = Yaml::decode($content); } } -if (($content = Filesystem::read($site_settings_file_path)) === false) { - throw new RuntimeException('Load file: ' . $site_settings_file_path . ' - failed!'); +if (($content = Filesystem::read($custom_flextype_settings_file_path)) === false) { + throw new RuntimeException('Load file: ' . $custom_flextype_settings_file_path . ' - failed!'); } else { if (trim($content) === '') { - $site_settings = []; + $custom_flextype_settings = []; } else { - $site_settings = Yaml::decode($content); + $custom_flextype_settings = Yaml::decode($content); } } -// Merge settings -$settings = array_replace_recursive($default_settings, $site_settings); +// Merge flextype settings +$flextype_settings = array_replace_recursive($default_flextype_settings, $custom_flextype_settings); -// Set settings -$registry->set('settings', $settings); +// Set flextype settings +$registry->set('flextype', $flextype_settings); /** * Create new application */ $app = new App([ 'settings' => [ - 'debug' => $registry->get('settings.errors.display'), - 'whoops.editor' => $registry->get('settings.whoops.editor'), - 'whoops.page_title' => $registry->get('settings.whoops.page_title'), - 'displayErrorDetails' => $registry->get('settings.display_error_details'), - 'addContentLengthHeader' => $registry->get('settings.add_content_length_header'), - 'routerCacheFile' => $registry->get('settings.router_cache_file'), - 'determineRouteBeforeAppMiddleware' => $registry->get('settings.determine_route_before_app_middleware'), - 'outputBuffering' => $registry->get('settings.output_buffering'), - 'responseChunkSize' => $registry->get('settings.response_chunk_size'), - 'httpVersion' => $registry->get('settings.http_version'), + 'debug' => $registry->get('flextype.errors.display'), + 'whoops.editor' => $registry->get('flextype.whoops.editor'), + 'whoops.page_title' => $registry->get('flextype.whoops.page_title'), + 'displayErrorDetails' => $registry->get('flextype.display_error_details'), + 'addContentLengthHeader' => $registry->get('flextype.add_content_length_header'), + 'routerCacheFile' => $registry->get('flextype.router_cache_file'), + 'determineRouteBeforeAppMiddleware' => $registry->get('flextype.determine_route_before_app_middleware'), + 'outputBuffering' => $registry->get('flextype.output_buffering'), + 'responseChunkSize' => $registry->get('flextype.response_chunk_size'), + 'httpVersion' => $registry->get('flextype.http_version'), 'twig' => [ - 'charset' => $registry->get('settings.twig.charset'), - 'debug' => $registry->get('settings.twig.debug'), - 'cache' => $registry->get('settings.twig.cache') ? PATH['cache'] . '/twig' : false, - 'auto_reload' => $registry->get('settings.twig.auto_reload'), + 'charset' => $registry->get('flextype.twig.charset'), + 'debug' => $registry->get('flextype.twig.debug'), + 'cache' => $registry->get('flextype.twig.cache') ? PATH['cache'] . '/twig' : false, + 'auto_reload' => $registry->get('flextype.twig.auto_reload'), ], 'images' => [ - 'driver' => $registry->get('settings.image.driver'), + 'driver' => $registry->get('flextype.image.driver'), ], ], ]); @@ -135,13 +135,13 @@ include_once 'api/delivery/entries.php'; * Set internal encoding */ function_exists('mb_language') and mb_language('uni'); -function_exists('mb_regex_encoding') and mb_regex_encoding($flextype['registry']->get('settings.charset')); -function_exists('mb_internal_encoding') and mb_internal_encoding($flextype['registry']->get('settings.charset')); +function_exists('mb_regex_encoding') and mb_regex_encoding($flextype['registry']->get('flextype.charset')); +function_exists('mb_internal_encoding') and mb_internal_encoding($flextype['registry']->get('flextype.charset')); /** * Display Errors */ -if ($flextype['registry']->get('settings.errors.display')) { +if ($flextype['registry']->get('flextype.errors.display')) { /** * Add WhoopsMiddleware @@ -154,14 +154,14 @@ if ($flextype['registry']->get('settings.errors.display')) { /** * Set default timezone */ -date_default_timezone_set($flextype['registry']->get('settings.timezone')); +date_default_timezone_set($flextype['registry']->get('flextype.timezone')); /** * Init shortocodes * * Load Flextype Shortcodes extensions from directory /flextype/shortcodes/ based on settings.shortcodes.extensions array */ -$shortcodes_extensions = $flextype['registry']->get('settings.shortcodes.extensions'); +$shortcodes_extensions = $flextype['registry']->get('flextype.shortcodes.extensions'); foreach($shortcodes_extensions as $shortcodes_extension) { $shortcodes_extension_file_path = ROOT_DIR . '/flextype/shortcodes/' . $shortcodes_extension . 'ShortcodeExtension.php'; diff --git a/flextype/cache/MemcachedAdapter.php b/flextype/cache/MemcachedAdapter.php index b9fb6d02..3b430954 100644 --- a/flextype/cache/MemcachedAdapter.php +++ b/flextype/cache/MemcachedAdapter.php @@ -19,8 +19,8 @@ class MemcachedAdapter implements CacheAdapterInterface { $memcached = new Memecached(); $memcached->addServer( - $this->flextype['registry']->get('settings.cache.memcached.server', 'localhost'), - $this->flextype['registry']->get('settings.cache.memcache.port', 11211) + $this->flextype['registry']->get('flextype.cache.memcached.server', 'localhost'), + $this->flextype['registry']->get('flextype.cache.memcache.port', 11211) ); $driver = new MemcachedCache(); diff --git a/flextype/cache/RedisAdapter.php b/flextype/cache/RedisAdapter.php index 30decb9a..447f28e5 100644 --- a/flextype/cache/RedisAdapter.php +++ b/flextype/cache/RedisAdapter.php @@ -19,15 +19,15 @@ class RedisAdapter implements CacheAdapterInterface public function getDriver() : object { $redis = new Redis(); - $socket = $this->flextype['registry']->get('settings.cache.redis.socket', false); - $password = $this->flextype['registry']->get('settings.cache.redis.password', false); + $socket = $this->flextype['registry']->get('flextype.cache.redis.socket', false); + $password = $this->flextype['registry']->get('flextype.cache.redis.password', false); if ($socket) { $redis->connect($socket); } else { $redis->connect( - $this->flextype['registry']->get('settings.cache.redis.server', 'localhost'), - $this->flextype['registry']->get('settings.cache.redis.port', 6379) + $this->flextype['registry']->get('flextype.cache.redis.server', 'localhost'), + $this->flextype['registry']->get('flextype.cache.redis.port', 6379) ); } diff --git a/flextype/cache/SQLite3Adapter.php b/flextype/cache/SQLite3Adapter.php index 0081939d..8edb605b 100644 --- a/flextype/cache/SQLite3Adapter.php +++ b/flextype/cache/SQLite3Adapter.php @@ -24,8 +24,8 @@ class SQLite3Adapter implements CacheAdapterInterface Filesystem::createDir($cache_directory); } - $db = new SQLite3($cache_directory . $this->flextype['registry']->get('settings.cache.sqlite3.database', 'flextype') . '.db'); + $db = new SQLite3($cache_directory . $this->flextype['registry']->get('flextype.cache.sqlite3.database', 'flextype') . '.db'); - return new SQLite3Cache($db, $this->flextype['registry']->get('settings.cache.sqlite3.table', 'flextype')); + return new SQLite3Cache($db, $this->flextype['registry']->get('flextype.cache.sqlite3.table', 'flextype')); } } diff --git a/flextype/core/Cache.php b/flextype/core/Cache.php index d3ee658a..591fbf8c 100755 --- a/flextype/core/Cache.php +++ b/flextype/core/Cache.php @@ -67,7 +67,7 @@ class Cache $this->now = time(); // Create cache key to allow invalidate all cache on configuration changes. - $this->key = ($this->flextype['registry']->get('settings.cache.prefix') ?? 'flextype') . '-' . md5(PATH['site'] . 'Flextype::VERSION'); + $this->key = ($this->flextype['registry']->get('flextype.cache.prefix') ?? 'flextype') . '-' . md5(PATH['site'] . 'Flextype::VERSION'); // Get Cache Driver $this->driver = $this->getCacheDriver(); @@ -117,7 +117,7 @@ class Cache */ public function fetch(string $id) { - if ($this->flextype['registry']->get('settings.cache.enabled')) { + if ($this->flextype['registry']->get('flextype.cache.enabled')) { return $this->driver->fetch($id); } @@ -133,7 +133,7 @@ class Cache */ public function contains(string $id) : bool { - if ($this->flextype['registry']->get('settings.cache.enabled')) { + if ($this->flextype['registry']->get('flextype.cache.enabled')) { return $this->driver->contains($id); } @@ -153,7 +153,7 @@ class Cache */ public function save(string $id, $data, ?int $lifetime = null) : void { - if (! $this->flextype['registry']->get('settings.cache.enabled')) { + if (! $this->flextype['registry']->get('flextype.cache.enabled')) { return; } @@ -168,7 +168,7 @@ class Cache */ public function delete(string $id) : void { - if (! $this->flextype['registry']->get('settings.cache.enabled')) { + if (! $this->flextype['registry']->get('flextype.cache.enabled')) { return; } @@ -237,7 +237,7 @@ class Cache public function getLifetime() { if ($this->lifetime === null) { - $this->lifetime = $this->flextype['registry']->get('settings.cache.lifetime') ?: 604800; + $this->lifetime = $this->flextype['registry']->get('flextype.cache.lifetime') ?: 604800; } return $this->lifetime; diff --git a/flextype/core/Entries.php b/flextype/core/Entries.php index ba83b468..128679a2 100755 --- a/flextype/core/Entries.php +++ b/flextype/core/Entries.php @@ -474,8 +474,8 @@ class Entries // Check if new entry file exists if (! Filesystem::has($entry_file = $entry_dir . '/entry.md')) { $data['uuid'] = Uuid::uuid4()->toString(); - $data['published_at'] = date($this->flextype->registry->get('settings.date_format'), time()); - $data['created_at'] = date($this->flextype->registry->get('settings.date_format'), time()); + $data['published_at'] = date($this->flextype->registry->get('flextype.date_format'), time()); + $data['created_at'] = date($this->flextype->registry->get('flextype.date_format'), time()); $data['published_by'] = (Session::exists('uuid') ? Session::get('uuid') : ''); $data['created_by'] = (Session::exists('uuid') ? Session::get('uuid') : ''); diff --git a/flextype/core/Parser.php b/flextype/core/Parser.php index fca995da..fdaf1934 100644 --- a/flextype/core/Parser.php +++ b/flextype/core/Parser.php @@ -103,7 +103,7 @@ class Parser { switch ($parser) { case 'frontmatter': - if ($cache === true && $this->flextype['registry']->get('settings.cache.enabled') === true) { + if ($cache === true && $this->flextype['registry']->get('flextype.cache.enabled') === true) { $key = md5($input); if ($data_from_cache = $this->flextype['cache']->fetch($key)) { @@ -120,7 +120,7 @@ class Parser break; case 'json': - if ($cache === true && $this->flextype['registry']->get('settings.cache.enabled') === true) { + if ($cache === true && $this->flextype['registry']->get('flextype.cache.enabled') === true) { $key = md5($input); if ($data_from_cache = $this->flextype['cache']->fetch($key)) { @@ -137,7 +137,7 @@ class Parser break; case 'yaml': - if ($cache === true && $this->flextype['registry']->get('settings.cache.enabled') === true) { + if ($cache === true && $this->flextype['registry']->get('flextype.cache.enabled') === true) { $key = md5($input); if ($data_from_cache = $this->flextype['cache']->fetch($key)) { @@ -154,7 +154,7 @@ class Parser break; case 'markdown': - if ($cache === true && $this->flextype['registry']->get('settings.cache.enabled') === true) { + if ($cache === true && $this->flextype['registry']->get('flextype.cache.enabled') === true) { $key = md5($input); if ($data_from_cache = $this->flextype['cache']->fetch($key)) { diff --git a/flextype/core/Plugins.php b/flextype/core/Plugins.php index eb76111e..2952d352 100755 --- a/flextype/core/Plugins.php +++ b/flextype/core/Plugins.php @@ -68,7 +68,7 @@ class Plugins $this->flextype['registry']->set('plugins', []); // Set locale - $locale = $this->flextype['registry']->get('settings.locale'); + $locale = $this->flextype['registry']->get('flextype.locale'); // Get plugins list $plugins_list = $this->getPluginsList(); diff --git a/flextype/dependencies.php b/flextype/dependencies.php index bd1d1e83..d8f0129b 100644 --- a/flextype/dependencies.php +++ b/flextype/dependencies.php @@ -88,12 +88,12 @@ $flextype['emitter'] = static function ($container) { */ $flextype['slugify'] = static function ($container) { return new Slugify([ - 'separator' => $container['registry']->get('settings.slugify.separator'), - 'lowercase' => $container['registry']->get('settings.slugify.lowercase'), - 'trim' => $container['registry']->get('settings.slugify.trim'), - 'regexp' => $container['registry']->get('settings.slugify.regexp'), - 'lowercase_after_regexp' => $container['registry']->get('settings.slugify.lowercase_after_regexp'), - 'strip_tags' => $container['registry']->get('settings.slugify.strip_tags'), + 'separator' => $container['registry']->get('flextype.slugify.separator'), + 'lowercase' => $container['registry']->get('flextype.slugify.lowercase'), + 'trim' => $container['registry']->get('flextype.slugify.trim'), + 'regexp' => $container['registry']->get('flextype.slugify.regexp'), + 'lowercase_after_regexp' => $container['registry']->get('flextype.slugify.lowercase_after_regexp'), + 'strip_tags' => $container['registry']->get('flextype.slugify.strip_tags'), ]); }; @@ -108,7 +108,7 @@ $flextype['flash'] = static function ($container) { * Adds the cache adapter to the Flextype container */ $flextype['cache_adapter'] = static function ($container) use ($flextype) { - $driver_name = $container['registry']->get('settings.cache.driver'); + $driver_name = $container['registry']->get('flextype.cache.driver'); if (! $driver_name || $driver_name === 'auto') { if (extension_loaded('apcu')) { @@ -245,7 +245,7 @@ $flextype['view'] = static function ($container) { $view->addExtension(new DebugExtension()); // Load Flextype Twig extensions from directory /flextype/twig/ based on settings.twig.extensions array - $twig_extensions = $container['registry']->get('settings.twig.extensions'); + $twig_extensions = $container['registry']->get('flextype.twig.extensions'); foreach($twig_extensions as $twig_extension) { diff --git a/site/plugins/admin/app/Controllers/ApiController.php b/site/plugins/admin/app/Controllers/ApiController.php index bfac781a..fba03755 100644 --- a/site/plugins/admin/app/Controllers/ApiController.php +++ b/site/plugins/admin/app/Controllers/ApiController.php @@ -182,7 +182,7 @@ class ApiController extends Controller $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->registry->get('settings.date_format'), time()); + $time = date($this->registry->get('flextype.date_format'), time()); // Create API Token account if (Filesystem::write( @@ -276,7 +276,7 @@ class ApiController extends Controller 'created_by' => $post_data['created_by'], 'created_at' => $post_data['created_at'], 'updated_by' => Session::get('uuid'), - 'updated_at' => date($this->registry->get('settings.date_format'), time()), + 'updated_at' => date($this->registry->get('flextype.date_format'), time()), ], 'yaml') )) { $this->flash->addMessage('success', __('admin_message_' . $post_data['api'] . '_api_token_updated')); diff --git a/site/plugins/admin/app/Controllers/EntriesController.php b/site/plugins/admin/app/Controllers/EntriesController.php index 88931a98..e4b8fcac 100644 --- a/site/plugins/admin/app/Controllers/EntriesController.php +++ b/site/plugins/admin/app/Controllers/EntriesController.php @@ -227,7 +227,7 @@ class EntriesController extends Controller // We need to check if template for current fieldset is exists // if template is not exist then `default` template will be used! - $template_path = PATH['themes'] . '/' . $this->registry->get('settings.theme') . '/templates/' . $data['fieldset'] . '.html'; + $template_path = PATH['themes'] . '/' . $this->registry->get('flextype.theme') . '/templates/' . $data['fieldset'] . '.html'; $template = (Filesystem::has($template_path)) ? $data['fieldset'] : 'default'; // Init entry data @@ -442,7 +442,7 @@ class EntriesController extends Controller if ($_entry['slug'] != '') { $entries_list[$_entry['slug']] = $_entry['slug']; } else { - $entries_list[$this->registry->get('settings.entries.main')] = $this->registry->get('settings.entries.main'); + $entries_list[$this->registry->get('flextype.entries.main')] = $this->registry->get('flextype.entries.main'); } } @@ -1094,9 +1094,8 @@ class EntriesController extends Controller if ($post_data['id'] == '') { $data = []; - Arr::set($data, 'entries.items_view_default', $post_data['items_view']); - //$this->registry->get('settings') - Filesystem::write(PATH['config']['site'] . '/settings.yaml', $this->parser->encode(array_replace_recursive($this->registry->get('settings'), $data), 'yaml')); + Arr::set($data, 'plugins.admin.entries.items_view_default', $post_data['items_view']); + //Filesystem::write(PATH['config']['site'] . '/settings.yaml', $this->parser->encode(array_replace_recursive($this->registry->get('settings'), $data), 'yaml')); } else { $this->entries->update($post_data['id'], ['items_view' => $post_data['items_view']]); } diff --git a/site/plugins/admin/app/Controllers/TemplatesController.php b/site/plugins/admin/app/Controllers/TemplatesController.php index ce7ceb8b..0488c51b 100644 --- a/site/plugins/admin/app/Controllers/TemplatesController.php +++ b/site/plugins/admin/app/Controllers/TemplatesController.php @@ -261,7 +261,7 @@ class TemplatesController extends Controller $theme = $request->getParsedBody()['theme']; $type = $request->getParsedBody()['type_current']; - if (! Filesystem::has(PATH['themes'] . '/' . $this->registry->get('settings.theme') . '/' . $this->_type_location($type) . $request->getParsedBody()['id'] . '.html')) { + if (! Filesystem::has(PATH['themes'] . '/' . $this->registry->get('flextype.theme') . '/' . $this->_type_location($type) . $request->getParsedBody()['id'] . '.html')) { if (Filesystem::rename( PATH['themes'] . '/' . $theme . '/' . $this->_type_location($type) . $request->getParsedBody()['id_current'] . '.html', PATH['themes'] . '/' . $theme . '/' . $this->_type_location($type) . $request->getParsedBody()['id'] . '.html' diff --git a/site/plugins/admin/app/Controllers/UsersController.php b/site/plugins/admin/app/Controllers/UsersController.php index a7b02044..1412e535 100644 --- a/site/plugins/admin/app/Controllers/UsersController.php +++ b/site/plugins/admin/app/Controllers/UsersController.php @@ -134,7 +134,7 @@ class UsersController extends Controller $uuid = Uuid::uuid4()->toString(); // Get time - $time = date($this->registry->get('settings.date_format'), time()); + $time = date($this->registry->get('flextype.date_format'), time()); // Create accounts directory and account Filesystem::createDir(PATH['site'] . '/accounts/'); diff --git a/site/plugins/admin/dependencies.php b/site/plugins/admin/dependencies.php index c90eb73e..55bcf2ee 100644 --- a/site/plugins/admin/dependencies.php +++ b/site/plugins/admin/dependencies.php @@ -15,7 +15,7 @@ use Flextype\Component\I18n\I18n; use function Flextype\Component\I18n\__; // Set Default Admin locale -I18n::$locale = $flextype->registry->get('settings.locale'); +I18n::$locale = $flextype->registry->get('flextype.locale'); // Add Admin Navigation $flextype->registry->set('admin_navigation.content.entries', ['title' => __('admin_entries'), 'icon' => 'fas fa-database', 'link' => $flextype->router->pathFor('admin.entries.index')]); diff --git a/site/plugins/form/app/Controllers/FormController.php b/site/plugins/form/app/Controllers/FormController.php index dbe169cf..78d57a3b 100644 --- a/site/plugins/form/app/Controllers/FormController.php +++ b/site/plugins/form/app/Controllers/FormController.php @@ -311,7 +311,7 @@ class FormController extends Controller $name = isset($properties['name']) ? $properties['name'] : $field_name; $current_value = isset($properties['value']) ? $properties['value'] : $field_value; - $_templates_list = $this->flextype['themes']->getTemplates($this->flextype['registry']->get('settings.theme')); + $_templates_list = $this->flextype['themes']->getTemplates($this->flextype['registry']->get('flextype.theme')); $options = []; diff --git a/site/plugins/site/app/Controllers/SiteController.php b/site/plugins/site/app/Controllers/SiteController.php index 046fea69..489489ec 100644 --- a/site/plugins/site/app/Controllers/SiteController.php +++ b/site/plugins/site/app/Controllers/SiteController.php @@ -45,7 +45,7 @@ class SiteController extends Controller // If uri is empty then it is main entry else use entry uri if ($uri === '/') { - $entry_uri = $this->registry->get('settings.entries.main'); + $entry_uri = $this->registry->get('flextype.entries.main'); } else { $entry_uri = ltrim($uri, '/'); } @@ -87,7 +87,7 @@ class SiteController extends Controller } // Set template path for current entry - $path = 'themes/' . $this->registry->get('settings.theme') . '/' . (empty($this->entry['template']) ? 'templates/default' : 'templates/' . $this->entry['template']) . '.html'; + $path = 'themes/' . $this->registry->get('flextype.theme') . '/' . (empty($this->entry['template']) ? 'templates/default' : 'templates/' . $this->entry['template']) . '.html'; if ($is_entry_not_found) { return $this->view->render($response->withStatus(404), $path, ['entry' => $this->entry, 'query' => $query, 'uri' => $uri]); @@ -106,10 +106,10 @@ class SiteController extends Controller public function error404() : array { return [ - 'title' => $this->registry->get('settings.entries.error404.title'), - 'description' => $this->registry->get('settings.entries.error404.description'), - 'content' => $this->registry->get('settings.entries.error404.content'), - 'template' => $this->registry->get('settings.entries.error404.template'), + 'title' => $this->registry->get('flextype.entries.error404.title'), + 'description' => $this->registry->get('flextype.entries.error404.description'), + 'content' => $this->registry->get('flextype.entries.error404.content'), + 'template' => $this->registry->get('flextype.entries.error404.template'), ]; } }