Skip to content

Commit

Permalink
Admin 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Dec 7, 2020
1 parent 9651238 commit c065d6d
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 63 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Global
.composer
composer.lock
package-lock.json
vendor/
node_modules/
dist/

# Flextype Site Specific
var/

# OS Generated
.DS_Store*
ehthumbs.db
Expand Down
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.4.0"></a>
# [1.4.0](https://github.com/flextype-plugins/admin) (2020-12-07)

### Features

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

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

Expand Down
8 changes: 4 additions & 4 deletions app/Controllers/ApiAccessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Ramsey\Uuid\Uuid;
Expand Down Expand Up @@ -142,9 +142,9 @@ public function addProcess(Request $request, Response $response) : Response
'calls' => (int) 0,
'state' => $post_data['state'],
'uuid' => $uuid,
'created_by' => Session::get('uuid'),
'created_by' => flextype('session')->get('uuid'),
'created_at' => $time,
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => $time,
])
)) {
Expand Down Expand Up @@ -227,7 +227,7 @@ public function editProcess(Request $request, Response $response) : Response
'uuid' => $post_data['uuid'],
'created_by' => $post_data['created_by'],
'created_at' => $post_data['created_at'],
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()),
])
)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Ramsey\Uuid\Uuid;
Expand Down
8 changes: 4 additions & 4 deletions app/Controllers/ApiEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Ramsey\Uuid\Uuid;
Expand Down Expand Up @@ -142,9 +142,9 @@ public function addProcess(Request $request, Response $response) : Response
'calls' => (int) 0,
'state' => $post_data['state'],
'uuid' => $uuid,
'created_by' => Session::get('uuid'),
'created_by' => flextype('session')->get('uuid'),
'created_at' => $time,
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => $time,
])
)) {
Expand Down Expand Up @@ -227,7 +227,7 @@ public function editProcess(Request $request, Response $response) : Response
'uuid' => $post_data['uuid'],
'created_by' => $post_data['created_by'],
'created_at' => $post_data['created_at'],
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()),
])
)) {
Expand Down
8 changes: 4 additions & 4 deletions app/Controllers/ApiFilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Ramsey\Uuid\Uuid;
Expand Down Expand Up @@ -142,9 +142,9 @@ public function addProcess(Request $request, Response $response) : Response
'calls' => (int) 0,
'state' => $post_data['state'],
'uuid' => $uuid,
'created_by' => Session::get('uuid'),
'created_by' => flextype('session')->get('uuid'),
'created_at' => $time,
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => $time,
])
)) {
Expand Down Expand Up @@ -227,7 +227,7 @@ public function editProcess(Request $request, Response $response) : Response
'uuid' => $post_data['uuid'],
'created_by' => $post_data['created_by'],
'created_at' => $post_data['created_at'],
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()),
])
)) {
Expand Down
8 changes: 4 additions & 4 deletions app/Controllers/ApiFoldersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Ramsey\Uuid\Uuid;
Expand Down Expand Up @@ -140,9 +140,9 @@ public function addProcess(Request $request, Response $response) : Response
'calls' => (int) 0,
'state' => $post_data['state'],
'uuid' => $uuid,
'created_by' => Session::get('uuid'),
'created_by' => flextype('session')->get('uuid'),
'created_at' => $time,
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => $time,
])
)) {
Expand Down Expand Up @@ -225,7 +225,7 @@ public function editProcess(Request $request, Response $response) : Response
'uuid' => $post_data['uuid'],
'created_by' => $post_data['created_by'],
'created_at' => $post_data['created_at'],
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()),
])
)) {
Expand Down
8 changes: 4 additions & 4 deletions app/Controllers/ApiImagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Ramsey\Uuid\Uuid;
Expand Down Expand Up @@ -140,9 +140,9 @@ public function addProcess(Request $request, Response $response) : Response
'calls' => (int) 0,
'state' => $post_data['state'],
'uuid' => $uuid,
'created_by' => Session::get('uuid'),
'created_by' => flextype('session')->get('uuid'),
'created_at' => $time,
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => $time,
])
)) {
Expand Down Expand Up @@ -225,7 +225,7 @@ public function editProcess(Request $request, Response $response) : Response
'uuid' => $post_data['uuid'],
'created_by' => $post_data['created_by'],
'created_at' => $post_data['created_at'],
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()),
])
)) {
Expand Down
8 changes: 4 additions & 4 deletions app/Controllers/ApiRegistryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Ramsey\Uuid\Uuid;
Expand Down Expand Up @@ -140,9 +140,9 @@ public function addProcess(Request $request, Response $response) : Response
'calls' => (int) 0,
'state' => $post_data['state'],
'uuid' => $uuid,
'created_by' => Session::get('uuid'),
'created_by' => flextype('session')->get('uuid'),
'created_at' => $time,
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => $time,
])
)) {
Expand Down Expand Up @@ -225,7 +225,7 @@ public function editProcess(Request $request, Response $response) : Response
'uuid' => $post_data['uuid'],
'created_by' => $post_data['created_by'],
'created_at' => $post_data['created_at'],
'updated_by' => Session::get('uuid'),
'updated_by' => flextype('session')->get('uuid'),
'updated_at' => date(flextype('registry')->get('flextype.settings.date_format'), time()),
])
)) {
Expand Down
45 changes: 25 additions & 20 deletions app/Controllers/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Flextype\Plugin\Admin\Controllers;

use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Session\Session;

use Flextype\Component\Arrays\Arrays;
use function Flextype\Component\I18n\__;
use Respect\Validation\Validator as v;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function index(Request $request, Response $response) : Response
}
}

