ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PanelContent.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\MetaData\Editor\Full\Services\Services as FullEditorServices;
28use ILIAS\UI\Factory as UIFactory;
32
34{
35 protected UIFactory $ui_factory;
36 protected FullEditorServices $services;
38
39 public function __construct(
40 FullEditorServices $services,
41 UIFactory $ui_factory,
43 ) {
44 $this->services = $services;
45 $this->ui_factory = $ui_factory;
46 $this->presenter = $presenter;
47 }
48
52 public function content(
53 PathInterface $base_path,
54 ElementInterface $element,
55 bool $is_subpanel,
57 ): \Generator {
58 $buttons = [];
59 $delete_modal = $this->services->actions()->getModal()->delete(
60 $base_path,
61 $element,
62 true
63 );
64 if ($delete_modal) {
65 $buttons[] = $this->services->actions()->getButton()->delete(
66 $delete_modal->getFlexibleSignal(),
67 true,
68 true
69 );
70 yield ContentType::MODAL => $delete_modal;
71 }
72 foreach ($element->getSubElements() as $sub) {
73 if (!$sub->isScaffold()) {
74 continue;
75 }
76 $create_modal = $this->services->actions()->getModal()->create(
77 $base_path,
78 $sub,
79 $request
80 );
81 $buttons[] = $this->services->actions()->getButton()->create(
82 $create_modal->getFlexibleSignal(),
83 $sub,
84 true
85 );
86 yield ContentType::MODAL => $create_modal;
87 }
88 $dropdown = $this->ui_factory->dropdown()->standard($buttons);
89
90 if ($is_subpanel) {
91 $panel = $this->ui_factory->panel()->sub(
92 $this->presenter->elements()->nameWithRepresentation(false, $element),
93 $this->listing($element) ?? []
94 )->withActions($dropdown);
95 } else {
96 $panel = $this->ui_factory->panel()->standard(
97 $this->presenter->elements()->nameWithParents($element),
98 $this->listing($element) ?? []
99 )->withActions($dropdown);
100 }
101 yield ContentType::MAIN => $panel;
102 }
103
104 protected function listing(
105 ElementInterface $element
106 ): ?Listing {
107 $properties = $this->services->propertiesFetcher()
108 ->getPropertiesByPreview($element);
109 $properties = iterator_to_array($properties);
110 if (!empty($properties)) {
111 return $this->ui_factory->listing()
112 ->characteristicValue()
113 ->text($properties);
114 }
115 return null;
116 }
117}
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(FullEditorServices $services, UIFactory $ui_factory, PresenterInterface $presenter)
This describes how a panel could be modified during construction of UI.
Definition: Panel.php:31