ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
StandardActionProvider.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 use ILIAS\Data\URI;
27 
32 final class StandardActionProvider implements ActionProvider
33 {
34  private const ACTION_UNZIP = 'unzip';
35  private const ACTION_DOWNLOAD = 'download';
36  private const ACTION_REMOVE = 'remove';
37 
38  private \ilLanguage $language;
39  private \ilCtrlInterface $ctrl;
40  private \ILIAS\UI\Component\Modal\RoundTrip $add_directory_modal;
41  private \ILIAS\UI\Factory $ui_factory;
42  private bool $show_paths = false;
43 
44  public function __construct(
45  private Request $request
46  ) {
47  global $DIC;
48  $this->ui_factory = $DIC->ui()->factory();
49  $this->language = $DIC->language();
50  $this->ctrl = $DIC->ctrl();
51  $this->initModals();
52  }
53 
54  protected function initModals(): void
55  {
56  $this->add_directory_modal = $this->ui_factory->modal()->roundtrip(
57  $this->language->txt('create_directory'),
58  [],
59  [
60  $this->ui_factory->input()->field()->text(
61  $this->language->txt('directory_name'),
62  $this->language->txt('directory_name_info'),
63  )->withRequired(true)
64  ],
65  $this->ctrl->getFormActionByClass(\ilContainerResourceGUI::class, \ilContainerResourceGUI::ADD_DIRECTORY)
66  );
67  }
68 
70  {
72  }
73 
74  public function getComponents(): array
75  {
76  $components = [
78  ];
79 
80  if ($this->show_paths) {
81  $components[] = $this->ui_factory->messageBox()->info(
82  implode('<br>', array_keys($this->request->getWrapper()->getData()))
83  );
84  }
85 
86  return $components;
87  }
88 
89  public function getTopActions(): array
90  {
91  return [
92  new TopAction(
93  $this->language->txt('create_directory'),
94  $this->add_directory_modal->getShowSignal()
95  ),
96  new TopAction(
97  $this->language->txt('download_zip'),
99  ),
100  ];
101  }
102 
103  public function getSingleActions(Request $view_request): array
104  {
105  $single_actions = [
106  self::ACTION_DOWNLOAD => new SingleAction(
107  $this->language->txt(self::ACTION_DOWNLOAD),
109  false,
110  false,
111  false
112  )
113  ];
114  if ($view_request->canUserAdministrate()) {
115  $single_actions[self::ACTION_REMOVE] = new SingleAction(
116  $this->language->txt(self::ACTION_REMOVE),
118  true,
119  true,
120  true
121  );
122 
123  $single_actions[self::ACTION_UNZIP] = new SingleAction(
124  $this->language->txt(self::ACTION_UNZIP),
126  false,
127  false,
128  false,
129  ['application/zip', 'application/x-zip-compressed']
130  );
131  }
132 
133  return $single_actions;
134  }
135 
136  private function buildURI(
137  string $command
138  ): URI {
139  return $this->retrieveURI(
140  \ilContainerResourceGUI::class,
141  $command
142  );
143  }
144 
145  public function retrieveURI(
146  string $class,
147  string $command
148  ): URI {
149  return new URI(
150  ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
151  $class,
152  $command
153  )
154  );
155  }
156 
157 }
This describes commonalities between the different modals.
Definition: Modal.php:34
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$components
global $DIC
Definition: shib_login.php:25
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34
language()
description: > Example for rendring a language glyph.
Definition: language.php:25