ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
PanelContent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
28use ILIAS\UI\Factory as UIFactory;
34
36{
37 public function __construct(
38 protected Actions $actions,
39 protected PropertiesFetcher $properties_fetcher,
40 protected UIFactory $ui_factory,
41 protected PresenterInterface $presenter
42 ) {
43 }
44
48 public function content(
49 PathInterface $base_path,
50 ElementInterface $element,
51 bool $is_subpanel,
53 ): Generator {
54 $buttons = [];
55 $delete_modal = $this->actions->getModal()->delete(
56 $base_path,
57 $element,
58 true
59 );
60 if ($delete_modal) {
61 $buttons[] = $this->actions->getButton()->delete(
62 $delete_modal->getFlexibleSignal(),
63 true,
64 true
65 );
66 yield ContentType::MODAL => $delete_modal;
67 }
68 foreach ($element->getSubElements() as $sub) {
69 if (!$sub->isScaffold()) {
70 continue;
71 }
72 $create_modal = $this->actions->getModal()->create(
73 $base_path,
74 $sub,
75 $request
76 );
77 $buttons[] = $this->actions->getButton()->create(
78 $create_modal->getFlexibleSignal(),
79 $sub,
80 true
81 );
82 yield ContentType::MODAL => $create_modal;
83 }
84 $dropdown = $this->ui_factory->dropdown()->standard($buttons);
85
86 if ($is_subpanel) {
87 $panel = $this->ui_factory->panel()->sub(
88 $this->presenter->elements()->nameWithRepresentation(false, $element),
89 $this->listing($element) ?? []
90 )->withActions($dropdown);
91 } else {
92 $panel = $this->ui_factory->panel()->standard(
93 $this->presenter->elements()->nameWithParents($element),
94 $this->listing($element) ?? []
95 )->withActions($dropdown);
96 }
97 yield ContentType::MAIN => $panel;
98 }
99
100 protected function listing(
101 ElementInterface $element
102 ): ?Listing {
103 $properties = $this->properties_fetcher->getPropertiesByPreview($element);
104 $properties = iterator_to_array($properties);
105 if (!empty($properties)) {
106 return $this->ui_factory->listing()
107 ->characteristicValue()
108 ->text($properties);
109 }
110 return null;
111 }
112}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
content(PathInterface $base_path, ElementInterface $element, bool $is_subpanel, ?RequestForFormInterface $request)
listing(ElementInterface $element)
__construct(protected Actions $actions, protected PropertiesFetcher $properties_fetcher, protected UIFactory $ui_factory, protected PresenterInterface $presenter)
This describes how a panel could be modified during construction of UI.
Definition: Panel.php:31