Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Aug 25, 2020
2 parents 7b645ce + 42d55ac commit c0a3d24
Show file tree
Hide file tree
Showing 20 changed files with 479 additions and 528 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<a name="1.3.0"></a>
# [1.3.0](https://github.com/flextype-plugins/admin) (2020-08-25)

### Features

* **core** update code base for new Flextype 0.9.11

<a name="1.2.0"></a>
# [1.2.0](https://github.com/flextype-plugins/admin) (2020-08-19)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![preview](https://github.com/flextype-plugins/admin/raw/dev/preview.png)

<p align="center">
<a href="https://github.com/flextype-plugins/admin/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/admin.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/github/downloads/flextype-plugins/admin/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.10-green.svg?color=black" alt="Flextype"></a> <a href="https://crowdin.com/project/flextype-plugin-admin"><img src="https://d322cqt584bo4o.cloudfront.net/flextype-plugin-admin/localized.svg?color=black" alt="Crowdin"></a> <a href="https://scrutinizer-ci.com/g/flextype-plugins/admin?branch=dev&color=black"><img src="https://img.shields.io/scrutinizer/g/flextype-plugins/admin.svg?branch=dev&color=black" alt="Quality Score"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&colorB=728ADA&label=Discord%20Chat" alt="Discord"></a>
<a href="https://github.com/flextype-plugins/admin/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/admin.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/admin"><img src="https://img.shields.io/github/downloads/flextype-plugins/admin/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.11-green.svg?color=black" alt="Flextype"></a> <a href="https://crowdin.com/project/flextype-plugin-admin"><img src="https://d322cqt584bo4o.cloudfront.net/flextype-plugin-admin/localized.svg?color=black" alt="Crowdin"></a> <a href="https://scrutinizer-ci.com/g/flextype-plugins/admin?branch=dev&color=black"><img src="https://img.shields.io/scrutinizer/g/flextype-plugins/admin.svg?branch=dev&color=black" alt="Quality Score"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&colorB=728ADA&label=Discord%20Chat" alt="Discord"></a>
</p>

Admin Panel plugin for Flextype.
Expand All @@ -14,7 +14,7 @@ The following dependencies need to be installed for Form Admin Plugin.

