19declare(strict_types=1);
33use ILIAS\GlobalScreen\GUI\Hasher;
66 $this->ui_factory = $pons->
out()->ui()->factory();
70 $DIC->repositoryTree()
74 $DIC[
'static_url']->builder(),
78 $this->token = $this->pons->in()->buildToken(
'alias',
'id');
79 $this->configuration =
$DIC[
'static_url.config'];
84 $id_from_request = $this->pons->in()->getFirstFromRequest($this->token);
86 if ($this->
repository->hasId($id_from_request)) {
97 $this->pons->flow()->getHereAsURI(self::CMD_SAVE),
108 match ($cmd = $this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
109 self::CMD_DEFAULT => $this->
index(),
110 self::CMD_FORM => $this->
form(),
111 self::CMD_SAVE => $this->
save(),
113 self::CMD_DELETE => $this->
delete(),
115 self::CMD_TOGGLE => $this->
toggle(),
117 default => $this->pons->out()->outString(
118 'Unknown command: ' . $cmd
133 if (($out_form = $form->save()) instanceof
Standard) {
134 $this->pons->out()->out(
143 $this->pons->i18n()->t(
144 'stus_stored_sucessfully'
161 $this->pons->in()->keep(
165 $this->pons->out()->outAsyncAsModal(
166 $this->pons->i18n()->t(
'shortlink'),
167 $this->pons->flow()->getHereAsURI(self::CMD_SAVE),
168 ...iterator_to_array($form->get())
175 if ($this->pons->access()->hasUserPermissionTo(
'write')) {
177 $modal = $this->ui_factory->modal()->roundtrip(
178 $this->pons->i18n()->t(
'create_shortlink'),
182 )->withAsyncRenderUrl(
183 (
string) $this->pons->flow()->getHereAsURI(self::CMD_FORM),
188 $button = $this->ui_factory->button()->primary(
189 $this->pons->i18n()->t(
'create_shortlink'),
190 (
string) $this->pons->flow()->getHereAsURI(self::CMD_FORM),
192 $modal->getShowSignal()
200 $this->link_resolver,
201 $this->pons->flow()->getHereAsURI(self::CMD_SAVE_ORDERING),
203 $this->configuration,
204 $this->pons->access()->hasUserPermissionTo(
'write'),
207 $this->pons->out()->out(...iterator_to_array($table->get()));
212 string $target_command,
215 string $button_title,
220 $this->pons->out()->nok();
221 $this->pons->out()->ok();
223 foreach ($from_request as
$id) {
225 if ($shortlink ===
null) {
230 $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
232 $shortlink->getAlias(),
236 $this->pons->out()->outAsyncAsConfirmation(
240 $this->pons->flow()->getHereAsURI($target_command),
250 $this->pons->i18n()->t(
'delete_shortlink'),
251 $this->pons->i18n()->t(
'delete_shortlink_msg'),
252 $this->pons->i18n()->t(
'delete')
257 private function delete():
void
259 $from_request = $this->getAllIds();
260 foreach ($from_request as
$id) {
262 if ($shortlink ===
null) {
268 $this->pons->out()->success($this->pons->i18n()->t(
'shortlinks_deleted'));
269 $this->pons->flow()->redirect(self::CMD_DEFAULT);
277 $this->pons->i18n()->t(
'toggle_shortlink'),
278 $this->pons->i18n()->t(
'toggle_shortlink_msg'),
279 $this->pons->i18n()->t(
'toggle')
286 $from_request = $this->getAllIds();
287 foreach ($from_request as
$id) {
289 if ($shortlink ===
null) {
292 $shortlink = $shortlink->withActive(
293 !$shortlink->isActive()
299 $this->pons->out()->success($this->pons->i18n()->t(
'shortlinks_toggled'));
300 $this->pons->flow()->redirect(self::CMD_DEFAULT);
306 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
307 $item = $this->
repository->getById($this->unhash($hashed_id));
308 $item = $item->withPosition((
int) $position);
311 $this->pons->out()->success($this->pons->i18n()->translate(
'order_saved'));
312 $this->pons->flow()->redirect(self::CMD_DEFAULT);
317 $from_request = $this->pons->in()->getAllFromRequest($this->token);
318 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
321 iterator_to_array($this->
repository->getAll())
324 return array_unique($from_request);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
const string CMD_SAVE_ORDERING
TargetLinkResolver $link_resolver
Configuration $configuration
const string CMD_CONFIRM_TOGGLE
confirm(string $target_command, string $title, string $message, string $button_title,)
const string CMD_CONFIRM_DELETE
This is how the factory for UI elements looks.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.