Merge branch 'feature-63437/cis4_iframe_component'

This commit is contained in:
Harald Bamberger
2025-09-25 16:15:17 +02:00
4 changed files with 123 additions and 27 deletions
+10 -27
View File
@@ -2,6 +2,8 @@ import raum_contentmittitel from './Content_types/Raum_contentmittitel.js'
import general from './Content_types/General.js'
import BsConfirm from "../../Bootstrap/Confirm.js";
import news_content from './Content_types/News_content.js';
import iframe_content from './Content_types/Iframe_content.js';
import ApiCms from '../../../api/factory/cms.js';
export default {
@@ -24,42 +26,23 @@ export default {
raum_contentmittitel,
news_content,
general,
iframe_content
},
data() {
return {
content_type: null,
content: null,
content_id_internal: this.content_id
};
},
methods: {
fetchContent(){
return this.$api
this.$api
.call(ApiCms.content(this.content_id_internal, this.version, this.sprache, this.sichtbar))
.then(res => {
this.content = res.data.content;
this.content_type = res.data.type;
document.querySelectorAll("#cms [data-confirm]").forEach((el) => {
el.addEventListener("click", (evt) => {
evt.preventDefault();
BsConfirm.popup(el.dataset.confirm)
.then(() => {
Axios.get(el.href)
.then((res) => {
// TODO(chris): check for success then show message and/or reload
location = location;
})
.catch((err) => console.error("ERROR:", err));
})
.catch(() => {
});
});
});
document.querySelectorAll("#cms [data-href]").forEach((el) => {
el.href = el.dataset.href.replace(
/^ROOT\//,
FHC_JS_DATA_STORAGE_OBJECT.app_root
);
this.$nextTick(function() {
this.content = res.data.content;
this.content_type = res.data.type;
});
});
}
@@ -83,6 +66,8 @@ export default {
return "raum_contentmittitel";
case "news":
return "news_content";
case "iframe":
return "iframe_content";
default:
return "general";
};
@@ -91,8 +76,6 @@ export default {
created() {
this.fetchContent();
},
mounted() {
},
template: /*html*/ `
<!-- div that contains the content -->
<div id="fhc-cms-content" v-if="content">
@@ -0,0 +1,31 @@
import { replaceRelativeLegacyLink } from "../../../../helpers/LegacyLinkReplaceHelper.js";
export default {
name: "iframe_content",
props: {
content: { type: String, required: true }
},
computed: {
srcUrl() {
const parser = new DOMParser()
const doc = parser.parseFromString(`<div>${this.content}</div>`, "text/html");
const iframe = doc.querySelector("iframe[src]");
if (!iframe)
return "";
let url = iframe.getAttribute("src") || "";
return replaceRelativeLegacyLink(url);
}
},
template: `
<div class="w-100">
<iframe
v-if="srcUrl"
:src="srcUrl"
style="width:100%; height:90vh; border:0; display:block;"
></iframe>
<div v-else class="alert alert-warning">Keine URL gefunden.</div>
</div>
`
};
+1
View File
@@ -77,6 +77,7 @@ require_once('dbupdate_3.4/55614_perm_verwaltetoe.php');
require_once('dbupdate_3.4/25999_C4_dashboard.php');
require_once('dbupdate_3.4/61730_Dashboard_Anpassungen.php');
require_once('dbupdate_3.4/40128_search.php');
require_once('dbupdate_3.4/63436_cis4_iframe_component.php');
require_once('dbupdate_3.4/60882_lehrfaecherverteilung_favorites.php');
require_once('dbupdate_3.4/66982_berufsschule.php');
@@ -0,0 +1,81 @@
<?php
$xsd= <<<EOD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="content">
<xs:complexType>
<xs:sequence>
<xs:element name="url" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
EOD;
$xslt_xhtml= <<<EOD
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="content">
<xsl:choose>
<xsl:when test="string(url)">
<iframe
src="{url}"
frameborder="0"
style="width:100%; height:90vh; border:0; display:block;"
>
</iframe>
</xsl:when>
<xsl:otherwise>
<div class="alert alert-warning">Keine URL im Inhalt gefunden.</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
EOD;
$xslt_xhtml_c4= <<<EOD
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="content">
<xsl:choose>
<xsl:when test="string(url)">
<iframe
src="{url}"
frameborder="0"
style="width:100%; height:90vh; border:0; display:block;"
>
</iframe>
</xsl:when>
<xsl:otherwise>
<div class="alert alert-warning">Keine URL im Inhalt gefunden.</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
EOD;
if ($result = @$db->db_query("SELECT * FROM campus.tbl_template WHERE template_kurzbz='iframe'"))
{
if ($db->db_num_rows($result) == 0)
{
$sql= <<<EOD
INSERT INTO campus.tbl_template
(template_kurzbz, bezeichnung, xsd, xslt_xhtml, xslfo_pdf, xslt_xhtml_c4)
VALUES
('iframe','iFrame Content ', '{$xsd}', '{$xslt_xhtml}' , NULL, '{$xslt_xhtml_c4}');
EOD;
if (!$db->db_query($sql))
{
echo '<strong>campus.tbl_template: ' . $db->db_last_error() . '</strong><br>';
}
else
{
echo ' campus.tbl_template: Template "iframe" hinzugefügt.<br>';
}
}
}