1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-24 05:43:10 +02:00

Merge branch 'dev'

This commit is contained in:
Awilum
2019-06-18 18:01:08 +03:00
21 changed files with 363 additions and 139 deletions

View File

@@ -1,3 +1,39 @@
## [0.9.1] - 2019-06-XX
### Added
- Flextype Admin Panel: new setting `route` added to customize admin base route. #154
- Flextype Core: GlobalVarsTwigExtension - new global constant `PATH_FIELDSETS` added. #154
- Flextype Core: Entries API - public property `$entry` added. #154
- Flextype Core: Entries API - public property `$entries` added. #154
- Flextype Core: Entries API - new event `onEntryAfterInitialized` added. #154
- Flextype Core: Entries API - new event `onEntriesAfterInitialized` added. #154
- Flextype Core: Shortcodes - `EntriesShortcode` added. #154
- Flextype Core: Shortcodes - `BaseUrlShortcode` added. #154
- Flextype Core: Snippets - SnippetsTwigExtension: `snippets_exec()` added. #154
- Flextype Core: Snippets - `[snppets_fetch]` shortcode added. #154
- Flextype Core: Snippets - `_exec_snippet()` method added. #154
- Flextype Core: Snippets - `exec()` method added. #154
- Flextype Core: Snippets - added ability to access $flextype and $app inside snippets. #154
- Flextype Core: GlobalVarsTwigExtension `FLEXTYPE_VERSION` added. #154
- Flextype Site Plugin: public property `$entry` added. #154
- Flextype Site Plugin: new event `onSiteEntryAfterInitialized` added. #154
### Fixed
- Flextype Core: Entries API - `fetchALL()` issue with fetching entries recursively fixed. #154 #161
### Changed
- Flextype Site: code refactoring. #154
- Flextype Admin Panel: code refactoring. #154
- Flextype Core: Snippets - from now we will set prefix `bind_` for all variables. #154
### Removed
- Flextype Core: Entries API - remove unused Shortcodes code from method `fetch()` #162
- Flextype Core: Shortcodes - `SiteUrlShortcode` removed. #154
- Flextype Core: Snippets - `SnippetsTwigExtension`: snippet removed. #154
- Flextype Core: Snippets - `[snippets]` shortcode removed. #154
- Flextype Core: Snippets - `_display_snippet()` method removed. #154
- Flextype Core: Snippets - `- display()` method removed. #154
- Flextype Core: GlobalVarsTwigExtension `flextype_version` removed. #154
## [0.9.0] - 2019-06-14
### Added
- Flextype Core: Slim Framework Integration!
@@ -48,7 +84,6 @@
- Flextype Core: Flextype Error Handler Component removed.
- Flextype Core: Flextype Event Component removed.
## [0.8.3] - 2019-01-16
### Added
- Admin Panel: New Gorgeous Light Theme for Admin panel!

View File

