diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 57bac8a0b2fe..2ad8cc197f72 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -3772,6 +3772,7 @@ common#:#copy_all#:#Alle kopieren common#:#copy_n_of_suffix#:#- Kopie (%1$s) common#:#copy_of#:#Kopie von common#:#copy_of_suffix#:#- Kopie +common#:#copy_perma_link#:#Link in Zwischenablage kopieren common#:#copy_selected_items#:#Kopieren common#:#count#:#Anzahl common#:#counter_novelty#:#Neuigkeiten @@ -5254,6 +5255,7 @@ common#:#pd_items_news#:#Einschließlich Neuigkeiten der ausgewählten Objekte common#:#pdf_export#:#PDF-Export common#:#perm_settings#:#Rechte common#:#perma_link#:#Link zu dieser Seite +common#:#perma_link_copied#:#Link zu dieser Seite wurde in die Zwischenablage kopiert. common#:#permission#:#Recht common#:#permission_denied#:#Kein Zugriffsrecht common#:#permission_settings#:#Rechteeinstellungen diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 89f6673d37bc..10ab787bbb3e 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -3772,6 +3772,7 @@ common#:#copy_all#:#Copy all common#:#copy_n_of_suffix#:#- Copy (%1$s) common#:#copy_of#:#Copy of common#:#copy_of_suffix#:#- Copy +common#:#copy_perma_link#:#Copy link to clipboard common#:#copy_selected_items#:#Copy common#:#count#:#Count common#:#counter_novelty#:#News @@ -5254,6 +5255,7 @@ common#:#pd_items_news#:#Include News of Personal Items common#:#pdf_export#:#PDF Export common#:#perm_settings#:#Permissions common#:#perma_link#:#Permanent Link +common#:#perma_link_copied#:#Link to this page has been copied to the clipboard. common#:#permission#:#Permission common#:#permission_denied#:#Permission Denied common#:#permission_settings#:#Object Permission Settings diff --git a/src/UI/Implementation/Component/MainControls/Renderer.php b/src/UI/Implementation/Component/MainControls/Renderer.php index 145f67260e3e..79a12236a36c 100644 --- a/src/UI/Implementation/Component/MainControls/Renderer.php +++ b/src/UI/Implementation/Component/MainControls/Renderer.php @@ -441,11 +441,16 @@ protected function renderFooter(Footer $component, RendererInterface $default_re $perm_url = $component->getPermanentURL(); if ($perm_url instanceof URI) { - $url = $perm_url->__toString(); - $link = $this->getUIFactory() - ->link() - ->standard($this->txt('perma_link'), $url); - $tpl->setVariable('PERMANENT', $default_renderer->render($link)); + $code = function (string $id) use ($perm_url): string { + $id = $this->jsonEncode($id); + $perm_url = $this->jsonEncode((string) $perm_url); + + return "document.getElementById($id).addEventListener('click', e => il.Footer.permalink.copyText($perm_url) + .then(() => il.Footer.permalink.showTooltip(e.target.nextElementSibling, 5000)));"; + }; + $button = $this->getUIFactory()->button()->shy($this->txt('copy_perma_link'), '')->withAdditionalOnLoadCode($code); + $tpl->setVariable('PERMANENT', $default_renderer->render($button)); + $tpl->setVariable('PERMANENT_TOOLTIP', $this->txt('perma_link_copied')); } return $tpl->get(); } @@ -460,6 +465,7 @@ public function registerResources(ResourceRegistry $registry): void $registry->register('./src/UI/templates/js/MainControls/dist/maincontrols.min.js'); $registry->register('./src/GlobalScreen/Client/dist/GS.js'); $registry->register('./src/UI/templates/js/MainControls/system_info.js'); + $registry->register('./src/UI/templates/js/MainControls/dist/footer.min.js'); } /** @@ -475,4 +481,9 @@ protected function getComponentInterfaceName(): array Component\MainControls\SystemInfo::class ); } + + private function jsonEncode($value): string + { + return json_encode($value, JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_THROW_ON_ERROR); + } } diff --git a/src/UI/templates/default/MainControls/tpl.footer.html b/src/UI/templates/default/MainControls/tpl.footer.html index 136f7254444d..6102133e35b2 100644 --- a/src/UI/templates/default/MainControls/tpl.footer.html +++ b/src/UI/templates/default/MainControls/tpl.footer.html @@ -2,8 +2,11 @@