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