mirror of
https://github.com/flextype/flextype.git
synced 2025-08-05 04:37:43 +02:00
@@ -121,7 +121,7 @@ $flextype['images'] = static function ($container) {
|
||||
|
||||
// Set source filesystem
|
||||
$source = new Filesystem(
|
||||
new Local(PATH['assets'])
|
||||
new Local(PATH['entries'])
|
||||
);
|
||||
|
||||
// Set cache filesystem
|
||||
|
@@ -17,7 +17,7 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
* Generates and returns the image response
|
||||
*/
|
||||
$app->get('/image/{path:.+}', function (Request $request, Response $response, array $args) use ($flextype) {
|
||||
if (Filesystem::has(PATH['assets'] . '/' . $args['path'])) {
|
||||
if (Filesystem::has(PATH['entries'] . '/' . $args['path'])) {
|
||||
return $flextype['images']->getImageResponse($args['path'], $_GET);
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,6 @@ define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
|
||||
*/
|
||||
define('PATH', [
|
||||
'site' => ROOT_DIR . '/site',
|
||||
'assets' => ROOT_DIR . '/site/assets',
|
||||
'plugins' => ROOT_DIR . '/site/plugins',
|
||||
'themes' => ROOT_DIR . '/site/themes',
|
||||
'entries' => ROOT_DIR . '/site/entries',
|
||||
|
@@ -31,6 +31,12 @@ use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
*/
|
||||
class EntriesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Get Entry ID
|
||||
*
|
||||
* @param array Query
|
||||
*/
|
||||
protected function getEntryID($query)
|
||||
{
|
||||
if (isset($query['id'])) {
|
||||
@@ -440,7 +446,6 @@ class EntriesController extends Controller
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
if (!$this->entries->has($data['parent_entry'] . '/' . $data['entry_id_current'])) {
|
||||
|
||||
if ($this->entries->rename(
|
||||
$data['entry_id_path_current'],
|
||||
$data['parent_entry'] . '/' . $this->slugify->slugify($data['entry_id_current'])
|
||||
@@ -543,6 +548,7 @@ class EntriesController extends Controller
|
||||
$id_current = $data['id-current'];
|
||||
|
||||
if ($this->entries->delete($id)) {
|
||||
|
||||
$this->flash->addMessage('success', __('admin_message_entry_deleted'));
|
||||
} else {
|
||||
$this->flash->addMessage('error', __('admin_message_entry_was_not_deleted'));
|
||||
@@ -809,7 +815,7 @@ class EntriesController extends Controller
|
||||
$entry_id = $data['entry-id'];
|
||||
$media_id = $data['media-id'];
|
||||
|
||||
$files_directory = PATH['assets'] . '/entries/' . $entry_id . '/' . $media_id;
|
||||
$files_directory = PATH['entries'] . '/' . $entry_id . '/' . $media_id;
|
||||
|
||||
Filesystem::delete($files_directory);
|
||||
|
||||
@@ -832,10 +838,7 @@ class EntriesController extends Controller
|
||||
|
||||
$id = $data['entry-id'];
|
||||
|
||||
$files_directory = PATH['assets'] . '/entries/' . $id . '/';
|
||||
|
||||
// Create files directory if its not exists
|
||||
! Filesystem::has($files_directory) and Filesystem::createDir($files_directory);
|
||||
$files_directory = PATH['entries'] . '/' . $id . '/';
|
||||
|
||||
$file = $this->_uploadFile($_FILES['file'], $files_directory, $this->registry->get('settings.entries.media.accept_file_types'), 27000000);
|
||||
|
||||
@@ -998,17 +1001,27 @@ class EntriesController extends Controller
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getMediaList(string $entry, bool $path = false) : array
|
||||
/**
|
||||
* Get media list
|
||||
*
|
||||
* @param string $id Entry ID
|
||||
* @param bool $path if true returns with url paths
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMediaList(string $id, bool $path = false) : array
|
||||
{
|
||||
$base_url = \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getBaseUrl();
|
||||
$files = [];
|
||||
foreach (array_diff(scandir(PATH['assets'] . '/entries/' . $entry), ['..', '.']) as $file) {
|
||||
foreach (array_diff(scandir(PATH['entries'] . '/' . $id), ['..', '.']) as $file) {
|
||||
if (strpos($this->registry->get('settings.entries.media.accept_file_types'), $file_ext = substr(strrchr($file, '.'), 1)) !== false) {
|
||||
if (strpos($file, strtolower($file_ext), 1)) {
|
||||
if ($path) {
|
||||
$files[$base_url . '/' . $entry . '/' . $file] = $base_url . '/' . $entry . '/' . $file;
|
||||
} else {
|
||||
$files[$file] = $file;
|
||||
if ($file !== 'entry.md') {
|
||||
if ($path) {
|
||||
$files[$base_url . '/' . $id . '/' . $file] = $base_url . '/' . $id . '/' . $file;
|
||||
} else {
|
||||
$files[$file] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,14 +25,14 @@
|
||||
<div class="item">
|
||||
<a href="javascript:;"
|
||||
{% if (filesystem_ext(file) in ['jpeg', 'png', 'gif', 'jpg']) %}
|
||||
style="background-image: url('{{ base_url() }}/image/entries/{{ id }}/{{ filesystem_basename(file) }}?w=200');"
|
||||
style="background-image: url('{{ base_url() }}/image/{{ id }}/{{ filesystem_basename(file) }}?w=200');"
|
||||
{% else %}
|
||||
style="background: #000;"
|
||||
{% endif %}
|
||||
class="img-item js-entries-image-preview"
|
||||
data-media-id="{{ filesystem_basename(file) }}"
|
||||
data-entry-id="{{ id }}"
|
||||
data-image-url="{{ base_url() }}/image/entries/{{ id }}/{{ filesystem_basename(file) }}">
|
||||
data-image-url="{{ base_url() }}/image/{{ id }}/{{ filesystem_basename(file) }}">
|
||||
<i class="fas fa-eye"></i>
|
||||
{% if (filesystem_ext(file) in ['jpeg', 'png', 'gif', 'jpg']) %}
|
||||
{% else %}
|
||||
|
Reference in New Issue
Block a user