forked from laysense/laysite
Add page publication history and reusable blocks
This commit is contained in:
@@ -132,13 +132,17 @@ final class DesignLibrary
|
||||
];
|
||||
}
|
||||
|
||||
public static function layout(string $kind, array $site, array $page): array
|
||||
public static function layout(string $kind, array $site, array $page, bool $preview = false): array
|
||||
{
|
||||
$id = (int) ($page[$kind . '_id'] ?? 0) ?: (int) ($site[$kind . '_id'] ?? 0);
|
||||
$repo = new Repository();
|
||||
foreach (array_unique([(int) ($page[$kind . '_id'] ?? 0), (int) ($site[$kind . '_id'] ?? 0)]) as $id) {
|
||||
$layout = self::find($id, $kind);
|
||||
if ($layout && ($preview || $repo->layoutPage($id) !== null)) {
|
||||
return $layout;
|
||||
}
|
||||
}
|
||||
|
||||
return self::find($id, $kind) ?? [
|
||||
'id' => 0, 'preset' => array_key_first(self::PRESETS[$kind]), 'payload' => self::defaults($kind),
|
||||
];
|
||||
return ['id' => 0, 'preset' => array_key_first(self::PRESETS[$kind]), 'payload' => self::defaults($kind)];
|
||||
}
|
||||
|
||||
public static function selection(string $kind, mixed $value): ?int
|
||||
@@ -256,7 +260,7 @@ final class DesignLibrary
|
||||
}
|
||||
|
||||
$page = (new Repository())->layoutPage((int) $layout['id']);
|
||||
if ($page !== null && !LayoutPage::hasMember($page['sections'])) {
|
||||
if ($page === null || !LayoutPage::hasMember($page['sections'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user