diff --git a/Modules/Blog/classes/class.ilBlogPostingGUI.php b/Modules/Blog/classes/class.ilBlogPostingGUI.php index 61d6e7f1bffe..354d09bade96 100644 --- a/Modules/Blog/classes/class.ilBlogPostingGUI.php +++ b/Modules/Blog/classes/class.ilBlogPostingGUI.php @@ -11,7 +11,7 @@ * @version $Id$ * * @ilCtrl_Calls ilBlogPostingGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector - * @ilCtrl_Calls ilBlogPostingGUI: ilRatingGUI, ilPublicUserProfileGUI, ilPageObjectGUI, ilNoteGUI + * @ilCtrl_Calls ilBlogPostingGUI: ilRatingGUI, ilPublicUserProfileGUI, ilPageObjectGUI, ilNoteGUI, ilPCPluggedGUI * * @ingroup ModulesBlog */ diff --git a/Modules/Course/classes/Objectives/class.ilLOPageGUI.php b/Modules/Course/classes/Objectives/class.ilLOPageGUI.php index de7beefc665f..cc8735a822b4 100644 --- a/Modules/Course/classes/Objectives/class.ilLOPageGUI.php +++ b/Modules/Course/classes/Objectives/class.ilLOPageGUI.php @@ -12,7 +12,7 @@ * * @ilCtrl_Calls ilLOPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI * @ilCtrl_Calls ilLOPageGUI: ilPublicUserProfileGUI, ilNoteGUI - * @ilCtrl_Calls ilLOPageGUI: ilPropertyFormGUI, ilInternalLinkGUI, ilPageMultiLangGUI + * @ilCtrl_Calls ilLOPageGUI: ilPropertyFormGUI, ilInternalLinkGUI, ilPageMultiLangGUI, ilPCPluggedGUI * * @ingroup ModulesCourse */ diff --git a/Modules/DataCollection/classes/DetailedView/class.ilDclDetailedViewDefinitionGUI.php b/Modules/DataCollection/classes/DetailedView/class.ilDclDetailedViewDefinitionGUI.php index 5ebfa5055ae0..4bbde4dcc61c 100644 --- a/Modules/DataCollection/classes/DetailedView/class.ilDclDetailedViewDefinitionGUI.php +++ b/Modules/DataCollection/classes/DetailedView/class.ilDclDetailedViewDefinitionGUI.php @@ -11,7 +11,7 @@ * @author Jörg Lützenkirchen * * @ilCtrl_Calls ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector - * @ilCtrl_Calls ilDclDetailedViewDefinitionGUI: ilPublicUserProfileGUI, ilPageObjectGUI + * @ilCtrl_Calls ilDclDetailedViewDefinitionGUI: ilPublicUserProfileGUI, ilPageObjectGUI, ilPCPluggedGUI */ class ilDclDetailedViewDefinitionGUI extends ilPageObjectGUI { diff --git a/Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php b/Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php index a257e15928c9..c01fab477377 100755 --- a/Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php +++ b/Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php @@ -12,7 +12,7 @@ * * @ilCtrl_Calls ilGlossaryDefPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilObjectMetaDataGUI * @ilCtrl_Calls ilGlossaryDefPageGUI: ilPublicUserProfileGUI, ilNoteGUI - * @ilCtrl_Calls ilGlossaryDefPageGUI: ilPropertyFormGUI, ilInternalLinkGUI + * @ilCtrl_Calls ilGlossaryDefPageGUI: ilPropertyFormGUI, ilInternalLinkGUI, ilPCPluggedGUI * * @ingroup ModulesGlossary */ diff --git a/Modules/LearningModule/classes/class.ilLMPageGUI.php b/Modules/LearningModule/classes/class.ilLMPageGUI.php index ff4385ccbabf..53eb35f03dd5 100644 --- a/Modules/LearningModule/classes/class.ilLMPageGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPageGUI.php @@ -11,7 +11,7 @@ * @author Alex Killing * @version $Id$ * @ilCtrl_Calls ilLMPageGUI: ilPageEditorGUI, ilObjectMetaDataGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector, ilCommonActionDispatcherGUI, ilPageObjectGUI - * @ilCtrl_Calls ilLMPageGUI: ilNewsItemGUI, ilQuestionEditGUI, ilAssQuestionFeedbackEditingGUI, ilPageMultiLangGUI, ilPropertyFormGUI + * @ilCtrl_Calls ilLMPageGUI: ilNewsItemGUI, ilQuestionEditGUI, ilAssQuestionFeedbackEditingGUI, ilPageMultiLangGUI, ilPropertyFormGUI, ilPCPluggedGUI * @ingroup ModuleLearningModule */ class ilLMPageGUI extends ilPageObjectGUI diff --git a/Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php b/Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php index 3e945d03e45f..06ef59833b0b 100644 --- a/Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php +++ b/Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php @@ -12,7 +12,7 @@ * @version $Id$ * * @ilCtrl_Calls ilMediaPoolPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector -* @ilCtrl_Calls ilMediaPoolPageGUI: ilPublicUserProfileGUI +* @ilCtrl_Calls ilMediaPoolPageGUI: ilPublicUserProfileGUI, ilPCPluggedGUI * * @ingroup ModulesMediaPool */ diff --git a/Modules/Portfolio/classes/class.ilPortfolioPageGUI.php b/Modules/Portfolio/classes/class.ilPortfolioPageGUI.php index 10013bf3fb37..0656dfb91330 100644 --- a/Modules/Portfolio/classes/class.ilPortfolioPageGUI.php +++ b/Modules/Portfolio/classes/class.ilPortfolioPageGUI.php @@ -11,7 +11,7 @@ * * @ilCtrl_Calls ilPortfolioPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector * @ilCtrl_Calls ilPortfolioPageGUI: ilPageObjectGUI, ilObjBlogGUI, ilBlogPostingGUI - * @ilCtrl_Calls ilPortfolioPageGUI: ilCalendarMonthGUI, ilConsultationHoursGUI + * @ilCtrl_Calls ilPortfolioPageGUI: ilCalendarMonthGUI, ilConsultationHoursGUI, ilPCPluggedGUI * * @ingroup ModulesPortfolio */ diff --git a/Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php b/Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php index ca52cf0422df..0a9b593a0c02 100755 --- a/Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php +++ b/Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php @@ -13,7 +13,7 @@ * @version $Id$ * * @ilCtrl_Calls ilSCORM2004PageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector - * @ilCtrl_Calls ilSCORM2004PageGUI: ilRatingGUI, ilPublicUserProfileGUI, ilPageObjectGUI, ilNoteGUI + * @ilCtrl_Calls ilSCORM2004PageGUI: ilRatingGUI, ilPublicUserProfileGUI, ilPageObjectGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilSCORM2004PageGUI: ilObjectMetaDataGUI, ilQuestionEditGUI, ilAssQuestionFeedbackEditingGUI * * @ingroup ModulesScormAicc diff --git a/Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php b/Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php index a9c6cc993267..330d8fc2e437 100755 --- a/Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php +++ b/Modules/TestQuestionPool/classes/class.ilAssHintPageGUI.php @@ -11,7 +11,7 @@ * * @ilCtrl_Calls ilAssHintPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI * @ilCtrl_Calls ilAssHintPageGUI: ilPublicUserProfileGUI, ilNoteGUI - * @ilCtrl_Calls ilAssHintPageGUI: ilPropertyFormGUI, ilInternalLinkGUI + * @ilCtrl_Calls ilAssHintPageGUI: ilPropertyFormGUI, ilInternalLinkGUI, ilPCPluggedGUI * * @ingroup ModulesTestQuestionPool * ilasshintpagegui diff --git a/Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php b/Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php index d3324c723ce7..6d3c40ca400a 100755 --- a/Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php +++ b/Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php @@ -10,7 +10,7 @@ * @author Alex Killing * * @ilCtrl_Calls ilAssQuestionPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI - * @ilCtrl_Calls ilAssQuestionPageGUI: ilPublicUserProfileGUI, ilNoteGUI + * @ilCtrl_Calls ilAssQuestionPageGUI: ilPublicUserProfileGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilAssQuestionPageGUI: ilPropertyFormGUI, ilInternalLinkGUI * * @ingroup ModulesTestQuestionPool diff --git a/Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php b/Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php index 08eae46ab04d..a3f2c48bc9bb 100755 --- a/Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php +++ b/Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php @@ -10,7 +10,7 @@ * @author Alex Killing * * @ilCtrl_Calls ilAssGenFeedbackPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI - * @ilCtrl_Calls ilAssGenFeedbackPageGUI: ilPublicUserProfileGUI, ilNoteGUI + * @ilCtrl_Calls ilAssGenFeedbackPageGUI: ilPublicUserProfileGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilAssGenFeedbackPageGUI: ilPropertyFormGUI, ilInternalLinkGUI * * @ingroup ModulesTestQuestionPool diff --git a/Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php b/Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php index 799c457abb5b..d1c1241c0374 100755 --- a/Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php +++ b/Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php @@ -10,7 +10,7 @@ * @author Alex Killing * * @ilCtrl_Calls ilAssSpecFeedbackPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI - * @ilCtrl_Calls ilAssSpecFeedbackPageGUI: ilPublicUserProfileGUI, ilNoteGUI + * @ilCtrl_Calls ilAssSpecFeedbackPageGUI: ilPublicUserProfileGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilAssSpecFeedbackPageGUI: ilPropertyFormGUI, ilInternalLinkGUI * * @ingroup ModulesTestQuestionPool diff --git a/Modules/Wiki/classes/class.ilWikiPageGUI.php b/Modules/Wiki/classes/class.ilWikiPageGUI.php index 6179356677fd..a2b0d991f997 100755 --- a/Modules/Wiki/classes/class.ilWikiPageGUI.php +++ b/Modules/Wiki/classes/class.ilWikiPageGUI.php @@ -11,7 +11,7 @@ * @version $Id$ * * @ilCtrl_Calls ilWikiPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector -* @ilCtrl_Calls ilWikiPageGUI: ilPublicUserProfileGUI, ilPageObjectGUI, ilNoteGUI +* @ilCtrl_Calls ilWikiPageGUI: ilPublicUserProfileGUI, ilPageObjectGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilWikiPageGUI: ilCommonActionDispatcherGUI, ilRatingGUI, ilWikiStatGUI * @ilCtrl_Calls ilWikiPageGUI: ilObjectMetaDataGUI * diff --git a/Services/Authentication/classes/class.ilLoginPageGUI.php b/Services/Authentication/classes/class.ilLoginPageGUI.php index a6803be72097..074d7a78953b 100755 --- a/Services/Authentication/classes/class.ilLoginPageGUI.php +++ b/Services/Authentication/classes/class.ilLoginPageGUI.php @@ -11,7 +11,7 @@ * @author Alex Killing * * @ilCtrl_Calls ilLoginPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI - * @ilCtrl_Calls ilLoginPageGUI: ilPublicUserProfileGUI, ilNoteGUI + * @ilCtrl_Calls ilLoginPageGUI: ilPublicUserProfileGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilLoginPageGUI: ilPropertyFormGUI, ilInternalLinkGUI * * @ingroup ServicesAuthentication diff --git a/Services/COPage/Layout/classes/class.ilPageLayoutGUI.php b/Services/COPage/Layout/classes/class.ilPageLayoutGUI.php index 304647375404..b7a6b38eea33 100755 --- a/Services/COPage/Layout/classes/class.ilPageLayoutGUI.php +++ b/Services/COPage/Layout/classes/class.ilPageLayoutGUI.php @@ -11,7 +11,7 @@ * @version $Id$ * * @ilCtrl_Calls ilPageLayoutGUI: ilPageEditorGUI, ilEditClipboardGUI -* @ilCtrl_Calls ilPageLayoutGUI: ilPublicUserProfileGUI, ilPageObjectGUI +* @ilCtrl_Calls ilPageLayoutGUI: ilPublicUserProfileGUI, ilPageObjectGUI, ilPCPluggedGUI * */ class ilPageLayoutGUI extends ilPageObjectGUI diff --git a/Services/COPage/classes/class.ilPCPluggedGUI.php b/Services/COPage/classes/class.ilPCPluggedGUI.php index 4a8a5bc3e702..abce1904e7e2 100755 --- a/Services/COPage/classes/class.ilPCPluggedGUI.php +++ b/Services/COPage/classes/class.ilPCPluggedGUI.php @@ -14,6 +14,7 @@ * @author Alex Killing * @version $Id$ * + * @ilCtrl_Calls ilPCPluggedGUI: ilPasswordAssistanceGUI * @ingroup ServicesCOPage */ class ilPCPluggedGUI extends ilPageContentGUI @@ -34,7 +35,7 @@ class ilPCPluggedGUI extends ilPageContentGUI * Constructor * @access public */ - function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_plugin_name = "", $a_pc_id = "") + function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_plugin_name = "", $a_pc_id = "") { global $DIC; diff --git a/Services/COPage/classes/class.ilPageComponentPlugin.php b/Services/COPage/classes/class.ilPageComponentPlugin.php index c0eca24a15e5..4c58a99f6a55 100644 --- a/Services/COPage/classes/class.ilPageComponentPlugin.php +++ b/Services/COPage/classes/class.ilPageComponentPlugin.php @@ -181,6 +181,16 @@ public function getParentType() return ''; } + /** + * Get name of page gui class + * + * @return string + */ + public function getPageGUIClass() + { + return get_class($this->page_obj)."GUI"; + } + /** * This function is called when the page content is cloned * @param array $a_properties (properties saved in the page, should be modified if neccessary) diff --git a/Services/COPage/classes/class.ilPageObjectGUI.php b/Services/COPage/classes/class.ilPageObjectGUI.php index 6d5bb3c7bad2..a02416ac47fb 100755 --- a/Services/COPage/classes/class.ilPageObjectGUI.php +++ b/Services/COPage/classes/class.ilPageObjectGUI.php @@ -22,7 +22,7 @@ * @version $Id$ * * @ilCtrl_Calls ilPageObjectGUI: ilPageEditorGUI, ilEditClipboardGUI, ilObjectMetaDataGUI - * @ilCtrl_Calls ilPageObjectGUI: ilPublicUserProfileGUI, ilNoteGUI, ilNewsItemGUI + * @ilCtrl_Calls ilPageObjectGUI: ilPublicUserProfileGUI, ilNoteGUI, ilNewsItemGUI, ilPCPluggedGUI * @ilCtrl_Calls ilPageObjectGUI: ilPropertyFormGUI, ilInternalLinkGUI, ilPageMultiLangGUI * * @ingroup ServicesCOPage @@ -987,6 +987,7 @@ function executeCommand() $next_class = $this->ctrl->getNextClass($this); $this->log->debug("next_class: ".$next_class); + switch($next_class) { case 'ilobjectmetadatagui': @@ -1039,6 +1040,14 @@ function executeCommand() $ret = $this->ctrl->forwardCommand($page_editor); break; + // Plugged Component + case "ilpcpluggedgui": + include_once ("./Services/COPage/classes/class.ilPCPluggedGUI.php"); + $plugged_gui = new ilPCPluggedGUI($this->obj, null, 0, "", ""); + $ret = $this->ctrl->forwardCommand($plugged_gui); + break; + + case 'ilnewsitemgui': include_once("./Services/News/classes/class.ilNewsItemGUI.php"); $news_item_gui = new ilNewsItemGUI(); diff --git a/Services/Container/classes/class.ilContainerGUI.php b/Services/Container/classes/class.ilContainerGUI.php index 5f6e541d0b69..e616612f6c60 100644 --- a/Services/Container/classes/class.ilContainerGUI.php +++ b/Services/Container/classes/class.ilContainerGUI.php @@ -269,15 +269,8 @@ function &forwardToPageObject() $cmd = $ilCtrl->getCmd(); - if (in_array($cmd, array("displayMediaFullscreen", "downloadFile", "displayMedia"))) - { - $this->checkPermission("read"); - } - else - { - $this->checkPermission("write"); - } - + $this->checkPermission("read"); + $ilTabs->clearTargets(); if ($_GET["redirectSource"] == "ilinternallinkgui") @@ -329,6 +322,11 @@ function &forwardToPageObject() $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId( $this->object->getStyleSheetId(), $this->object->getType())); + if (!$this->access->checkAccess("write", "", $this->ref_id)) + { + $page_gui->setEnableEditing(false); + } + $page_gui->setTemplateTargetVar("ADM_CONTENT"); $page_gui->setFileDownloadLink(""); $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen")); diff --git a/Services/Container/classes/class.ilContainerPageGUI.php b/Services/Container/classes/class.ilContainerPageGUI.php index bfd5cdb9605e..cef5cc0c4928 100755 --- a/Services/Container/classes/class.ilContainerPageGUI.php +++ b/Services/Container/classes/class.ilContainerPageGUI.php @@ -11,7 +11,7 @@ * @author Alex Killing * * @ilCtrl_Calls ilContainerPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI - * @ilCtrl_Calls ilContainerPageGUI: ilPublicUserProfileGUI, ilNoteGUI + * @ilCtrl_Calls ilContainerPageGUI: ilPublicUserProfileGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilContainerPageGUI: ilPropertyFormGUI, ilInternalLinkGUI, ilPageMultiLangGUI * * @ingroup ServicesContainer diff --git a/Services/Container/classes/class.ilContainerStartObjectsPageGUI.php b/Services/Container/classes/class.ilContainerStartObjectsPageGUI.php index e98c94ce2a50..326f93a551e4 100644 --- a/Services/Container/classes/class.ilContainerStartObjectsPageGUI.php +++ b/Services/Container/classes/class.ilContainerStartObjectsPageGUI.php @@ -11,7 +11,7 @@ * @author Jörg Lützenkirchen * * @ilCtrl_Calls ilContainerStartObjectsPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI - * @ilCtrl_Calls ilContainerStartObjectsPageGUI: ilPublicUserProfileGUI, ilNoteGUI + * @ilCtrl_Calls ilContainerStartObjectsPageGUI: ilPublicUserProfileGUI, ilNoteGUI, ilPCPluggedGUI * @ilCtrl_Calls ilContainerStartObjectsPageGUI: ilPropertyFormGUI, ilInternalLinkGUI, ilPageMultiLangGUI * * @ingroup ServicesContainer diff --git a/Services/Imprint/classes/class.ilImprintGUI.php b/Services/Imprint/classes/class.ilImprintGUI.php index 015634dba9bb..6b1183c6c8dd 100644 --- a/Services/Imprint/classes/class.ilImprintGUI.php +++ b/Services/Imprint/classes/class.ilImprintGUI.php @@ -10,7 +10,7 @@ * @author Jörg Lützenkirchen * * @ilCtrl_Calls ilImprintGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector -* @ilCtrl_Calls ilImprintGUI: ilPublicUserProfileGUI, ilPageObjectGUI +* @ilCtrl_Calls ilImprintGUI: ilPublicUserProfileGUI, ilPageObjectGUI, ilPCPluggedGUI * * @ingroup ModulesImprint */ diff --git a/src/UI/Component/Modal/Modal.php b/src/UI/Component/Modal/Modal.php index 51519c2537ec..895e481eeda9 100644 --- a/src/UI/Component/Modal/Modal.php +++ b/src/UI/Component/Modal/Modal.php @@ -64,5 +64,4 @@ public function getShowSignal(); * @return Signal */ public function getCloseSignal(); - } diff --git a/src/UI/Component/Modal/ReplaceContentSignal.php b/src/UI/Component/Modal/ReplaceContentSignal.php new file mode 100644 index 000000000000..11930b13b0d9 --- /dev/null +++ b/src/UI/Component/Modal/ReplaceContentSignal.php @@ -0,0 +1,31 @@ + + * @package ILIAS\UI\Component\Modal + */ +interface ReplaceContentSignal extends Signal +{ + + /** + * Get the same signal returning the Modal content from the given url. + * + * @param string $url + * + * @return ReplaceContentSignal + */ + public function withAsyncRenderUrl($url); + + /** + * Get the url called to return the content. + * + * @return string + */ + public function getAsyncRenderUrl(); +} \ No newline at end of file diff --git a/src/UI/Component/Modal/RoundTrip.php b/src/UI/Component/Modal/RoundTrip.php index 61a58559f5df..bde0b396a092 100644 --- a/src/UI/Component/Modal/RoundTrip.php +++ b/src/UI/Component/Modal/RoundTrip.php @@ -23,6 +23,14 @@ public function getTitle(); */ public function getContent(); + /** + * Get Modal likee this with the provided components representing the content of the modal + * + * @param \ILIAS\UI\Component\Component[] $a_content + * @return RoundTrip + */ + public function withContent($a_content); + /** * Get all action buttons in the footer of the modal @@ -57,4 +65,25 @@ public function withActionButtons(array $buttons); * @return RoundTrip */ public function withCancelButtonLabel($label); + + /** + * Get the signal to replace the content of this modal. + * + * @return ReplaceContentSignal + */ + public function getReplaceContentSignal(); + + /** + * Get the url returning the rendered content, if the popovers content is rendered via ajax. + * + * @return string + */ + public function getAsyncContentUrl(); + + public function withAsyncContentUrl($url); + + /** + * Init the default signals plus extra signals like replaceContent + */ + public function initSignals(); } diff --git a/src/UI/Implementation/Component/Modal/Modal.php b/src/UI/Implementation/Component/Modal/Modal.php index 6ff3bc219444..d03f91c6a5b2 100644 --- a/src/UI/Implementation/Component/Modal/Modal.php +++ b/src/UI/Implementation/Component/Modal/Modal.php @@ -33,7 +33,6 @@ abstract class Modal implements Component\Modal\Modal { * @var Signal */ protected $close_signal; - /** * @var string */ diff --git a/src/UI/Implementation/Component/Modal/Renderer.php b/src/UI/Implementation/Component/Modal/Renderer.php index eec4525f7d62..efd4004f96de 100644 --- a/src/UI/Implementation/Component/Modal/Renderer.php +++ b/src/UI/Implementation/Component/Modal/Renderer.php @@ -17,11 +17,20 @@ class Renderer extends AbstractComponentRenderer { public function render(Component\Component $component, RendererInterface $default_renderer) { $this->checkComponent($component); + global $DIC; + + $log = $DIC->logger()->root(); + // If the modal is rendered async, we just create a fake container which will be // replaced by the modal upon successful ajax request /** @var Modal $component */ if ($component->getAsyncRenderUrl()) { + + $log->debug("///// Modal getAsyncRenderURL"); return $this->renderAsync($component); + } else + { + $log->debug("///// MOdal else not async render URL"); } if ($component instanceof Component\Modal\Interruptive) { @@ -48,12 +57,28 @@ public function registerResources(ResourceRegistry $registry) { * @param string $id */ protected function registerSignals(Component\Modal\Modal $modal) { + + /** + * THis method is not called temporary by the roundtrip modal. + */ + $replacement = array( + '"'=> '\"', + "\n"=>"", + "\t"=>"", + "\r"=>"", + ); + $show = $modal->getShowSignal(); $close = $modal->getCloseSignal(); - $options = json_encode(array( + $replace = $modal->getReplaceContentSignal(); + + $is_async = $modal->getAsyncContentUrl(); + + $options = array( 'ajaxRenderUrl' => $modal->getAsyncRenderUrl(), 'keyboard' => $modal->getCloseWithKeyboard(), - )); + //'template' => str_replace(array_keys($replacement), array_values($replacement), $tpl->get()) + ); // ATTENTION, ATTENTION: // with(Additional)OnLoadCode opens a wormhole into the future, where some unspecified // entity magically created an id for the component that can be used to refer to it @@ -70,10 +95,15 @@ protected function registerSignals(Component\Modal\Modal $modal) { // created // * since withAdditionalOnLoadCode refers to some yet unknown future, it disencourages // tempering with the id _here_. - return $modal->withAdditionalOnLoadCode(function($id) use ($show, $close, $options) { + return $modal->withAdditionalOnLoadCode(function($id) use ($show, $close, $options, $replace, $is_async) { + if (!$is_async) { + $options["url"] = "#{$id}"; + } + $options = json_encode($options); return - "$(document).on('{$show}', function() { il.UI.modal.showModal('{$id}', {$options}); return false; });". - "$(document).on('{$close}', function() { il.UI.modal.closeModal('{$id}'); return false; });"; + "$(document).on('{$show}', function(event, signalData) { il.UI.modal.showModal('{$id}', {$options}, signalData); return false; });". + "$(document).on('{$close}', function() { il.UI.modal.closeModal('{$id}'); return false; });". + "$(document).on('{$replace}', function(event, signalData) { il.UI.modal.replaceContentFromSignal('{$show}', signalData);});"; }); } @@ -126,10 +156,69 @@ protected function renderInterruptive(Component\Modal\Interruptive $modal, Rende * * @return string */ - protected function renderRoundTrip(Component\Modal\RoundTrip $modal, RendererInterface $default_renderer) { + protected function renderRoundTrip(Component\Modal\RoundTrip $modal, RendererInterface $default_renderer) + { + global $DIC; + + $log = $DIC->logger()->root(); + $tpl = $this->getTemplate('tpl.roundtrip.html', true, true); - $modal = $this->registerSignals($modal); + + /** + * Todo after fixing: Put the proper code in registerSignals method. + */ + //$modal = $this->registerSignals($modal); + + $replacement = array( + '"'=> '\"', + "\n"=>"", + "\t"=>"", + "\r"=>"", + ); + + $options = array( + 'ajaxRenderUrl' => $modal->getAsyncRenderUrl(), + 'keyboard' => $modal->getCloseWithKeyboard() + //'template' => str_replace(array_keys($replacement), array_values($replacement), $tpl->get()) + ); + $is_async = $modal->getAsyncContentUrl(); + if ($is_async) { +$log->debug("RENDER IS ASYNCR."); + $options['type'] = 'async'; + $options['url'] = $modal->getAsyncContentUrl(); + } else + { +$log->debug("ELSE: RENDER IS NOT ASYNCR."); + } + + $show = $modal->getShowSignal(); + $close = $modal->getCloseSignal(); + $replace = $modal->getReplaceContentSignal(); + +$ar = $replace->getAsyncRenderUrl(); +$log->debug("Async render URL => ".$ar); + + $modal = $modal->withAdditionalOnLoadCode(function($id) use ($show, $close, $options, $replace, $is_async) { + if (!$is_async) { + $options["url"] = "#{$id}"; + } + $options = json_encode($options); + + return + "$(document).on('{$show}', function() { il.UI.modal.showModal('{$id}', {$options}); return false; });". + "$(document).on('{$close}', function() { il.UI.modal.closeModal('{$id}'); return false; });". + "$(document).on('{$replace}', function(event, signalData) { il.UI.modal.replaceContentFromSignal('{$show}', signalData);});"; + }); + + //should we send it via param to the renderer? $id = $this->bindJavaScript($modal); + + if ($modal->getAsyncContentUrl()) { + $log->debug("RETURN WITHOUT CONTENT"); + return ''; + } else { + $log->debug("ELSE no async content"); + } $tpl->setVariable('ID', $id); $tpl->setVariable('TITLE', $modal->getTitle()); foreach ($modal->getContent() as $content) { diff --git a/src/UI/Implementation/Component/Modal/ReplaceContentSignal.php b/src/UI/Implementation/Component/Modal/ReplaceContentSignal.php new file mode 100644 index 000000000000..93f9a4368636 --- /dev/null +++ b/src/UI/Implementation/Component/Modal/ReplaceContentSignal.php @@ -0,0 +1,39 @@ + DRY and centralize it. + * + * @author Jesús López + * @package ILIAS\UI\Implementation\Component\Modal + */ +class ReplaceContentSignal extends Signal implements \ILIAS\UI\Component\Modal\ReplaceContentSignal { + + use ComponentHelper; + + + /** + * @inheritdoc + */ + public function withAsyncRenderUrl($url) { + $this->checkStringArg('url', $url); + $clone = clone $this; + $clone->addOption('url', $url); + + return $clone; + } + + + /** + * @inheritdoc + */ + public function getAsyncRenderUrl() { + return (string)$this->getOption('url'); + } +} \ No newline at end of file diff --git a/src/UI/Implementation/Component/Modal/RoundTrip.php b/src/UI/Implementation/Component/Modal/RoundTrip.php index 67c7c76bcfac..0009272ad305 100644 --- a/src/UI/Implementation/Component/Modal/RoundTrip.php +++ b/src/UI/Implementation/Component/Modal/RoundTrip.php @@ -30,6 +30,9 @@ class RoundTrip extends Modal implements Component\Modal\RoundTrip { */ protected $cancel_button_label = 'cancel'; + protected $ajax_content_url; + protected $replace_content_signal; + /** * @param string $title @@ -99,4 +102,48 @@ public function withCancelButtonLabel($label) { $clone->cancel_button_label = $label; return $clone; } + + /** + * @inheritdoc + */ + public function withAsyncContentUrl($url) { + $this->checkStringArg('url', $url); + $clone = clone $this; + $clone->ajax_content_url = $url; + + return $clone; + } + + public function getAsyncContentUrl() + { + //remove this dummy line + return $this->ajax_content_url; + } + + /** + * @inheritdoc + */ + public function getReplaceContentSignal() { + return $this->replace_content_signal; + } + + /** + * Set the show/close/replace signals for this modal + */ + public function initSignals() { + parent::initSignals(); + //signal generator from parent class + $this->replace_content_signal = $this->signal_generator->create("ILIAS\\UI\\Implementation\\Component\\Modal\\ReplaceContentSignal"); + } + + /** + * @inheritdoc + */ + public function withContent($content) { + $clone = clone $this; + $clone->content = $content; + + return $clone; + } + } diff --git a/src/UI/Implementation/Component/SignalGeneratorInterface.php b/src/UI/Implementation/Component/SignalGeneratorInterface.php index f85373e015a2..638d6f8041b8 100644 --- a/src/UI/Implementation/Component/SignalGeneratorInterface.php +++ b/src/UI/Implementation/Component/SignalGeneratorInterface.php @@ -1,7 +1,9 @@ " + html + ""); + + // of the new modal, we want the inner html of the modal (without the new top modal node, since + // we want to keep our id. Additionally we want the script tag with its content. + // Since html() gives us the inner html of the script tag only, we clone, wrap and get the inner from the wrapper... + // console.log($new_modal.html()); + // console.log($new_modal.children("script").first().clone().wrap('

').parent().html()); + // console.log($new_modal.find("script").first().clone().wrap('

').parent().html()); + + $modal.html($new_modal.find(".modal").first().html() + $new_modal.children("script").first().clone().wrap('

').parent().html()); + }); + }; + + /** + * Replace the content of the modalbox of the $triggerer JQuery object with the data returned by the + * given url. + * + * @param $triggerer JQuery object where the modalbox belongs to + * @param url The URL where the ajax GET request is sent to load the new content + */ + var replaceContent = function($triggerer, url) { + var $content = $('#' + $triggerer.attr('data-target')).find('.modal-content'); + if (!$content.length) return; + $content.html('

 

'); + $content.load(url, function() { + console.log('loaded'); + }); + }; + return { showModal: showModal, - closeModal: closeModal + closeModal: closeModal, + replaceContentFromSignal: replaceContentFromSignal, + replaceContent: replaceContent }; })($);