ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Inline.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\UI\Implementation\Component\ComponentHelper;
32use Psr\Http\Message\ServerRequestInterface;
34
35class Inline implements C\Launcher\Inline
36{
37 use ComponentHelper;
38
39 protected I\Modal\Factory $modal_factory;
40 protected Link $target;
41 protected string $label;
42 protected string $description = '';
43 protected ?string $error_note = null;
44 protected null | Icon | ProgressMeter $status_icon = null;
45 protected bool $launchable = true;
46 protected ?I\Modal\Roundtrip $modal = null;
47 protected \Closure $evaluation;
50 protected ?ServerRequestInterface $request = null;
51 protected ?string $modal_submit_label = null;
52 protected ?string $modal_cancel_label = null;
53
54 public function __construct(
55 I\Modal\Factory $modal_factory,
56 Link $target
57 ) {
58 $this->modal_factory = $modal_factory;
59 $this->target = $target;
60 $this->label = $target->getLabel();
61 }
62
63 public function getTarget(): Link
64 {
65 return $this->target;
66 }
67
68 public function withDescription(string $description): self
69 {
70 $clone = clone $this;
71 $clone->description = $description;
72 return $clone;
73 }
74
75 public function getDescription(): string
76 {
77 return $this->description;
78 }
79
80 public function withStatusIcon(null | Icon | ProgressMeter $status_icon): self
81 {
82 $clone = clone $this;
83 $clone->status_icon = $status_icon;
84 return $clone;
85 }
86
87 public function getStatusIcon(): ?C\Component
88 {
89 return $this->status_icon;
90 }
91
92 public function withStatusMessageBox(?MessageBox\MessageBox $status_message): self
93 {
94 $clone = clone $this;
95 $clone->status_message = $status_message;
96 return $clone;
97 }
99 {
100 return $this->status_message;
101 }
102
103 public function withButtonLabel(string $label, bool $launchable = true): self
104 {
105 $clone = clone $this;
106 $clone->label = $label;
107 $clone->launchable = $launchable;
108 return $clone;
109 }
110
111 public function getButtonLabel(): ?string
112 {
113 return $this->label;
114 }
115
116 public function isLaunchable(): bool
117 {
118 return $this->launchable;
119 }
120
121 public function withInputs(Group $fields, \Closure $evaluation, ?MessageBox\MessageBox $instruction = null): self
122 {
123 $modal = $this->modal_factory->roundtrip(
124 $this->getButtonLabel(),
125 $instruction,
126 $fields->getInputs(),
127 $this->getTarget()->getURL()->__toString()
128 );
129 $clone = clone $this;
130 $clone->modal = $modal;
131 $clone->evaluation = $evaluation;
132 return $clone;
133 }
134
135 public function withRequest(ServerRequestInterface $request): self
136 {
137 $clone = clone $this;
138 $clone->request = $request;
139 return $clone;
140 }
141
142 public function getResult(): ?Result
143 {
144 if ($this->request && $this->request->getMethod() == "POST") {
145 $modal = $this->modal->withRequest($this->request);
146 $result = $modal->getForm()->getInputGroup()->getContent();
147 return $result;
148 }
149 return null;
150 }
151
152 public function getModal(): ?I\Modal\Roundtrip
153 {
154 return $this->modal;
155 }
156
157 public function getEvaluation(): \Closure
158 {
159 return $this->evaluation;
160 }
161
162 public function withModalSubmitLabel(?string $label): self
163 {
164 $clone = clone $this;
165 $clone->modal_submit_label = $label;
166 return $clone;
167 }
168
169 public function getModalSubmitLabel(): ?string
170 {
171 return $this->modal_submit_label;
172 }
173
174 public function withModalCancelLabel(?string $label): self
175 {
176 $clone = clone $this;
177 $clone->modal_cancel_label = $label;
178 return $clone;
179 }
180
181 public function getModalCancelLabel(): ?string
182 {
183 return $this->modal_cancel_label;
184 }
185}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
withRequest(ServerRequestInterface $request)
Definition: Inline.php:135
__construct(I\Modal\Factory $modal_factory, Link $target)
Definition: Inline.php:54
withButtonLabel(string $label, bool $launchable=true)
Definition: Inline.php:103
withStatusMessageBox(?MessageBox\MessageBox $status_message)
Definition: Inline.php:92
withInputs(Group $fields, \Closure $evaluation, ?MessageBox\MessageBox $instruction=null)
Definition: Inline.php:121
withStatusIcon(null|Icon|ProgressMeter $status_icon)
Definition: Inline.php:80
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:29
Describes the monoid operation of grouping form inputs.
Definition: Group.php:32
This describes commonalities between the different modals.
Definition: Modal.php:35
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:29
modal(string $title="", string $cancel_label="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21