| Item | Version | Download |
|---|---|---|
| [flextype](https://github.com/flextype/flextype) | 0.9.10 | [download](https://github.com/flextype/flextype/releases) |
| [flextype](https://github.com/flextype/flextype) | 0.9.11 | [download](https://github.com/flextype/flextype/releases) |
| [twig](https://github.com/flextype-plugins/twig) | >=1.0.0 | [download](https://github.com/flextype-plugins/twig/releases) |
| [form](https://github.com/flextype-plugins/form) | >=1.0.0 | [download](https://github.com/flextype-plugins/form/releases) |
| [form-admin](https://github.com/flextype-plugins/form-admin) | >=1.0.0 | [download](https://github.com/flextype-plugins/form-admin/releases) |
Expand Down
64 changes: 30 additions & 34 deletions app/Controllers/ApiAccessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@

class ApiAccessController
{
/**
* Flextype Application
*/
protected $flextype;

/**
* __construct
*/
public function __construct($flextype)
public function __construct()
{
$this->flextype = $flextype;

}

/**
Expand All @@ -50,26 +46,26 @@ public function index(Request $request, Response $response) : Response
}
}

return $this->flextype->container('twig')->render(
return flextype('twig')->render(
$response,
'plugins/admin/templates/system/api/access/index.html',
[
'menu_item' => 'api',
'tokens' => $tokens,
'links' => [
'api' => [
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
'link' => flextype('router')->pathFor('admin.api.index'),
'title' => __('admin_api'),
],
'api_Access' => [
'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'),
'link' => flextype('router')->pathFor('admin.api_access.index'),
'title' => __('admin_access'),
'active' => true
],
],
'buttons' => [
'api_access_add' => [
'link' => $this->flextype->container('router')->pathFor('admin.api_access.add'),
'link' => flextype('router')->pathFor('admin.api_access.add'),
'title' => __('admin_create_new_token')
],
],
Expand All @@ -85,22 +81,22 @@ public function index(Request $request, Response $response) : Response
*/
public function add(Request $request, Response $response) : Response
{
return $this->flextype->container('twig')->render(
return flextype('twig')->render(
$response,
'plugins/admin/templates/system/api/access/add.html',
[
'menu_item' => 'api',
'links' => [
'api' => [
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
'link' => flextype('router')->pathFor('admin.api.index'),
'title' => __('admin_api'),
],
'api_access' => [
'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'),
'link' => flextype('router')->pathFor('admin.api_access.index'),
'title' => __('admin_access')
],
'api_access_add' => [
'link' => $this->flextype->container('router')->pathFor('admin.api_access.add'),
'link' => flextype('router')->pathFor('admin.api_access.add'),
'title' => __('admin_create_new_token'),
'active' => true
],
Expand Down Expand Up @@ -134,12 +130,12 @@ public function addProcess(Request $request, Response $response) : Response
$uuid = Uuid::uuid4()->toString();

// Get time
$time = date($this->flextype->container('registry')->get('flextype.settings.date_format'), time());
$time = date(flextype('registry')->get('flextype.settings.date_format'), time());

// Create API Token account
if (Filesystem::write(
$api_token_file_path,
$this->flextype->container('yaml')->encode([
flextype('yaml')->encode([
'title' => $post_data['title'],
'icon' => $post_data['icon'],
'limit_calls' => (int) $post_data['limit_calls'],
Expand All @@ -152,18 +148,18 @@ public function addProcess(Request $request, Response $response) : Response
'updated_at' => $time,
])
)) {
$this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_created'));
flextype('flash')->addMessage('success', __('admin_message_access_api_token_created'));
} else {
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created1'));
flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created1'));
}
} else {
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created2'));
flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_created2'));
}

if (isset($post_data['create-and-edit'])) {
return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.edit') . '?token=' . $api_token);
return $response->withRedirect(flextype('router')->pathFor('admin.api_access.edit') . '?token=' . $api_token);
} else {
return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index'));
return $response->withRedirect(flextype('router')->pathFor('admin.api_access.index'));
}
}

Expand All @@ -176,9 +172,9 @@ public function addProcess(Request $request, Response $response) : Response
public function edit(Request $request, Response $response) : Response
{
$token = $request->getQueryParams()['token'];
$token_data = $this->flextype->container('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens' . '/access/' . $token . '/token.yaml'));
$token_data = flextype('yaml')->decode(Filesystem::read(PATH['project'] . '/tokens' . '/access/' . $token . '/token.yaml'));

return $this->flextype->container('twig')->render(
return flextype('twig')->render(
$response,
'plugins/admin/templates/system/api/access/edit.html',
[
Expand All @@ -187,15 +183,15 @@ public function edit(Request $request, Response $response) : Response
'token_data' => $token_data,
'links' => [
'api' => [
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
'link' => flextype('router')->pathFor('admin.api.index'),
'title' => __('admin_api')
],
'api_access' => [
'link' => $this->flextype->container('router')->pathFor('admin.api_access.index'),
'link' => flextype('router')->pathFor('admin.api_access.index'),
'title' => __('admin_access')
],
'api_tokens_edit' => [
'link' => $this->flextype->container('router')->pathFor('admin.api_access.edit'),
'link' => flextype('router')->pathFor('admin.api_access.edit'),
'title' => __('admin_edit_token'),
'active' => true
],
Expand All @@ -222,7 +218,7 @@ public function editProcess(Request $request, Response $response) : Response
if (Filesystem::has($api_token_file_path)) {
if (Filesystem::write(
$api_token_file_path,
$this->flextype->container('yaml')->encode([
flextype('yaml')->encode([
'title' => $post_data['title'],
'icon' => $post_data['icon'],
'limit_calls' => (int) $post_data['limit_calls'],
Expand All @@ -232,16 +228,16 @@ public function editProcess(Request $request, Response $response) : Response
'created_by' => $post_data['created_by'],
'created_at' => $post_data['created_at'],
'updated_by' => Session::get('uuid'),
'updated_at' => date($this->flextype->container('registry')->get('flextype.settings.date_format'), time()),
'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()),
])
)) {
$this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_updated'));
flextype('flash')->addMessage('success', __('admin_message_access_api_token_updated'));
}
} else {
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_updated'));
flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_updated'));
}

return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index'));
return $response->withRedirect(flextype('router')->pathFor('admin.api_access.index'));
}

/**
Expand All @@ -258,11 +254,11 @@ public function deleteProcess(Request $request, Response $response) : Response
$api_token_dir_path = PATH['project'] . '/tokens' . '/access/' . $post_data['token'];

if (Filesystem::deleteDir($api_token_dir_path)) {
$this->flextype->container('flash')->addMessage('success', __('admin_message_access_api_token_deleted'));
flextype('flash')->addMessage('success', __('admin_message_access_api_token_deleted'));
} else {
$this->flextype->container('flash')->addMessage('error', __('admin_message_access_api_token_was_not_deleted'));
flextype('flash')->addMessage('error', __('admin_message_access_api_token_was_not_deleted'));
}

return $response->withRedirect($this->flextype->container('router')->pathFor('admin.api_access.index'));
return $response->withRedirect(flextype('router')->pathFor('admin.api_access.index'));
}
}
13 changes: 4 additions & 9 deletions app/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@

class ApiController
{
/**
* Flextype Application
*/
protected $flextype;

/**
* __construct
*/
public function __construct($flextype)
public function __construct()
{
$this->flextype = $flextype;

}

/**
Expand All @@ -39,7 +34,7 @@ public function __construct($flextype)
*/
public function index(Request $request, Response $response) : Response
{
return $this->flextype->container('twig')->render(
return flextype('twig')->render(
$response,
'plugins/admin/templates/system/api/index.html',
[
Expand Down Expand Up @@ -72,7 +67,7 @@ public function index(Request $request, Response $response) : Response
],
'links' => [
'api' => [
'link' => $this->flextype->container('router')->pathFor('admin.api.index'),
'link' => flextype('router')->pathFor('admin.api.index'),
'title' => __('admin_api'),
'active' => true,
],
Expand Down
Loading

0 comments on commit c0a3d24

Please sign in to comment.