@@ -21,7 +21,7 @@ use Flextype\Component\Filesystem\Filesystem;
*
* @var string
*/
define('FLEXTYPE_VERSION', '0.9.0');
define('FLEXTYPE_VERSION', '0.9.1');
// Start the session
Session::start();
@@ -29,10 +29,10 @@ Session::start();
// Configure application
$config = [
'settings' => [
'debug' => false,
'debug' => true,
'whoops.editor' => 'atom',
'whoops.page_title' => 'Error!',
'displayErrorDetails' => false,
'displayErrorDetails' => true,
'addContentLengthHeader' => true,
'addContentLengthHeader' => false,
'routerCacheFile' => false,

View File

@@ -17,8 +17,26 @@ use Flextype\Component\Filesystem\Filesystem;
class Entries
{
/**
* Current entry data array
*
* @var array
* @access public
*/
public $entry = [];
/**
* Current entries data array
*
* @var array
* @access public
*/
public $entries = [];
/**
* Flextype Dependency Container
*
* @access private
*/
private $flextype;
@@ -44,17 +62,13 @@ class Entries
$entry_file = $this->_file_location($id);
if (Filesystem::has($entry_file)) {
// Create unique entry cache_id
$cache_id = md5('entry' . $entry_file . ((Filesystem::getTimestamp($entry_file) === false) ? '' : Filesystem::getTimestamp($entry_file)));
// Try to get the entry from cache
if ($this->flextype['cache']->contains($cache_id)) {
if ($entry_decoded = $this->flextype['cache']->fetch($cache_id)) {
// Apply Shortcodes for each entry fields
foreach ($entry_decoded as $key => $_entry_decoded) {
$entry_decoded[$key] = $_entry_decoded;//$this->flextype['shortcodes']->process($_entry_decoded);
}
return $entry_decoded;
} else {
return false;
@@ -67,15 +81,17 @@ class Entries
$entry_decoded['date'] = $entry_decoded['date'] ?? date($this->flextype['registry']->get('settings.date_format'), Filesystem::getTimestamp($entry_file));
$entry_decoded['slug'] = $entry_decoded['slug'] ?? ltrim(rtrim($id, '/'), '/');
// Save to cache
// Save decoded entry content into the cache
$this->flextype['cache']->save($cache_id, $entry_decoded);
// Apply Shortcodes for each entry fields
foreach ($entry_decoded as $key => $_entry_decoded) {
$entry_decoded[$key] = $_entry_decoded;//$this->flextype['shortcodes']->process($_entry_decoded);
}
// Set entry
$this->entry = $entry_decoded;
return $entry_decoded;
// Run event onEntryAfterInitialized
$this->flextype['emitter']->emit('onEntryAfterInitialized');
// Return entry
return $this->entry;
} else {
return false;
}
@@ -97,23 +113,24 @@ class Entries
* @param string $order_type Order type: DESC or ASC
* @param int $offset Offset
* @param int $length Length
* @param bool $recursive Whether to list recursively.
* @return array The entries
*/
public function fetchAll(string $id, string $order_by = 'date', string $order_type = 'DESC', int $offset = null, int $length = null) : array
public function fetchAll(string $id, string $order_by = 'date', string $order_type = 'DESC', int $offset = null, int $length = null, bool $recursive = false) : array
{
// Entries array where founded entries will stored
// Set empty entries array where founded entries will stored
$entries = [];
// Сache id
// Set empty cache id for the entries
$cache_id = '';
// Entries path
// Get entries path
$entries_path = $this->_dir_location($id);
// Get entries list
$entries_list = Filesystem::listContents($entries_path);
$entries_list = Filesystem::listContents($entries_path, $recursive);
// Create entries cached id
// Create unique entries cache_id
foreach ($entries_list as $current_entry) {
if (strpos($current_entry['path'], $id . '/entry.json') !== false) {
// ignore ...
@@ -124,6 +141,8 @@ class Entries
}
}
// If the entries exist at a specific cache_id,
// then we take them from the cache otherwise we look for them.
if ($this->flextype['cache']->contains($cache_id)) {
$entries = $this->flextype['cache']->fetch($cache_id);
} else {
@@ -133,25 +152,45 @@ class Entries
if (strpos($current_entry['path'], $id . '/entry.json') !== false) {
// ignore ...
} else {
// We are checking...
// Whether the requested entry is a director and whether the file entry.json is in this directory.
if ($current_entry['type'] == 'dir' && Filesystem::has($current_entry['path'] . '/entry.json')) {
$entries[$current_entry['dirname']] = $this->fetch($id . '/' . $current_entry['dirname']);
// Get entry uid
// 1. Remove entries path
// 2. Remove left and right slashes
$uid = ltrim(rtrim(str_replace(PATH['entries'], '', $current_entry['path']), '/'), '/');
// For each founded entry we should create $entries array.
$entries[$uid] = $this->fetch($uid);
}
}
}
// Save entries into the cache
$this->flextype['cache']->save($cache_id, $entries);
}
// Sort and Slice entries if $raw === false
// If count of the entries more then 0 then sort and slice them.
if (count($entries) > 0) {
// Sort entries
$entries = Arr::sort($entries, $order_by, $order_type);
// Slice entries
if ($offset !== null && $length !== null) {
$entries = array_slice($entries, $offset, $length);
}
}
return $entries;
// Set entries
$this->entries = $entries;
// Run event onEntriesAfterInitialized
$this->flextype['emitter']->emit('onEntriesAfterInitialized');
// Return entries
return $this->entries;
}
/**
@@ -171,7 +210,7 @@ class Entries
* Update entry
*
* @access public
* @param string $id Entry
* @param string $id Entry
* @param array $data Data
* @return bool
*/
@@ -190,7 +229,7 @@ class Entries
* Create entry
*
* @access public
* @param string $id Entry id
* @param string $id Entry id
* @param array $data Data
* @return bool
*/
@@ -203,6 +242,8 @@ class Entries
// Try to create directory for new entry
if (Filesystem::createDir($entry_dir)) {
// Entry file path
$entry_file = $entry_dir . '/entry.json';
// Check if new entry file exists

View File

@@ -21,27 +21,33 @@ class Snippets
*/
private $flextype;
/**
* Flextype Application
*/
private $app;
/**
* Constructor
*
* @access public
*/
public function __construct($flextype)
public function __construct($flextype, $app)
{
$this->flextype = $flextype;
$this->app = $app;
}
/**
* Get snippet
* Exec snippet
*
* @access public
* @param string $id Snippet id
* @return string|bool Returns the contents of the output buffer and end output buffering.
* If output buffering isn't active then FALSE is returned.
*/
public function display(string $id)
public function exec(string $id)
{
return $this->_display_snippet(['fetch' => $id]);
return $this->_exec_snippet(['id' => $id]);
}
/**
@@ -93,7 +99,7 @@ class Snippets
}
/**
* Rename snippet.
* Rename snippet
*
* @access public
* @param string $id Snippet id
@@ -182,23 +188,23 @@ class Snippets
}
/**
* Helper private method _display_snippet
* Helper private method _exec_snippet
*
* @access private
* @param array $vars Vars
* @return string|bool Returns the contents of the output buffer and end output buffering.
* If output buffering isn't active then FALSE is returned.
*/
private function _display_snippet(array $vars)
private function _exec_snippet(array $vars)
{
// Extracst attributes
extract($vars);
// Extracts vars and set prefix bind_ for all of them
extract($vars, EXTR_PREFIX_ALL, 'bind');
// Get snippet name
$name = (isset($fetch)) ? (string) $fetch : '';
// Get snippet id
$snippet_id = (string) $bind_id ?? '';
// Define snippet path
$snippet_file = $this->_file_location($name);
// Define snippet file path
$snippet_file = $this->_file_location($snippet_id);
// Process snippet
if (Filesystem::has($snippet_file)) {
@@ -206,13 +212,19 @@ class Snippets
// Turn on output buffering
ob_start();
// Include view file
// Re-init $flextype for snippets
$flextype = $this->flextype;
// Re-init $app for snippets
$app = $this->app;
// Include snippet file
include $snippet_file;
// Output...
return ob_get_clean();
} else {
throw new \RuntimeException("Snippet {$name} does not exist.");
throw new \RuntimeException("Snippet {$snippet_id} does not exist.");
}
}

View File

@@ -140,8 +140,8 @@ $flextype['fieldsets'] = function ($container) use ($flextype) {
/**
* Add snippets service to Flextype container
*/
$flextype['snippets'] = function ($container) use ($flextype) {
return new Snippets($flextype);
$flextype['snippets'] = function ($container) use ($flextype, $app) {
return new Snippets($flextype, $app);
};
/**

View File

@@ -1,5 +1,15 @@
<?php
/**
* @package Flextype
*
* @author Romanenko Sergey <hello@romanenko.digital>
* @link http://romanenko.digital
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use Psr\Http\Message\ResponseInterface as Response;

View File

@@ -15,7 +15,7 @@ namespace Flextype;
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Shortcode: [site_url]
$flextype['shortcodes']->addHandler('site_url', function () {
// Shortcode: [base_url]
$flextype['shortcodes']->addHandler('base_url', function () {
return \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getBaseUrl();
});

View File

@@ -0,0 +1,22 @@
<?php
/**
* @package Flextype
*
* @author Sergey Romanenko <hello@romanenko.digital>
* @link http://romanenko.digital
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use Flextype\Component\Arr\Arr;
// Shortcode: [entries_fetch id="entry-id" field="field-name" default="default-value"]
$flextype['shortcodes']->addHandler('entries_fetch', function (ShortcodeInterface $s) use ($flextype) {
return Arr::get($flextype['entries']->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default'));
});

View File

@@ -15,7 +15,7 @@ namespace Flextype;
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Shortcode: [snippets fetch=snippet-name]
$flextype['shortcodes']->addHandler('snippets', function (ShortcodeInterface $s) use ($flextype) {
return $flextype['snippets']->display($s->getParameter('fetch'));
// Shortcode: [snippets_fetch id="snippet-name"]
$flextype['shortcodes']->addHandler('snippets_fetch', function (ShortcodeInterface $s) use ($flextype) {
return $flextype['snippets']->exec($s->getParameter('id'));
});

View File

@@ -45,8 +45,8 @@ class EntriesTwigExtension extends \Twig_Extension
return $this->flextype['entries']->fetch($entry);
}
public function fetchAll(string $entry, string $order_by = 'date', string $order_type = 'DESC', int $offset = null, int $length = null) : array
public function fetchAll(string $entry, string $order_by = 'date', string $order_type = 'DESC', int $offset = null, int $length = null, bool $recursive = false) : array
{
return $this->flextype['entries']->fetchAll($entry, $order_by, $order_type, $offset, $length);
return $this->flextype['entries']->fetchAll($entry, $order_by, $order_type, $offset, $length, $recursive);
}
}

View File

@@ -12,8 +12,6 @@
namespace Flextype;
use Flextype\Component\Session\Session;
class GlobalVarsTwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{
/**
@@ -37,10 +35,11 @@ class GlobalVarsTwigExtension extends \Twig_Extension implements \Twig_Extension
'PATH_THEMES' => PATH['themes'],
'PATH_ENTRIES' => PATH['entries'],
'PATH_SNIPPETS' => PATH['snippets'],
'PATH_FIELDSETS' => PATH['fieldsets'],
'PATH_CONFIG_DEFAULT' => PATH['config']['default'],
'PATH_CONFIG_SITE' => PATH['config']['site'],
'PATH_CACHE' => PATH['cache'],
'flextype_version' => FLEXTYPE_VERSION,
'FLEXTYPE_VERSION' => FLEXTYPE_VERSION,
'registry' => $this->flextype['registry']->dump()
];
}

View File

@@ -35,12 +35,12 @@ class SnippetsTwigExtension extends \Twig_Extension
public function getFunctions()
{
return [
new \Twig_SimpleFunction('snippet', [$this, 'snippet'])
new \Twig_SimpleFunction('snippets_exec', [$this, 'exec'])
];
}
public function snippet(string $id)
public function exec(string $id)
{
return $this->flextype['snippets']->display($id);
return $this->flextype['snippets']->exec($id);
}
}

View File

@@ -1,7 +1,5 @@
<?php
namespace Flextype;
/**
*
* Flextype Admin Plugin
@@ -13,73 +11,35 @@ namespace Flextype;
* file that was distributed with this source code.
*/
use Flextype\Component\Arr\Arr;
use Flextype\Component\I18n\I18n;
use function Flextype\Component\I18n\__;
namespace Flextype;
// Get URI
$uri = explode('/', \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getPath());
/**
* Set base admin route
*/
$admin_route = $flextype->registry->get('plugins.admin.route');
// Set base admin route
$admin_route = 'admin';
/**
* Ensure vendor libraries exist
*/
!is_file($admin_autoload = __DIR__ . '/vendor/autoload.php') and exit("Please run: <i>composer install</i>");
// Ensure vendor libraries exist
!is_file($autoload = __DIR__ . '/vendor/autoload.php') and exit("Please run: <i>composer install</i>");
/**
* Register The Auto Loader
*
* Composer provides a convenient, automatically generated class loader for
* our application. We just need to utilize it! We'll simply require it
* into the script here so that we don't have to worry about manual
* loading any of our classes later on. It feels nice to relax.
* Register The Auto Loader
*/
$admin_loader = require_once $admin_autoload;
// Register The Auto Loader
$loader = require_once $autoload;
// Include routes
/**
* Include web routes
*/
include_once 'routes/web.php';
// Set Default Admin locale
I18n::$locale = $flextype->registry->get('settings.locale');
// Add Admin Navigation
$flextype->registry->set('admin_navigation.content.entries', ['title' => '<i class="far fa-newspaper"></i>' . __('admin_entries'), 'link' => $flextype->router->pathFor('admin.entries.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.fieldsets', ['title' => '<i class="fas fa-list"></i>' . __('admin_fieldsets'), 'link' => $flextype->router->pathFor('admin.fieldsets.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.templates', ['title' => '<i class="fas fa-layer-group"></i>' . __('admin_templates'), 'link' => $flextype->router->pathFor('admin.templates.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.snippets', ['title' => '<i class="far fa-file-code"></i>' . __('admin_snippets'), 'link' => $flextype->router->pathFor('admin.snippets.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.plugins', ['title' => '<i class="fas fa-plug"></i>' . __('admin_plugins'), 'link' => $flextype->router->pathFor('admin.plugins.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.settings.settings', ['title' => '<i class="fas fa-cog"></i>' . __('admin_settings'), 'link' => $flextype->router->pathFor('admin.settings.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.settings.infomation', ['title' => '<i class="fas fa-info"></i>' . __('admin_information'), 'link' => $flextype->router->pathFor('admin.information.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.help.docs', ['title' => '<i class="far fa-question-circle"></i>' . __('admin_documentation'), 'link' => 'http://flextype.org/en/documentation', 'attributes' => ['class' => 'nav-link', 'target' => '_blank']]);
// Add Global Vars Admin Twig Extension
$flextype->view->addExtension(new GlobalVarsAdminTwigExtension($flextype));
$flextype['DashboardController'] = function ($container) {
return new DashboardController($container);
};
$flextype['SettingsController'] = function ($container) {
return new SettingsController($container);
};
$flextype['InformationController'] = function ($container) {
return new InformationController($container);
};
$flextype['PluginsController'] = function ($container) {
return new PluginsController($container);
};
$flextype['EntriesController'] = function ($container) {
return new EntriesController($container);
};
$flextype['FieldsetsController'] = function ($container) {
return new FieldsetsController($container);
};
$flextype['SnippetsController'] = function ($container) {
return new SnippetsController($container);
};
$flextype['TemplatesController'] = function ($container) {
return new TemplatesController($container);
};
$flextype['UsersController'] = function ($container) {
return new UsersController($container);
};
/**
* Include dependencies
*/
include_once 'dependencies.php';

View File

@@ -0,0 +1,69 @@
<?php
/**
* @package Flextype
*
* @author Romanenko Sergey <hello@romanenko.digital>
* @link http://romanenko.digital
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use Flextype\Component\Arr\Arr;
use Flextype\Component\I18n\I18n;
use function Flextype\Component\I18n\__;
// Set Default Admin locale
I18n::$locale = $flextype->registry->get('settings.locale');
// Add Admin Navigation
$flextype->registry->set('admin_navigation.content.entries', ['title' => '<i class="far fa-newspaper"></i>' . __('admin_entries'), 'link' => $flextype->router->pathFor('admin.entries.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.fieldsets', ['title' => '<i class="fas fa-list"></i>' . __('admin_fieldsets'), 'link' => $flextype->router->pathFor('admin.fieldsets.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.templates', ['title' => '<i class="fas fa-layer-group"></i>' . __('admin_templates'), 'link' => $flextype->router->pathFor('admin.templates.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.snippets', ['title' => '<i class="far fa-file-code"></i>' . __('admin_snippets'), 'link' => $flextype->router->pathFor('admin.snippets.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.extends.plugins', ['title' => '<i class="fas fa-plug"></i>' . __('admin_plugins'), 'link' => $flextype->router->pathFor('admin.plugins.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.settings.settings', ['title' => '<i class="fas fa-cog"></i>' . __('admin_settings'), 'link' => $flextype->router->pathFor('admin.settings.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.settings.infomation', ['title' => '<i class="fas fa-info"></i>' . __('admin_information'), 'link' => $flextype->router->pathFor('admin.information.index'), 'attributes' => ['class' => 'nav-link']]);
$flextype->registry->set('admin_navigation.help.docs', ['title' => '<i class="far fa-question-circle"></i>' . __('admin_documentation'), 'link' => 'http://flextype.org/en/documentation', 'attributes' => ['class' => 'nav-link', 'target' => '_blank']]);
// Add Global Vars Admin Twig Extension
$flextype->view->addExtension(new GlobalVarsAdminTwigExtension($flextype));
$flextype['DashboardController'] = function ($container) {
return new DashboardController($container);
};
$flextype['SettingsController'] = function ($container) {
return new SettingsController($container);
};
$flextype['InformationController'] = function ($container) {
return new InformationController($container);
};
$flextype['PluginsController'] = function ($container) {
return new PluginsController($container);
};
$flextype['EntriesController'] = function ($container) {
return new EntriesController($container);
};
$flextype['FieldsetsController'] = function ($container) {
return new FieldsetsController($container);
};
$flextype['SnippetsController'] = function ($container) {
return new SnippetsController($container);
};
$flextype['TemplatesController'] = function ($container) {
return new TemplatesController($container);
};
$flextype['UsersController'] = function ($container) {
return new UsersController($container);
};

View File

@@ -1,3 +1,4 @@
{
"enabled": true
"enabled": true,
"route": "admin"
}

View File

@@ -64,7 +64,7 @@
<div class="modal-body">
<label for="shortcode">{{ tr('admin_shortcode') }}</label>
<div class="alert alert-dark clipboard" role="alert">
<span id="snippet">[snippet fetch="<span class="js-snippets-snippet-placeholder"></span>"]</span>
<span id="snippet">[snippets_fetch id="<span class="js-snippets-snippet-placeholder"></span>"]</span>
<button class="js-clipboard-btn btn" data-clipboard-target="#snippet">
{{ tr('admin_copy') }}
</button>
@@ -72,7 +72,7 @@
<br>
<label for="template_code">{{ tr('admin_template_code') }}</label>
<div id="template_code" class="alert alert-dark clipboard" role="alert">
<span id="html">&lcub;&lcub; snippet('<span class="js-snippets-php-placeholder"></span>') &rcub;&rcub;</span>
<span id="html">&lcub;&lcub; snippets_exec('<span class="js-snippets-php-placeholder"></span>') &rcub;&rcub;</span>
<button class="js-clipboard-btn btn" data-clipboard-target="#html">
{{ tr('admin_copy') }}
</button>

View File

@@ -6,7 +6,7 @@
<tbody>
<tr>
<td width="200">{{ tr('admin_flextype_version') }}</td>
<td>{{ flextype_version }}</td>
<td>{{ FLEXTYPE_VERSION }}</td>
</tr>
<tr>
<td>{{ tr('admin_debugging') }}</td>

View File

@@ -1,5 +1,15 @@
<?php
/**
* @package Flextype
*
* @author Romanenko Sergey <hello@romanenko.digital>
* @link http://romanenko.digital
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use Flextype\Component\Arr\Arr;
@@ -8,6 +18,14 @@ use Psr\Http\Message\ServerRequestInterface as Request;
class SiteController extends Controller
{
/**
* Current entry data array
*
* @var array
* @access private
*/
public $entry = [];
/**
* Index page
*
@@ -60,12 +78,19 @@ class SiteController extends Controller
$is_entry_not_found = true;
}
$path = 'themes/' . $this->registry->get('settings.theme') . '/' . (empty($entry['template']) ? 'templates/default' : 'templates/' . $entry['template']) . '.html';
// Set entry
$this->entry = $entry;
// Run event onSiteEntryAfterInitialized
$this->emitter->emit('onSiteEntryAfterInitialized');
// Set template path for current entry
$path = 'themes/' . $this->registry->get('settings.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' => $entry]);
return $this->view->render($response->withStatus(404), $path, ['entry' => $this->entry]);
} else {
return $this->view->render($response, $path, ['entry' => $entry]);
return $this->view->render($response, $path, ['entry' => $this->entry]);
}
}

View File

@@ -1,19 +1,39 @@
<?php
/**
* @package Flextype
*
* @author Romanenko Sergey <hello@romanenko.digital>
* @link http://romanenko.digital
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
// Ensure vendor libraries exist
!is_file($autoload = __DIR__ . '/vendor/autoload.php') and exit("Please run: <i>composer install</i>");
/**
* Ensure vendor libraries exist
*/
!is_file($site_autoload = __DIR__ . '/vendor/autoload.php') and exit("Please run: <i>composer install</i>");
// Register The Auto Loader
$loader = require_once $autoload;
/**
* Register The Auto Loader
*
* Composer provides a convenient, automatically generated class loader for
* our application. We just need to utilize it! We'll simply require it
* into the script here so that we don't have to worry about manual
* loading any of our classes later on. It feels nice to relax.
* Register The Auto Loader
*/
$site_loader = require_once $site_autoload;
// Include routes
/**
* Include web routes
*/
include_once 'routes/web.php';
/**
* Add site controller to Flextype container
* Include dependencies
*/
$flextype['SiteController'] = function($container) {
return new SiteController($container);
};
include_once 'dependencies.php';

View File

@@ -0,0 +1,20 @@
<?php
/**
* @package Flextype
*
* @author Romanenko Sergey <hello@romanenko.digital>
* @link http://romanenko.digital
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
/**
* Add site controller to Flextype container
*/
$flextype['SiteController'] = function($container) {
return new SiteController($container);
};

View File

@@ -1,5 +1,15 @@
<?php
/**
* @package Flextype
*
* @author Romanenko Sergey <hello@romanenko.digital>
* @link http://romanenko.digital
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
$app->get('{uri:.+}', 'SiteController:index')->setName('site.index');