$entry_current = flextype('entries')->fetch($this->getEntryID($query));
$entry_current = flextype('entries')->fetchSingle($this->getEntryID($query))->toArray();

if (isset($entry_current['items_view'])) {
$items_view = $entry_current['items_view'];
Expand All @@ -92,12 +92,16 @@ public function index(Request $request, Response $response) : Response

$entries_list = [];
$entries_collection = [];
$entries_collection = collect(flextype('entries')->fetchCollection($this->getEntryID($query), ['depth' => ['1']]))->orderBy('published_at', 'DESC')->all();
$entries_collection = arrays(flextype('entries')
->fetchCollection($this->getEntryID($query),
['depth' => ['1']]))
->sortBy('published_at', 'DESC')
->toArray();

foreach ($entries_collection as $slug => $body) {
$entries_list[$slug] = $body;
if (find()->in(PATH['project'] . '/entries/' . $slug)->depth('>=1')->depth('<=2')->hasResults()) {
$entries_list[$slug] += ['has_children' => true];
if (filesystem()->find()->in(PATH['project'] . '/entries/' . $slug)->depth('>=1')->depth('<=2')->hasResults()) {
$entries_list[$slug]['has_children'] = true;
}
}

Expand Down Expand Up @@ -158,7 +162,7 @@ public function add(Request $request, Response $response) : Response
$response,
'plugins/admin/templates/content/entries/add.html',
[
'entries_list' => collect(flextype('entries')->fetchCollection($this->getEntryID($query)))->orderBy('order_by', 'ASC')->all(),
'entries_list' => arrays(flextype('entries')->fetchCollection($this->getEntryID($query)))->sortBy('order_by', 'ASC')->toArray(),
'menu_item' => 'entries',
'current_id' => $this->getEntryID($query),
'parts' => $parts,
Expand Down Expand Up @@ -231,7 +235,7 @@ public function addProcess(Request $request, Response $response) : Response
if (flextype('fieldsets')->has($data['fieldset'])) {

// Get fieldset
$fieldset = flextype('fieldsets')->fetch($data['fieldset']);
$fieldset = flextype('fieldsets')->fetchSingle($data['fieldset']);

// Init entry data
$data_from_post = [];
Expand Down Expand Up @@ -332,7 +336,7 @@ public function type(Request $request, Response $response) : Response
$parts = [0 => ''];
}

$entry = flextype('entries')->fetch($this->getEntryID($query));
$entry = flextype('entries')->fetchSingle($this->getEntryID($query))->toArray();

$fieldsets = [];

Expand Down Expand Up @@ -400,7 +404,7 @@ public function typeProcess(Request $request, Response $response) : Response

$id = $post_data['id'];

$entry = flextype('entries')->fetch($id);
$entry = flextype('entries')->fetchSingle($id)->toArray();

Arrays::delete($entry, 'slug');
Arrays::delete($entry, 'id');
Expand Down Expand Up @@ -451,7 +455,7 @@ public function move(Request $request, Response $response) : Response
$entry_id_current = array_pop($parts);

// Fetch entry
$entry = flextype('entries')->fetch($this->getEntryID($query));
$entry = flextype('entries')->fetchSingle($this->getEntryID($query))->toArray();

// Set Entries IDs in parts
if (isset($query['id'])) {
Expand All @@ -462,7 +466,7 @@ public function move(Request $request, Response $response) : Response

// Get entries list
$entries_list['/'] = '/';
foreach (flextype('entries')->fetchCollection('', ['depth' => '>0', 'order_by' => ['field' => ['id']]]) as $_entry) {
foreach (flextype('entries')->fetchCollection('', ['depth' => '>0', 'order_by' => ['field' => ['id']]])->toArray() as $_entry) {
if ($_entry['id'] != '') {
$entries_list[$_entry['id']] = $_entry['id'];
} else {
Expand Down Expand Up @@ -515,11 +519,11 @@ public function moveProcess(Request $request, Response $response)
$entry_id_current = $data['entry_id_current'];

if (!flextype('entries')->has($data['parent_entry'] . '/' . $entry_id_current)) {
if (flextype('entries')->rename(
if (flextype('entries')->move(
$data['entry_id_path_current'],
$data['parent_entry'] . '/' . $entry_id_current
)) {
flextype('media_folders')->rename('entries/' . $data['entry_id_path_current'], 'entries/' . $data['parent_entry'] . '/' . $entry_id_current);
flextype('media_folders')->move('entries/' . $data['entry_id_path_current'], 'entries/' . $data['parent_entry'] . '/' . $entry_id_current);

flextype('flash')->addMessage('success', __('admin_message_entry_moved'));
} else {
Expand Down Expand Up @@ -601,11 +605,11 @@ public function renameProcess(Request $request, Response $response) : Response
$name = $data['name'];
}

if (flextype('entries')->rename(
if (flextype('entries')->move(
$data['entry_path_current'],
$data['entry_parent'] . '/' . $name)
) {
flextype('media_folders')->rename('entries/' . $data['entry_path_current'], 'entries/' . $data['entry_parent'] . '/' . flextype('slugify')->slugify($data['name']));
flextype('media_folders')->move('entries/' . $data['entry_path_current'], 'entries/' . $data['entry_parent'] . '/' . flextype('slugify')->slugify($data['name']));
flextype('flash')->addMessage('success', __('admin_message_entry_renamed'));
} else {
flextype('flash')->addMessage('error', __('admin_message_entry_was_not_renamed'));
Expand Down Expand Up @@ -662,7 +666,9 @@ public function duplicateProcess(Request $request, Response $response) : Respons
flextype('media_folders')->copy('entries/' . $id, 'entries/' . $id . '-duplicate-' . $random_date, true);

if (Filesystem::has(PATH['project'] . '/uploads' . '/entries/' . $id)) {
Filesystem::copy(PATH['project'] . '/uploads' . '/entries/' . $id, PATH['project'] . '/uploads' . '/entries/' . $id . '-duplicate-' . $random_date, true);
filesystem()
->directory(PATH['project'] . '/uploads' . '/entries/' . $id)
->copy(PATH['project'] . '/uploads' . '/entries/' . $id . '-duplicate-' . $random_date);
} else {
Filesystem::createDir(PATH['project'] . '/uploads' . '/entries/' . $id . '-duplicate-' . $random_date);
}
Expand Down Expand Up @@ -698,7 +704,7 @@ public function edit(Request $request, Response $response) : Response
flextype('registry')->set('entries.fields.parsers.settings.enabled', false);

// Get Entry
$entry = flextype('entries')->fetch($this->getEntryID($query));
$entry = flextype('entries')->fetchSingle($this->getEntryID($query))->toArray();

Arrays::delete($entry, 'slug');
Arrays::delete($entry, 'id');
Expand Down Expand Up @@ -894,11 +900,10 @@ public function editProcess(Request $request, Response $response) : Response
isset($data['flatpickr-date-format']) and Arrays::delete($data, 'flatpickr-date-format');
isset($data['flatpickr-locale']) and Arrays::delete($data, 'flatpickr-locale');


$data['published_by'] = Session::get('uuid');
$data['published_by'] = flextype('session')->get('uuid');

// Fetch entry
$entry = flextype('entries')->fetch($id);
$entry = flextype('entries')->fetchSingle($id)->toArray();
Arrays::delete($entry, 'slug');
Arrays::delete($entry, 'id');
Arrays::delete($entry, 'modified_at');
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public function pluginStatusProcess(Request $request, Response $response) : Resp

Filesystem::write($custom_plugin_settings_file, flextype('yaml')->encode($custom_plugin_settings_file_data));

// Clear doctrine cache
flextype('cache')->purge('doctrine');
// clear cache
Filesystem::deleteDir(PATH['tmp'] . '/data');

// Redirect to plugins index page
return $response->withRedirect(flextype('router')->pathFor('admin.plugins.index'));
Expand Down
Loading

0 comments on commit c065d6d

Please sign in to comment.