diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e429f82..91dafebf 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [0.9.3] - 2019-07-07 +### Fixed +- Flextype Core: Entries - issue with binding arguments inside method fetchAll() - fixed. #182 +- Flextype Core: Entries - issue with possible boolean false result from Filesystem::getTimestamp() inside method fetchAll() - fixed. #182 +- Flextype Core: Entries - issue with possible boolean false result from Filesystem::getTimestamp() inside method fetch() - fixed. #182 +- Flextype Admin Panel: critical issue with possibility to register two admins! - fixed. #183 #182 +- Flextype Admin Panel: Left Navigation - active state for Templates area - fixed. #182 +- Flextype Default Theme: issue with `TypeError: undefined is not an object` for lightbox - fixed. #182 +- Flextype Default Theme: fix thumbnail image for Default Theme #182 + + ## [0.9.2] - 2019-07-06 ### Added - Flextype Default Theme: pagination for blog entries added. #164 #165 diff --git a/README.md b/README.md index e0974afd..3a6d1981 100755 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Flextype is open source, community driven project, and maintained by community! * [Github Repository](https://github.com/flextype/flextype) * [Discord](https://discord.gg/CCKPKVG) +* [Forum](http://forum.flextype.org) * [Vkontakte](https://vk.com/flextype) * [Twitter](https://twitter.com/getflextype) diff --git a/flextype/bootstrap.php b/flextype/bootstrap.php index 557a8a8a..a898b11f 100755 --- a/flextype/bootstrap.php +++ b/flextype/bootstrap.php @@ -21,7 +21,7 @@ use Flextype\Component\Filesystem\Filesystem; * * @var string */ -define('FLEXTYPE_VERSION', '0.9.2'); +define('FLEXTYPE_VERSION', '0.9.3'); /** * Start the session diff --git a/flextype/core/Entries.php b/flextype/core/Entries.php index 8451c077..295a4c6d 100755 --- a/flextype/core/Entries.php +++ b/flextype/core/Entries.php @@ -70,7 +70,11 @@ class Entries // Create unique entry cache_id // Entry Cache ID = entry + entry file + entry file time stamp - $entry_cache_id = md5('entry' . $entry_file . Filesystem::getTimestamp($entry_file)); + if ($timestamp = Filesystem::getTimestamp($entry_file)) { + $entry_cache_id = md5('entry' . $entry_file . $timestamp); + } else { + $entry_cache_id = md5('entry' . $entry_file); + } // Try to get the requested entry from cache if ($this->flextype['cache']->contains($entry_cache_id)) { @@ -178,6 +182,7 @@ class Entries // Bind: where if (isset($args['where']['key']) && isset($args['where']['expr']) && isset($args['where']['value'])) { + $bind_where = []; $bind_where['where']['key'] = $args['where']['key']; $bind_where['where']['expr'] = $expression[$args['where']['expr']]; $bind_where['where']['value'] = $args['where']['value']; @@ -187,6 +192,7 @@ class Entries // Bind: and where if (isset($args['and_where']['key']) && isset($args['and_where']['expr']) && isset($args['and_where']['value'])) { + $bind_and_where = []; $bind_and_where['and_where']['key'] = $args['and_where']['key']; $bind_and_where['and_where']['expr'] = $expression[$args['and_where']['expr']]; $bind_and_where['and_where']['value'] = $args['and_where']['value']; @@ -196,6 +202,7 @@ class Entries // Bind: or where if (isset($args['or_where']['key']) && isset($args['or_where']['expr']) && isset($args['or_where']['value'])) { + $bind_or_where = []; $bind_or_where['or_where']['key'] = $args['or_where']['key']; $bind_or_where['or_where']['expr'] = $expression[$args['or_where']['expr']]; $bind_or_where['or_where']['value'] = $args['or_where']['value']; @@ -205,6 +212,7 @@ class Entries // Bind: order by if (isset($args['order_by']['field']) && isset($args['order_by']['direction'])) { + $bind_order_by = []; $bind_order_by['order_by']['field'] = $args['order_by']['field']; $bind_order_by['order_by']['direction'] = $args['order_by']['direction']; } else { @@ -226,7 +234,11 @@ class Entries // ignore ... } else { if ($current_entry['type'] == 'dir' && Filesystem::has($current_entry['path'] . '/entry.json')) { - $_entries_ids .= 'entry:' . ltrim(rtrim(str_replace(PATH['entries'], '', $current_entry['path']), '/'), '/') . ' timestamp:' . Filesystem::getTimestamp($current_entry['path'] . '/entry.json') . ' '; + if ($timestamp = Filesystem::getTimestamp($current_entry['path'] . '/entry.json')) { + $_entries_ids .= 'entry:' . ltrim(rtrim(str_replace(PATH['entries'], '', $current_entry['path']), '/'), '/') . ' timestamp:' . $timestamp; + } else { + $_entries_ids .= 'entry:' . ltrim(rtrim(str_replace(PATH['entries'], '', $current_entry['path']), '/'), '/'); + } } } } diff --git a/site/plugins/admin/app/Controllers/TemplatesController.php b/site/plugins/admin/app/Controllers/TemplatesController.php index 84821657..de4484d3 100644 --- a/site/plugins/admin/app/Controllers/TemplatesController.php +++ b/site/plugins/admin/app/Controllers/TemplatesController.php @@ -79,7 +79,7 @@ class TemplatesController extends Controller $response, 'plugins/admin/views/templates/extends/themes/templates/add.html', [ - 'menu_item' => 'templates', + 'menu_item' => 'themes', 'theme' => $theme, 'links' => [ 'themes' => [ @@ -153,7 +153,7 @@ class TemplatesController extends Controller $response, 'plugins/admin/views/templates/extends/themes/templates/edit.html', [ - 'menu_item' => 'templates', + 'menu_item' => 'themes', 'theme' => $theme, 'id' => $request->getQueryParams()['id'], 'data' => Filesystem::read(PATH['themes'] . '/' . $theme . '/' . $this->_type_location($type) . $request->getQueryParams()['id'] . '.html'), @@ -227,7 +227,7 @@ class TemplatesController extends Controller $response, 'plugins/admin/views/templates/extends/themes/templates/rename.html', [ - 'menu_item' => 'templates', + 'menu_item' => 'themes', 'theme' => $theme, 'types' => ['partial' => __('admin_partial'), 'template' => __('admin_template')], 'id_current' => $request->getQueryParams()['id'], diff --git a/site/plugins/admin/app/Controllers/UsersController.php b/site/plugins/admin/app/Controllers/UsersController.php index 1e45f78d..622ad726 100644 --- a/site/plugins/admin/app/Controllers/UsersController.php +++ b/site/plugins/admin/app/Controllers/UsersController.php @@ -6,6 +6,8 @@ use Flextype\Component\Filesystem\Filesystem; use Flextype\Component\Session\Session; use Flextype\Component\Text\Text; use function Flextype\Component\I18n\__; +use Psr\Http\Message\ResponseInterface as Response; +use Psr\Http\Message\ServerRequestInterface as Request; /** * @property View $view @@ -23,14 +25,22 @@ class UsersController extends Controller ); } - public function login($request, $response) + /** + * Login page + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * + * @return Response + */ + public function login(Request $request, Response $response) : Response { $users = $this->getUsers(); if ((Session::exists('role') && Session::get('role') == 'admin')) { return $response->withRedirect($this->router->pathFor('admin.entries.index')); } else { - if ($users && count($users) > 0) { + if (count($users) > 0) { return $this->container->get('view')->render( $response, 'plugins/admin/views/templates/users/login.html' @@ -41,7 +51,15 @@ class UsersController extends Controller } } - public function loginProcess($request, $response) + /** + * Login page process + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * + * @return Response + */ + public function loginProcess(Request $request, Response $response) : Response { $data = $request->getParsedBody(); @@ -61,22 +79,41 @@ class UsersController extends Controller } } - public function registration($request, $response) + /** + * Registration page + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * + * @return Response + */ + public function registration(Request $request, Response $response) : Response { - if ((Session::exists('role') && Session::get('role') == 'admin')) { - return $response->withRedirect($this->router->pathFor('admin.entries.index')); + $users = $this->getUsers(); + + if (count($users) > 0) { + return $response->withRedirect($this->router->pathFor('admin.users.login')); } else { - return $this->view->render( - $response, - 'plugins/admin/views/templates/users/registration.html' - ); + if ((Session::exists('role') && Session::get('role') == 'admin')) { + return $response->withRedirect($this->router->pathFor('admin.entries.index')); + } else { + return $this->view->render( + $response, + 'plugins/admin/views/templates/users/registration.html' + ); + } } } /** - * registrationProcess + * Registration page process + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * + * @return Response */ - public function registrationProcess($request, $response) + public function registrationProcess(Request $request, Response $response) : Response { // Get POST data $data = $request->getParsedBody(); @@ -101,26 +138,35 @@ class UsersController extends Controller } /** - * logoutProcess + * Logout page process + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * + * @return Response */ - public function logoutProcess($request, $response) + public function logoutProcess(Request $request, Response $response) : Response { Session::destroy(); return $response->withRedirect($this->router->pathFor('admin.users.login')); } - public function getUsers() + /** + * Get Users list + * + * @return array + */ + public function getUsers() : array { // Get Users Profiles - $users = Filesystem::listContents(PATH['site'] . '/accounts/'); + $users_list = Filesystem::listContents(PATH['site'] . '/accounts/'); - // Get Plugins List - $_users_list = Filesystem::listContents(PATH['plugins']); - $users_list = []; + // Users + $users = []; - foreach($_users_list as $user) { - if ($user['type'] == 'dir') { - $users_list[] = $user; + foreach($users_list as $user) { + if ($user['type'] == 'file' && $user['extension'] == 'json') { + $users[$user['basename']] = $user; } } diff --git a/site/plugins/admin/app/Middleware/AuthMiddleware.php b/site/plugins/admin/app/Middleware/AuthMiddleware.php index 4af8657f..9094ec0e 100644 --- a/site/plugins/admin/app/Middleware/AuthMiddleware.php +++ b/site/plugins/admin/app/Middleware/AuthMiddleware.php @@ -1,12 +1,37 @@ + * @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\Session\Session; +use Psr\Http\Message\ResponseInterface as Response; +use Psr\Http\Message\ServerRequestInterface as Request; +/** + * @property Router $router + */ class AuthMiddleware extends Middleware { - public function __invoke($request, $response, $next) + + /** + * __invoke + * + * @param Request $request PSR7 request + * @param Response $response PSR7 response + * @param callable $next Next middleware + * + * @return Response + */ + public function __invoke(Request $request, Response $response, $next) : Response { if (Session::exists('role') && Session::get('role') == 'admin') { $response = $next($request, $response); diff --git a/site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php b/site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php index 1b84ff73..47ffddb4 100644 --- a/site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php +++ b/site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php @@ -29,6 +29,9 @@ class GlobalVarsAdminTwigExtension extends \Twig_Extension implements \Twig_Exte $this->flextype = $flextype; } + /** + * Register Global variables in an extension + */ public function getGlobals() { return [ diff --git a/site/themes/default/templates/partials/base.html b/site/themes/default/templates/partials/base.html index 1a8d654f..cfd1964e 100644 --- a/site/themes/default/templates/partials/base.html +++ b/site/themes/default/templates/partials/base.html @@ -76,8 +76,11 @@ {{ emitter.emit('onThemeTail') }} diff --git a/site/themes/default/thumbnail.jpg b/site/themes/default/thumbnail.jpg index 85e41bac..4e7020d1 100644 Binary files a/site/themes/default/thumbnail.jpg and b/site/themes/default/thumbnail.jpg differ