v0.9.5
This commit is contained in:
commit
6aa66cfa49
286 files changed
+19274
No files matched your search
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\Pages;
|
||||
|
||||
use IriksIT\Manager\Models\Page;
|
||||
use IriksIT\Manager\Modules\BaseModule;
|
||||
use IriksIT\Manager\Support\Frontend;
|
||||
use IriksIT\Manager\Support\MediaUsage;
|
||||
use IriksIT\Manager\Support\Names;
|
||||
use IriksIT\Manager\Support\Permission;
|
||||
|
||||
class PagesModule extends BaseModule
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'pages';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Pages';
|
||||
}
|
||||
|
||||
public function enabledByDefault(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function tables(): array
|
||||
{
|
||||
return ['pages', 'block_templates'];
|
||||
}
|
||||
|
||||
/** The page API for a frontend of its own and the pages the package draws itself (`manager.frontend`): nothing unless the site switches it on. */
|
||||
public function publicRoutes(): ?string
|
||||
{
|
||||
return Frontend::api() || Frontend::renders() ? __DIR__.'/public-routes.php' : null;
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
{
|
||||
return [
|
||||
new Permission('pages.edit', 'Change the texts of the pages', 'Site content'),
|
||||
new Permission('pages.layout', 'Add, move, hide and remove the blocks of a page', 'Site content', needs: ['pages.edit']),
|
||||
];
|
||||
}
|
||||
|
||||
public function navigation(): array
|
||||
{
|
||||
return [
|
||||
['label' => 'Pages', 'section' => 'Content', 'route' => Names::route('pages.index'), 'permission' => 'pages.edit', 'simple' => true, 'hint' => 'Change the texts and photos of your pages'],
|
||||
];
|
||||
}
|
||||
|
||||
/** The tour: how a page of blocks is built and where the photos come from. Only for a site that has pages of blocks. */
|
||||
public function tutorial(): array
|
||||
{
|
||||
$blocks = (bool) config('manager.blocks.free_pages') || array_filter(Page::definitions(), fn ($definition) => ! empty($definition['blocks'])) !== [];
|
||||
|
||||
if (! $blocks) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
['title' => 'Build a page from parts', 'text' => 'A page is made of parts: a big photo with a title, a text, photos, questions and answers. Open a page, press "Add something to the page", pick a part and fill it in. The arrows move a part up or down.', 'image' => 'pages', 'menu' => 'pages.index', 'permission' => 'pages.layout'],
|
||||
['title' => 'Photos from your phone', 'text' => 'Wherever you can choose a photo, you can also pick one from your phone or take a new one. It is made smaller by itself, so do not worry about the size. Tip: hold your phone sideways for a wide photo and keep what matters in the middle.', 'image' => 'photos', 'permission' => 'media.upload'],
|
||||
];
|
||||
}
|
||||
|
||||
/** Where the media library looks for the use of a file: the texts of the pages. */
|
||||
public function views(): array
|
||||
{
|
||||
return ['pages.index' => 'Opened the pages', 'pages.show' => 'Opened a page'];
|
||||
}
|
||||
|
||||
public function actions(): array
|
||||
{
|
||||
return [
|
||||
'pages.store' => ['Created a page'],
|
||||
'pages.update' => ['Changed a page'],
|
||||
'pages.destroy' => ['Removed a page'],
|
||||
'pages.preview' => ['Prepared a preview of a page'],
|
||||
];
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
app(MediaUsage::class)->register(fn () => Page::query()->get(['body', 'content'])->flatMap(fn (Page $row) => [$row->body, ...array_values(array_filter((array) $row->content, 'is_string'))]));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user