1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui\Layout;
6:
7: use Atk4\Ui\Layout;
8:
9: /**
10: * Implements a fixed-width single-column bevel in the middle of the page, centered
11: * horizontally and vertically. Icon / Title will appear above the bevel.
12: *
13: * Bevel will use some padding and will contain your Content.
14: * This layout is handy for a simple and single-purpose applications.
15: */
16: class Centered extends Layout
17: {
18: use \Atk4\Core\DebugTrait;
19:
20: public $defaultTemplate = 'layout/centered.html';
21:
22: /** @var string|null @see App::$cdn */
23: public $image;
24: /** @var string */
25: public $imageAlt = 'Logo';
26:
27: #[\Override]
28: protected function init(): void
29: {
30: parent::init();
31:
32: // if image is still unset load it when layout is initialized from the App
33: if ($this->image === null) {
34: $this->image = $this->getApp()->cdn['atk'] . '/logo.png';
35: }
36:
37: // set application's title
38: $this->template->trySet('title', $this->getApp()->title);
39: }
40:
41: #[\Override]
42: protected function renderView(): void
43: {
44: if ($this->image) {
45: $this->template->tryDangerouslySetHtml('HeaderImage', $this->getApp()->getTag('img/', ['class' => 'ui image', 'src' => $this->image, 'alt' => $this->imageAlt]));
46: }
47:
48: parent::renderView();
49: }
50: }
51: