mirror of
https://github.com/flextype/flextype.git
synced 2025-08-17 10:30:46 +02:00
Merge branch 'dev'
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
# Flextype 0.7.3, 2018-12-13
|
||||
* Content: visibility hidden for pages - added
|
||||
* Settings merged into one settings.yaml file
|
||||
* Using Imagine library for image manipulation
|
||||
* Flextype Component - I18n updated to 1.2.0
|
||||
* Flextype Component - Filesystem updated to 1.1.3
|
||||
* Symfony YAML - updated to 4.2.1
|
||||
|
||||
# Flextype 0.7.2, 2018-11-24
|
||||
* Flextype Component - Cookie updated to 1.2.0
|
||||
* Flextype Component - Filesystem updated to 1.1.2
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# Flextype
|
||||

|
||||
[](https://discordapp.com/invite/CCKPKVG)
|
||||

|
||||

|
||||
|
||||
Flextype is Open Source, fast and flexible file-based Content Management System.
|
||||
@@ -96,4 +97,4 @@ Flextype is an open source project and community contributions are essential to
|
||||
|
||||
|
||||
## LICENSE
|
||||
See [LICENSE](https://github.com/flextype/flextype/blob/master/LICENSE.md)
|
||||
See [LICENSE](https://github.com/flextype/flextype/blob/master/LICENSE.txt)
|
||||
|
@@ -18,8 +18,9 @@
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"doctrine/cache": "1.8.0",
|
||||
"symfony/yaml": "4.1.1",
|
||||
"symfony/yaml": "4.2.1",
|
||||
"thunderer/shortcode": "0.6.5",
|
||||
"imagine/imagine": "1.2.0",
|
||||
"flextype-components/arr" : "1.2.3",
|
||||
"flextype-components/assets" : "1.0.1",
|
||||
"flextype-components/cookie" : "1.2.0",
|
||||
@@ -27,9 +28,9 @@
|
||||
"flextype-components/debug" : "1.0.0",
|
||||
"flextype-components/event" : "1.0.4",
|
||||
"flextype-components/errorhandler" : "1.0.4",
|
||||
"flextype-components/filesystem" : "1.1.2",
|
||||
"flextype-components/filesystem" : "1.1.3",
|
||||
"flextype-components/form" : "1.0.1",
|
||||
"flextype-components/i18n" : "1.1.1",
|
||||
"flextype-components/i18n" : "1.2.0",
|
||||
"flextype-components/http" : "1.1.1",
|
||||
"flextype-components/html" : "1.0.0",
|
||||
"flextype-components/number" : "1.0.0",
|
||||
|
@@ -12,7 +12,8 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\{Filesystem\Filesystem, Registry\Registry};
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Flextype\Component\Registry\Registry;
|
||||
use \Doctrine\Common\Cache as DoctrineCache;
|
||||
|
||||
class Cache
|
||||
@@ -58,14 +59,18 @@ class Cache
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __clone() { }
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private wakeup method to enforce singleton behavior.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __wakeup() { }
|
||||
private function __wakeup()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private construct method to enforce singleton behavior.
|
||||
@@ -89,7 +94,7 @@ class Cache
|
||||
Cache::$now = time();
|
||||
|
||||
// Create cache key to allow invalidate all cache on configuration changes.
|
||||
Cache::$key = (Registry::get('system.cache.prefix') ?? 'flextype') . '-' . md5(PATH['site'] . Flextype::VERSION);
|
||||
Cache::$key = (Registry::get('settings.cache.prefix') ?? 'flextype') . '-' . md5(PATH['site'] . Flextype::VERSION);
|
||||
|
||||
// Get Cache Driver
|
||||
Cache::$driver = Cache::getCacheDriver();
|
||||
@@ -106,7 +111,7 @@ class Cache
|
||||
*/
|
||||
public static function getCacheDriver()
|
||||
{
|
||||
$driver_name = Registry::get('system.cache.driver');
|
||||
$driver_name = Registry::get('settings.cache.driver');
|
||||
|
||||
if (!$driver_name || $driver_name == 'auto') {
|
||||
if (extension_loaded('apcu')) {
|
||||
@@ -137,28 +142,34 @@ class Cache
|
||||
break;
|
||||
case 'memcache':
|
||||
$memcache = new \Memcache();
|
||||
$memcache->connect(Registry::get('system.cache.memcache.server', 'localhost'),
|
||||
Registry::get('system.cache.memcache.port', 11211));
|
||||
$memcache->connect(
|
||||
Registry::get('settings.cache.memcache.server', 'localhost'),
|
||||
Registry::get('settings.cache.memcache.port', 11211)
|
||||
);
|
||||
$driver = new DoctrineCache\MemcacheCache();
|
||||
$driver->setMemcache($memcache);
|
||||
break;
|
||||
case 'memcached':
|
||||
$memcached = new \Memcached();
|
||||
$memcached->addServer(Registry::get('system.cache.memcached.server', 'localhost'),
|
||||
Registry::get('system.cache.memcache.port', 11211));
|
||||
$memcached->addServer(
|
||||
Registry::get('settings.cache.memcached.server', 'localhost'),
|
||||
Registry::get('settings.cache.memcache.port', 11211)
|
||||
);
|
||||
$driver = new DoctrineCache\MemcachedCache();
|
||||
$driver->setMemcached($memcached);
|
||||
break;
|
||||
case 'redis':
|
||||
$redis = new \Redis();
|
||||
$socket = Registry::get('system.cache.redis.socket', false);
|
||||
$password = Registry::get('system.cache.redis.password', false);
|
||||
$socket = Registry::get('settings.cache.redis.socket', false);
|
||||
$password = Registry::get('settings.cache.redis.password', false);
|
||||
|
||||
if ($socket) {
|
||||
$redis->connect($socket);
|
||||
} else {
|
||||
$redis->connect(Registry::get('system.cache.redis.server', 'localhost'),
|
||||
Registry::get('system.cache.redis.port', 6379));
|
||||
$redis->connect(
|
||||
Registry::get('settings.cache.redis.server', 'localhost'),
|
||||
Registry::get('settings.cache.redis.port', 6379)
|
||||
);
|
||||
}
|
||||
|
||||
// Authenticate with password if set
|
||||
@@ -209,7 +220,7 @@ class Cache
|
||||
*/
|
||||
public static function fetch(string $id)
|
||||
{
|
||||
if (Registry::get('system.cache.enabled')) {
|
||||
if (Registry::get('settings.cache.enabled')) {
|
||||
return Cache::$driver->fetch($id);
|
||||
} else {
|
||||
return false;
|
||||
@@ -224,7 +235,7 @@ class Cache
|
||||
*/
|
||||
public static function contains($id)
|
||||
{
|
||||
if (Registry::get('system.cache.enabled')) {
|
||||
if (Registry::get('settings.cache.enabled')) {
|
||||
return Cache::$driver->contains(($id));
|
||||
} else {
|
||||
return false;
|
||||
@@ -243,7 +254,7 @@ class Cache
|
||||
*/
|
||||
public static function save(string $id, $data, $lifetime = null)
|
||||
{
|
||||
if (Registry::get('system.cache.enabled')) {
|
||||
if (Registry::get('settings.cache.enabled')) {
|
||||
if ($lifetime === null) {
|
||||
$lifetime = Cache::getLifetime();
|
||||
}
|
||||
@@ -294,7 +305,7 @@ class Cache
|
||||
public static function getLifetime()
|
||||
{
|
||||
if (Cache::$lifetime === null) {
|
||||
Cache::$lifetime = Registry::get('system.cache.lifetime') ?: 604800;
|
||||
Cache::$lifetime = Registry::get('settings.cache.lifetime') ?: 604800;
|
||||
}
|
||||
|
||||
return Cache::$lifetime;
|
||||
@@ -306,12 +317,12 @@ class Cache
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(Cache::$instance)) {
|
||||
Cache::$instance = new self;
|
||||
}
|
||||
|
||||
return Cache::$instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,11 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\{Arr\Arr, Http\Http, Filesystem\Filesystem, Event\Event, Registry\Registry};
|
||||
use Flextype\Component\Arr\Arr;
|
||||
use Flextype\Component\Http\Http;
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Flextype\Component\Event\Event;
|
||||
use Flextype\Component\Registry\Registry;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Thunder\Shortcode\ShortcodeFacade;
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
@@ -48,14 +52,18 @@ class Content
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __clone() { }
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private wakeup method to enforce singleton behavior.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __wakeup() { }
|
||||
private function __wakeup()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private construct method to enforce singleton behavior.
|
||||
@@ -150,7 +158,7 @@ class Content
|
||||
{
|
||||
// if $url is empty then set path for defined main page
|
||||
if ($url === '') {
|
||||
$file_path = PATH['pages'] . '/' . Registry::get('system.pages.main') . '/page.html';
|
||||
$file_path = PATH['pages'] . '/' . Registry::get('settings.pages.main') . '/page.html';
|
||||
} else {
|
||||
$file_path = PATH['pages'] . '/' . $url . '/page.html';
|
||||
}
|
||||
@@ -186,7 +194,7 @@ class Content
|
||||
$page = Content::processPage($file_path);
|
||||
|
||||
// Get 404 page if page is not published
|
||||
if (isset($page['visibility']) && $page['visibility'] === 'draft') {
|
||||
if (isset($page['visibility']) && ($page['visibility'] === 'draft' || $page['visibility'] === 'hidden')) {
|
||||
if (Filesystem::fileExists($file_path = PATH['pages'] . '/404/page.html')) {
|
||||
$page = Content::processPage($file_path);
|
||||
Http::setResponseStatus(404);
|
||||
@@ -234,7 +242,7 @@ class Content
|
||||
if ($url === '') {
|
||||
|
||||
// Get pages list
|
||||
$pages_list = Filesystem::getFilesList($file_path , 'html');
|
||||
$pages_list = Filesystem::getFilesList($file_path, 'html');
|
||||
|
||||
// Create pages cached id
|
||||
foreach ($pages_list as $key => $page) {
|
||||
@@ -251,7 +259,6 @@ class Content
|
||||
|
||||
Cache::save($pages_cache_id, $pages);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Get pages list
|
||||
@@ -293,7 +300,6 @@ class Content
|
||||
|
||||
// Return pages array
|
||||
return $pages;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +324,7 @@ class Content
|
||||
* @param bool $ignore_content Ignore content parsing
|
||||
* @return array|string
|
||||
*/
|
||||
public static function processPage(string $file_path, bool $raw = false, $ignore_content = false)
|
||||
public static function processPage(string $file_path, bool $raw = false, bool $ignore_content = false)
|
||||
{
|
||||
// Get page from file
|
||||
$page = trim(Filesystem::getFileContent($file_path));
|
||||
@@ -340,7 +346,7 @@ class Content
|
||||
$_page = Yaml::parse(Content::processShortcodes($page_frontmatter));
|
||||
|
||||
// Create page url item
|
||||
$url = str_replace(PATH['pages'] , Http::getBaseUrl(), $file_path);
|
||||
$url = str_replace(PATH['pages'], Http::getBaseUrl(), $file_path);
|
||||
$url = str_replace('page.html', '', $url);
|
||||
$url = str_replace('.html', '', $url);
|
||||
$url = str_replace('\\', '/', $url);
|
||||
@@ -348,7 +354,6 @@ class Content
|
||||
$url = str_replace('//', '/', $url);
|
||||
$url = str_replace('http:/', 'http://', $url);
|
||||
$url = str_replace('https:/', 'https://', $url);
|
||||
$url = str_replace('/'.Registry::get('system.pages.main'), '', $url);
|
||||
$url = rtrim($url, '/');
|
||||
$_page['url'] = $url;
|
||||
|
||||
@@ -358,8 +363,11 @@ class Content
|
||||
$url = rtrim($url, '/');
|
||||
$_page['slug'] = str_replace(Http::getBaseUrl(), '', $url);
|
||||
|
||||
// Create page template item
|
||||
$_page['template'] = $_page['template'] ?? 'default';
|
||||
|
||||
// Create page date item
|
||||
$_page['date'] = $_page['date'] ?? date(Registry::get('system.date_format'), filemtime($file_path));
|
||||
$_page['date'] = $_page['date'] ?? date(Registry::get('settings.date_format'), filemtime($file_path));
|
||||
|
||||
// Create page content item with $page_content
|
||||
if ($ignore_content) {
|
||||
@@ -436,7 +444,7 @@ class Content
|
||||
*/
|
||||
private static function displayCurrentPage() : void
|
||||
{
|
||||
Http::setRequestHeaders('Content-Type: text/html; charset='.Registry::get('system.charset'));
|
||||
Http::setRequestHeaders('Content-Type: text/html; charset='.Registry::get('settings.charset'));
|
||||
Themes::view(empty(Content::$page['template']) ? 'templates/default' : 'templates/' . Content::$page['template'])
|
||||
->assign('page', Content::$page, true)
|
||||
->display();
|
||||
@@ -448,12 +456,12 @@ class Content
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(Content::$instance)) {
|
||||
Content::$instance = new self;
|
||||
}
|
||||
|
||||
return Content::$instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,11 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\{Http\Http, Session\Session, ErrorHandler\ErrorHandler, Registry\Registry, Filesystem\Filesystem};
|
||||
use Flextype\Component\Http\Http;
|
||||
use Flextype\Component\Session\Session;
|
||||
use Flextype\Component\ErrorHandler\ErrorHandler;
|
||||
use Flextype\Component\Registry\Registry;
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Flextype
|
||||
@@ -22,7 +26,7 @@ class Flextype
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '0.7.2';
|
||||
const VERSION = '0.7.3';
|
||||
|
||||
/**
|
||||
* An instance of the Flextype class
|
||||
@@ -37,14 +41,18 @@ class Flextype
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __clone() { }
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private wakeup method to enforce singleton behavior.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __wakeup() { }
|
||||
private function __wakeup()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private construct method to enforce singleton behavior.
|
||||
@@ -66,19 +74,18 @@ class Flextype
|
||||
// Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
Flextype::setSiteConfig();
|
||||
Flextype::setConfig();
|
||||
|
||||
// Set internal encoding
|
||||
function_exists('mb_language') and mb_language('uni');
|
||||
function_exists('mb_regex_encoding') and mb_regex_encoding(Registry::get('system.charset'));
|
||||
function_exists('mb_internal_encoding') and mb_internal_encoding(Registry::get('system.charset'));
|
||||
function_exists('mb_regex_encoding') and mb_regex_encoding(Registry::get('settings.charset'));
|
||||
function_exists('mb_internal_encoding') and mb_internal_encoding(Registry::get('settings.charset'));
|
||||
|
||||
// Set error handler
|
||||
Flextype::setErrorHandler();
|
||||
|
||||
// Set default timezone
|
||||
date_default_timezone_set(Registry::get('system.timezone'));
|
||||
|
||||
date_default_timezone_set(Registry::get('settings.timezone'));
|
||||
|
||||
// Start the session
|
||||
Session::start();
|
||||
@@ -107,7 +114,7 @@ class Flextype
|
||||
private static function setErrorHandler() : void
|
||||
{
|
||||
// Display Errors
|
||||
if (Registry::get('system.errors.display')) {
|
||||
if (Registry::get('settings.errors.display')) {
|
||||
define('DEVELOPMENT', true);
|
||||
error_reporting(-1);
|
||||
} else {
|
||||
@@ -125,30 +132,20 @@ class Flextype
|
||||
}
|
||||
|
||||
/**
|
||||
* Set site config
|
||||
* Set config
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private static function setSiteConfig() : void
|
||||
private static function setConfig() : void
|
||||
{
|
||||
// Set empty site item
|
||||
Registry::set('site', []);
|
||||
Registry::set('settings', []);
|
||||
|
||||
// Set site items if site config exists
|
||||
if (Filesystem::fileExists($site_config = PATH['config'] . '/' . 'site.yaml')) {
|
||||
Registry::set('site', Yaml::parseFile($site_config));
|
||||
// Set settings items if settings config exists
|
||||
if (Filesystem::fileExists($settings_config = PATH['config'] . '/' . 'settings.yaml')) {
|
||||
Registry::set('settings', Yaml::parseFile($settings_config));
|
||||
} else {
|
||||
throw new \RuntimeException("Flextype site config file does not exist.");
|
||||
}
|
||||
|
||||
// Set empty system item
|
||||
Registry::set('system', []);
|
||||
|
||||
// Set site items if system config exists
|
||||
if (Filesystem::fileExists($system_config = PATH['config'] . '/' . 'system.yaml')) {
|
||||
Registry::set('system', Yaml::parseFile($system_config));
|
||||
} else {
|
||||
throw new \RuntimeException("Flextype system config file does not exist.");
|
||||
throw new \RuntimeException("Flextype settings config file does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,12 +155,12 @@ class Flextype
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(Flextype::$instance)) {
|
||||
Flextype::$instance = new self;
|
||||
}
|
||||
|
||||
return Flextype::$instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,10 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\{Filesystem\Filesystem, Event\Event, I18n\I18n, Registry\Registry};
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Flextype\Component\Event\Event;
|
||||
use Flextype\Component\I18n\I18n;
|
||||
use Flextype\Component\Registry\Registry;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Plugins
|
||||
@@ -50,6 +53,7 @@ class Plugins
|
||||
'id' => 'Bahasa Indonesia',
|
||||
'ja' => '日本語',
|
||||
'lt' => 'Lietuvių',
|
||||
'hr' => 'Hrvatski',
|
||||
'nl' => 'Nederlands',
|
||||
'no' => 'Norsk',
|
||||
'pl' => 'Polski',
|
||||
@@ -70,14 +74,18 @@ class Plugins
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __clone() { }
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private wakeup method to enforce singleton behavior.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __wakeup() { }
|
||||
private function __wakeup()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private construct method to enforce singleton behavior.
|
||||
@@ -131,7 +139,6 @@ class Plugins
|
||||
|
||||
// Go through...
|
||||
foreach ($plugins_list as $plugin) {
|
||||
|
||||
if (Filesystem::fileExists($_plugin_settings = PATH['plugins'] . '/' . $plugin . '/settings.yaml')) {
|
||||
$plugin_settings = Yaml::parseFile($_plugin_settings);
|
||||
}
|
||||
@@ -177,12 +184,12 @@ class Plugins
|
||||
* Get locales.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
* @return array
|
||||
*/
|
||||
public static function getLocales()
|
||||
{
|
||||
public static function getLocales() : array
|
||||
{
|
||||
return Plugins::$locales;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Plugins instance.
|
||||
@@ -190,12 +197,12 @@ class Plugins
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(Plugins::$instance)) {
|
||||
Plugins::$instance = new self;
|
||||
}
|
||||
|
||||
return Plugins::$instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,9 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\{Filesystem\Filesystem, View\View, Registry\Registry};
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Flextype\Component\View\View;
|
||||
use Flextype\Component\Registry\Registry;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Themes
|
||||
@@ -29,14 +31,18 @@ class Themes
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __clone() { }
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private wakeup method to enforce singleton behavior.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function __wakeup() { }
|
||||
private function __wakeup()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private construct method to enforce singleton behavior.
|
||||
@@ -63,7 +69,7 @@ class Themes
|
||||
$theme_cache_id = '';
|
||||
|
||||
// Get current theme
|
||||
$theme = Registry::get('system.theme');
|
||||
$theme = Registry::get('settings.theme');
|
||||
|
||||
// Set empty themes items
|
||||
Registry::set('themes', []);
|
||||
@@ -72,16 +78,16 @@ class Themes
|
||||
$theme_cache_id = md5('theme' . filemtime(PATH['themes'] .'/'. $theme . '/' . 'settings.yaml') .
|
||||
filemtime(PATH['themes'] .'/'. $theme . '/' . $theme . '.yaml'));
|
||||
|
||||
// Get Theme mafifest file and write to site.themes array
|
||||
// Get Theme mafifest file and write to settings.themes array
|
||||
if (Cache::contains($theme_cache_id)) {
|
||||
Registry::set('themes.'.Registry::get('system.theme'), Cache::fetch($theme_cache_id));
|
||||
Registry::set('themes.'.Registry::get('settings.theme'), Cache::fetch($theme_cache_id));
|
||||
} else {
|
||||
if (Filesystem::fileExists($theme_settings = PATH['themes'] . '/' . $theme . '/' . 'settings.yaml') and
|
||||
Filesystem::fileExists($theme_config = PATH['themes'] . '/' . $theme . '/' . $theme . '.yaml')) {
|
||||
$theme_settings = Yaml::parseFile($theme_settings);
|
||||
$theme_config = Yaml::parseFile($theme_config);
|
||||
$_theme = array_merge($theme_settings, $theme_config);
|
||||
Registry::set('themes.'.Registry::get('system.theme'), $_theme);
|
||||
Registry::set('themes.'.Registry::get('settings.theme'), $_theme);
|
||||
Cache::save($theme_cache_id, $_theme);
|
||||
}
|
||||
}
|
||||
@@ -99,8 +105,8 @@ class Themes
|
||||
{
|
||||
// Set view file
|
||||
// From current theme folder or from plugin folder
|
||||
if (Filesystem::fileExists(PATH['themes'] . '/' . Registry::get('system.theme') . '/views/' . $template . View::$view_ext)) {
|
||||
$template = PATH['themes'] . '/' . Registry::get('system.theme') . '/views/' . $template;
|
||||
if (Filesystem::fileExists(PATH['themes'] . '/' . Registry::get('settings.theme') . '/views/' . $template . View::$view_ext)) {
|
||||
$template = PATH['themes'] . '/' . Registry::get('settings.theme') . '/views/' . $template;
|
||||
} else {
|
||||
$template = PATH['plugins'] . '/' . $template;
|
||||
}
|
||||
@@ -109,18 +115,85 @@ class Themes
|
||||
return new View($template, $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get templates for current theme
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getTemplates() : array
|
||||
{
|
||||
$templates = [];
|
||||
|
||||
// Get templates files
|
||||
$_templates = Filesystem::getFilesList(PATH['themes'] . '/' . Registry::get('settings.theme') . '/views/templates/', 'php');
|
||||
|
||||
// If there is any template file then go...
|
||||
if (count($_templates) > 0) {
|
||||
foreach ($_templates as $template) {
|
||||
if (!is_bool(Themes::_strrevpos($template, '/templates/'))) {
|
||||
$template_name = str_replace('.php', '', substr($template, Themes::_strrevpos($template, '/templates/')+strlen('/templates/')));
|
||||
$templates[$template_name] = $template_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return templates
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get templates blueprints for current theme
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getTemplatesBlueprints() : array
|
||||
{
|
||||
$blueprints = [];
|
||||
|
||||
// Get blueprints files
|
||||
$_blueprints = Filesystem::getFilesList(PATH['themes'] . '/' . Registry::get('settings.theme') . '/blueprints/', 'yaml');
|
||||
|
||||
// If there is any template file then go...
|
||||
if (count($_blueprints) > 0) {
|
||||
foreach ($_blueprints as $blueprint) {
|
||||
if (!is_bool(Themes::_strrevpos($blueprint, '/blueprints/'))) {
|
||||
$blueprint_name = str_replace('.yaml', '', substr($blueprint, Themes::_strrevpos($blueprint, '/blueprints/')+strlen('/blueprints/')));
|
||||
$blueprints[$blueprint_name] = $blueprint_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return blueprints
|
||||
return $blueprints;
|
||||
}
|
||||
|
||||
/**
|
||||
* _strrevpos
|
||||
*/
|
||||
private static function _strrevpos($instr, $needle)
|
||||
{
|
||||
$rev_pos = strpos(strrev($instr), strrev($needle));
|
||||
if ($rev_pos === false) {
|
||||
return false;
|
||||
} else {
|
||||
return strlen($instr) - $rev_pos - strlen($needle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Themes instance.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(Themes::$instance)) {
|
||||
Themes::$instance = new self;
|
||||
}
|
||||
|
||||
return Themes::$instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
site/config/settings.yaml
Normal file
21
site/config/settings.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
title: Flextype
|
||||
description: 'Modern Open Source Flat-File Content Management System'
|
||||
keywords: 'flextype, php, cms, flat-file cms, flat cms, flatfile cms, html'
|
||||
robots: 'index, follow'
|
||||
author:
|
||||
name: ''
|
||||
email: ''
|
||||
timezone: UTC
|
||||
date_format: 'F d Y H:i:s'
|
||||
charset: UTF-8
|
||||
theme: simple
|
||||
locale: en
|
||||
pages:
|
||||
main: home
|
||||
errors:
|
||||
display: true
|
||||
cache:
|
||||
enabled: true
|
||||
prefix: flextype
|
||||
driver: auto
|
||||
lifetime: 604800
|
@@ -1,7 +0,0 @@
|
||||
title: 'Flextype'
|
||||
description: 'Modern Open Source Flat-File Content Management System'
|
||||
keywords: 'flextype, php, cms, flat-file cms, flat cms, flatfile cms, html'
|
||||
robots: 'index, follow'
|
||||
author:
|
||||
name: ''
|
||||
email: ''
|
@@ -1,19 +0,0 @@
|
||||
timezone: UTC
|
||||
date_format: 'F d Y H:i:s.'
|
||||
charset: UTF-8
|
||||
|
||||
theme: simple
|
||||
|
||||
locale: 'en'
|
||||
|
||||
pages:
|
||||
main: home
|
||||
|
||||
errors:
|
||||
display: false
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
prefix: flextype
|
||||
driver: auto
|
||||
lifetime: 604800
|
0
site/pages/404/page.html
Normal file → Executable file
0
site/pages/404/page.html
Normal file → Executable file
7
site/pages/home/page.html
Normal file → Executable file
7
site/pages/home/page.html
Normal file → Executable file
@@ -1,15 +1,12 @@
|
||||
---
|
||||
title: Welcome
|
||||
description: 'Flextype is a simple and light-weighted Content Management System'
|
||||
date: 'June 27 2018 14:54:22.'
|
||||
visibility: visible
|
||||
template: default
|
||||
---
|
||||
<h2>Flextype is succesfully installed!</h2>
|
||||
<p>You can start editing the content and customising your site.</p>
|
||||
|
||||
<h3>Edit this Page</h3>
|
||||
<p>To edit this page, simply go to the folder you installed Flextype, and then browse to the `/site/pages/home/` folder and open the `page.md` file in your editor.</p>
|
||||
<p>To edit this page, simply go to the folder you installed Flextype, and then browse to the `/site/pages/home/` folder and open the `page.html` file in your editor.</p>
|
||||
|
||||
<h3>Create a New page</h3>
|
||||
<p>Creating a new page is very simple in Flextype.</p>
|
||||
@@ -24,6 +21,6 @@ title: My New Page
|
||||
<p>This is the body of <b>My New Page</b></p>
|
||||
</code></pre><code>
|
||||
</code>
|
||||
2. Save this file in the <code>/site/pages/my-new-page/</code> folder as <code>page.md</code> and its will be available by this url: http://your_site_url/my-new-page
|
||||
2. Save this file in the <code>/site/pages/my-new-page/</code> folder as <code>page.html</code> and its will be available by this url: http://your_site_url/my-new-page
|
||||
<p></p>
|
||||
<p>That is it!</p>
|
||||
|
19
site/themes/simple/blueprints/default.yaml
Normal file
19
site/themes/simple/blueprints/default.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
fields:
|
||||
title:
|
||||
title: "admin_pages_title"
|
||||
type: text
|
||||
content:
|
||||
title: "admin_pages_content"
|
||||
type: html
|
||||
template:
|
||||
title: "admin_pages_template"
|
||||
type: template_select
|
||||
size: col-4
|
||||
visibility:
|
||||
title: "admin_pages_visibility"
|
||||
type: visibility_select
|
||||
size: col-4
|
||||
date:
|
||||
title: "admin_pages_date"
|
||||
type: text
|
||||
size: col-4
|
@@ -3,23 +3,23 @@
|
||||
use Flextype\Component\{Event\Event, Http\Http, Registry\Registry, Assets\Assets, Text\Text, Html\Html};
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="<?php echo Registry::get('system.locale'); ?>">
|
||||
<html lang="<?php echo Registry::get('settings.locale'); ?>">
|
||||
<head>
|
||||
<meta charset="<?php echo Text::lowercase(Registry::get('system.charset')); ?>">
|
||||
<meta charset="<?php echo Text::lowercase(Registry::get('settings.charset')); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="<?php echo (isset($page['description']) ? Html::toText($page['description']) : Html::toText(Registry::get('site.description'))); ?>">
|
||||
<meta name="keywords" content="<?php echo (isset($page['keywords']) ? $page['keywords'] : Registry::get('site.keywords')); ?>">
|
||||
<meta name="robots" content="<?php echo (isset($page['robots']) ? $page['robots'] : Registry::get('site.robots')); ?>">
|
||||
<meta name="description" content="<?php echo (isset($page['description']) ? Html::toText($page['description']) : Html::toText(Registry::get('settings.description'))); ?>">
|
||||
<meta name="keywords" content="<?php echo (isset($page['keywords']) ? $page['keywords'] : Registry::get('settings.keywords')); ?>">
|
||||
<meta name="robots" content="<?php echo (isset($page['robots']) ? $page['robots'] : Registry::get('settings.robots')); ?>">
|
||||
<meta name="generator" content="Powered by Flextype <?php echo Flextype::VERSION; ?>" />
|
||||
|
||||
<?php Event::dispatch('onThemeMeta'); ?>
|
||||
|
||||
<title><?php echo Html::toText($page['title']); ?> | <?php echo Html::toText(Registry::get('site.title')); ?></title>
|
||||
<title><?php echo Html::toText($page['title']); ?> | <?php echo Html::toText(Registry::get('settings.title')); ?></title>
|
||||
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<?php Assets::add('css', Http::getBaseUrl() . '/site/themes/' . Registry::get('system.theme') . '/assets/dist/css/bootstrap.min.css', 'site', 1); ?>
|
||||
<?php Assets::add('css', Http::getBaseUrl() . '/site/themes/' . Registry::get('system.theme') . '/assets/dist/css/simple.min.css', 'site', 2); ?>
|
||||
<?php Assets::add('css', Http::getBaseUrl() . '/site/themes/' . Registry::get('settings.theme') . '/assets/dist/css/bootstrap.min.css', 'site', 1); ?>
|
||||
<?php Assets::add('css', Http::getBaseUrl() . '/site/themes/' . Registry::get('settings.theme') . '/assets/dist/css/simple.min.css', 'site', 2); ?>
|
||||
<?php foreach (Assets::get('css', 'site') as $assets_by_priorities) { foreach ($assets_by_priorities as $assets) { ?>
|
||||
<link href="<?php echo $assets['asset']; ?>" rel="stylesheet">
|
||||
<?php } } ?>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
?>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom box-shadow">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="<?php echo Http::getBaseUrl(); ?>"><?php echo Registry::get('site.title'); ?></a>
|
||||
<a class="navbar-brand" href="<?php echo Http::getBaseUrl(); ?>"><?php echo Registry::get('settings.title'); ?></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
namespace Flextype;
|
||||
use Flextype\Component\{Event\Event, Http\Http, Registry\Registry, Assets\Assets};
|
||||
?>
|
||||
<?php Assets::add('js', Http::getBaseUrl() . '/site/themes/' . Registry::get('system.theme') . '/assets/dist/js/simple.min.js', 'site', 1); ?>
|
||||
<?php Assets::add('js', Http::getBaseUrl() . '/site/themes/' . Registry::get('settings.theme') . '/assets/dist/js/simple.min.js', 'site', 1); ?>
|
||||
<?php foreach (Assets::get('js', 'site') as $assets_by_priorities) { foreach ($assets_by_priorities as $assets) { ?>
|
||||
<script src="<?php echo $assets['asset']; ?>"></script>
|
||||
<?php } } ?>
|
||||
|
Reference in New Issue
Block a user