diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c9a823a..ceead92cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 2.x branch ## 2.31 branch +### 2.31.6 +* fixed the `connector.minimal.php` file for ElFinder and the `FixElFinderCommand`: the Composer autoload is now + correctly loaded via absolute path; +* removed the default `userbar` and all code related; +* little fixes. + ### 2.31.5 * `login` layout changed to `single-column`. This name clarifies that it can be used for various purposes (login, sign up, but also error views); diff --git a/config/elfinder/connector.minimal.php b/config/elfinder/connector.minimal.php index ec5f49261..32b80628d 100644 --- a/config/elfinder/connector.minimal.php +++ b/config/elfinder/connector.minimal.php @@ -1,17 +1,19 @@ isEmpty('id')) { header('HTTP/1.0 401 Unauthorized'); echo '{"error": "Login failed."}'; exit; } -is_readable('./vendor/autoload.php') && require './vendor/autoload.php'; -require './autoload.php'; - /** * Control file access using "accessControl" callback. * This method will disable accessing files/folders starting from '.' (dot) @@ -28,7 +30,7 @@ function access($attr, $path, $data, $volume, $isDir, $relpath) $basename = basename($path); return $basename[0] === '.' // if file/folder begins with '.' (dot) - && strlen($relpath) !== 1 // but with out volume root + && strlen($relpath) !== 1 // but without volume root ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true : null; //else elFinder decide it itself } @@ -53,7 +55,7 @@ function access($attr, $path, $data, $volume, $isDir, $relpath) 'path' => '{{UPLOADS_PATH}}.trash', 'tmbURL' => '{{UPLOADS_URL}}/.trash/.tmb/', 'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too - 'uploadDeny' => ['all'], // Recomend the same settings as the original volume that uses the trash + 'uploadDeny' => ['all'], // Recommend the same settings as the original volume that uses the trash 'uploadAllow' => ['image', 'text/plain'], // Same as above 'uploadOrder' => ['deny', 'allow'], // Same as above 'accessControl' => 'access', // Same as above diff --git a/config/me_cms.php b/config/me_cms.php index 1e1f38536..411d60c55 100644 --- a/config/me_cms.php +++ b/config/me_cms.php @@ -184,8 +184,5 @@ 'reset_password' => true, //Signup (enabled or disabled) 'signup' => true, - //Displays the userbar. This will have effect only on the frontend; in - // the backend, the userbar will always be visible - 'userbar' => true, ], ]]; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1d20a3f03..1607a2380 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -36,11 +36,6 @@ parent::__construct($name, $data, $dataName) - - - \Cake\Collection\CollectionInterface<array{class: class-string, name: string}> - - $this->extend('MeCms./common/form'); @@ -51,6 +46,11 @@ $this->extend('MeCms./common/form'); + + + $this->extend('/common/view'); + + diff --git a/src/Command/Install/FixElFinderCommand.php b/src/Command/Install/FixElFinderCommand.php index 5da83cdce..a96b09c46 100644 --- a/src/Command/Install/FixElFinderCommand.php +++ b/src/Command/Install/FixElFinderCommand.php @@ -54,8 +54,18 @@ protected function createConnectorMinimal(ConsoleIo $io): void return; } + $Filesystem = new Filesystem(); + $autoload = $Filesystem->concatenate(APP, 'vendor', 'autoload.php'); $origin = Plugin::path('MeCms', 'config' . DS . 'elfinder' . DS . 'connector.minimal.php'); - $content = str_replace(['{{UPLOADS_PATH}}', '{{UPLOADS_URL}}'], [Filesystem::instance()->addSlashTerm(UPLOADED), Router::url('/files', true)], file_get_contents($origin) ?: ''); + $content = str_replace([ + '{{AUTOLOAD_PATH}}', + '{{UPLOADS_PATH}}', + '{{UPLOADS_URL}}', + ], [ + is_readable($autoload) ? $autoload : $Filesystem->concatenate(ROOT, 'vendor', 'autoload.php'), + $Filesystem->addSlashTerm(UPLOADED), + Router::url('/files', true), + ], file_get_contents($origin) ?: ''); $io->createFile($target, $content); } diff --git a/src/Controller/Admin/SystemsController.php b/src/Controller/Admin/SystemsController.php index b8d478abb..ed9d1343d 100644 --- a/src/Controller/Admin/SystemsController.php +++ b/src/Controller/Admin/SystemsController.php @@ -130,8 +130,8 @@ protected function clearSitemap(): bool * Temporary cleaner (assets, cache, logs, sitemap and thumbnails) * @param string $type Type * @return \Cake\Http\Response|null - * @throws \Symfony\Component\Filesystem\Exception\IOException - * @throws \Symfony\Component\Finder\Exception\DirectoryNotFoundException + * @throws \Tools\Exception\MethodNotExistsException + * @throws \Tools\Exception\NotReadableException */ public function tmpCleaner(string $type): ?Response { diff --git a/src/Model/Table/PostsTable.php b/src/Model/Table/PostsTable.php index ef286fd7b..89119cc92 100644 --- a/src/Model/Table/PostsTable.php +++ b/src/Model/Table/PostsTable.php @@ -61,6 +61,7 @@ class PostsTable extends PostsAndPagesTables * @param \ArrayObject $data Request data * @return void * @since 2.15.2 + * @noinspection PhpUnusedParameterInspection */ public function beforeMarshal(EventInterface $event, ArrayObject $data): void { diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php index 664e614ee..b187d3408 100644 --- a/src/Model/Table/UsersTable.php +++ b/src/Model/Table/UsersTable.php @@ -64,6 +64,7 @@ protected function _initializeSchema(TableSchemaInterface $schema): TableSchemaI * @param \ArrayObject $options Options * @return void * @since 2.16.1 + * @noinspection PhpUnusedParameterInspection */ public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options): void { diff --git a/src/ORM/PostsAndPagesTables.php b/src/ORM/PostsAndPagesTables.php index d32c937c2..cd2904f64 100644 --- a/src/ORM/PostsAndPagesTables.php +++ b/src/ORM/PostsAndPagesTables.php @@ -86,6 +86,7 @@ public function afterSave(EventInterface $event, EntityInterface $entity): void * @return void * @throws \Tools\Exception\NotWritableException * @since 2.17.0 + * @noinspection PhpUnusedParameterInspection */ public function beforeSave(EventInterface $event, EntityInterface $entity): void { diff --git a/src/Utility/StaticPage.php b/src/Utility/StaticPage.php index 385e35fc2..debfdd68d 100644 --- a/src/Utility/StaticPage.php +++ b/src/Utility/StaticPage.php @@ -54,7 +54,6 @@ public static function getPaths(): array /** * Gets all static pages * @return \Cake\Collection\CollectionInterface Collection of static pages - * @throws \ErrorException */ public static function all(): CollectionInterface { diff --git a/src/View/View.php b/src/View/View.php index dbd648658..8626c576f 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -59,14 +59,12 @@ protected function getTitleForLayout(): string return $title; } - //If exists, it adds the title set by the controller, as if it has - // been set via `$this->View->set()` + //If exists, it adds the title set by the controller, as if it has been set via `$this->View->set()` if ($this->get('title')) { - $title = sprintf('%s - %s', $this->get('title'), $title); - //Else, if exists, it adds the title set by the current view, as if - // it has been set via `$this->View->Blocks->set()` + $title = $this->get('title') . ' - ' . $title; + //Else, if exists, it adds the title set by the current view, as if it has been set via `$this->View->Blocks->set()` } elseif ($this->fetch('title')) { - $title = sprintf('%s - %s', $this->fetch('title'), $title); + $title = $this->fetch('title') . ' - ' . $title; } return $this->titleForLayout = $title; diff --git a/src/View/View/AppView.php b/src/View/View/AppView.php index f729353c2..eca978701 100644 --- a/src/View/View/AppView.php +++ b/src/View/View/AppView.php @@ -27,12 +27,6 @@ */ class AppView extends View { - /** - * Internal property to set the userbar elements - * @var array - */ - protected array $userbar = []; - /** * Internal method to set some blocks * @return void @@ -86,20 +80,6 @@ public function renderLayout(string $content, ?string $layout = null): string $this->setBlocks(); - //Assign the userbar - $this->assign('userbar', implode(PHP_EOL, array_map(fn($element): string => $this->Html->li($element), $this->userbar))); - return parent::renderLayout($content, $layout); } - - /** - * Adds content to the userbar - * @param string ...$content Contents as string or an array of contents - * @return void - * @since 2.29.5 - */ - public function addToUserbar(string ...$content): void - { - $this->userbar = [...$this->userbar, $content]; - } } diff --git a/templates/Pages/view.php b/templates/Pages/view.php index 4a490862c..c16a819f0 100644 --- a/templates/Pages/view.php +++ b/templates/Pages/view.php @@ -11,32 +11,14 @@ * @copyright Copyright (c) Mirko Pagliai * @link https://github.com/mirko-pagliai/me-cms * @license https://opensource.org/licenses/mit-license.php MIT License - * - * @var \MeCms\Model\Entity\Page $page */ -$this->extend('/common/view'); -$this->assign('title', $page->get('title')); /** - * Userbar + * @var \MeCms\Model\Entity\Page $page + * @var \MeCms\View\View\AppView $this */ -$class = 'badge badge-warning'; -if (!$page->get('active')) { - $this->addToUserbar($this->Html->span(I18N_DRAFT, compact('class'))); -} -if ($page->get('created')->isFuture()) { - $this->addToUserbar($this->Html->span(I18N_SCHEDULED, compact('class'))); -} -$this->addToUserbar($this->Html->link( - __d('me_cms', 'Edit page'), - ['action' => 'edit', $page->get('id'), 'prefix' => ADMIN_PREFIX], - ['class' => 'nav-link', 'icon' => 'pencil-alt', 'target' => '_blank'] -)); -$this->addToUserbar($this->Form->postLink( - __d('me_cms', 'Delete page'), - ['action' => 'delete', $page->get('id'), 'prefix' => ADMIN_PREFIX], - ['class' => 'nav-link text-danger', 'icon' => 'trash-alt', 'confirm' => I18N_SURE_TO_DELETE, 'target' => '_blank'] -)); +$this->extend('/common/view'); +$this->assign('title', $page->get('title')); /** * Breadcrumb diff --git a/templates/PagesCategories/view.php b/templates/PagesCategories/view.php index 6a4c13e09..a1d3a2326 100644 --- a/templates/PagesCategories/view.php +++ b/templates/PagesCategories/view.php @@ -11,37 +11,22 @@ * @copyright Copyright (c) Mirko Pagliai * @link https://github.com/mirko-pagliai/me-cms * @license https://opensource.org/licenses/mit-license.php MIT License + */ +use MeCms\Model\Entity\Page; +/** * @var \MeCms\Model\Entity\PagesCategory $category * @var \MeCms\View\View\AppView $this */ -use MeCms\Model\Entity\Page; - $this->extend('/common/index'); $this->assign('title', $category->get('title')); -/** - * Userbar - */ -$this->addToUserbar($this->Html->link( - __d('me_cms', 'Edit category'), - ['action' => 'edit', $category->get('id'), 'prefix' => ADMIN_PREFIX], - ['class' => 'nav-link', 'icon' => 'pencil-alt', 'target' => '_blank'] -)); -$this->addToUserbar($this->Form->postLink( - __d('me_cms', 'Delete category'), - ['action' => 'delete', $category->get('id'), 'prefix' => ADMIN_PREFIX], - ['class' => 'nav-link text-danger', 'icon' => 'trash-alt', 'confirm' => I18N_SURE_TO_DELETE, 'target' => '_blank'] -)); - /** * Breadcrumb */ $this->Breadcrumbs->add($category->get('title'), ['_name' => 'pagesCategory', $category->get('title')]); -$pages = collection($category->get('pages')) - ->map(fn(Page $page): string => $this->Html->link($page->get('title'), $page->get('url'))) - ->toList(); +$pagesLinks = array_map(fn(Page $page): string => $this->Html->link($page->get('title'), $page->get('url')), $category->get('pages')); -echo $this->Html->ul($pages, ['icon' => 'caret-right']); +echo $this->Html->ul($pagesLinks, ['icon' => 'caret-right']); diff --git a/templates/Posts/view.php b/templates/Posts/view.php index 1aceb944c..e7a49839f 100644 --- a/templates/Posts/view.php +++ b/templates/Posts/view.php @@ -11,38 +11,18 @@ * @copyright Copyright (c) Mirko Pagliai * @link https://github.com/mirko-pagliai/me-cms * @license https://opensource.org/licenses/mit-license.php MIT License - * + */ +use MeCms\Model\Entity\Post; + +/** * @var \MeCms\Model\Entity\Post $post * @var \Cake\Collection\Collection<\MeCms\Model\Entity\Post> $related * @var \MeCms\View\View\AppView $this */ -use MeCms\Model\Entity\Post; - $this->extend('/common/view'); $this->assign('title', $post->get('title')); -/** - * Userbar - */ -$class = 'badge badge-warning'; -if (!$post->get('active')) { - $this->addToUserbar($this->Html->span(I18N_DRAFT, compact('class'))); -} -if ($post->get('created')->isFuture()) { - $this->addToUserbar($this->Html->span(I18N_SCHEDULED, compact('class'))); -} -$this->addToUserbar($this->Html->link( - __d('me_cms', 'Edit post'), - ['action' => 'edit', $post->get('id'), 'prefix' => ADMIN_PREFIX], - ['class' => 'nav-link', 'icon' => 'pencil-alt', 'target' => '_blank'] -)); -$this->addToUserbar($this->Form->postLink( - __d('me_cms', 'Delete post'), - ['action' => 'delete', $post->get('id'), 'prefix' => ADMIN_PREFIX], - ['class' => 'nav-link text-danger', 'icon' => 'trash-alt', 'confirm' => I18N_SURE_TO_DELETE, 'target' => '_blank'] -)); - /** * Breadcrumb */ @@ -89,14 +69,13 @@ isEmpty()) : ?> map(fn(Post $post): string => $this->Html->link($post->get('title'), ['_name' => 'post', $post->get('slug')])) + $relatedAsLinks = $related->map(fn(Post $post): string => $this->Html->link($post->get('title'), ['_name' => 'post', $post->get('slug')])) ->toArray(); ?>