From 6b6724bb9c3e65fad8746d5343982c7a2e541e74 Mon Sep 17 00:00:00 2001 From: Alex Killing Date: Fri, 27 Sep 2024 11:48:04 +0200 Subject: [PATCH] lui: fixed modal in page editing / internal link editing; moved code to copage --- components/ILIAS/COPage/COPage.php | 11 ++++++ .../IntLink}/Setup/class.Agent.php | 2 +- .../Setup/class.LinkDBUpdateSteps.php | 2 +- .../IntLink}/class.StandardGUIRequest.php | 2 +- .../class.ilIntLinkRepItemExplorerGUI.php | 0 .../IntLink}/class.ilInternalLink.php | 0 .../IntLink}/class.ilInternalLinkGUI.php | 38 ++++++++++++++----- .../class.ilLinkTargetObjectExplorerGUI.php | 0 .../IntLink}/resources/ilIntLink.js | 22 ++++++++++- .../templates/default/tpl.link_file.html | 0 .../templates/default/tpl.link_help.html | 0 .../default/tpl.link_help_asynch.html | 0 .../default/tpl.link_help_explorer.html | 0 components/ILIAS/Link/Link.php | 4 +- 14 files changed, 63 insertions(+), 18 deletions(-) rename components/ILIAS/{Link => COPage/IntLink}/Setup/class.Agent.php (96%) rename components/ILIAS/{Link => COPage/IntLink}/Setup/class.LinkDBUpdateSteps.php (97%) rename components/ILIAS/{Link/classes => COPage/IntLink}/class.StandardGUIRequest.php (98%) rename components/ILIAS/{Link/classes => COPage/IntLink}/class.ilIntLinkRepItemExplorerGUI.php (100%) rename components/ILIAS/{Link/classes => COPage/IntLink}/class.ilInternalLink.php (100%) rename components/ILIAS/{Link/classes => COPage/IntLink}/class.ilInternalLinkGUI.php (97%) rename components/ILIAS/{Link/classes => COPage/IntLink}/class.ilLinkTargetObjectExplorerGUI.php (100%) rename components/ILIAS/{Link => COPage/IntLink}/resources/ilIntLink.js (94%) rename components/ILIAS/{Link => COPage/IntLink}/templates/default/tpl.link_file.html (100%) rename components/ILIAS/{Link => COPage/IntLink}/templates/default/tpl.link_help.html (100%) rename components/ILIAS/{Link => COPage/IntLink}/templates/default/tpl.link_help_asynch.html (100%) rename components/ILIAS/{Link => COPage/IntLink}/templates/default/tpl.link_help_explorer.html (100%) diff --git a/components/ILIAS/COPage/COPage.php b/components/ILIAS/COPage/COPage.php index 2b9f86a6e56a..fbafe8bcb4c4 100644 --- a/components/ILIAS/COPage/COPage.php +++ b/components/ILIAS/COPage/COPage.php @@ -80,5 +80,16 @@ public function getTarget(): string return "components/ILIAS/COPage/css"; } }; + $contribute[Component\Resource\PublicAsset::class] = static fn() => new class () implements Component\Resource\PublicAsset { + public function getSource(): string + { + return "components/ILIAS/COPage/IntLink/resources/ilIntLink.js"; + } + public function getTarget(): string + { + return "assets/js/ilIntLink.js"; + } + }; + } } diff --git a/components/ILIAS/Link/Setup/class.Agent.php b/components/ILIAS/COPage/IntLink/Setup/class.Agent.php similarity index 96% rename from components/ILIAS/Link/Setup/class.Agent.php rename to components/ILIAS/COPage/IntLink/Setup/class.Agent.php index 7fc0b883236a..ae1df722cfd8 100755 --- a/components/ILIAS/Link/Setup/class.Agent.php +++ b/components/ILIAS/COPage/IntLink/Setup/class.Agent.php @@ -18,7 +18,7 @@ * *********************************************************************/ -namespace ILIAS\Link\Setup; +namespace ILIAS\COPage\IntLink\Setup; use ILIAS\Setup; use ILIAS\Setup\Objective; diff --git a/components/ILIAS/Link/Setup/class.LinkDBUpdateSteps.php b/components/ILIAS/COPage/IntLink/Setup/class.LinkDBUpdateSteps.php similarity index 97% rename from components/ILIAS/Link/Setup/class.LinkDBUpdateSteps.php rename to components/ILIAS/COPage/IntLink/Setup/class.LinkDBUpdateSteps.php index 1466a4b088a0..3db743eea2bc 100755 --- a/components/ILIAS/Link/Setup/class.LinkDBUpdateSteps.php +++ b/components/ILIAS/COPage/IntLink/Setup/class.LinkDBUpdateSteps.php @@ -18,7 +18,7 @@ * *********************************************************************/ -namespace ILIAS\Link\Setup; +namespace ILIAS\COPage\IntLink\Setup; /** * @author Alexander Killing diff --git a/components/ILIAS/Link/classes/class.StandardGUIRequest.php b/components/ILIAS/COPage/IntLink/class.StandardGUIRequest.php similarity index 98% rename from components/ILIAS/Link/classes/class.StandardGUIRequest.php rename to components/ILIAS/COPage/IntLink/class.StandardGUIRequest.php index e551a0845129..85a45b124cb3 100755 --- a/components/ILIAS/Link/classes/class.StandardGUIRequest.php +++ b/components/ILIAS/COPage/IntLink/class.StandardGUIRequest.php @@ -16,7 +16,7 @@ * *********************************************************************/ -namespace ILIAS\Link; +namespace ILIAS\COPage\IntLink; use ILIAS\Repository\BaseGUIRequest; diff --git a/components/ILIAS/Link/classes/class.ilIntLinkRepItemExplorerGUI.php b/components/ILIAS/COPage/IntLink/class.ilIntLinkRepItemExplorerGUI.php similarity index 100% rename from components/ILIAS/Link/classes/class.ilIntLinkRepItemExplorerGUI.php rename to components/ILIAS/COPage/IntLink/class.ilIntLinkRepItemExplorerGUI.php diff --git a/components/ILIAS/Link/classes/class.ilInternalLink.php b/components/ILIAS/COPage/IntLink/class.ilInternalLink.php similarity index 100% rename from components/ILIAS/Link/classes/class.ilInternalLink.php rename to components/ILIAS/COPage/IntLink/class.ilInternalLink.php diff --git a/components/ILIAS/Link/classes/class.ilInternalLinkGUI.php b/components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php similarity index 97% rename from components/ILIAS/Link/classes/class.ilInternalLinkGUI.php rename to components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php index bcb8087de8c0..22dd60bdd102 100755 --- a/components/ILIAS/Link/classes/class.ilInternalLinkGUI.php +++ b/components/ILIAS/COPage/IntLink/class.ilInternalLinkGUI.php @@ -16,7 +16,7 @@ * *********************************************************************/ -use ILIAS\Link\StandardGUIRequest; +use ILIAS\COPage\IntLink\StandardGUIRequest; /** * Internal link selector @@ -275,7 +275,7 @@ public function showLinkHelp(): void } } if ($ilCtrl->isAsynch()) { - $tpl = new ilGlobalTemplate("tpl.link_help_asynch.html", true, true, "components/ILIAS/Link"); + $tpl = new ilGlobalTemplate("tpl.link_help_asynch.html", true, true, "components/ILIAS/COPage/IntLink"); $tpl->setVariable("NEW_LINK_URL", $this->ctrl->getLinkTarget( $this, "", @@ -284,7 +284,7 @@ public function showLinkHelp(): void false )); } else { - $tpl = new ilGlobalTemplate("tpl.link_help.html", true, true, "components/ILIAS/Link"); + $tpl = new ilGlobalTemplate("tpl.link_help.html", true, true, "components/ILIAS/COPage/IntLink"); $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); } @@ -676,7 +676,7 @@ public function getFileLinkHTML(): string $lng = $this->lng; $ilCtrl = $this->ctrl; - $tpl = new ilTemplate("tpl.link_file.html", true, true, "components/ILIAS/Link"); + $tpl = new ilTemplate("tpl.link_file.html", true, true, "components/ILIAS/COPage/IntLink"); if (!is_object($this->uploaded_file)) { $tpl->setCurrentBlock("form"); $tpl->setVariable( @@ -841,7 +841,7 @@ public function changeTargetObject( $ilCtrl->setParameter($this, "link_type", $this->link_type); - $tpl = new ilTemplate("tpl.link_help_explorer.html", true, true, "components/ILIAS/Link"); + $tpl = new ilTemplate("tpl.link_help_explorer.html", true, true, "components/ILIAS/COPage/IntLink"); $output = $this->getTargetExplorer(); @@ -927,18 +927,36 @@ public static function getInitHTML(string $a_url): string $tpl->addJavaScript("assets/js/ilExplorer.js"); ilExplorerBaseGUI::init(); + //$tpl->addJavascript("../components/ILIAS/COPage/IntLink/resources/ilIntLink.js"); $tpl->addJavascript("assets/js/ilIntLink.js"); // #18721 $tpl->addJavaScript("assets/js/Form.js"); - $modal = ilModalGUI::getInstance(); - $modal->setHeading($lng->txt("link_link")); - $modal->setId("ilIntLinkModal"); - $modal->setBody("
"); + $mt = self::getModalTemplate(); - return $modal->getHTML(); + $html = "
". + $mt["template"] . + "
"; + + return $html; + } + + public static function getModalTemplate(): array + { + global $DIC; + + $lng = $DIC->language(); + + $ui = $DIC->ui(); + $modal = $ui->factory()->modal()->roundtrip($lng->txt("link_link"), $ui->factory()->legacy("
")); + $modalt["show"] = $modal->getShowSignal()->getId(); + $modalt["close"] = $modal->getCloseSignal()->getId(); + $modalt["template"] = $ui->renderer()->renderAsync($modal); + + return $modalt; } + /** * Render internal link item */ diff --git a/components/ILIAS/Link/classes/class.ilLinkTargetObjectExplorerGUI.php b/components/ILIAS/COPage/IntLink/class.ilLinkTargetObjectExplorerGUI.php similarity index 100% rename from components/ILIAS/Link/classes/class.ilLinkTargetObjectExplorerGUI.php rename to components/ILIAS/COPage/IntLink/class.ilLinkTargetObjectExplorerGUI.php diff --git a/components/ILIAS/Link/resources/ilIntLink.js b/components/ILIAS/COPage/IntLink/resources/ilIntLink.js similarity index 94% rename from components/ILIAS/Link/resources/ilIntLink.js rename to components/ILIAS/COPage/IntLink/resources/ilIntLink.js index f6469b9d003c..b7029fc1de0e 100644 --- a/components/ILIAS/Link/resources/ilIntLink.js +++ b/components/ILIAS/COPage/IntLink/resources/ilIntLink.js @@ -143,7 +143,16 @@ il.IntLink = * panel is used by other features, too (e.g. wiki link handling) */ showPanel: function() { - $('#ilIntLinkModal').modal('show'); + const modalEl = document.getElementById("ilIntLinkModal"); + const showSignal = modalEl.dataset.showSignal; + $(document).trigger( + showSignal, + { + id: showSignal, + triggerer: $(this), + options: JSON.parse('[]'), + }, + ); }, sendAjaxGetRequestToUrl: function (url, par = {}, args= {}) { @@ -351,7 +360,16 @@ il.IntLink = }, hidePanel: function () { - $('#ilIntLinkModal').modal('hide'); + const modalEl = document.getElementById("ilIntLinkModal"); + const closeSignal = modalEl.dataset.closeSignal; + $(document).trigger( + closeSignal, + { + id: closeSignal, + triggerer: $(this), + options: JSON.parse('[]'), + }, + ); }, setMepPoolFolder: function(mep_fold_id) { diff --git a/components/ILIAS/Link/templates/default/tpl.link_file.html b/components/ILIAS/COPage/IntLink/templates/default/tpl.link_file.html similarity index 100% rename from components/ILIAS/Link/templates/default/tpl.link_file.html rename to components/ILIAS/COPage/IntLink/templates/default/tpl.link_file.html diff --git a/components/ILIAS/Link/templates/default/tpl.link_help.html b/components/ILIAS/COPage/IntLink/templates/default/tpl.link_help.html similarity index 100% rename from components/ILIAS/Link/templates/default/tpl.link_help.html rename to components/ILIAS/COPage/IntLink/templates/default/tpl.link_help.html diff --git a/components/ILIAS/Link/templates/default/tpl.link_help_asynch.html b/components/ILIAS/COPage/IntLink/templates/default/tpl.link_help_asynch.html similarity index 100% rename from components/ILIAS/Link/templates/default/tpl.link_help_asynch.html rename to components/ILIAS/COPage/IntLink/templates/default/tpl.link_help_asynch.html diff --git a/components/ILIAS/Link/templates/default/tpl.link_help_explorer.html b/components/ILIAS/COPage/IntLink/templates/default/tpl.link_help_explorer.html similarity index 100% rename from components/ILIAS/Link/templates/default/tpl.link_help_explorer.html rename to components/ILIAS/COPage/IntLink/templates/default/tpl.link_help_explorer.html diff --git a/components/ILIAS/Link/Link.php b/components/ILIAS/Link/Link.php index d39b160757fb..c49832762898 100644 --- a/components/ILIAS/Link/Link.php +++ b/components/ILIAS/Link/Link.php @@ -33,12 +33,10 @@ public function init( array | \ArrayAccess &$internal, ): void { $contribute[\ILIAS\Setup\Agent::class] = static fn() => - new \ILIAS\Link\Setup\Agent( + new COPage\IntLink\Setup\Agent( $pull[\ILIAS\Refinery\Factory::class] ); - $contribute[Component\Resource\PublicAsset::class] = fn() => - new Component\Resource\ComponentJS($this, "ilIntLink.js"); $contribute[Component\Resource\PublicAsset::class] = fn() => new Component\Resource\ComponentJS($this, "ilExtLink.js"); $contribute[Component\Resource\PublicAsset::class] = static fn() =>