19 declare(strict_types=1);
63 $this->
ctrl = $DIC->ctrl();
64 $this->
lng = $DIC->language();
65 $this->tpl = $DIC->ui()->mainTemplate();
66 $this->tabs_gui = $DIC->tabs();
67 $this->toolbar_gui = $DIC->toolbar();
68 $this->
http = $DIC->http();
70 $this->ui_factory = $DIC->ui()->factory();
71 $this->ui_renderer = $DIC->ui()->renderer();
72 $this->irss = $DIC->resourceStorage();
76 $this->parent_gui->getRefId(),
83 $DIC->ui()->factory(),
84 $DIC->resourceStorage()
88 $this->
lng->loadLanguageModule(
"meta");
93 $next_class = $this->
ctrl->getNextClass($this);
94 $cmd = $this->
ctrl->getCmd();
97 !$this->access_service->hasCurrentUserVisibleAccess() ||
98 !$this->access_service->hasCurrentUserReadAccess()
103 switch ($next_class) {
104 case strtolower(ilMDCopyrightUsageGUI::class):
106 $this->
ctrl->setReturn($this,
'showCopyrightSelection');
109 $this->
ctrl->forwardCommand($gui);
112 case strtolower(ilMDCopyrightImageUploadHandlerGUI::class):
114 $file_id = empty($entry?->copyrightData()?->imageFile()) ?
'' : $entry?->copyrightData()?->imageFile();
120 if (!$cmd || $cmd ===
'view') {
121 $cmd =
'showCopyrightSettings';
132 !$this->access_service->hasCurrentUserVisibleAccess() ||
133 !$this->access_service->hasCurrentUserReadAccess()
137 $this->tabs_gui->setTabActive(
'md_copyright');
139 $this->tabs_gui->addSubTab(
140 'md_copyright_settings',
141 $this->
lng->txt(
'settings'),
142 $this->
ctrl->getLinkTarget($this,
'showCopyrightSettings')
145 $this->tabs_gui->addSubTab(
146 'md_copyright_selection',
147 $this->
lng->txt(
'md_copyright_selection'),
148 $this->
ctrl->getLinkTarget($this,
'showCopyrightSelection')
151 if (in_array($active_subtab, [
152 'md_copyright_settings',
153 'md_copyright_selection' 155 $this->tabs_gui->activateSubTab($active_subtab);
158 $this->tabs_gui->activateSubTab(
'md_copyright_settings');
168 $this->tpl->setContent($form->getHTML());
177 $has_write = $this->access_service->hasCurrentUserWriteAccess();
180 $table_gui->setTitle($this->
lng->txt(
"md_copyright_selection"));
181 $table_gui->parseSelections();
185 foreach ($this->
repository->getAllEntries() as $entry) {
186 if ($entry->id() === $current_id) {
187 $modal = $current_modal;
191 $table_gui->setEditModalSignal($entry->id(), $modal->getShowSignal());
192 $edit_modals[] = $modal;
194 if ($current_id === 0 && !is_null($current_modal)) {
195 $add_modal = $current_modal;
199 $this->toolbar_gui->addComponent($this->ui_factory->button()->standard(
200 $this->
lng->txt(
'md_copyright_add'),
201 $add_modal->getShowSignal()
204 $table_gui->addMultiCommand(
"confirmDeleteEntries", $this->
lng->txt(
"delete"));
205 $table_gui->setSelectAllCheckbox(
"entry_id");
208 $this->tpl->setContent(
209 $table_gui->getHTML() .
210 (isset($add_modal) ? $this->ui_renderer->render($add_modal) :
'') .
211 $this->ui_renderer->render($edit_modals)
217 if (!$this->access_service->hasCurrentUserWriteAccess()) {
218 $this->
ctrl->redirect($this,
"showCopyrightSettings");
221 if ($form->checkInput()) {
222 $this->
MDSettings()->activateCopyrightSelection((
bool) $form->getInput(
'active'));
224 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
225 $this->
ctrl->redirect($this,
'showCopyrightSettings');
227 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'),
true);
234 ->initCopyrightEditModal(null,
true)
235 ->withRequest($this->
http->request());
237 if (
$data = $modal->getData()) {
240 $data[
'description'],
241 (
bool)
$data[
'outdated'],
242 $data[
'copyright'][
'full_name'],
243 $data[
'copyright'][
'link'],
245 $data[
'copyright'][
'alt_text']
247 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
249 $this->
ctrl->redirect($this,
'showCopyrightSelection');
257 if (!count($entry_ids)) {
258 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
265 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
"deleteEntries"));
266 $c_gui->setHeaderText($this->
lng->txt(
"md_delete_cp_sure"));
267 $c_gui->setCancel($this->
lng->txt(
"cancel"),
"showCopyrightSelection");
268 $c_gui->setConfirm($this->
lng->txt(
"confirm"),
"deleteEntries");
271 foreach ($entry_ids as $entry_id) {
272 $entry = $this->
repository->getEntry($entry_id);
273 $c_gui->addItem(
'entry_id[]', (
string) $entry_id, $entry->title());
275 $this->tpl->setContent($c_gui->getHTML());
281 if (!count($entry_ids)) {
282 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
287 foreach ($entry_ids as $entry_id) {
288 $entry = $this->
repository->getEntry($entry_id);
292 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_copyrights_deleted'));
301 ->initCopyrightEditModal($entry,
true)
302 ->withRequest($this->
http->request());
304 if (
$data = $modal->getData()) {
309 $data[
'description'],
310 (bool) $data[
'outdated'],
311 $data[
'copyright'][
'full_name'],
312 $data[
'copyright'][
'link'],
314 $data[
'copyright'][
'alt_text']
316 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
318 $this->
ctrl->redirect($this,
'showCopyrightSelection');
325 bool $open_on_load =
false 328 $ff = $this->ui_factory->input()->field();
331 ->text($this->
lng->txt(
'title'))
334 ->withMaxLength(255);
338 ->textarea($this->
lng->txt(
'description'))
339 ->
withValue($entry?->description() ??
'');
343 ->radio($this->
lng->txt(
'meta_copyright_usage'))
344 ->withOption(
'0', $this->
lng->txt(
'meta_copyright_in_use'))
345 ->withOption(
'1', $this->
lng->txt(
'meta_copyright_outdated'))
346 ->
withValue((
int) $entry?->isOutdated());
349 $cp_data = $entry?->copyrightData();
352 ->text($this->
lng->txt(
'md_copyright_full_name'))
353 ->
withValue($cp_data?->fullName() ??
'');
357 $this->
lng->txt(
'md_copyright_link'),
358 $this->
lng->txt(
'md_copyright_link_info')
362 $this->
refinery->custom()->transformation(fn($v) => $v instanceof
URI ? $v : null)
366 ->url($this->
lng->txt(
'md_copyright_image_link'))
367 ->
withValue((
string) $cp_data?->imageLink())
369 fn($v) => $v instanceof
URI ? $v : null
372 $file_id = empty($cp_data?->imageFile()) ?
'' : $cp_data?->imageFile();
376 $this->
lng->txt(
'md_copyright_image_file')
379 ->withAcceptedMimeTypes([MimeType::IMAGE__PNG, MimeType::IMAGE__JPEG]);
380 if ($file_id !==
'') {
381 $image_file = $image_file->withValue([$file_id]);
384 $image_value =
'link_group';
385 if (!is_null($cp_data) && !$cp_data->isImageLink()) {
386 $image_value =
'file_group';
391 'link_group' => $ff->group(
392 [
'image_link' => $image_link],
393 $this->lng->txt(
'md_copyright_image_is_link')
395 'file_group' => $ff->group(
396 [
'image_file' => $image_file],
397 $this->lng->txt(
'md_copyright_image_is_file')
400 $this->
lng->txt(
'md_copyright_image')
406 $this->
lng->txt(
'md_copyright_alt_text'),
407 $this->
lng->txt(
'md_copyright_alt_text_info')
414 'full_name' => $full_name,
417 'alt_text' => $alt_text
419 $this->
lng->txt(
'md_copyright_value')
423 if (!isset($entry)) {
424 $title = $this->
lng->txt(
'md_copyright_add');
425 $post_url = $this->
ctrl->getLinkTarget($this,
'saveEntry');
427 $title = $this->
lng->txt(
'md_copyright_edit');
428 $this->
ctrl->setParameter($this,
'entry_id', $entry->id());
429 $post_url = $this->
ctrl->getLinkTarget($this,
'updateEntry');
430 $this->
ctrl->clearParameters($this);
433 $modal = $this->modal_service->modalWithForm(
439 $modal = $modal->withOnLoad($modal->getShowSignal());
447 $form->setFormAction($this->
ctrl->getFormAction($this));
448 $form->setTitle($this->
lng->txt(
'md_copyright_settings'));
450 if ($this->access_service->hasCurrentUserWriteAccess()) {
451 $form->addCommandButton(
'saveCopyrightSettings', $this->
lng->txt(
'save'));
457 $check->setInfo($this->
lng->txt(
'md_copyright_enable_info'));
470 if (!$this->
http->wrapper()->post()->has(
'order')) {
471 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_select_one'),
true);
472 $this->
ctrl->redirect($this,
'showCopyrightSelection');
475 $positions = $this->
http->wrapper()->post()->retrieve(
477 $this->
refinery->kindlyTo()->dictOf(
478 $this->
refinery->kindlyTo()->string()
483 foreach ($positions as $entry_id => $position_ignored) {
484 $ids[] = (
int) $entry_id;
487 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'));
488 $this->
ctrl->redirect($this,
'showCopyrightSelection');
494 if (($image_file = $entry->
copyrightData()->imageFile()) ===
'') {
497 if (
$id = $this->irss->manage()->find($image_file)) {
506 if (($image_file = $entry->
copyrightData()->imageFile()) ===
'') {
510 $data[
'copyright'][
'image'][0] ===
'file_group' &&
511 $image_file === ($data[
'copyright'][
'image'][1][
'image_file'][0] ??
'')
520 $v = $data[
'copyright'][
'image'];
521 if ($v[0] ===
'link_group') {
522 return empty($link = $v[1][
'image_link']) ?
'' : $link;
524 if ($v[0] ===
'file_group') {
525 return $v[1][
'image_file'][0] ??
'';
532 if (!isset($this->md_settings)) {
541 if ($this->
http->wrapper()->query()->has(
'entry_id')) {
542 $entry_id = $this->
http->wrapper()->query()->retrieve(
553 if ($this->
http->wrapper()->post()->has(
'entry_id')) {
554 return $this->
http->wrapper()->post()->retrieve(
556 $this->
refinery->kindlyTo()->listOf(
Interface GlobalHttpState.
ilMDCopyrightSelectionGUI: ilMDCopyrightUsageGUI
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
RendererInterface $renderer
ilObjMDSettingsGUI $parent_gui
ilGlobalTemplateInterface $tpl
ilMDSettingsAccessService $access_service
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
showCopyrightSelection(int $current_id=0, RoundTrip $current_modal=null)
static http()
Fetches the global http state from ILIAS.
deleteFileIfChanged(EntryInterface $entry, array $data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initCopyrightEditModal(EntryInterface $entry=null, bool $open_on_load=false)
The scope of this class is split ilias-conform URI's into components.
ilMDCopyrightImageUploadHandlerGUI: ilMDCopyrightSelectionGUI
extractImageFromData(array $data)
ilToolbarGUI $toolbar_gui
deleteFile(EntryInterface $entry)
getAdministrationFormId()
RepositoryInterface $repository
setCopyrightTabs(string $active_subtab)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ilMDSettings $md_settings
showCopyrightSettings(?ilPropertyFormGUI $form=null)
ilMDSettingsModalService $modal_service
__construct(ilObjMDSettingsGUI $parent_gui)