19declare(strict_types=1);
60 $this->
ctrl = $DIC->ctrl();
61 $this->
lng = $DIC->language();
62 $this->tpl =
$DIC->ui()->mainTemplate();
63 $this->toolbar_gui =
$DIC->toolbar();
64 $this->
http = $DIC->http();
66 $this->ui_factory =
$DIC->ui()->factory();
67 $this->ui_renderer =
$DIC->ui()->renderer();
68 $this->irss =
$DIC->resourceStorage();
72 $this->parent_obj_gui->getRefId(),
76 $DIC->ui()->factory(),
77 $DIC->resourceStorage()
81 $this->
lng->loadLanguageModule(
"meta");
86 $next_class = $this->
ctrl->getNextClass($this);
87 $cmd = $this->
ctrl->getCmd();
89 if (!$this->access_service->hasCurrentUserReadAccess()) {
93 switch ($next_class) {
94 case strtolower(ilMDCopyrightUsageGUI::class):
96 $this->
ctrl->setReturn($this,
'showCopyrightSelection');
99 $this->
ctrl->forwardCommand($gui);
102 case strtolower(ilMDCopyrightImageUploadHandlerGUI::class):
104 $file_id = empty($entry?->copyrightData()?->imageFile()) ?
'' : $entry?->copyrightData()?->imageFile();
110 if (!$cmd || $cmd ===
'view') {
111 $cmd =
'showCopyrightSelection';
123 $has_write = $this->access_service->hasCurrentUserWriteAccess();
129 'showCopyrightSelection',
132 $table_gui->setTitle($this->
lng->txt(
"md_copyright_selection"));
133 $table_gui->parseSelections();
137 foreach ($this->
repository->getAllEntries() as $entry) {
138 if ($entry->id() === $current_id) {
139 $modal = $current_modal;
143 $table_gui->setEditModalSignal($entry->id(), $modal->getShowSignal());
144 $edit_modals[] = $modal;
146 if ($current_id === 0 && !is_null($current_modal)) {
147 $add_modal = $current_modal;
151 $this->toolbar_gui->addComponent($this->ui_factory->button()->standard(
152 $this->lng->txt(
'md_copyright_add'),
153 $add_modal->getShowSignal()
156 $table_gui->addMultiCommand(
"confirmDeleteEntries", $this->
lng->txt(
"delete"));
157 $table_gui->setSelectAllCheckbox(
"entry_id");
160 $this->tpl->setContent(
161 $table_gui->getHTML() .
162 (isset($add_modal) ? $this->ui_renderer->render($add_modal) :
'') .
163 $this->ui_renderer->render($edit_modals)
170 ->initCopyrightEditModal(
null,
true)
171 ->withRequest($this->
http->request());
173 if (
$data = $modal->getData()) {
176 $data[
'description'],
177 (
bool)
$data[
'outdated'],
178 $data[
'copyright'][
'full_name'],
179 $data[
'copyright'][
'link'],
180 $this->extractImageFromData(
$data),
181 $data[
'copyright'][
'alt_text']
183 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
185 $this->
ctrl->redirect($this,
'showCopyrightSelection');
187 $this->showCopyrightSelection(0, $modal);
192 $entry_ids = $this->initEntryIdFromPost();
193 if (!count($entry_ids)) {
194 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
195 $this->showCopyrightSelection();
201 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
"deleteEntries"));
202 $c_gui->setHeaderText($this->
lng->txt(
"md_delete_cp_sure"));
203 $c_gui->setCancel($this->
lng->txt(
"cancel"),
"showCopyrightSelection");
204 $c_gui->setConfirm($this->
lng->txt(
"confirm"),
"deleteEntries");
207 foreach ($entry_ids as $entry_id) {
208 $entry = $this->
repository->getEntry($entry_id);
209 $c_gui->addItem(
'entry_id[]', (
string) $entry_id, $entry->title());
211 $this->tpl->setContent($c_gui->getHTML());
216 $entry_ids = $this->initEntryIdFromPost();
217 if (!count($entry_ids)) {
218 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
219 $this->showCopyrightSelection();
223 foreach ($entry_ids as $entry_id) {
224 $entry = $this->
repository->getEntry($entry_id);
225 $this->deleteFile($entry);
228 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_copyrights_deleted'));
229 $this->showCopyrightSelection();
235 $entry = $this->
repository->getEntry($this->initEntryIdFromQuery());
237 ->initCopyrightEditModal($entry,
true)
238 ->withRequest($this->
http->request());
240 if (
$data = $modal->getData()) {
241 $this->deleteFileIfChanged($entry,
$data);
245 $data[
'description'],
246 (
bool)
$data[
'outdated'],
247 $data[
'copyright'][
'full_name'],
248 $data[
'copyright'][
'link'],
249 $this->extractImageFromData(
$data),
250 $data[
'copyright'][
'alt_text']
252 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
254 $this->
ctrl->redirect($this,
'showCopyrightSelection');
256 $this->showCopyrightSelection($entry->id(), $modal);
261 bool $open_on_load =
false
264 $ff = $this->ui_factory->input()->field();
267 ->text($this->
lng->txt(
'title'))
268 ->withValue($entry?->title() ??
'')
270 ->withMaxLength(255);
274 ->textarea($this->
lng->txt(
'description'))
275 ->withValue($entry?->description() ??
'');
279 ->radio($this->
lng->txt(
'meta_copyright_usage'))
280 ->withOption(
'0', $this->
lng->txt(
'meta_copyright_in_use'))
281 ->withOption(
'1', $this->
lng->txt(
'meta_copyright_outdated'))
282 ->withValue((
int) $entry?->isOutdated());
285 $cp_data = $entry?->copyrightData();
288 ->text($this->
lng->txt(
'md_copyright_full_name'))
289 ->withValue($cp_data?->fullName() ??
'');
293 $this->
lng->txt(
'md_copyright_link'),
294 $this->lng->txt(
'md_copyright_link_info')
296 ->withValue((
string) $cp_data?->
link())
297 ->withAdditionalTransformation(
298 $this->
refinery->custom()->transformation(fn($v) => $v instanceof
URI ? $v :
null)
302 ->url($this->
lng->txt(
'md_copyright_image_link'))
303 ->withValue((
string) $cp_data?->imageLink())
304 ->withAdditionalTransformation($this->
refinery->custom()->transformation(
305 fn($v) => $v instanceof
URI ? $v :
null
308 $file_id = empty($cp_data?->imageFile()) ?
'' : $cp_data?->imageFile();
312 $this->
lng->txt(
'md_copyright_image_file')
315 ->withAcceptedMimeTypes([MimeType::IMAGE__PNG, MimeType::IMAGE__JPEG]);
316 if ($file_id !==
'') {
317 $image_file = $image_file->withValue([$file_id]);
320 $image_value =
'link_group';
321 if (!is_null($cp_data) && !$cp_data->isImageLink()) {
322 $image_value =
'file_group';
327 'link_group' => $ff->group(
328 [
'image_link' => $image_link],
329 $this->lng->txt(
'md_copyright_image_is_link')
331 'file_group' => $ff->group(
332 [
'image_file' => $image_file],
333 $this->lng->txt(
'md_copyright_image_is_file')
336 $this->lng->txt(
'md_copyright_image')
338 ->withValue($image_value);
342 $this->
lng->txt(
'md_copyright_alt_text'),
343 $this->lng->txt(
'md_copyright_alt_text_info')
345 ->withValue($cp_data?->altText() ??
'');
350 'full_name' => $full_name,
353 'alt_text' => $alt_text
355 $this->
lng->txt(
'md_copyright_value')
359 if (!isset($entry)) {
360 $title = $this->
lng->txt(
'md_copyright_add');
361 $post_url = $this->
ctrl->getLinkTarget($this,
'saveEntry');
363 $title = $this->
lng->txt(
'md_copyright_edit');
364 $this->
ctrl->setParameter($this,
'entry_id', $entry->id());
365 $post_url = $this->
ctrl->getLinkTarget($this,
'updateEntry');
366 $this->
ctrl->clearParameters($this);
369 $modal = $this->ui_factory->modal()->roundtrip(
376 $modal = $modal->withOnLoad($modal->getShowSignal());
383 if (!$this->
http->wrapper()->post()->has(
'order')) {
384 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_select_one'),
true);
385 $this->
ctrl->redirect($this,
'showCopyrightSelection');
388 $positions = $this->
http->wrapper()->post()->retrieve(
390 $this->
refinery->kindlyTo()->dictOf(
391 $this->refinery->kindlyTo()->string()
396 foreach ($positions as $entry_id => $position_ignored) {
397 $ids[] = (
int) $entry_id;
400 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'));
401 $this->
ctrl->redirect($this,
'showCopyrightSelection');
407 if (($image_file = $entry->
copyrightData()->imageFile()) ===
'') {
410 if (
$id = $this->irss->manage()->find($image_file)) {
419 if (($image_file = $entry->copyrightData()->imageFile()) ===
'') {
423 $data[
'copyright'][
'image'][0] ===
'file_group' &&
424 $image_file === (
$data[
'copyright'][
'image'][1][
'image_file'][0] ??
'')
428 $this->deleteFile($entry);
433 $v =
$data[
'copyright'][
'image'];
434 if ($v[0] ===
'link_group') {
435 return empty($link = $v[1][
'image_link']) ?
'' : $link;
437 if ($v[0] ===
'file_group') {
438 return $v[1][
'image_file'][0] ??
'';
446 if ($this->
http->wrapper()->query()->has(
'entry_id')) {
447 $entry_id = $this->
http->wrapper()->query()->retrieve(
458 if ($this->
http->wrapper()->post()->has(
'entry_id')) {
459 return $this->
http->wrapper()->post()->retrieve(
461 $this->
refinery->kindlyTo()->listOf(
462 $this->refinery->kindlyTo()->int()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
The scope of this class is split ilias-conform URI's into components.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
@ilCtrl_Calls ilMDCopyrightConfigurationGUI: ilMDCopyrightUsageGUI, ilMDCopyrightImageUploadHandlerGU...
RepositoryInterface $repository
deleteFileIfChanged(EntryInterface $entry, array $data)
showCopyrightSelection(int $current_id=0, ?RoundTrip $current_modal=null)
ilGlobalTemplateInterface $tpl
deleteFile(EntryInterface $entry)
ilObjMDSettingsGUI $parent_obj_gui
RendererInterface $renderer
ilMDSettingsAccessService $access_service
__construct(ilObjMDSettingsGUI $parent_obj_gui)
ilToolbarGUI $toolbar_gui
extractImageFromData(array $data)
initCopyrightEditModal(?EntryInterface $entry=null, bool $open_on_load=false)
Interface GlobalHttpState.
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.
link(string $caption, string $href, bool $new_viewport=false)
if(!file_exists('../ilias.ini.php'))