mirror of
https://github.com/flextype/flextype.git
synced 2025-08-13 00:24:15 +02:00
@@ -64,7 +64,7 @@ class Entries
|
||||
} else {
|
||||
|
||||
if ($entry_body = Filesystem::read($entry_file)) {
|
||||
if ($entry_decoded = YamlParser::decode($entry_body)) {
|
||||
if ($entry_decoded = JsonParser::decode($entry_body)) {
|
||||
|
||||
// Create default entry items
|
||||
$entry_decoded['date'] = $entry_decoded['date'] ?? date($this->flextype['registry']->get('settings.date_format'), Filesystem::getTimestamp($entry_file));
|
||||
@@ -119,11 +119,11 @@ class Entries
|
||||
|
||||
// Create entries cached id
|
||||
foreach ($entries_list as $current_entry) {
|
||||
if (strpos($current_entry['path'], $entry . '/entry.yaml') !== false) {
|
||||
if (strpos($current_entry['path'], $entry . '/entry.json') !== false) {
|
||||
// ignore ...
|
||||
} else {
|
||||
if ($current_entry['type'] == 'dir' && Filesystem::has($current_entry['path'] . '/entry.yaml')) {
|
||||
$cache_id .= md5('entries' . $current_entry['path'] . Filesystem::getTimestamp($current_entry['path'] . '/entry.yaml'));
|
||||
if ($current_entry['type'] == 'dir' && Filesystem::has($current_entry['path'] . '/entry.json')) {
|
||||
$cache_id .= md5('entries' . $current_entry['path'] . Filesystem::getTimestamp($current_entry['path'] . '/entry.json'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,10 +134,10 @@ class Entries
|
||||
|
||||
// Create entries array from entries list and ignore current requested entry
|
||||
foreach ($entries_list as $current_entry) {
|
||||
if (strpos($current_entry['path'], $entry . '/entry.yaml') !== false) {
|
||||
if (strpos($current_entry['path'], $entry . '/entry.json') !== false) {
|
||||
// ignore ...
|
||||
} else {
|
||||
if ($current_entry['type'] == 'dir' && Filesystem::has($current_entry['path'] . '/entry.yaml')) {
|
||||
if ($current_entry['type'] == 'dir' && Filesystem::has($current_entry['path'] . '/entry.json')) {
|
||||
$entries[$current_entry['dirname']] = $this->fetch($entry . '/' . $current_entry['dirname']);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ class Entries
|
||||
$entry_file = $this->_file_location($entry);
|
||||
|
||||
if (Filesystem::has($entry_file)) {
|
||||
return Filesystem::write($entry_file, YamlParser::encode($data));
|
||||
return Filesystem::write($entry_file, JsonParser::encode($data));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -209,11 +209,11 @@ class Entries
|
||||
// Try to create directory for new entry
|
||||
if (Filesystem::createDir($entry_dir)) {
|
||||
|
||||
$entry_file = $entry_dir . '/entry.yaml';
|
||||
$entry_file = $entry_dir . '/entry.json';
|
||||
|
||||
// Check if new entry file exists
|
||||
if (!Filesystem::has($entry_file)) {
|
||||
return Filesystem::write($entry_file, YamlParser::encode($data));
|
||||
return Filesystem::write($entry_file, JsonParser::encode($data));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ class Entries
|
||||
*/
|
||||
private function _file_location(string $name) : string
|
||||
{
|
||||
return PATH['entries'] . '/' . $name . '/entry.yaml';
|
||||
return PATH['entries'] . '/' . $name . '/entry.json';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -81,23 +81,23 @@ class Plugins
|
||||
|
||||
// Go through...
|
||||
foreach ($plugins_list as $plugin) {
|
||||
if (Filesystem::has($_plugin_settings = PATH['plugins'] . '/' . $plugin['dirname'] . '/settings.yaml')) {
|
||||
if (Filesystem::has($_plugin_settings = PATH['plugins'] . '/' . $plugin['dirname'] . '/settings.json')) {
|
||||
if (($content = Filesystem::read($_plugin_settings)) === false) {
|
||||
throw new \RuntimeException('Load file: ' . $_plugin_settings . ' - failed!');
|
||||
} else {
|
||||
$plugin_settings = YamlParser::decode($content);
|
||||
$plugin_settings = JsonParser::decode($content);
|
||||
}
|
||||
}
|
||||
|
||||
if (Filesystem::has($_plugin_config = PATH['plugins'] . '/' . $plugin['dirname'] . '/' . $plugin['dirname'] . '.yaml')) {
|
||||
if (Filesystem::has($_plugin_config = PATH['plugins'] . '/' . $plugin['dirname'] . '/' . $plugin['dirname'] . '.json')) {
|
||||
if (($content = Filesystem::read($_plugin_config)) === false) {
|
||||
throw new \RuntimeException('Load file: ' . $_plugin_config . ' - failed!');
|
||||
} else {
|
||||
$plugin_config = YamlParser::decode($content);
|
||||
$plugin_config = JsonParser::decode($content);
|
||||
}
|
||||
}
|
||||
|
||||
$_plugins_config[basename($_plugin_config, '.yaml')] = array_merge($plugin_settings, $plugin_config);
|
||||
$_plugins_config[basename($_plugin_config, '.json')] = array_merge($plugin_settings, $plugin_config);
|
||||
}
|
||||
|
||||
$this->flextype['registry']->set('plugins', $_plugins_config);
|
||||
@@ -125,12 +125,12 @@ class Plugins
|
||||
if (is_array($plugins_list) && count($plugins_list) > 0) {
|
||||
foreach ($this->locales as $locale => $locale_title) {
|
||||
foreach ($plugins_list as $plugin) {
|
||||
$language_file = PATH['plugins'] . '/' . $plugin['dirname'] . '/languages/' . $locale . '.yaml';
|
||||
$language_file = PATH['plugins'] . '/' . $plugin['dirname'] . '/languages/' . $locale . '.json';
|
||||
if (Filesystem::has($language_file)) {
|
||||
if (($content = Filesystem::read($language_file)) === false) {
|
||||
throw new \RuntimeException('Load file: ' . $language_file . ' - failed!');
|
||||
} else {
|
||||
I18n::add(YamlParser::decode($content), $locale);
|
||||
I18n::add(JsonParser::decode($content), $locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,8 +153,8 @@ class Plugins
|
||||
// Go through...
|
||||
if (is_array($plugins_list) && count($plugins_list) > 0) {
|
||||
foreach ($plugins_list as $plugin) {
|
||||
if (Filesystem::has($_plugin_settings = PATH['plugins'] . '/' . $plugin['dirname'] . '/settings.yaml') and
|
||||
Filesystem::has($_plugin_config = PATH['plugins'] . '/' . $plugin['dirname'] . '/' . $plugin['dirname'] . '.yaml')) {
|
||||
if (Filesystem::has($_plugin_settings = PATH['plugins'] . '/' . $plugin['dirname'] . '/settings.json') and
|
||||
Filesystem::has($_plugin_config = PATH['plugins'] . '/' . $plugin['dirname'] . '/' . $plugin['dirname'] . '.json')) {
|
||||
$_plugins_cache_id .= filemtime($_plugin_settings) . filemtime($_plugin_config);
|
||||
}
|
||||
}
|
||||
|
@@ -30,17 +30,17 @@ class Themes
|
||||
Registry::set('themes', []);
|
||||
|
||||
// Create Unique Cache ID for Theme
|
||||
$theme_cache_id = md5('theme' . filemtime(PATH['themes'] . '/' . $theme . '/' . 'settings.yaml') .
|
||||
filemtime(PATH['themes'] . '/' . $theme . '/' . $theme . '.yaml'));
|
||||
$theme_cache_id = md5('theme' . filemtime(PATH['themes'] . '/' . $theme . '/' . 'settings.json') .
|
||||
filemtime(PATH['themes'] . '/' . $theme . '/' . $theme . '.json'));
|
||||
|
||||
// Get Theme mafifest file and write to settings.themes array
|
||||
if (Cache::contains($theme_cache_id)) {
|
||||
Registry::set('themes.' . Registry::get('settings.theme'), Cache::fetch($theme_cache_id));
|
||||
} else {
|
||||
if (Filesystem::has($theme_settings = PATH['themes'] . '/' . $theme . '/' . 'settings.yaml') and
|
||||
Filesystem::has($theme_config = PATH['themes'] . '/' . $theme . '/' . $theme . '.yaml')) {
|
||||
$theme_settings = YamlParser::decode(Filesystem::read($theme_settings));
|
||||
$theme_config = YamlParser::decode(Filesystem::read($theme_config));
|
||||
if (Filesystem::has($theme_settings = PATH['themes'] . '/' . $theme . '/' . 'settings.json') and
|
||||
Filesystem::has($theme_config = PATH['themes'] . '/' . $theme . '/' . $theme . '.json')) {
|
||||
$theme_settings = JsonParser::decode(Filesystem::read($theme_settings));
|
||||
$theme_config = JsonParser::decode(Filesystem::read($theme_config));
|
||||
$_theme = array_merge($theme_settings, $theme_config);
|
||||
Registry::set('themes.' . Registry::get('settings.theme'), $_theme);
|
||||
Cache::save($theme_cache_id, $_theme);
|
||||
|
Reference in New Issue
Block a user