diff --git a/Modules/LearningModule/classes/class.ilLMPageConfig.php b/Modules/LearningModule/classes/class.ilLMPageConfig.php
index 7424a22891ac..2e5a273136bb 100644
--- a/Modules/LearningModule/classes/class.ilLMPageConfig.php
+++ b/Modules/LearningModule/classes/class.ilLMPageConfig.php
@@ -57,6 +57,7 @@ public function init(): void
if ($mset->get("mep_activate_pages")) {
$this->setEnablePCType("ContentInclude", true);
}
+ $this->setLayoutTemplateType(ilPageLayout::MODULE_LM);
}
/**
diff --git a/Services/COPage/PC/LayoutTemplate/class.ilPCLayoutTemplate.php b/Services/COPage/PC/LayoutTemplate/class.ilPCLayoutTemplate.php
new file mode 100755
index 000000000000..e46914749995
--- /dev/null
+++ b/Services/COPage/PC/LayoutTemplate/class.ilPCLayoutTemplate.php
@@ -0,0 +1,75 @@
+
+ */
+class ilPCLayoutTemplate extends ilPageContent
+{
+ public function init(): void
+ {
+ $this->setType("lay");
+ }
+
+ public function create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id, int $a_tmpl): void
+ {
+ $source_page = ilPageObjectFactory::getInstance("stys", $a_tmpl);
+ $source_page->buildDom();
+ $source_page->addHierIDs();
+ $hier_ids = $source_page->getHierIds();
+
+ $copy_ids = array();
+ foreach ($hier_ids as $hier_id) {
+ // move top level nodes only
+ if (!is_int(strpos($hier_id, "_"))) {
+ if ($hier_id != "pg") {
+ $copy_ids[] = $hier_id;
+ }
+ }
+ }
+ arsort($copy_ids);
+
+ foreach ($copy_ids as $copy_id) {
+ $source_content = $source_page->getContentObject($copy_id);
+
+ $source_node = $source_content->getNode();
+ $clone_node = $source_node->clone_node(true);
+ $clone_node->unlink_node($clone_node);
+
+ // insert cloned node at target
+ $source_content->setNode($clone_node);
+ $this->getPage()->insertContent($source_content, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
+
+ $xpath = new DOMXpath($this->getPage()->getDomDoc());
+ if ($clone_node->get_attribute("PCID") != "") {
+ $clone_node->set_attribute("PCID", "");
+ }
+ $els = $xpath->query(".//*[@PCID]", $clone_node->myDOMNode);
+ foreach ($els as $el) {
+ $el->setAttribute("PCID", "");
+ }
+ }
+
+ $this->getPage()->update();
+ }
+}
diff --git a/Services/COPage/PC/LayoutTemplate/class.ilPCLayoutTemplateGUI.php b/Services/COPage/PC/LayoutTemplate/class.ilPCLayoutTemplateGUI.php
new file mode 100755
index 000000000000..3ec657af8e46
--- /dev/null
+++ b/Services/COPage/PC/LayoutTemplate/class.ilPCLayoutTemplateGUI.php
@@ -0,0 +1,129 @@
+tpl = $DIC["tpl"];
+ $this->ctrl = $DIC->ctrl();
+ $this->lng = $DIC->language();
+ parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
+ }
+
+ /**
+ * Execute command
+ */
+ public function executeCommand(): void
+ {
+ // get next class that processes or forwards current command
+ $next_class = $this->ctrl->getNextClass($this);
+
+ // get current command
+ $cmd = $this->ctrl->getCmd();
+
+ switch ($next_class) {
+ default:
+ $this->$cmd();
+ break;
+ }
+ }
+
+ /**
+ * Insert content template
+ */
+ public function insert(): void
+ {
+ $tpl = $this->tpl;
+
+ $this->displayValidationError();
+ $form = $this->initForm();
+ $tpl->setContent($form->getHTML());
+ }
+
+ /**
+ * Init creation from
+ */
+ public function initForm(): ilPropertyFormGUI
+ {
+ $ilCtrl = $this->ctrl;
+ $lng = $this->lng;
+
+ // edit form
+ $form = new ilPropertyFormGUI();
+ $form->setFormAction($ilCtrl->getFormAction($this));
+ $form->setTitle($this->lng->txt("cont_ed_insert_lay"));
+
+ $config = $this->getPage()->getPageConfig();
+ $templates = ilPageLayout::activeLayouts($config->getLayoutTemplateType());
+ if ($templates) {
+ $use_template = new ilRadioGroupInputGUI($this->lng->txt("cont_layout"), "tmpl");
+ $use_template->setRequired(true);
+ $form->addItem($use_template);
+
+ foreach ($templates as $templ) {
+ $templ->readObject();
+ $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), (string) $templ->getId());
+ $use_template->addOption($opt);
+ }
+ }
+
+ $form->addCommandButton("create_templ", $lng->txt("insert"));
+ $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
+
+ return $form;
+ }
+
+ /**
+ * Insert the template
+ */
+ public function create(): void
+ {
+ $tpl = $this->tpl;
+
+ $form = $this->initForm();
+ if ($form->checkInput()) {
+ $this->content_obj = new ilPCLayoutTemplate($this->getPage());
+ $this->content_obj->create(
+ $this->pg_obj,
+ $this->hier_id,
+ $this->pc_id,
+ (int) $form->getInput("tmpl")
+ );
+ $this->updated = $this->pg_obj->update();
+ if ($this->updated === true) {
+ $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
+ return;
+ }
+ }
+ $this->displayValidationError();
+ $form->setValuesByPost();
+ $tpl->setContent($form->getHTML());
+ }
+}
diff --git a/Services/COPage/classes/class.ilPageConfig.php b/Services/COPage/classes/class.ilPageConfig.php
index ce39e602b801..e200344f52d0 100644
--- a/Services/COPage/classes/class.ilPageConfig.php
+++ b/Services/COPage/classes/class.ilPageConfig.php
@@ -27,6 +27,7 @@ abstract class ilPageConfig
public const SEC_PROTECT_NONE = 0; // page does not support section protection
public const SEC_PROTECT_EDITABLE = 1; // current use can edit protected sections
public const SEC_PROTECT_PROTECTED = 2; // current use cannot edit protected sections
+ protected int $layout_template_type = 0;
protected bool $int_link_def_id_is_ref = false;
protected ilLanguage $lng;
@@ -87,12 +88,28 @@ final public function __construct()
}
}
$this->init();
+ if ($this->getLayoutTemplateType() > 0) {
+ $templates = ilPageLayout::activeLayouts($this->getLayoutTemplateType());
+ if (count($templates) > 0) {
+ $this->setEnablePCType("LayoutTemplate", true);
+ }
+ }
}
public function init(): void
{
}
+ public function setLayoutTemplateType(int $type): void
+ {
+ $this->layout_template_type = $type;
+ }
+
+ public function getLayoutTemplateType(): int
+ {
+ return $this->layout_template_type;
+ }
+
public function setEnablePCType(string $a_pc_type, bool $a_val): void
{
$this->pc_enabled[$a_pc_type] = $a_val;
diff --git a/Services/COPage/service.xml b/Services/COPage/service.xml
index e31282b735cc..3aed74cf8d27 100644
--- a/Services/COPage/service.xml
+++ b/Services/COPage/service.xml
@@ -28,6 +28,7 @@
+
diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang
index ea15bbb5d479..ef7245f740ed 100644
--- a/lang/ilias_de.lang
+++ b/lang/ilias_de.lang
@@ -6354,6 +6354,7 @@ content#:#cont_ed_insert_grid#:#Spaltenlayout einfügen
content#:#cont_ed_insert_grid_info#:#Fügt ein responsives Spaltenlayout basierend auf einem Raster mit 12 Einheiten je Zeile ein.
content#:#cont_ed_insert_iim#:#Interaktives Bild einfügen
content#:#cont_ed_insert_incl#:#Inhaltsbaustein einfügen
+content#:#cont_ed_insert_lay#:#Layoutvorlage einfügen
content#:#cont_ed_insert_lhist#:#Lernverlauf einfügen
content#:#cont_ed_insert_list#:#Erweiterte Liste einfügen
content#:#cont_ed_insert_lpe#:#Login-Seitenelement einfügen
diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang
index 690f4014c41f..20c587536382 100644
--- a/lang/ilias_en.lang
+++ b/lang/ilias_en.lang
@@ -6354,6 +6354,7 @@ content#:#cont_ed_insert_grid#:#Insert Column Layout
content#:#cont_ed_insert_grid_info#:#Adds a responsive column layout based on a grid with 12 units per row.
content#:#cont_ed_insert_iim#:#Insert Interactive Image
content#:#cont_ed_insert_incl#:#Insert Content Snippet
+content#:#cont_ed_insert_lay#:#Insert Layout Template
content#:#cont_ed_insert_lhist#:#Insert Learning History
content#:#cont_ed_insert_list#:#Insert Advanced List
content#:#cont_ed_insert_lpe#:#Insert Login Page Element