Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jul 7, 2019
2 parents 2c71643 + f20c8d0 commit c1c10cb
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 30 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion flextype/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @var string
*/
define('FLEXTYPE_VERSION', '0.9.2');
define('FLEXTYPE_VERSION', '0.9.3');

/**
* Start the session
Expand Down
16 changes: 14 additions & 2 deletions flextype/core/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public function fetch(string $id)

// 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)) {
Expand Down Expand Up @@ -178,6 +182,7 @@ public function fetchAll(string $id, array $args = []) : array

// 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'];
Expand All @@ -187,6 +192,7 @@ public function fetchAll(string $id, array $args = []) : array

// 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'];
Expand All @@ -196,6 +202,7 @@ public function fetchAll(string $id, array $args = []) : array

// 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'];
Expand All @@ -205,6 +212,7 @@ public function fetchAll(string $id, array $args = []) : array

// 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 {
Expand All @@ -226,7 +234,11 @@ public function fetchAll(string $id, array $args = []) : array
// 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']), '/'), '/');
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions site/plugins/admin/app/Controllers/TemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function add(/** @scrutinizer ignore-unused */ Request $request, Response
$response,
'plugins/admin/views/templates/extends/themes/templates/add.html',
[
'menu_item' => 'templates',
'menu_item' => 'themes',
'theme' => $theme,
'links' => [
'themes' => [
Expand Down Expand Up @@ -153,7 +153,7 @@ public function edit(Request $request, Response $response) : Response
$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'),
Expand Down Expand Up @@ -227,7 +227,7 @@ public function rename(Request $request, Response $response) : Response
$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'],
Expand Down
90 changes: 68 additions & 22 deletions site/plugins/admin/app/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
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
Expand All @@ -23,14 +25,22 @@ public function profile($request, $response)
);
}

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'
Expand All @@ -41,7 +51,15 @@ public function login($request, $response)
}
}

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();

Expand All @@ -61,22 +79,41 @@ public function loginProcess($request, $response)
}
}

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();
Expand All @@ -101,26 +138,35 @@ public function registrationProcess($request, $response)
}

/**
* 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;
}
}

Expand Down
27 changes: 26 additions & 1 deletion site/plugins/admin/app/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
<?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 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);
Expand Down
3 changes: 3 additions & 0 deletions site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function __construct($flextype)
$this->flextype = $flextype;
}

/**
* Register Global variables in an extension
*/
public function getGlobals()
{
return [
Expand Down
6 changes: 5 additions & 1 deletion site/themes/default/templates/partials/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@
<script src="//unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script type="text/javascript">

var lightbox = $('.gallery-grid a').simpleLightbox({'fileExt': false});
if ($('.gallery-grid a').length) {
var lightbox = $('.gallery-grid a').simpleLightbox({'fileExt': false});
}

if ($('.gallery-grid').length) {
var $grid = $('.gallery-grid').imagesLoaded()
.done( function( instance ) {
$('.preloader').hide();
Expand All @@ -89,6 +92,7 @@
.progress( function( instance, image ) {

});
}
</script>

{{ emitter.emit('onThemeTail') }}
Expand Down
Binary file modified site/themes/default/thumbnail.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c1c10cb

Please sign in to comment.